diff --git a/cmake/cmake.version b/cmake/cmake.version index fcb31adc39..05094f10cc 100644 --- a/cmake/cmake.version +++ b/cmake/cmake.version @@ -2,7 +2,7 @@ IF (DEFINED VERNUMBER) SET(TD_VER_NUMBER ${VERNUMBER}) ELSE () - SET(TD_VER_NUMBER "3.0.1.2") + SET(TD_VER_NUMBER "3.0.1.4") ENDIF () IF (DEFINED VERCOMPATIBLE) diff --git a/cmake/taostools_CMakeLists.txt.in b/cmake/taostools_CMakeLists.txt.in index 39f243d147..5d2fcf27b2 100644 --- a/cmake/taostools_CMakeLists.txt.in +++ b/cmake/taostools_CMakeLists.txt.in @@ -2,7 +2,7 @@ # taos-tools ExternalProject_Add(taos-tools GIT_REPOSITORY https://github.com/taosdata/taos-tools.git - GIT_TAG cf1df1c + GIT_TAG 70f5a1c SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools" BINARY_DIR "" #BUILD_IN_SOURCE TRUE diff --git a/docs/en/07-develop/03-insert-data/02-influxdb-line.mdx b/docs/en/07-develop/03-insert-data/02-influxdb-line.mdx index 11db3daeb0..c91dbba5d2 100644 --- a/docs/en/07-develop/03-insert-data/02-influxdb-line.mdx +++ b/docs/en/07-develop/03-insert-data/02-influxdb-line.mdx @@ -37,7 +37,8 @@ meters,location=California.LosAngeles,groupid=2 current=13.4,voltage=223,phase=0 - All the data in `tag_set` will be converted to nchar type automatically . - Each data in `field_set` must be self-descriptive for its data type. For example 1.2f32 means a value 1.2 of float type. Without the "f" type suffix, it will be treated as type double. - Multiple kinds of precision can be used for the `timestamp` field. Time precision can be from nanosecond (ns) to hour (h). - +- You can configure smlChildTableName in taos.cfg to specify table names, for example, `smlChildTableName=tname`. You can insert `st,tname=cpul,t1=4 c1=3 1626006833639000000` and the cpu1 table will be automatically created. Note that if multiple rows have the same tname but different tag_set values, the tag_set of the first row is used to create the table and the others are ignored. +- It is assumed that the order of field_set in a supertable is consistent, meaning that the first record contains all fields and subsequent records store fields in the same order. If the order is not consistent, set smlDataFormat in taos.cfg to false. Otherwise, data will be written out of order and a database error will occur.(smlDataFormat in taos.cfg default to false after version of 3.0.1.3) ::: For more details please refer to [InfluxDB Line Protocol](https://docs.influxdata.com/influxdb/v2.0/reference/syntax/line-protocol/) and [TDengine Schemaless](/reference/schemaless/#Schemaless-Line-Protocol) @@ -64,3 +65,7 @@ For more details please refer to [InfluxDB Line Protocol](https://docs.influxdat + +## Query Examples +If you want query the data of `location=California.LosAngeles,groupid=2`,here is the query sql: +select * from `meters.voltage` where location="California.LosAngeles" and groupid=2 diff --git a/docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx b/docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx index db9bfd7364..a71efde735 100644 --- a/docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx +++ b/docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx @@ -31,7 +31,7 @@ For example: ```txt meters.current 1648432611250 11.3 location=California.LosAngeles groupid=3 ``` - +- The defult child table name is generated by rules.You can configure smlChildTableName in taos.cfg to specify chile table names, for example, `smlChildTableName=tname`. You can insert `meters.current 1648432611250 11.3 tname=cpu1 location=California.LosAngeles groupid=3` and the cpu1 table will be automatically created. Note that if multiple rows have the same tname but different tag_set values, the tag_set of the first row is used to create the table and the others are ignored. Please refer to [OpenTSDB Telnet API](http://opentsdb.net/docs/build/html/api_telnet/put.html) for more details. ## Examples @@ -64,10 +64,10 @@ taos> use test; Database changed. taos> show stables; - name | created_time | columns | tags | tables | -============================================================================================ - meters.current | 2022-03-30 17:04:10.877 | 2 | 2 | 2 | - meters.voltage | 2022-03-30 17:04:10.882 | 2 | 2 | 2 | + name | +================================= + meters.current | + meters.voltage | Query OK, 2 row(s) in set (0.002544s) taos> select tbname, * from `meters.current`; @@ -79,3 +79,6 @@ taos> select tbname, * from `meters.current`; t_7e7b26dd860280242c6492a16... | 2022-03-28 09:56:51.250 | 12.600000000 | 2 | California.SanFrancisco | Query OK, 4 row(s) in set (0.005399s) ``` +## Query Examples +If you want query the data of `location=California.LosAngeles groupid=3`,here is the query sql: +select * from `meters.voltage` where location="California.LosAngeles" and groupid=3 diff --git a/docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx b/docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx index 23703f4087..c0a287e331 100644 --- a/docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx +++ b/docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx @@ -48,7 +48,7 @@ Please refer to [OpenTSDB HTTP API](http://opentsdb.net/docs/build/html/api_http - In JSON protocol, strings will be converted to nchar type and numeric values will be converted to double type. - Only data in array format is accepted and so an array must be used even if there is only one row. - +- The defult child table name is generated by rules.You can configure smlChildTableName in taos.cfg to specify chile table names, for example, `smlChildTableName=tname`. You can insert `"tags": { "host": "web02","dc": "lga","tname":"cpu1"}` and the cpu1 table will be automatically created. Note that if multiple rows have the same tname but different tag_set values, the tag_set of the first row is used to create the table and the others are ignored. ::: ## Examples @@ -81,10 +81,10 @@ taos> use test; Database changed. taos> show stables; - name | created_time | columns | tags | tables | -============================================================================================ - meters.current | 2022-03-29 16:05:25.193 | 2 | 2 | 1 | - meters.voltage | 2022-03-29 16:05:25.200 | 2 | 2 | 1 | + name | +================================= + meters.current | + meters.voltage | Query OK, 2 row(s) in set (0.001954s) taos> select * from `meters.current`; @@ -94,3 +94,6 @@ taos> select * from `meters.current`; 2022-03-28 09:56:51.250 | 12.600000000 | 2.000000000 | California.SanFrancisco | Query OK, 2 row(s) in set (0.004076s) ``` +## Query Examples +If you want query the data of "tags": {"location": "California.LosAngeles", "groupid": 1},here is the query sql: +select * from `meters.voltage` where location="California.LosAngeles" and groupid=1 diff --git a/docs/en/12-taos-sql/06-select.md b/docs/en/12-taos-sql/06-select.md index 786444ad77..c065245827 100644 --- a/docs/en/12-taos-sql/06-select.md +++ b/docs/en/12-taos-sql/06-select.md @@ -181,6 +181,14 @@ In TDengine, the first column of all tables must be a timestamp. This column is select _rowts, max(current) from meters; ``` +**\_IROWTS** + +The \_IROWTS pseudocolumn can only be used with INTERP function. This pseudocolumn can be used to retrieve the corresponding timestamp column associated with the interpolation results. + +```sql +select _irowts, interp(current) from meters range('2020-01-01 10:00:00', '2020-01-01 10:30:00') every(1s) fill(linear); +``` + ## Query Objects `FROM` can be followed by a number of tables or super tables, or can be followed by a sub-query. diff --git a/docs/en/12-taos-sql/10-function.md b/docs/en/12-taos-sql/10-function.md index ab1d2f900b..243ede5fcb 100644 --- a/docs/en/12-taos-sql/10-function.md +++ b/docs/en/12-taos-sql/10-function.md @@ -13,7 +13,7 @@ Single row functions return a result for each row. #### ABS ```sql -SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause] +ABS(expr) ``` **Description**: The absolute value of a specific field. @@ -31,7 +31,7 @@ SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause] #### ACOS ```sql -SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause] +ACOS(expr) ``` **Description**: The arc cosine of a specific field. @@ -49,7 +49,7 @@ SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause] #### ASIN ```sql -SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause] +ASIN(expr) ``` **Description**: The arc sine of a specific field. @@ -68,7 +68,7 @@ SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause] #### ATAN ```sql -SELECT ATAN(field_name) FROM { tb_name | stb_name } [WHERE clause] +ATAN(expr) ``` **Description**: The arc tangent of a specific field. @@ -87,7 +87,7 @@ SELECT ATAN(field_name) FROM { tb_name | stb_name } [WHERE clause] #### CEIL ```sql -SELECT CEIL(field_name) FROM { tb_name | stb_name } [WHERE clause]; +CEIL(expr) ``` **Description**: The rounded up value of a specific field @@ -105,7 +105,7 @@ SELECT CEIL(field_name) FROM { tb_name | stb_name } [WHERE clause]; #### COS ```sql -SELECT COS(field_name) FROM { tb_name | stb_name } [WHERE clause] +COS(expr) ``` **Description**: The cosine of a specific field. @@ -123,7 +123,7 @@ SELECT COS(field_name) FROM { tb_name | stb_name } [WHERE clause] #### FLOOR ```sql -SELECT FLOOR(field_name) FROM { tb_name | stb_name } [WHERE clause]; +FLOOR(expr) ``` **Description**: The rounded down value of a specific field @@ -132,7 +132,7 @@ SELECT FLOOR(field_name) FROM { tb_name | stb_name } [WHERE clause]; #### LOG ```sql -SELECT LOG(field_name[, base]) FROM { tb_name | stb_name } [WHERE clause] +LOG(expr [, base]) ``` **Description**: The logarithm of a specific field with `base` as the radix. If you do not enter a base, the natural logarithm of the field is returned. @@ -151,7 +151,7 @@ SELECT LOG(field_name[, base]) FROM { tb_name | stb_name } [WHERE clause] #### POW ```sql -SELECT POW(field_name, power) FROM { tb_name | stb_name } [WHERE clause] +POW(expr, power) ``` **Description**: The power of a specific field with `power` as the exponent. @@ -170,7 +170,7 @@ SELECT POW(field_name, power) FROM { tb_name | stb_name } [WHERE clause] #### ROUND ```sql -SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; +ROUND(expr) ``` **Description**: The rounded value of a specific field. @@ -180,7 +180,7 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; #### SIN ```sql -SELECT SIN(field_name) FROM { tb_name | stb_name } [WHERE clause] +SIN(expr) ``` **Description**: The sine of a specific field. @@ -198,7 +198,7 @@ SELECT SIN(field_name) FROM { tb_name | stb_name } [WHERE clause] #### SQRT ```sql -SELECT SQRT(field_name) FROM { tb_name | stb_name } [WHERE clause] +SQRT(expr) ``` **Description**: The square root of a specific field. @@ -216,7 +216,7 @@ SELECT SQRT(field_name) FROM { tb_name | stb_name } [WHERE clause] #### TAN ```sql -SELECT TAN(field_name) FROM { tb_name | stb_name } [WHERE clause] +TAN(expr) ``` **Description**: The tangent of a specific field. @@ -238,7 +238,7 @@ Concatenation functions take strings as input and produce string or numeric valu #### CHAR_LENGTH ```sql -SELECT CHAR_LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] +CHAR_LENGTH(expr) ``` **Description**: The length in number of characters of a string @@ -254,7 +254,7 @@ SELECT CHAR_LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] #### CONCAT ```sql -SELECT CONCAT(str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] +CONCAT(expr1, expr2 [, expr] ...) ``` **Description**: The concatenation result of two or more strings @@ -271,7 +271,7 @@ SELECT CONCAT(str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHER #### CONCAT_WS ```sql -SELECT CONCAT_WS(separator, str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] +CONCAT_WS(separator_expr, expr1, expr2 [, expr] ...) ``` **Description**: The concatenation result of two or more strings with separator @@ -288,7 +288,7 @@ SELECT CONCAT_WS(separator, str1|column1, str2|column2, ...) FROM { tb_name | st #### LENGTH ```sql -SELECT LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] +LENGTH(expr) ``` **Description**: The length in bytes of a string @@ -305,7 +305,7 @@ SELECT LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] #### LOWER ```sql -SELECT LOWER(str|column) FROM { tb_name | stb_name } [WHERE clause] +LOWER(expr) ``` **Description**: Convert the input string to lower case @@ -322,7 +322,7 @@ SELECT LOWER(str|column) FROM { tb_name | stb_name } [WHERE clause] #### LTRIM ```sql -SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] +LTRIM(expr) ``` **Description**: Remove the left leading blanks of a string @@ -339,7 +339,7 @@ SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] #### RTRIM ```sql -SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] +LTRIM(expr) ``` **Description**: Remove the right tailing blanks of a string @@ -356,7 +356,7 @@ SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] #### SUBSTR ```sql -SELECT SUBSTR(str,pos[,len]) FROM { tb_name | stb_name } [WHERE clause] +SUBSTR(expr, pos [, len]) ``` **Description**: The sub-string starting from `pos` with length of `len` from the original string `str` - If `len` is not specified, it means from `pos` to the end. @@ -373,7 +373,7 @@ SELECT SUBSTR(str,pos[,len]) FROM { tb_name | stb_name } [WHERE clause] #### UPPER ```sql -SELECT UPPER(str|column) FROM { tb_name | stb_name } [WHERE clause] +UPPER(expr) ``` **Description**: Convert the input string to upper case @@ -394,10 +394,10 @@ Conversion functions change the data type of a value. #### CAST ```sql -SELECT CAST(expression AS type_name) FROM { tb_name | stb_name } [WHERE clause] +CAST(expr AS type_name) ``` -**Description**: Convert the input data `expression` into the type specified by `type_name`. This function can be used only in SELECT statements. +**Description**: Convert the input data `expr` into the type specified by `type_name`. This function can be used only in SELECT statements. **Return value type**: The type specified by parameter `type_name` @@ -418,7 +418,7 @@ SELECT CAST(expression AS type_name) FROM { tb_name | stb_name } [WHERE clause] #### TO_ISO8601 ```sql -SELECT TO_ISO8601(ts[, timezone]) FROM { tb_name | stb_name } [WHERE clause]; +TO_ISO8601(expr [, timezone]) ``` **Description**: The ISO8601 date/time format converted from a UNIX timestamp, plus the timezone. You can specify any time zone with the timezone parameter. If you do not enter this parameter, the time zone on the client is used. @@ -441,7 +441,7 @@ SELECT TO_ISO8601(ts[, timezone]) FROM { tb_name | stb_name } [WHERE clause]; #### TO_JSON ```sql -SELECT TO_JSON(str_literal) FROM { tb_name | stb_name } [WHERE clause]; +TO_JSON(str_literal) ``` **Description**: Converts a string into JSON. @@ -458,7 +458,7 @@ SELECT TO_JSON(str_literal) FROM { tb_name | stb_name } [WHERE clause]; #### TO_UNIXTIMESTAMP ```sql -SELECT TO_UNIXTIMESTAMP(datetime_string) FROM { tb_name | stb_name } [WHERE clause]; +TO_UNIXTIMESTAMP(expr) ``` **Description**: UNIX timestamp converted from a string of date/time format @@ -486,9 +486,7 @@ All functions that return the current time, such as `NOW`, `TODAY`, and `TIMEZON #### NOW ```sql -SELECT NOW() FROM { tb_name | stb_name } [WHERE clause]; -SELECT select_expr FROM { tb_name | stb_name } WHERE ts_col cond_operatior NOW(); -INSERT INTO tb_name VALUES (NOW(), ...); +NOW() ``` **Description**: The current time of the client side system @@ -511,7 +509,7 @@ INSERT INTO tb_name VALUES (NOW(), ...); #### TIMEDIFF ```sql -SELECT TIMEDIFF(ts | datetime_string1, ts | datetime_string2 [, time_unit]) FROM { tb_name | stb_name } [WHERE clause]; +TIMEDIFF(expr1, expr2 [, time_unit]) ``` **Description**: The difference between two timestamps, and rounded to the time unit specified by `time_unit` @@ -534,7 +532,7 @@ SELECT TIMEDIFF(ts | datetime_string1, ts | datetime_string2 [, time_unit]) FROM #### TIMETRUNCATE ```sql -SELECT TIMETRUNCATE(ts | datetime_string , time_unit) FROM { tb_name | stb_name } [WHERE clause]; +TIMETRUNCATE(expr, time_unit) ``` **Description**: Truncate the input timestamp with unit specified by `time_unit` @@ -555,7 +553,7 @@ SELECT TIMETRUNCATE(ts | datetime_string , time_unit) FROM { tb_name | stb_name #### TIMEZONE ```sql -SELECT TIMEZONE() FROM { tb_name | stb_name } [WHERE clause]; +TIMEZONE() ``` **Description**: The timezone of the client side system @@ -570,9 +568,7 @@ SELECT TIMEZONE() FROM { tb_name | stb_name } [WHERE clause]; #### TODAY ```sql -SELECT TODAY() FROM { tb_name | stb_name } [WHERE clause]; -SELECT select_expr FROM { tb_name | stb_name } WHERE ts_col cond_operatior TODAY()]; -INSERT INTO tb_name VALUES (TODAY(), ...); +TODAY() ``` **Description**: The timestamp of 00:00:00 of the client side system @@ -599,7 +595,12 @@ TDengine supports the following aggregate functions: ### APERCENTILE ```sql -SELECT APERCENTILE(field_name, P[, algo_type]) FROM { tb_name | stb_name } [WHERE clause] +APERCENTILE(expr, p [, algo_type]) + +algo_type: { + "default" + | "t-digest" +} ``` **Description**: Similar to `PERCENTILE`, but a simulated result is returned @@ -611,14 +612,14 @@ SELECT APERCENTILE(field_name, P[, algo_type]) FROM { tb_name | stb_name } [WHER **Applicable table types**: standard tables and supertables **Explanations**: -- _P_ is in range [0,100], when _P_ is 0, the result is same as using function MIN; when _P_ is 100, the result is same as function MAX. +- _p_ is in range [0,100], when _p_ is 0, the result is same as using function MIN; when _p_ is 100, the result is same as function MAX. - `algo_type` can only be input as `default` or `t-digest` Enter `default` to use a histogram-based algorithm. Enter `t-digest` to use the t-digest algorithm to calculate the approximation of the quantile. `default` is used by default. - The approximation result of `t-digest` algorithm is sensitive to input data order. For example, when querying STable with different input data order there might be minor differences in calculated results. ### AVG ```sql -SELECT AVG(field_name) FROM tb_name [WHERE clause]; +AVG(expr) ``` **Description**: The average value of the specified fields. @@ -633,7 +634,7 @@ SELECT AVG(field_name) FROM tb_name [WHERE clause]; ### COUNT ```sql -SELECT COUNT([*|field_name]) FROM tb_name [WHERE clause]; +COUNT({* | expr}) ``` **Description**: The number of records in the specified fields. @@ -653,7 +654,7 @@ If you input a specific column, the number of non-null values in the column is r ### ELAPSED ```sql -SELECT ELAPSED(ts_primary_key [, time_unit]) FROM { tb_name | stb_name } [WHERE clause] [INTERVAL(interval [, offset]) [SLIDING sliding]]; +ELAPSED(ts_primary_key [, time_unit]) ``` **Description**:`elapsed` function can be used to calculate the continuous time length in which there is valid data. If it's used with `INTERVAL` clause, the returned result is the calcualted time length within each time window. If it's used without `INTERVAL` caluse, the returned result is the calculated time length within the specified time range. Please be noted that the return value of `elapsed` is the number of `time_unit` in the calculated time length. @@ -665,7 +666,7 @@ SELECT ELAPSED(ts_primary_key [, time_unit]) FROM { tb_name | stb_name } [WHERE **Applicable tables**: table, STable, outter in nested query **Explanations**: -- `field_name` parameter can only be the first column of a table, i.e. timestamp primary key. +- `ts_primary_key` parameter can only be the first column of a table, i.e. timestamp primary key. - The minimum value of `time_unit` is the time precision of the database. If `time_unit` is not specified, the time precision of the database is used as the default time unit. Time unit specified by `time_unit` can be: 1b (nanoseconds), 1u (microseconds), 1a (milliseconds), 1s (seconds), 1m (minutes), 1h (hours), 1d (days), or 1w (weeks) - It can be used with `INTERVAL` to get the time valid time length of each time window. Please be noted that the return value is same as the time window for all time windows except for the first and the last time window. @@ -679,7 +680,7 @@ SELECT ELAPSED(ts_primary_key [, time_unit]) FROM { tb_name | stb_name } [WHERE ### LEASTSQUARES ```sql -SELECT LEASTSQUARES(field_name, start_val, step_val) FROM tb_name [WHERE clause]; +LEASTSQUARES(expr, start_val, step_val) ``` **Description**: The linear regression function of the specified column and the timestamp column (primary key), `start_val` is the initial value and `step_val` is the step value. @@ -694,7 +695,7 @@ SELECT LEASTSQUARES(field_name, start_val, step_val) FROM tb_name [WHERE clause] ### SPREAD ```sql -SELECT SPREAD(field_name) FROM { tb_name | stb_name } [WHERE clause]; +SPREAD(expr) ``` **Description**: The difference between the max and the min of a specific column @@ -709,7 +710,7 @@ SELECT SPREAD(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### STDDEV ```sql -SELECT STDDEV(field_name) FROM tb_name [WHERE clause]; +STDDEV(expr) ``` **Description**: Standard deviation of a specific column in a table or STable @@ -724,7 +725,7 @@ SELECT STDDEV(field_name) FROM tb_name [WHERE clause]; ### SUM ```sql -SELECT SUM(field_name) FROM tb_name [WHERE clause]; +SUM(expr) ``` **Description**: The sum of a specific column in a table or STable @@ -739,7 +740,7 @@ SELECT SUM(field_name) FROM tb_name [WHERE clause]; ### HYPERLOGLOG ```sql -SELECT HYPERLOGLOG(field_name) FROM { tb_name | stb_name } [WHERE clause]; +HYPERLOGLOG(expr) ``` **Description**: @@ -756,7 +757,7 @@ SELECT HYPERLOGLOG(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### HISTOGRAM ```sql -SELECT HISTOGRAM(field_name,bin_type, bin_description, normalized) FROM tb_name [WHERE clause]; +HISTOGRAM(expr,bin_type, bin_description, normalized) ``` **Description**:Returns count of data points in user-specified ranges. @@ -786,7 +787,7 @@ SELECT HISTOGRAM(field_name,bin_type, bin_description, normalized) FROM tb_nam ### PERCENTILE ```sql -SELECT PERCENTILE(field_name, P) FROM { tb_name } [WHERE clause]; +PERCENTILE(expr, p) ``` **Description**: The value whose rank in a specific column matches the specified percentage. If such a value matching the specified percentage doesn't exist in the column, an interpolation value will be returned. @@ -797,7 +798,7 @@ SELECT PERCENTILE(field_name, P) FROM { tb_name } [WHERE clause]; **Applicable table types**: table only -**More explanations**: _P_ is in range [0,100], when _P_ is 0, the result is same as using function MIN; when _P_ is 100, the result is same as function MAX. +**More explanations**: _p_ is in range [0,100], when _p_ is 0, the result is same as using function MIN; when _p_ is 100, the result is same as function MAX. ## Selection Functions @@ -807,7 +808,7 @@ Selection functions return one or more results depending. You can specify the ti ### BOTTOM ```sql -SELECT BOTTOM(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; +BOTTOM(expr, k) ``` **Description**: The least _k_ values of a specific column in a table or STable. If a value has multiple occurrences in the column but counting all of them in will exceed the upper limit _k_, then a part of them will be returned randomly. @@ -827,7 +828,7 @@ SELECT BOTTOM(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; ### FIRST ```sql -SELECT FIRST(field_name) FROM { tb_name | stb_name } [WHERE clause]; +FIRST(expr) ``` **Description**: The first non-null value of a specific column in a table or STable @@ -847,7 +848,7 @@ SELECT FIRST(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### INTERP ```sql -SELECT INTERP(field_name) FROM { tb_name | stb_name } [WHERE where_condition] RANGE(timestamp1,timestamp2) EVERY(interval) FILL({ VALUE | PREV | NULL | LINEAR | NEXT}); +INTERP(expr) ``` **Description**: The value that matches the specified timestamp range is returned, if existing; or an interpolation value is returned. @@ -866,11 +867,12 @@ SELECT INTERP(field_name) FROM { tb_name | stb_name } [WHERE where_condition] RA - The number of rows in the result set of `INTERP` is determined by the parameter `EVERY`. Starting from timestamp1, one interpolation is performed for every time interval specified `EVERY` parameter. - Interpolation is performed based on `FILL` parameter. - `INTERP` can only be used to interpolate in single timeline. So it must be used with `partition by tbname` when it's used on a STable. +- Pseudo column `_irowts` can be used along with `INTERP` to return the timestamps associated with interpolation points(support after version 3.0.1.4). ### LAST ```sql -SELECT LAST(field_name) FROM { tb_name | stb_name } [WHERE clause]; +LAST(expr) ``` **Description**: The last non-NULL value of a specific column in a table or STable @@ -891,7 +893,7 @@ SELECT LAST(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### LAST_ROW ```sql -SELECT LAST_ROW(field_name) FROM { tb_name | stb_name }; +LAST_ROW(expr) ``` **Description**: The last row of a table or STable @@ -910,7 +912,7 @@ SELECT LAST_ROW(field_name) FROM { tb_name | stb_name }; ### MAX ```sql -SELECT MAX(field_name) FROM { tb_name | stb_name } [WHERE clause]; +MAX(expr) ``` **Description**: The maximum value of a specific column of a table or STable @@ -925,7 +927,7 @@ SELECT MAX(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### MIN ```sql -SELECT MIN(field_name) FROM {tb_name | stb_name} [WHERE clause]; +MIN(expr) ``` **Description**: The minimum value of a specific column in a table or STable @@ -940,7 +942,7 @@ SELECT MIN(field_name) FROM {tb_name | stb_name} [WHERE clause]; ### MODE ```sql -SELECT MODE(field_name) FROM tb_name [WHERE clause]; +MODE(expr) ``` **Description**:The value which has the highest frequency of occurrence. NULL is returned if there are multiple values which have highest frequency of occurrence. @@ -955,7 +957,7 @@ SELECT MODE(field_name) FROM tb_name [WHERE clause]; ### SAMPLE ```sql -SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause] +SAMPLE(expr, k) ``` **Description**: _k_ sampling values of a specific column. The applicable range of _k_ is [1,1000]. @@ -977,7 +979,7 @@ This function cannot be used in expression calculation. ### TAIL ```sql -SELECT TAIL(field_name, k, offset_val) FROM {tb_name | stb_name} [WHERE clause]; +TAIL(expr, k, offset_val) ``` **Description**: The next _k_ rows are returned after skipping the last `offset_val` rows, NULL values are not ignored. `offset_val` is optional parameter. When it's not specified, the last _k_ rows are returned. When `offset_val` is used, the effect is same as `order by ts desc LIMIT k OFFSET offset_val`. @@ -994,7 +996,7 @@ SELECT TAIL(field_name, k, offset_val) FROM {tb_name | stb_name} [WHERE clause]; ### TOP ```sql -SELECT TOP(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; +TOP(expr, k) ``` **Description**: The greatest _k_ values of a specific column in a table or STable. If a value has multiple occurrences in the column but counting all of them in will exceed the upper limit _k_, then a part of them will be returned randomly. @@ -1014,7 +1016,7 @@ SELECT TOP(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; ### UNIQUE ```sql -SELECT UNIQUE(field_name) FROM {tb_name | stb_name} [WHERE clause]; +UNIQUE(expr) ``` **Description**: The values that occur the first time in the specified column. The effect is similar to `distinct` keyword, but it can also be used to match tags or timestamp. The first occurrence of a timestamp or tag is used. @@ -1033,7 +1035,7 @@ TDengine includes extensions to standard SQL that are intended specifically for ### CSUM ```sql -SELECT CSUM(field_name) FROM { tb_name | stb_name } [WHERE clause] +CSUM(expr) ``` **Description**: The cumulative sum of each row for a specific column. The number of output rows is same as that of the input rows. @@ -1056,7 +1058,12 @@ SELECT CSUM(field_name) FROM { tb_name | stb_name } [WHERE clause] ### DERIVATIVE ```sql -SELECT DERIVATIVE(field_name, time_interval, ignore_negative) FROM tb_name [WHERE clause]; +DERIVATIVE(expr, time_inerval, ignore_negative) + +ignore_negative: { + 0 + | 1 +} ``` **Description**: The derivative of a specific column. The time rage can be specified by parameter `time_interval`, the minimum allowed time range is 1 second (1s); the value of `ignore_negative` can be 0 or 1, 1 means negative values are ignored. @@ -1075,7 +1082,12 @@ SELECT DERIVATIVE(field_name, time_interval, ignore_negative) FROM tb_name [WHER ### DIFF ```sql -SELECT {DIFF(field_name, ignore_negative) | DIFF(field_name)} FROM tb_name [WHERE clause]; +DIFF(expr [, ignore_negative]) + +ignore_negative: { + 0 + | 1 +} ``` **Description**: The different of each row with its previous row for a specific column. `ignore_negative` can be specified as 0 or 1, the default value is 1 if it's not specified. `1` means negative values are ignored. @@ -1095,7 +1107,7 @@ SELECT {DIFF(field_name, ignore_negative) | DIFF(field_name)} FROM tb_name [WHER ### IRATE ```sql -SELECT IRATE(field_name) FROM tb_name WHERE clause; +IRATE(expr) ``` **Description**: instantaneous rate on a specific column. The last two samples in the specified time range are used to calculate instantaneous rate. If the last sample value is smaller, then only the last sample value is used instead of the difference between the last two sample values. @@ -1110,7 +1122,7 @@ SELECT IRATE(field_name) FROM tb_name WHERE clause; ### MAVG ```sql -SELECT MAVG(field_name, K) FROM { tb_name | stb_name } [WHERE clause] +MAVG(expr, k) ``` **Description**: The moving average of continuous _k_ values of a specific column. If the number of input rows is less than _k_, nothing is returned. The applicable range of _k_ is [1,1000]. @@ -1133,7 +1145,7 @@ SELECT MAVG(field_name, K) FROM { tb_name | stb_name } [WHERE clause] ### STATECOUNT ```sql -SELECT STATECOUNT(field_name, oper, val) FROM { tb_name | stb_name } [WHERE clause]; +STATECOUNT(expr, oper, val) ``` **Description**: The number of continuous rows satisfying the specified conditions for a specific column. The result is shown as an extra column for each row. If the specified condition is evaluated as true, the number is increased by 1; otherwise the number is reset to -1. If the input value is NULL, then the corresponding row is skipped. @@ -1160,7 +1172,7 @@ SELECT STATECOUNT(field_name, oper, val) FROM { tb_name | stb_name } [WHERE clau ### STATEDURATION ```sql -SELECT stateDuration(field_name, oper, val, unit) FROM { tb_name | stb_name } [WHERE clause]; +STATEDURATION(expr, oper, val, unit) ``` **Description**: The length of time range in which all rows satisfy the specified condition for a specific column. The result is shown as an extra column for each row. The length for the first row that satisfies the condition is 0. Next, if the condition is evaluated as true for a row, the time interval between current row and its previous row is added up to the time range; otherwise the time range length is reset to -1. If the value of the column is NULL, the corresponding row is skipped. @@ -1188,7 +1200,7 @@ SELECT stateDuration(field_name, oper, val, unit) FROM { tb_name | stb_name } [W ### TWA ```sql -SELECT TWA(field_name) FROM tb_name WHERE clause; +TWA(expr) ``` **Description**: Time weighted average on a specific column within a time range diff --git a/docs/en/12-taos-sql/20-keywords.md b/docs/en/12-taos-sql/20-keywords.md index f7eb067c96..4b479b866b 100644 --- a/docs/en/12-taos-sql/20-keywords.md +++ b/docs/en/12-taos-sql/20-keywords.md @@ -343,6 +343,7 @@ The following list shows all reserved keywords: ### \_ - \_C0 +- \_IROWTS - \_QDURATION - \_QEND - \_QSTART diff --git a/docs/en/12-taos-sql/22-meta.md b/docs/en/12-taos-sql/22-meta.md index 9bda5a0a10..0a59777946 100644 --- a/docs/en/12-taos-sql/22-meta.md +++ b/docs/en/12-taos-sql/22-meta.md @@ -11,7 +11,15 @@ TDengine includes a built-in database named `INFORMATION_SCHEMA` to provide acce 4. Future versions of TDengine can add new columns to INFORMATION_SCHEMA tables without affecting existing business systems. 5. It is easier for users coming from other database management systems. For example, Oracle users can query data dictionary tables. -Note: SHOW statements are still supported for the convenience of existing users. +:::info + +- SHOW statements are still supported for the convenience of existing users. +- Some columns in the system table may be keywords, and you need to use the escape character '\`' when querying, for example, to query the VGROUPS in the database `test`: +```sql + select `vgroups` from ins_databases where name = 'test'; +``` + +::: This document introduces the tables of INFORMATION_SCHEMA and their structure. @@ -102,7 +110,11 @@ Provides information about user-created databases. Similar to SHOW DATABASES. | 24 | wal_retention_period | INT | WAL retention period | | 25 | wal_retention_size | INT | Maximum WAL size | | 26 | wal_roll_period | INT | WAL rotation period | -| 27 | wal_segment_size | WAL file size | +| 27 | wal_segment_size | BIGINT | WAL file size | +| 28 | stt_trigger | SMALLINT | The threshold for number of files to trigger file merging | +| 29 | table_prefix | SMALLINT | The prefix length in the table name that is ignored when distributing table to vnode based on table name | +| 30 | table_suffix | SMALLINT | The suffix length in the table name that is ignored when distributing table to vnode based on table name | +| 31 | tsdb_pagesize | INT | The page size for internal storage engine, its unit is KB | ## INS_FUNCTIONS diff --git a/docs/en/12-taos-sql/29-changes.md b/docs/en/12-taos-sql/29-changes.md index 8532eeac5d..78b6d5fc05 100644 --- a/docs/en/12-taos-sql/29-changes.md +++ b/docs/en/12-taos-sql/29-changes.md @@ -11,12 +11,13 @@ description: "This document explains how TDengine SQL has changed in version 3.0 | 1 | VARCHAR | Added | Alias of BINARY. | 2 | TIMESTAMP literal | Added | TIMESTAMP 'timestamp format' syntax now supported. | 3 | _ROWTS pseudocolumn | Added | Indicates the primary key. Alias of _C0. -| 4 | INFORMATION_SCHEMA | Added | Database for system metadata containing all schema definitions -| 5 | PERFORMANCE_SCHEMA | Added | Database for system performance information. -| 6 | Connection queries | Deprecated | Connection queries are no longer supported. The syntax and interfaces are deprecated. -| 7 | Mixed operations | Enhanced | Mixing scalar and vector operations in queries has been enhanced and is supported in all SELECT clauses. -| 8 | Tag operations | Added | Tag columns can be used in queries and clauses like data columns. -| 9 | Timeline clauses and time functions in supertables | Enhanced | When PARTITION BY is not used, data in supertables is merged into a single timeline. +| 4 | _IROWTS pseudocolumn | Added | Used to retrieve timestamps with INTERP function. +| 5 | INFORMATION_SCHEMA | Added | Database for system metadata containing all schema definitions +| 6 | PERFORMANCE_SCHEMA | Added | Database for system performance information. +| 7 | Connection queries | Deprecated | Connection queries are no longer supported. The syntax and interfaces are deprecated. +| 8 | Mixed operations | Enhanced | Mixing scalar and vector operations in queries has been enhanced and is supported in all SELECT clauses. +| 9 | Tag operations | Added | Tag columns can be used in queries and clauses like data columns. +| 10 | Timeline clauses and time functions in supertables | Enhanced | When PARTITION BY is not used, data in supertables is merged into a single timeline. ## SQL Syntax diff --git a/docs/en/14-reference/03-connector/04-java.mdx b/docs/en/14-reference/03-connector/04-java.mdx index 129d90ea85..c032687d0f 100644 --- a/docs/en/14-reference/03-connector/04-java.mdx +++ b/docs/en/14-reference/03-connector/04-java.mdx @@ -109,7 +109,7 @@ TDengine's JDBC URL specification format is: For establishing connections, native connections differ slightly from REST connections. - + ```java diff --git a/docs/en/14-reference/03-connector/05-go.mdx b/docs/en/14-reference/03-connector/05-go.mdx index 518d3625d5..f00e635af9 100644 --- a/docs/en/14-reference/03-connector/05-go.mdx +++ b/docs/en/14-reference/03-connector/05-go.mdx @@ -113,7 +113,7 @@ username:password@protocol(address)/dbname?param=value ``` ### Connecting via connector - + _taosSql_ implements Go's `database/sql/driver` interface via cgo. You can use the [`database/sql`](https://golang.org/pkg/database/sql/) interface by simply introducing the driver. diff --git a/docs/en/14-reference/03-connector/06-rust.mdx b/docs/en/14-reference/03-connector/06-rust.mdx index edc3016cde..4e2a7848dc 100644 --- a/docs/en/14-reference/03-connector/06-rust.mdx +++ b/docs/en/14-reference/03-connector/06-rust.mdx @@ -55,16 +55,6 @@ taos = "*" - - -In `cargo.toml`, add [taos][taos] and enable the native feature: - -```toml -[dependencies] -taos = { version = "*", default-features = false, features = ["native"] } -``` - - In `cargo.toml`, add [taos][taos] and enable the ws feature: @@ -75,6 +65,18 @@ taos = { version = "*", default-features = false, features = ["ws"] } ``` + + + +In `cargo.toml`, add [taos][taos] and enable the native feature: + +```toml +[dependencies] +taos = { version = "*", default-features = false, features = ["native"] } +``` + + + ## Establishing a connection diff --git a/docs/en/14-reference/03-connector/07-python.mdx b/docs/en/14-reference/03-connector/07-python.mdx index d92a93fd4f..1e7945bfd2 100644 --- a/docs/en/14-reference/03-connector/07-python.mdx +++ b/docs/en/14-reference/03-connector/07-python.mdx @@ -80,7 +80,7 @@ pip3 install git+https://github.com/taosdata/taos-connector-python.git ### Verify - + For native connection, you need to verify that both the client driver and the Python connector itself are installed correctly. The client driver and Python connector have been installed properly if you can successfully import the `taos` module. In the Python Interactive Shell, you can type. @@ -118,7 +118,7 @@ Requirement already satisfied: taospy in c:\users\username\appdata\local\program Before establishing a connection with the connector, we recommend testing the connectivity of the local TDengine CLI to the TDengine cluster. - + Ensure that the TDengine instance is up and that the FQDN of the machines in the cluster (the FQDN defaults to hostname if you are starting a standalone version) can be resolved locally, by testing with the `ping` command. @@ -173,7 +173,7 @@ If the test is successful, it will output the server version information, e.g. The following example code assumes that TDengine is installed locally and that the default configuration is used for both FQDN and serverPort. - + ```python @@ -219,7 +219,7 @@ All arguments to the `connect()` function are optional keyword arguments. The fo ### Basic Usage - + ##### TaosConnection class @@ -289,7 +289,7 @@ For a more detailed description of the `sql()` method, please refer to [RestClie ### Used with pandas - + ```python diff --git a/docs/en/14-reference/03-connector/08-node.mdx b/docs/en/14-reference/03-connector/08-node.mdx index bf7c6b95ea..a36cf0efc9 100644 --- a/docs/en/14-reference/03-connector/08-node.mdx +++ b/docs/en/14-reference/03-connector/08-node.mdx @@ -85,7 +85,7 @@ If using ARM64 Node.js on Windows 10 ARM, you must add "Visual C++ compilers and ### Install via npm - + ```bash @@ -124,7 +124,7 @@ node nodejsChecker.js host=localhost Please choose to use one of the connectors. - + Install and import the `@tdengine/client` package. diff --git a/docs/en/14-reference/03-connector/09-csharp.mdx b/docs/en/14-reference/03-connector/09-csharp.mdx index 87a10e17ca..85514f58ac 100644 --- a/docs/en/14-reference/03-connector/09-csharp.mdx +++ b/docs/en/14-reference/03-connector/09-csharp.mdx @@ -97,7 +97,7 @@ dotnet add exmaple.csproj reference src/TDengine.csproj ## Establish a Connection - + @@ -173,7 +173,7 @@ ws://localhost:6041/test #### SQL Write - + @@ -204,7 +204,7 @@ ws://localhost:6041/test #### Parameter Binding - + @@ -227,7 +227,7 @@ ws://localhost:6041/test #### Synchronous Query - + diff --git a/docs/en/14-reference/03-connector/_verify_linux.mdx b/docs/en/14-reference/03-connector/_verify_linux.mdx index 3438b1578e..220fccfef3 100644 --- a/docs/en/14-reference/03-connector/_verify_linux.mdx +++ b/docs/en/14-reference/03-connector/_verify_linux.mdx @@ -4,11 +4,11 @@ Execute TDengine CLI program `taos` directly from the Linux shell to connect to $ taos taos> show databases; - name | create_time | vgroups | ntables | replica | strict | duration | keep | buffer | pagesize | pages | minrows | maxrows | comp | precision | status | retention | single_stable | cachemodel | cachesize | wal_level | wal_fsync_period | wal_retention_period | wal_retention_size | wal_roll_period | wal_seg_size | -========================================================================================================================================================================================================================================================================================================================================================================================================================================================================= - information_schema | NULL | NULL | 14 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | ready | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | - performance_schema | NULL | NULL | 3 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | ready | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | - db | 2022-08-04 14:14:49.385 | 2 | 4 | 1 | off | 14400m | 5254560m,5254560m,5254560m | 96 | 4 | 256 | 100 | 4096 | 2 | ms | ready | NULL | false | none | 1 | 1 | 3000 | 0 | 0 | 0 | 0 | + name | +================================= + information_schema | + performance_schema | + db | Query OK, 3 rows in database (0.019154s) taos> diff --git a/docs/en/14-reference/03-connector/_verify_windows.mdx b/docs/en/14-reference/03-connector/_verify_windows.mdx index 402b170511..65d10f0875 100644 --- a/docs/en/14-reference/03-connector/_verify_windows.mdx +++ b/docs/en/14-reference/03-connector/_verify_windows.mdx @@ -2,12 +2,11 @@ Go to the `C:\TDengine` directory from `cmd` and execute TDengine CLI program `t ```text taos> show databases; - name | create_time | vgroups | ntables | replica | strict | duration | keep | buffer | pagesize | pages | minrows | maxrows | comp | precision | status | retention | single_stable | cachemodel | cachesize | wal_level | wal_fsync_period | wal_retention_period | wal_retention_size | wal_roll_period | wal_seg_size | -========================================================================================================================================================================================================================================================================================================================================================================================================================================================================= - information_schema | NULL | NULL | 14 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | ready | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | - performance_schema | NULL | NULL | 3 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | ready | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | - test | 2022-08-04 16:46:40.506 | 2 | 0 | 1 | off | 14400m | 5256000m,5256000m,5256000m | 96 | 4 | 256 | -100 | 4096 | 2 | ms | ready | NULL | false | none | 1 | 1 | 3000 | 0 | 0 | 0 | 0 | + name | +================================= + information_schema | + performance_schema | + test | Query OK, 3 rows in database (0.123000s) taos> diff --git a/docs/en/14-reference/11-docker/index.md b/docs/en/14-reference/11-docker/index.md index 7cd1e810dc..89987c456f 100644 --- a/docs/en/14-reference/11-docker/index.md +++ b/docs/en/14-reference/11-docker/index.md @@ -25,10 +25,11 @@ The TDengine client taos can be executed in this container to access TDengine us $ docker exec -it tdengine taos taos> show databases; - name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | -==================================================================================================================================================================================================================================================================================== - log | 2022-01-17 13:57:22.270 | 10 | 1 | 1 | 1 | 10 | 30 | 1 | 3 | 100 | 4096 | 1 | 3000 | 2 | 0 | us | 0 | ready | -Query OK, 1 row(s) in set (0.002843s) + name | +================================= + information_schema | + performance_schema | +Query OK, 2 row(s) in set (0.002843s) ``` The TDengine server running in the container uses the container's hostname to establish a connection. Using TDengine CLI or various connectors (such as JDBC-JNI) to access the TDengine inside the container from outside the container is more complicated. So the above is the simplest way to access the TDengine service in the container and is suitable for some simple scenarios. Please refer to the next section if you want to access the TDengine service in the container from outside the container using TDengine CLI or various connectors for complex scenarios. diff --git a/docs/en/14-reference/12-config/index.md b/docs/en/14-reference/12-config/index.md index 5ab6f59454..726a1ccd69 100644 --- a/docs/en/14-reference/12-config/index.md +++ b/docs/en/14-reference/12-config/index.md @@ -177,12 +177,21 @@ The parameters described in this document by the effect that they have on the sy ### maxNumOfDistinctRes | Attribute | Description | -| -------- | -------------------------------- | --- | +| -------- | -------------------------------- | | Applicable | Server Only | | Meaning | The maximum number of distinct rows returned | | Value Range | [100,000 - 100,000,000] | | Default Value | 100,000 | +### keepColumnName + +| Attribute | Description | +| -------- | -------------------------------- | +| Applicable | Client only | +| Meaning | When the Last, First, LastRow function is queried, whether the returned column name contains the function name. | +| Value Range | 0 means including the function name, 1 means not including the function name. | +| Default Value | 0 | + ## Locale Parameters ### timezone diff --git a/docs/en/14-reference/13-schemaless/13-schemaless.md b/docs/en/14-reference/13-schemaless/13-schemaless.md index 4f50c38cbb..5b7924ce56 100644 --- a/docs/en/14-reference/13-schemaless/13-schemaless.md +++ b/docs/en/14-reference/13-schemaless/13-schemaless.md @@ -47,9 +47,8 @@ In the schemaless writing data line protocol, each data item in the field_set ne - `t`, `T`, `true`, `True`, `TRUE`, `f`, `F`, `false`, and `False` will be handled directly as BOOL types. -For example, the following data rows indicate that the t1 label is "3" (NCHAR), the t2 label is "4" (NCHAR), and the t3 label -is "t3" to the super table named `st` labeled "t3" (NCHAR), write c1 column as 3 (BIGINT), c2 column as false (BOOL), c3 column -is "passit" (BINARY), c4 column is 4 (DOUBLE), and the primary key timestamp is 1626006833639000000 in one row. +For example, the following data rows write c1 column as 3 (BIGINT), c2 column as false (BOOL), c3 column +as "passit" (BINARY), c4 column as 4 (DOUBLE), and the primary key timestamp as 1626006833639000000 to child table with the t1 label as "3" (NCHAR), the t2 label as "4" (NCHAR), and the t3 label as "t3" (NCHAR) and the super table named `st`. ```json st,t1=3,t2=4,t3=t3 c1=3i64,c3="passit",c2=false,c4=4f64 1626006833639000000 @@ -69,7 +68,7 @@ Schemaless writes process row data according to the following principles. Note that tag_key1, tag_key2 are not the original order of the tags entered by the user but the result of using the tag names in ascending order of the strings. Therefore, tag_key1 is not the first tag entered in the line protocol. The string's MD5 hash value "md5_val" is calculated after the ranking is completed. The calculation result is then combined with the string to generate the table name: "t_md5_val". "t_" is a fixed prefix that every table generated by this mapping relationship has. -You can configure smlChildTableName to specify table names, for example, `smlChildTableName=tname`. You can insert `st,tname=cpul,t1=4 c1=3 1626006833639000000` and the cpu1 table will be automatically created. Note that if multiple rows have the same tname but different tag_set values, the tag_set of the first row is used to create the table and the others are ignored. +You can configure smlChildTableName in taos.cfg to specify table names, for example, `smlChildTableName=tname`. You can insert `st,tname=cpul,t1=4 c1=3 1626006833639000000` and the cpu1 table will be automatically created. Note that if multiple rows have the same tname but different tag_set values, the tag_set of the first row is used to create the table and the others are ignored. 2. If the super table obtained by parsing the line protocol does not exist, this super table is created. 3. If the subtable obtained by the parse line protocol does not exist, Schemaless creates the sub-table according to the subtable name determined in steps 1 or 2. @@ -78,7 +77,7 @@ You can configure smlChildTableName to specify table names, for example, `smlChi NULL. 6. For BINARY or NCHAR columns, if the length of the value provided in a data row exceeds the column type limit, the maximum length of characters allowed to be stored in the column is automatically increased (only incremented and not decremented) to ensure complete preservation of the data. 7. Errors encountered throughout the processing will interrupt the writing process and return an error code. -8. It is assumed that the order of field_set in a supertable is consistent, meaning that the first record contains all fields and subsequent records store fields in the same order. If the order is not consistent, set smlDataFormat to false. Otherwise, data will be written out of order and a database error will occur. +8. It is assumed that the order of field_set in a supertable is consistent, meaning that the first record contains all fields and subsequent records store fields in the same order. If the order is not consistent, set smlDataFormat in taos.cfg to false. Otherwise, data will be written out of order and a database error will occur.(smlDataFormat in taos.cfg default to false after version of 3.0.1.3) :::tip All processing logic of schemaless will still follow TDengine's underlying restrictions on data structures, such as the total length of each row of data cannot exceed diff --git a/docs/en/14-reference/_statsd.mdx b/docs/en/14-reference/_statsd.mdx index d0721a16fb..d068304a1d 100644 --- a/docs/en/14-reference/_statsd.mdx +++ b/docs/en/14-reference/_statsd.mdx @@ -51,5 +51,6 @@ port: 8125 Start StatsD after adding the following (assuming the config file is modified to config.js) ``` +npm install node stats.js config.js & ``` diff --git a/docs/en/14-reference/_telegraf.mdx b/docs/en/14-reference/_telegraf.mdx index e32fb25693..bcf1a0893f 100644 --- a/docs/en/14-reference/_telegraf.mdx +++ b/docs/en/14-reference/_telegraf.mdx @@ -22,5 +22,4 @@ An example is as follows. username = "root" password = "taosdata" data_format = "influx" - influx_max_line_bytes = 250 ``` diff --git a/docs/en/20-third-party/02-prometheus.md b/docs/en/20-third-party/02-prometheus.md index 0fb41a1696..ef9b9cb637 100644 --- a/docs/en/20-third-party/02-prometheus.md +++ b/docs/en/20-third-party/02-prometheus.md @@ -30,21 +30,20 @@ After restarting Prometheus, you can refer to the following example to verify th ``` taos> show databases; - name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | -==================================================================================================================================================================================================================================================================================== - test | 2022-04-12 08:07:58.756 | 1 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | - log | 2022-04-20 07:19:50.260 | 2 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | - prometheus_data | 2022-04-20 07:21:09.202 | 158 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | - db | 2022-04-15 06:37:08.512 | 1 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | -Query OK, 4 row(s) in set (0.000585s) + name | +================================= + information_schema | + performance_schema | + prometheus_data | +Query OK, 3 row(s) in set (0.000585s) taos> use prometheus_data; Database changed. taos> show stables; - name | created_time | columns | tags | tables | -============================================================================================ - metrics | 2022-04-20 07:21:09.209 | 2 | 1 | 1389 | + name | +================================= + metrics | Query OK, 1 row(s) in set (0.000487s) taos> select * from metrics limit 10; @@ -89,3 +88,7 @@ VALUE TIMESTAMP ``` +:::note + +- TDengine will automatically create unique IDs for sub-table names by the rule. +::: diff --git a/docs/en/20-third-party/03-telegraf.md b/docs/en/20-third-party/03-telegraf.md index 6a7aac322f..8f3cab0e57 100644 --- a/docs/en/20-third-party/03-telegraf.md +++ b/docs/en/20-third-party/03-telegraf.md @@ -15,6 +15,7 @@ To write Telegraf data to TDengine requires the following preparations. - The TDengine cluster is deployed and functioning properly - taosAdapter is installed and running properly. Please refer to the [taosAdapter manual](/reference/taosadapter) for details. - Telegraf has been installed. Please refer to the [official documentation](https://docs.influxdata.com/telegraf/v1.22/install/) for Telegraf installation. +- Telegraf collects the running status measurements of current system. You can enable [input plugins](https://docs.influxdata.com/telegraf/v1.22/plugins/) to insert [other formats](https://docs.influxdata.com/telegraf/v1.24/data_formats/input/) data to Telegraf then forward to TDengine. ## Configuration steps @@ -31,26 +32,27 @@ Use TDengine CLI to verify Telegraf correctly writing data to TDengine and read ``` taos> show databases; - name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | -==================================================================================================================================================================================================================================================================================== - telegraf | 2022-04-20 08:47:53.488 | 22 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | - log | 2022-04-20 07:19:50.260 | 9 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | -Query OK, 2 row(s) in set (0.002401s) + name | +================================= + information_schema | + performance_schema | + telegraf | +Query OK, 3 rows in database (0.010568s) taos> use telegraf; Database changed. taos> show stables; - name | created_time | columns | tags | tables | -============================================================================================ - swap | 2022-04-20 08:47:53.532 | 7 | 1 | 1 | - cpu | 2022-04-20 08:48:03.488 | 11 | 2 | 5 | - system | 2022-04-20 08:47:53.512 | 8 | 1 | 1 | - diskio | 2022-04-20 08:47:53.550 | 12 | 2 | 15 | - kernel | 2022-04-20 08:47:53.503 | 6 | 1 | 1 | - mem | 2022-04-20 08:47:53.521 | 35 | 1 | 1 | - processes | 2022-04-20 08:47:53.555 | 12 | 1 | 1 | - disk | 2022-04-20 08:47:53.541 | 8 | 5 | 2 | + name | +================================= + swap | + cpu | + system | + diskio | + kernel | + mem | + processes | + disk | Query OK, 8 row(s) in set (0.000521s) taos> select * from telegraf.system limit 10; @@ -65,3 +67,11 @@ taos> select * from telegraf.system limit 10; | Query OK, 3 row(s) in set (0.013269s) ``` + +:::note + +- TDengine take influxdb format data and create unique ID for table names by the rule. +The user can configure `smlChildTableName` parameter to generate specified table names if he/she needs. And he/she also need to insert data with specified data format. +For example, Add `smlChildTableName=tname` in the taos.cfg file. Insert data `st,tname=cpu1,t1=4 c1=3 1626006833639000000` then the table name will be cpu1. If there are multiple lines has same tname but different tag_set, the first line's tag_set will be used to automatically creating table and ignore other lines. Please refer to [TDengine Schemaless](/reference/schemaless/#Schemaless-Line-Protocol) +::: + diff --git a/docs/en/20-third-party/05-collectd.md b/docs/en/20-third-party/05-collectd.md index db62f2ecd1..5b52e3b7bc 100644 --- a/docs/en/20-third-party/05-collectd.md +++ b/docs/en/20-third-party/05-collectd.md @@ -32,28 +32,29 @@ Use the TDengine CLI to verify that collectd's data is written to TDengine and c ``` taos> show databases; - name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | -==================================================================================================================================================================================================================================================================================== - collectd | 2022-04-20 09:27:45.460 | 95 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | - log | 2022-04-20 07:19:50.260 | 11 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | -Query OK, 2 row(s) in set (0.003266s) + name | +================================= + information_schema | + performance_schema | + collectd | +Query OK, 3 row(s) in set (0.003266s) taos> use collectd; Database changed. taos> show stables; - name | created_time | columns | tags | tables | -============================================================================================ - load_1 | 2022-04-20 09:27:45.492 | 2 | 2 | 1 | - memory_value | 2022-04-20 09:27:45.463 | 2 | 3 | 6 | - df_value | 2022-04-20 09:27:45.463 | 2 | 4 | 25 | - load_2 | 2022-04-20 09:27:45.501 | 2 | 2 | 1 | - load_0 | 2022-04-20 09:27:45.485 | 2 | 2 | 1 | - interface_1 | 2022-04-20 09:27:45.488 | 2 | 3 | 12 | - irq_value | 2022-04-20 09:27:45.476 | 2 | 3 | 31 | - interface_0 | 2022-04-20 09:27:45.480 | 2 | 3 | 12 | - entropy_value | 2022-04-20 09:27:45.473 | 2 | 2 | 1 | - swap_value | 2022-04-20 09:27:45.477 | 2 | 3 | 5 | + name | +================================= + load_1 | + memory_value | + df_value | + load_2 | + load_0 | + interface_1 | + irq_value | + interface_0 | + entropy_value | + swap_value | Query OK, 10 row(s) in set (0.002236s) taos> select * from collectd.memory_value limit 10; @@ -72,3 +73,7 @@ taos> select * from collectd.memory_value limit 10; Query OK, 10 row(s) in set (0.010348s) ``` +:::note + +- TDengine will automatically create unique IDs for sub-table names by the rule. +::: diff --git a/docs/en/20-third-party/06-statsd.md b/docs/en/20-third-party/06-statsd.md index 32b1bbb97a..b861a48ecd 100644 --- a/docs/en/20-third-party/06-statsd.md +++ b/docs/en/20-third-party/06-statsd.md @@ -26,7 +26,7 @@ Start StatsD: ``` $ node stats.js config.js & [1] 8546 -$ 20 Apr 09:54:41 - [8546] reading config file: exampleConfig.js +$ 20 Apr 09:54:41 - [8546] reading config file: config.js 20 Apr 09:54:41 - server is up INFO ``` @@ -40,19 +40,20 @@ Use the TDengine CLI to verify that StatsD data is written to TDengine and can r ``` taos> show databases; - name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | -==================================================================================================================================================================================================================================================================================== - log | 2022-04-20 07:19:50.260 | 11 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | - statsd | 2022-04-20 09:54:51.220 | 1 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | -Query OK, 2 row(s) in set (0.003142s) + name | +================================= + information_schema | + performance_schema | + statsd | +Query OK, 3 row(s) in set (0.003142s) taos> use statsd; Database changed. taos> show stables; - name | created_time | columns | tags | tables | -============================================================================================ - foo | 2022-04-20 09:54:51.234 | 2 | 1 | 1 | + name | +================================= + foo | Query OK, 1 row(s) in set (0.002161s) taos> select * from foo; @@ -63,3 +64,8 @@ Query OK, 1 row(s) in set (0.004179s) taos> ``` + +:::note + +- TDengine will automatically create unique IDs for sub-table names by the rule. +::: diff --git a/docs/en/20-third-party/07-icinga2.md b/docs/en/20-third-party/07-icinga2.md index b27196dfe3..167b6a4303 100644 --- a/docs/en/20-third-party/07-icinga2.md +++ b/docs/en/20-third-party/07-icinga2.md @@ -36,39 +36,45 @@ After waiting about 10 seconds, use the TDengine CLI to query TDengine to verify ``` taos> show databases; - name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | -==================================================================================================================================================================================================================================================================================== - log | 2022-04-20 07:19:50.260 | 11 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | - icinga2 | 2022-04-20 12:11:39.697 | 13 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | -Query OK, 2 row(s) in set (0.001867s) + name | +================================= + information_schema | + performance_schema | + icinga2 | +Query OK, 3 row(s) in set (0.001867s) taos> use icinga2; Database changed. taos> show stables; - name | created_time | columns | tags | tables | -============================================================================================ - icinga.service.users.state_... | 2022-04-20 12:11:39.726 | 2 | 1 | 1 | - icinga.service.users.acknow... | 2022-04-20 12:11:39.756 | 2 | 1 | 1 | - icinga.service.procs.downti... | 2022-04-20 12:11:44.541 | 2 | 1 | 1 | - icinga.service.users.users | 2022-04-20 12:11:39.770 | 2 | 1 | 1 | - icinga.service.procs.procs_min | 2022-04-20 12:11:44.599 | 2 | 1 | 1 | - icinga.service.users.users_min | 2022-04-20 12:11:39.809 | 2 | 1 | 1 | - icinga.check.max_check_atte... | 2022-04-20 12:11:39.847 | 2 | 3 | 2 | - icinga.service.procs.state_... | 2022-04-20 12:11:44.522 | 2 | 1 | 1 | - icinga.service.procs.procs_... | 2022-04-20 12:11:44.576 | 2 | 1 | 1 | - icinga.service.users.users_... | 2022-04-20 12:11:39.796 | 2 | 1 | 1 | - icinga.check.latency | 2022-04-20 12:11:39.869 | 2 | 3 | 2 | - icinga.service.procs.procs_... | 2022-04-20 12:11:44.588 | 2 | 1 | 1 | - icinga.service.users.downti... | 2022-04-20 12:11:39.746 | 2 | 1 | 1 | - icinga.service.users.users_... | 2022-04-20 12:11:39.783 | 2 | 1 | 1 | - icinga.service.users.reachable | 2022-04-20 12:11:39.736 | 2 | 1 | 1 | - icinga.service.procs.procs | 2022-04-20 12:11:44.565 | 2 | 1 | 1 | - icinga.service.procs.acknow... | 2022-04-20 12:11:44.554 | 2 | 1 | 1 | - icinga.service.procs.state | 2022-04-20 12:11:44.509 | 2 | 1 | 1 | - icinga.service.procs.reachable | 2022-04-20 12:11:44.532 | 2 | 1 | 1 | - icinga.check.current_attempt | 2022-04-20 12:11:39.825 | 2 | 3 | 2 | - icinga.check.execution_time | 2022-04-20 12:11:39.898 | 2 | 3 | 2 | - icinga.service.users.state | 2022-04-20 12:11:39.704 | 2 | 1 | 1 | + name | +================================= + icinga.service.users.state_... | + icinga.service.users.acknow... | + icinga.service.procs.downti... | + icinga.service.users.users | + icinga.service.procs.procs_min | + icinga.service.users.users_min | + icinga.check.max_check_atte... | + icinga.service.procs.state_... | + icinga.service.procs.procs_... | + icinga.service.users.users_... | + icinga.check.latency | + icinga.service.procs.procs_... | + icinga.service.users.downti... | + icinga.service.users.users_... | + icinga.service.users.reachable | + icinga.service.procs.procs | + icinga.service.procs.acknow... | + icinga.service.procs.state | + icinga.service.procs.reachable | + icinga.check.current_attempt | + icinga.check.execution_time | + icinga.service.users.state | Query OK, 22 row(s) in set (0.002317s) ``` + +:::note + +- TDengine will automatically create unique IDs for sub-table names by the rule. +::: diff --git a/docs/en/20-third-party/08-tcollector.md b/docs/en/20-third-party/08-tcollector.md index 16b73c2394..b604a2d712 100644 --- a/docs/en/20-third-party/08-tcollector.md +++ b/docs/en/20-third-party/08-tcollector.md @@ -33,35 +33,41 @@ Wait for a few seconds and then use the TDengine CLI to query whether the corres ``` taos> show databases; - name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | -==================================================================================================================================================================================================================================================================================== - tcollector | 2022-04-20 12:44:49.604 | 88 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | - log | 2022-04-20 07:19:50.260 | 11 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | -Query OK, 2 row(s) in set (0.002679s) + name | +================================= + information_schema | + performance_schema | + tcollector | +Query OK, 3 rows in database (0.001647s) taos> use tcollector; Database changed. taos> show stables; - name | created_time | columns | tags | tables | -============================================================================================ - proc.meminfo.hugepages_rsvd | 2022-04-20 12:44:53.945 | 2 | 1 | 1 | - proc.meminfo.directmap1g | 2022-04-20 12:44:54.110 | 2 | 1 | 1 | - proc.meminfo.vmallocchunk | 2022-04-20 12:44:53.724 | 2 | 1 | 1 | - proc.meminfo.hugepagesize | 2022-04-20 12:44:54.004 | 2 | 1 | 1 | - tcollector.reader.lines_dro... | 2022-04-20 12:44:49.675 | 2 | 1 | 1 | - proc.meminfo.sunreclaim | 2022-04-20 12:44:53.437 | 2 | 1 | 1 | - proc.stat.ctxt | 2022-04-20 12:44:55.363 | 2 | 1 | 1 | - proc.meminfo.swaptotal | 2022-04-20 12:44:53.158 | 2 | 1 | 1 | - proc.uptime.total | 2022-04-20 12:44:52.813 | 2 | 1 | 1 | - tcollector.collector.lines_... | 2022-04-20 12:44:49.895 | 2 | 2 | 51 | - proc.meminfo.vmallocused | 2022-04-20 12:44:53.704 | 2 | 1 | 1 | - proc.meminfo.memavailable | 2022-04-20 12:44:52.939 | 2 | 1 | 1 | - sys.numa.foreign_allocs | 2022-04-20 12:44:57.929 | 2 | 2 | 1 | - proc.meminfo.committed_as | 2022-04-20 12:44:53.639 | 2 | 1 | 1 | - proc.vmstat.pswpin | 2022-04-20 12:44:54.177 | 2 | 1 | 1 | - proc.meminfo.cmafree | 2022-04-20 12:44:53.865 | 2 | 1 | 1 | - proc.meminfo.mapped | 2022-04-20 12:44:53.349 | 2 | 1 | 1 | - proc.vmstat.pgmajfault | 2022-04-20 12:44:54.251 | 2 | 1 | 1 | + name | +================================= + proc.meminfo.hugepages_rsvd | + proc.meminfo.directmap1g | + proc.meminfo.vmallocchunk | + proc.meminfo.hugepagesize | + tcollector.reader.lines_dro... | + proc.meminfo.sunreclaim | + proc.stat.ctxt | + proc.meminfo.swaptotal | + proc.uptime.total | + tcollector.collector.lines_... | + proc.meminfo.vmallocused | + proc.meminfo.memavailable | + sys.numa.foreign_allocs | + proc.meminfo.committed_as | + proc.vmstat.pswpin | + proc.meminfo.cmafree | + proc.meminfo.mapped | + proc.vmstat.pgmajfault | ... ``` + +:::note + +- TDengine will automatically create unique IDs for sub-table names by the rule. +::: diff --git a/docs/en/25-application/01-telegraf.md b/docs/en/25-application/01-telegraf.md index 59491152bc..f700326449 100644 --- a/docs/en/25-application/01-telegraf.md +++ b/docs/en/25-application/01-telegraf.md @@ -60,7 +60,6 @@ For the configuration method, add the following text to `/etc/telegraf/telegraf. username = "" password = "" data_format = "influx" - influx_max_line_bytes = 250 ``` Then restart telegraf: diff --git a/docs/en/28-releases/01-tdengine.md b/docs/en/28-releases/01-tdengine.md index 414986d107..808a21474e 100644 --- a/docs/en/28-releases/01-tdengine.md +++ b/docs/en/28-releases/01-tdengine.md @@ -6,6 +6,14 @@ description: TDengine release history, Release Notes and download links. import Release from "/components/ReleaseV3"; +## 3.0.1.4 + + + +## 3.0.1.3 + + + ## 3.0.1.2 diff --git a/docs/en/28-releases/02-tools.md b/docs/en/28-releases/02-tools.md index 086d3adea2..5d6693ae73 100644 --- a/docs/en/28-releases/02-tools.md +++ b/docs/en/28-releases/02-tools.md @@ -6,6 +6,14 @@ description: taosTools release history, Release Notes, download links. import Release from "/components/ReleaseV3"; +## 2.2.4 + + + +## 2.2.3 + + + ## 2.2.2 diff --git a/docs/zh/07-develop/03-insert-data/02-influxdb-line.mdx b/docs/zh/07-develop/03-insert-data/02-influxdb-line.mdx index f88284ad67..a107ffb1b6 100644 --- a/docs/zh/07-develop/03-insert-data/02-influxdb-line.mdx +++ b/docs/zh/07-develop/03-insert-data/02-influxdb-line.mdx @@ -37,7 +37,9 @@ meters,location=California.LosAngeles,groupid=2 current=13.4,voltage=223,phase=0 - tag_set 中的所有的数据自动转化为 nchar 数据类型; - field_set 中的每个数据项都需要对自身的数据类型进行描述, 比如 1.2f32 代表 float 类型的数值 1.2, 如果不带类型后缀会被当作 double 处理; - timestamp 支持多种时间精度。写入数据的时候需要用参数指定时间精度,支持从小时到纳秒的 6 种时间精度。 - +- 为了提高写入的效率,默认假设同一个超级表中 field_set 的顺序是一样的(第一条数据包含所有的 field,后面的数据按照这个顺序),如果顺序不一样,需要配置参数 smlDataFormat 为 false,否则,数据写入按照相同顺序写入,库中数据会异常。(3.0.1.3之后的版本 smlDataFormat 默认为 false) [TDengine 无模式写入参考指南](/reference/schemaless/#无模式写入行协议) +- 默认生产的子表名是根据规则生成的唯一ID值。为了让用户可以指定生成的表名,可以通过在taos.cfg里配置 smlChildTableName 参数来指定。 +举例如下:配置 smlChildTableName=tname 插入数据为 st,tname=cpu1,t1=4 c1=3 1626006833639000000 则创建的表名为 cpu1,注意如果多行数据 tname 相同,但是后面的 tag_set 不同,则使用第一行自动建表时指定的 tag_set,其他的行会忽略)。[TDengine 无模式写入参考指南](/reference/schemaless/#无模式写入行协议) ::: 要了解更多可参考:[InfluxDB Line 协议官方文档](https://docs.influxdata.com/influxdb/v2.0/reference/syntax/line-protocol/) 和 [TDengine 无模式写入参考指南](/reference/schemaless/#无模式写入行协议) @@ -64,3 +66,7 @@ meters,location=California.LosAngeles,groupid=2 current=13.4,voltage=223,phase=0 + +## 查询示例 +比如查询 location=California.LosAngeles,groupid=2 子表的数据可以通过如下sql: +select * from meters where location=California.LosAngeles and groupid=2 diff --git a/docs/zh/07-develop/03-insert-data/03-opentsdb-telnet.mdx b/docs/zh/07-develop/03-insert-data/03-opentsdb-telnet.mdx index 4f63e17635..8d097e3f65 100644 --- a/docs/zh/07-develop/03-insert-data/03-opentsdb-telnet.mdx +++ b/docs/zh/07-develop/03-insert-data/03-opentsdb-telnet.mdx @@ -32,6 +32,8 @@ OpenTSDB 行协议同样采用一行字符串来表示一行数据。OpenTSDB meters.current 1648432611250 11.3 location=California.LosAngeles groupid=3 ``` +- 默认生产的子表名是根据规则生成的唯一ID值。为了让用户可以指定生成的表名,可以通过在taos.cfg里配置 smlChildTableName 参数来指定。 +举例如下:配置 smlChildTableName=tname 插入数据为 meters.current 1648432611250 11.3 tname=cpu1 location=California.LosAngeles groupid=3 则创建的表名为 cpu1,注意如果多行数据 tname 相同,但是后面的 tag_set 不同,则使用第一行自动建表时指定的 tag_set,其他的行会忽略)。 参考[OpenTSDB Telnet API 文档](http://opentsdb.net/docs/build/html/api_telnet/put.html)。 ## 示例代码 @@ -64,10 +66,10 @@ taos> use test; Database changed. taos> show stables; - name | created_time | columns | tags | tables | -============================================================================================ - meters.current | 2022-03-30 17:04:10.877 | 2 | 2 | 2 | - meters.voltage | 2022-03-30 17:04:10.882 | 2 | 2 | 2 | + name | +================================= + meters.current | + meters.voltage | Query OK, 2 row(s) in set (0.002544s) taos> select tbname, * from `meters.current`; @@ -79,3 +81,6 @@ taos> select tbname, * from `meters.current`; t_7e7b26dd860280242c6492a16... | 2022-03-28 09:56:51.250 | 12.600000000 | 2 | California.SanFrancisco | Query OK, 4 row(s) in set (0.005399s) ``` +## 查询示例: +想要查询 location=California.LosAngeles groupid=3 的数据,可以通过如下sql: +select * from `meters.voltage` where location="California.LosAngeles" and groupid=3 diff --git a/docs/zh/07-develop/03-insert-data/04-opentsdb-json.mdx b/docs/zh/07-develop/03-insert-data/04-opentsdb-json.mdx index b0257b9cb7..e2e7d7c8fa 100644 --- a/docs/zh/07-develop/03-insert-data/04-opentsdb-json.mdx +++ b/docs/zh/07-develop/03-insert-data/04-opentsdb-json.mdx @@ -48,7 +48,8 @@ OpenTSDB JSON 格式协议采用一个 JSON 字符串表示一行或多行数据 - 对于 JSON 格式协议,TDengine 并不会自动把所有标签转成 nchar 类型, 字符串将将转为 nchar 类型, 数值将同样转换为 double 类型。 - TDengine 只接收 JSON **数组格式**的字符串,即使一行数据也需要转换成数组形式。 - +- 默认生产的子表名是根据规则生成的唯一ID值。为了让用户可以指定生成的表名,可以通过在taos.cfg里配置 smlChildTableName 参数来指定。 +举例如下:配置 smlChildTableName=tname 插入数据为 "tags": { "host": "web02","dc": "lga","tname":"cpu1"} 则创建的表名为 cpu1,注意如果多行数据 tname 相同,但是后面的 tag_set 不同,则使用第一行自动建表时指定的 tag_set,其他的行会忽略)。 ::: ## 示例代码 @@ -81,10 +82,10 @@ taos> use test; Database changed. taos> show stables; - name | created_time | columns | tags | tables | -============================================================================================ - meters.current | 2022-03-29 16:05:25.193 | 2 | 2 | 1 | - meters.voltage | 2022-03-29 16:05:25.200 | 2 | 2 | 1 | + name | +================================= + meters.current | + meters.voltage | Query OK, 2 row(s) in set (0.001954s) taos> select * from `meters.current`; @@ -94,3 +95,7 @@ taos> select * from `meters.current`; 2022-03-28 09:56:51.250 | 12.600000000 | 2.000000000 | California.SanFrancisco | Query OK, 2 row(s) in set (0.004076s) ``` + +## 查询示例 +想要查询"tags": {"location": "California.LosAngeles", "groupid": 1} 的数据,可以通过如下sql: +select * from `meters.voltage` where location="California.LosAngeles" and groupid=1 diff --git a/docs/zh/08-connector/14-java.mdx b/docs/zh/08-connector/14-java.mdx index 6b1715f8c6..d78da52aaa 100644 --- a/docs/zh/08-connector/14-java.mdx +++ b/docs/zh/08-connector/14-java.mdx @@ -109,7 +109,7 @@ TDengine 的 JDBC URL 规范格式为: 对于建立连接,原生连接与 REST 连接有细微不同。 - + ```java diff --git a/docs/zh/08-connector/20-go.mdx b/docs/zh/08-connector/20-go.mdx index 9d30f75190..515d1b030b 100644 --- a/docs/zh/08-connector/20-go.mdx +++ b/docs/zh/08-connector/20-go.mdx @@ -114,7 +114,7 @@ username:password@protocol(address)/dbname?param=value ``` ### 使用连接器进行连接 - + _taosSql_ 通过 cgo 实现了 Go 的 `database/sql/driver` 接口。只需要引入驱动就可以使用 [`database/sql`](https://golang.org/pkg/database/sql/) 的接口。 diff --git a/docs/zh/08-connector/26-rust.mdx b/docs/zh/08-connector/26-rust.mdx index f6b99beed3..63dce4b69b 100644 --- a/docs/zh/08-connector/26-rust.mdx +++ b/docs/zh/08-connector/26-rust.mdx @@ -55,16 +55,6 @@ taos = "*" - - -在 `Cargo.toml` 文件中添加 [taos][taos],并启用 `native` 特性: - -```toml -[dependencies] -taos = { version = "*", default-features = false, features = ["native"] } -``` - - 在 `Cargo.toml` 文件中添加 [taos][taos],并启用 `ws` 特性。 @@ -74,6 +64,17 @@ taos = { version = "*", default-features = false, features = ["native"] } taos = { version = "*", default-features = false, features = ["ws"] } ``` + + + + +在 `Cargo.toml` 文件中添加 [taos][taos],并启用 `native` 特性: + +```toml +[dependencies] +taos = { version = "*", default-features = false, features = ["native"] } +``` + diff --git a/docs/zh/08-connector/30-python.mdx b/docs/zh/08-connector/30-python.mdx index 0242486d3b..c70677f816 100644 --- a/docs/zh/08-connector/30-python.mdx +++ b/docs/zh/08-connector/30-python.mdx @@ -80,7 +80,7 @@ pip3 install git+https://github.com/taosdata/taos-connector-python.git ### 安装验证 - + 对于原生连接,需要验证客户端驱动和 Python 连接器本身是否都正确安装。如果能成功导入 `taos` 模块,则说明已经正确安装了客户端驱动和 Python 连接器。可在 Python 交互式 Shell 中输入: @@ -118,7 +118,7 @@ Requirement already satisfied: taospy in c:\users\username\appdata\local\program 在用连接器建立连接之前,建议先测试本地 TDengine CLI 到 TDengine 集群的连通性。 - + 请确保 TDengine 集群已经启动, 且集群中机器的 FQDN (如果启动的是单机版,FQDN 默认为 hostname)在本机能够解析, 可用 `ping` 命令进行测试: @@ -173,7 +173,7 @@ curl -u root:taosdata http://:/rest/sql -d "select server_version()" 以下示例代码假设 TDengine 安装在本机, 且 FQDN 和 serverPort 都使用了默认配置。 - + ```python @@ -219,7 +219,7 @@ curl -u root:taosdata http://:/rest/sql -d "select server_version()" ### 基本使用 - + ##### TaosConnection 类的使用 @@ -289,7 +289,7 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线 ### 与 pandas 一起使用 - + ```python diff --git a/docs/zh/08-connector/35-node.mdx b/docs/zh/08-connector/35-node.mdx index 167ae069d6..1de19cdd3a 100644 --- a/docs/zh/08-connector/35-node.mdx +++ b/docs/zh/08-connector/35-node.mdx @@ -85,7 +85,7 @@ REST 连接器支持所有能运行 Node.js 的平台。 ### 使用 npm 安装 - + ```bash @@ -124,7 +124,7 @@ node nodejsChecker.js host=localhost 请选择使用一种连接器。 - + 安装并引用 `@tdengine/client` 包。 diff --git a/docs/zh/08-connector/40-csharp.mdx b/docs/zh/08-connector/40-csharp.mdx index e99f41ae9c..70c0382080 100644 --- a/docs/zh/08-connector/40-csharp.mdx +++ b/docs/zh/08-connector/40-csharp.mdx @@ -35,7 +35,7 @@ import CSAsyncQuery from "../07-develop/04-query-data/_cs_async.mdx" ## 支持的功能特性 - + @@ -96,7 +96,7 @@ dotnet add exmaple.csproj reference src/TDengine.csproj ## 建立连接 - + @@ -171,7 +171,7 @@ namespace TDengineExample #### SQL 写入 - + @@ -203,7 +203,7 @@ namespace TDengineExample #### 参数绑定 - + @@ -227,7 +227,7 @@ namespace TDengineExample #### 同步查询 - + diff --git a/docs/zh/08-connector/_verify_linux.mdx b/docs/zh/08-connector/_verify_linux.mdx index 28957e77aa..4137b2880b 100644 --- a/docs/zh/08-connector/_verify_linux.mdx +++ b/docs/zh/08-connector/_verify_linux.mdx @@ -4,11 +4,11 @@ $ taos taos> show databases; - name | create_time | vgroups | ntables | replica | strict | duration | keep | buffer | pagesize | pages | minrows | maxrows | comp | precision | status | retention | single_stable | cachemodel | cachesize | wal_level | wal_fsync_period | wal_retention_period | wal_retention_size | wal_roll_period | wal_seg_size | -========================================================================================================================================================================================================================================================================================================================================================================================================================================================================= - information_schema | NULL | NULL | 14 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | ready | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | - performance_schema | NULL | NULL | 3 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | ready | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | - db | 2022-08-04 14:14:49.385 | 2 | 4 | 1 | off | 14400m | 5254560m,5254560m,5254560m | 96 | 4 | 256 | 100 | 4096 | 2 | ms | ready | NULL | false | none | 1 | 1 | 3000 | 0 | 0 | 0 | 0 | + name | +================================= + information_schema | + performance_schema | + db | Query OK, 3 rows in database (0.019154s) taos> diff --git a/docs/zh/12-taos-sql/06-select.md b/docs/zh/12-taos-sql/06-select.md index 394e4a99d5..b3b8ef3887 100644 --- a/docs/zh/12-taos-sql/06-select.md +++ b/docs/zh/12-taos-sql/06-select.md @@ -182,6 +182,14 @@ TDengine 中,所有表的第一列都必须是时间戳类型,且为其主 select _rowts, max(current) from meters; ``` +**\_IROWTS** + +\_irowts 伪列只能与 interp 函数一起使用,用于返回 interp 函数插值结果对应的时间戳列。 + +```sql +select _irowts, interp(current) from meters range('2020-01-01 10:00:00', '2020-01-01 10:30:00') every(1s) fill(linear); +``` + ## 查询对象 FROM 关键字后面可以是若干个表(超级表)列表,也可以是子查询的结果。 diff --git a/docs/zh/12-taos-sql/10-function.md b/docs/zh/12-taos-sql/10-function.md index 9726406b4d..4c33b5232a 100644 --- a/docs/zh/12-taos-sql/10-function.md +++ b/docs/zh/12-taos-sql/10-function.md @@ -14,7 +14,7 @@ toc_max_heading_level: 4 #### ABS ```sql -SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause] +ABS(expr) ``` **功能说明**:获得指定字段的绝对值。 @@ -32,7 +32,7 @@ SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause] #### ACOS ```sql -SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause] +ACOS(expr) ``` **功能说明**:获得指定字段的反余弦结果。 @@ -50,7 +50,7 @@ SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause] #### ASIN ```sql -SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause] +ASIN(expr) ``` **功能说明**:获得指定字段的反正弦结果。 @@ -69,7 +69,7 @@ SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause] #### ATAN ```sql -SELECT ATAN(field_name) FROM { tb_name | stb_name } [WHERE clause] +ATAN(expr) ``` **功能说明**:获得指定字段的反正切结果。 @@ -88,7 +88,7 @@ SELECT ATAN(field_name) FROM { tb_name | stb_name } [WHERE clause] #### CEIL ```sql -SELECT CEIL(field_name) FROM { tb_name | stb_name } [WHERE clause]; +CEIL(expr) ``` **功能说明**:获得指定字段的向上取整数的结果。 @@ -106,7 +106,7 @@ SELECT CEIL(field_name) FROM { tb_name | stb_name } [WHERE clause]; #### COS ```sql -SELECT COS(field_name) FROM { tb_name | stb_name } [WHERE clause] +COS(expr) ``` **功能说明**:获得指定字段的余弦结果。 @@ -124,7 +124,7 @@ SELECT COS(field_name) FROM { tb_name | stb_name } [WHERE clause] #### FLOOR ```sql -SELECT FLOOR(field_name) FROM { tb_name | stb_name } [WHERE clause]; +FLOOR(expr) ``` **功能说明**:获得指定字段的向下取整数的结果。 @@ -133,10 +133,10 @@ SELECT FLOOR(field_name) FROM { tb_name | stb_name } [WHERE clause]; #### LOG ```sql -SELECT LOG(field_name[, base]) FROM { tb_name | stb_name } [WHERE clause] +LOG(expr1[, expr2]) ``` -**功能说明**:获得指定字段对于底数 base 的对数。如果 base 参数省略,则返回指定字段的自然对数值。 +**功能说明**:获得 expr1 对于底数 expr2 的对数。如果 expr2 参数省略,则返回指定字段的自然对数值。 **返回结果类型**:DOUBLE。 @@ -152,10 +152,10 @@ SELECT LOG(field_name[, base]) FROM { tb_name | stb_name } [WHERE clause] #### POW ```sql -SELECT POW(field_name, power) FROM { tb_name | stb_name } [WHERE clause] +POW(expr1, expr2) ``` -**功能说明**:获得指定字段的指数为 power 的幂。 +**功能说明**:获得 expr1 的指数为 expr2 的幂。 **返回结果类型**:DOUBLE。 @@ -171,7 +171,7 @@ SELECT POW(field_name, power) FROM { tb_name | stb_name } [WHERE clause] #### ROUND ```sql -SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; +ROUND(expr) ``` **功能说明**:获得指定字段的四舍五入的结果。 @@ -181,7 +181,7 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; #### SIN ```sql -SELECT SIN(field_name) FROM { tb_name | stb_name } [WHERE clause] +SIN(expr) ``` **功能说明**:获得指定字段的正弦结果。 @@ -199,7 +199,7 @@ SELECT SIN(field_name) FROM { tb_name | stb_name } [WHERE clause] #### SQRT ```sql -SELECT SQRT(field_name) FROM { tb_name | stb_name } [WHERE clause] +SQRT(expr) ``` **功能说明**:获得指定字段的平方根。 @@ -217,7 +217,7 @@ SELECT SQRT(field_name) FROM { tb_name | stb_name } [WHERE clause] #### TAN ```sql -SELECT TAN(field_name) FROM { tb_name | stb_name } [WHERE clause] +TAN(expr) ``` **功能说明**:获得指定字段的正切结果。 @@ -239,7 +239,7 @@ SELECT TAN(field_name) FROM { tb_name | stb_name } [WHERE clause] #### CHAR_LENGTH ```sql -SELECT CHAR_LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] +CHAR_LENGTH(expr) ``` **功能说明**:以字符计数的字符串长度。 @@ -255,7 +255,7 @@ SELECT CHAR_LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] #### CONCAT ```sql -SELECT CONCAT(str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] +CONCAT(expr1, expr2 [, expr] ... ) ``` **功能说明**:字符串连接函数。 @@ -272,7 +272,7 @@ SELECT CONCAT(str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHER #### CONCAT_WS ```sql -SELECT CONCAT_WS(separator, str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] +CONCAT_WS(separator_expr, expr1, expr2 [, expr] ...) ``` **功能说明**:带分隔符的字符串连接函数。 @@ -289,7 +289,7 @@ SELECT CONCAT_WS(separator, str1|column1, str2|column2, ...) FROM { tb_name | st #### LENGTH ```sql -SELECT LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] +LENGTH(expr) ``` **功能说明**:以字节计数的字符串长度。 @@ -306,7 +306,7 @@ SELECT LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] #### LOWER ```sql -SELECT LOWER(str|column) FROM { tb_name | stb_name } [WHERE clause] +LOWER(expr) ``` **功能说明**:将字符串参数值转换为全小写字母。 @@ -323,7 +323,7 @@ SELECT LOWER(str|column) FROM { tb_name | stb_name } [WHERE clause] #### LTRIM ```sql -SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] +LTRIM(expr) ``` **功能说明**:返回清除左边空格后的字符串。 @@ -340,7 +340,7 @@ SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] #### RTRIM ```sql -SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] +LTRIM(expr) ``` **功能说明**:返回清除右边空格后的字符串。 @@ -357,7 +357,7 @@ SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] #### SUBSTR ```sql -SELECT SUBSTR(str,pos[,len]) FROM { tb_name | stb_name } [WHERE clause] +SUBSTR(expr, pos [,len]) ``` **功能说明**:从源字符串 str 中的指定位置 pos 开始取一个长度为 len 的子串并返回。如果输入参数 len 被忽略,返回的子串包含从 pos 开始的整个字串。 @@ -374,7 +374,7 @@ SELECT SUBSTR(str,pos[,len]) FROM { tb_name | stb_name } [WHERE clause] #### UPPER ```sql -SELECT UPPER(str|column) FROM { tb_name | stb_name } [WHERE clause] +UPPER(expr) ``` **功能说明**:将字符串参数值转换为全大写字母。 @@ -395,10 +395,10 @@ SELECT UPPER(str|column) FROM { tb_name | stb_name } [WHERE clause] #### CAST ```sql -SELECT CAST(expression AS type_name) FROM { tb_name | stb_name } [WHERE clause] +CAST(expr AS type_name) ``` -**功能说明**:数据类型转换函数,返回 expression 转换为 type_name 指定的类型后的结果。只适用于 select 子句中。 +**功能说明**:数据类型转换函数,返回 expr 转换为 type_name 指定的类型后的结果。只适用于 select 子句中。 **返回结果类型**:CAST 中指定的类型(type_name)。 @@ -419,7 +419,7 @@ SELECT CAST(expression AS type_name) FROM { tb_name | stb_name } [WHERE clause] #### TO_ISO8601 ```sql -SELECT TO_ISO8601(ts[, timezone]) FROM { tb_name | stb_name } [WHERE clause]; +TO_ISO8601(expr [, timezone]) ``` **功能说明**:将 UNIX 时间戳转换成为 ISO8601 标准的日期时间格式,并附加时区信息。timezone 参数允许用户为输出结果指定附带任意时区信息。如果 timezone 参数省略,输出结果则附带当前客户端的系统时区信息。 @@ -442,7 +442,7 @@ SELECT TO_ISO8601(ts[, timezone]) FROM { tb_name | stb_name } [WHERE clause]; #### TO_JSON ```sql -SELECT TO_JSON(str_literal) FROM { tb_name | stb_name } [WHERE clause]; +TO_JSON(str_literal) ``` **功能说明**: 将字符串常量转换为 JSON 类型。 @@ -459,7 +459,7 @@ SELECT TO_JSON(str_literal) FROM { tb_name | stb_name } [WHERE clause]; #### TO_UNIXTIMESTAMP ```sql -SELECT TO_UNIXTIMESTAMP(datetime_string) FROM { tb_name | stb_name } [WHERE clause]; +TO_UNIXTIMESTAMP(expr) ``` **功能说明**:将日期时间格式的字符串转换成为 UNIX 时间戳。 @@ -487,9 +487,7 @@ SELECT TO_UNIXTIMESTAMP(datetime_string) FROM { tb_name | stb_name } [WHERE clau #### NOW ```sql -SELECT NOW() FROM { tb_name | stb_name } [WHERE clause]; -SELECT select_expr FROM { tb_name | stb_name } WHERE ts_col cond_operatior NOW(); -INSERT INTO tb_name VALUES (NOW(), ...); +NOW() ``` **功能说明**:返回客户端当前系统时间。 @@ -512,7 +510,7 @@ INSERT INTO tb_name VALUES (NOW(), ...); #### TIMEDIFF ```sql -SELECT TIMEDIFF(ts | datetime_string1, ts | datetime_string2 [, time_unit]) FROM { tb_name | stb_name } [WHERE clause]; +TIMEDIFF(expr1, expr2 [, time_unit]) ``` **功能说明**:计算两个时间戳之间的差值,并近似到时间单位 time_unit 指定的精度。 @@ -535,7 +533,7 @@ SELECT TIMEDIFF(ts | datetime_string1, ts | datetime_string2 [, time_unit]) FROM #### TIMETRUNCATE ```sql -SELECT TIMETRUNCATE(ts | datetime_string , time_unit) FROM { tb_name | stb_name } [WHERE clause]; +TIMETRUNCATE(expr, time_unit) ``` **功能说明**:将时间戳按照指定时间单位 time_unit 进行截断。 @@ -556,7 +554,7 @@ SELECT TIMETRUNCATE(ts | datetime_string , time_unit) FROM { tb_name | stb_name #### TIMEZONE ```sql -SELECT TIMEZONE() FROM { tb_name | stb_name } [WHERE clause]; +TIMEZONE() ``` **功能说明**:返回客户端当前时区信息。 @@ -571,9 +569,7 @@ SELECT TIMEZONE() FROM { tb_name | stb_name } [WHERE clause]; #### TODAY ```sql -SELECT TODAY() FROM { tb_name | stb_name } [WHERE clause]; -SELECT select_expr FROM { tb_name | stb_name } WHERE ts_col cond_operatior TODAY()]; -INSERT INTO tb_name VALUES (TODAY(), ...); +TODAY() ``` **功能说明**:返回客户端当日零时的系统时间。 @@ -600,7 +596,12 @@ TDengine 支持针对数据的聚合查询。提供如下聚合函数。 ### APERCENTILE ```sql -SELECT APERCENTILE(field_name, P[, algo_type]) FROM { tb_name | stb_name } [WHERE clause] +APERCENTILE(expr, p [, algo_type]) + +algo_type: { + "default" + | "t-digest" +} ``` **功能说明**:统计表/超级表中指定列的值的近似百分比分位数,与 PERCENTILE 函数相似,但是返回近似结果。 @@ -612,14 +613,14 @@ SELECT APERCENTILE(field_name, P[, algo_type]) FROM { tb_name | stb_name } [WHER **适用于**:表和超级表。 **说明**: -- P值范围是[0,100],当为0时等同于MIN,为100时等同于MAX。 +- p值范围是[0,100],当为0时等同于MIN,为100时等同于MAX。 - algo_type 取值为 "default" 或 "t-digest"。 输入为 "default" 时函数使用基于直方图算法进行计算。输入为 "t-digest" 时使用t-digest算法计算分位数的近似结果。如果不指定 algo_type 则使用 "default" 算法。 - "t-digest"算法的近似结果对于输入数据顺序敏感,对超级表查询时不同的输入排序结果可能会有微小的误差。 ### AVG ```sql -SELECT AVG(field_name) FROM tb_name [WHERE clause]; +AVG(expr) ``` **功能说明**:统计指定字段的平均值。 @@ -634,7 +635,7 @@ SELECT AVG(field_name) FROM tb_name [WHERE clause]; ### COUNT ```sql -SELECT COUNT([*|field_name]) FROM tb_name [WHERE clause]; +COUNT({* | expr}) ``` **功能说明**:统计指定字段的记录行数。 @@ -654,7 +655,7 @@ SELECT COUNT([*|field_name]) FROM tb_name [WHERE clause]; ### ELAPSED ```sql -SELECT ELAPSED(ts_primary_key [, time_unit]) FROM { tb_name | stb_name } [WHERE clause] [INTERVAL(interval [, offset]) [SLIDING sliding]]; +ELAPSED(ts_primary_key [, time_unit]) ``` **功能说明**:elapsed函数表达了统计周期内连续的时间长度,和twa函数配合使用可以计算统计曲线下的面积。在通过INTERVAL子句指定窗口的情况下,统计在给定时间范围内的每个窗口内有数据覆盖的时间范围;如果没有INTERVAL子句,则返回整个给定时间范围内的有数据覆盖的时间范围。注意,ELAPSED返回的并不是时间范围的绝对值,而是绝对值除以time_unit所得到的单位个数。 @@ -666,7 +667,7 @@ SELECT ELAPSED(ts_primary_key [, time_unit]) FROM { tb_name | stb_name } [WHERE **适用于**: 表,超级表,嵌套查询的外层查询 **说明**: -- field_name参数只能是表的第一列,即 TIMESTAMP 类型的主键列。 +- ts_primary_key参数只能是表的第一列,即 TIMESTAMP 类型的主键列。 - 按time_unit参数指定的时间单位返回,最小是数据库的时间分辨率。time_unit 参数未指定时,以数据库的时间分辨率为时间单位。支持的时间单位 time_unit 如下: 1b(纳秒), 1u(微秒),1a(毫秒),1s(秒),1m(分),1h(小时),1d(天), 1w(周)。 - 可以和interval组合使用,返回每个时间窗口的时间戳差值。需要特别注意的是,除第一个时间窗口和最后一个时间窗口外,中间窗口的时间戳差值均为窗口长度。 @@ -680,14 +681,14 @@ SELECT ELAPSED(ts_primary_key [, time_unit]) FROM { tb_name | stb_name } [WHERE ### LEASTSQUARES ```sql -SELECT LEASTSQUARES(field_name, start_val, step_val) FROM tb_name [WHERE clause]; +LEASTSQUARES(expr, start_val, step_val) ``` **功能说明**:统计表中某列的值是主键(时间戳)的拟合直线方程。start_val 是自变量初始值,step_val 是自变量的步长值。 **返回数据类型**:字符串表达式(斜率, 截距)。 -**适用数据类型**:field_name 必须是数值类型。 +**适用数据类型**:expr 必须是数值类型。 **适用于**:表。 @@ -695,7 +696,7 @@ SELECT LEASTSQUARES(field_name, start_val, step_val) FROM tb_name [WHERE clause] ### SPREAD ```sql -SELECT SPREAD(field_name) FROM { tb_name | stb_name } [WHERE clause]; +SPREAD(expr) ``` **功能说明**:统计表中某列的最大值和最小值之差。 @@ -710,7 +711,7 @@ SELECT SPREAD(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### STDDEV ```sql -SELECT STDDEV(field_name) FROM tb_name [WHERE clause]; +STDDEV(expr) ``` **功能说明**:统计表中某列的均方差。 @@ -725,7 +726,7 @@ SELECT STDDEV(field_name) FROM tb_name [WHERE clause]; ### SUM ```sql -SELECT SUM(field_name) FROM tb_name [WHERE clause]; +SUM(expr) ``` **功能说明**:统计表/超级表中某列的和。 @@ -740,7 +741,7 @@ SELECT SUM(field_name) FROM tb_name [WHERE clause]; ### HYPERLOGLOG ```sql -SELECT HYPERLOGLOG(field_name) FROM { tb_name | stb_name } [WHERE clause]; +HYPERLOGLOG(expr) ``` **功能说明**: @@ -757,7 +758,7 @@ SELECT HYPERLOGLOG(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### HISTOGRAM ```sql -SELECT HISTOGRAM(field_name,bin_type, bin_description, normalized) FROM tb_name [WHERE clause]; +HISTOGRAM(expr,bin_type, bin_description, normalized) ``` **功能说明**:统计数据按照用户指定区间的分布。 @@ -787,7 +788,7 @@ SELECT HISTOGRAM(field_name,bin_type, bin_description, normalized) FROM tb_nam ### PERCENTILE ```sql -SELECT PERCENTILE(field_name, P) FROM { tb_name } [WHERE clause]; +PERCENTILE(expr, p) ``` **功能说明**:统计表中某列的值百分比分位数。 @@ -808,7 +809,7 @@ SELECT PERCENTILE(field_name, P) FROM { tb_name } [WHERE clause]; ### BOTTOM ```sql -SELECT BOTTOM(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; +BOTTOM(expr, k) ``` **功能说明**:统计表/超级表中某列的值最小 _k_ 个非 NULL 值。如果多条数据取值一样,全部取用又会超出 k 条限制时,系统会从相同值中随机选取符合要求的数量返回。 @@ -828,7 +829,7 @@ SELECT BOTTOM(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; ### FIRST ```sql -SELECT FIRST(field_name) FROM { tb_name | stb_name } [WHERE clause]; +FIRST(expr) ``` **功能说明**:统计表/超级表中某列的值最先写入的非 NULL 值。 @@ -848,7 +849,7 @@ SELECT FIRST(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### INTERP ```sql -SELECT INTERP(field_name) FROM { tb_name | stb_name } [WHERE where_condition] RANGE(timestamp1,timestamp2) EVERY(interval) FILL({ VALUE | PREV | NULL | LINEAR | NEXT}); +INTERP(expr) ``` **功能说明**:返回指定时间截面指定列的记录值或插值。 @@ -867,11 +868,12 @@ SELECT INTERP(field_name) FROM { tb_name | stb_name } [WHERE where_condition] RA - INTERP 根据 EVERY 字段来确定输出时间范围内的结果条数,即从 timestamp1 开始每隔固定长度的时间(EVERY 值)进行插值。如果没有指定 EVERY,则默认窗口大小为无穷大,即从 timestamp1 开始只有一个窗口。 - INTERP 根据 FILL 字段来决定在每个符合输出条件的时刻如何进行插值。 - INTERP 只能在一个时间序列内进行插值,因此当作用于超级表时必须跟 partition by tbname 一起使用。 +- INTERP 可以与伪列 _irowts 一起使用,返回插值点所对应的时间戳(3.0.1.4版本以后支持)。 ### LAST ```sql -SELECT LAST(field_name) FROM { tb_name | stb_name } [WHERE clause]; +LAST(expr) ``` **功能说明**:统计表/超级表中某列的值最后写入的非 NULL 值。 @@ -892,7 +894,7 @@ SELECT LAST(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### LAST_ROW ```sql -SELECT LAST_ROW(field_name) FROM { tb_name | stb_name }; +LAST_ROW(expr) ``` **功能说明**:返回表/超级表的最后一条记录。 @@ -911,7 +913,7 @@ SELECT LAST_ROW(field_name) FROM { tb_name | stb_name }; ### MAX ```sql -SELECT MAX(field_name) FROM { tb_name | stb_name } [WHERE clause]; +MAX(expr) ``` **功能说明**:统计表/超级表中某列的值最大值。 @@ -926,7 +928,7 @@ SELECT MAX(field_name) FROM { tb_name | stb_name } [WHERE clause]; ### MIN ```sql -SELECT MIN(field_name) FROM {tb_name | stb_name} [WHERE clause]; +MIN(expr) ``` **功能说明**:统计表/超级表中某列的值最小值。 @@ -941,7 +943,7 @@ SELECT MIN(field_name) FROM {tb_name | stb_name} [WHERE clause]; ### MODE ```sql -SELECT MODE(field_name) FROM tb_name [WHERE clause]; +MODE(expr) ``` **功能说明**:返回出现频率最高的值,若存在多个频率相同的最高值,输出NULL。 @@ -956,7 +958,7 @@ SELECT MODE(field_name) FROM tb_name [WHERE clause]; ### SAMPLE ```sql -SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause] +SAMPLE(expr, k) ``` **功能说明**: 获取数据的 k 个采样值。参数 k 的合法输入范围是 1≤ k ≤ 1000。 @@ -978,7 +980,7 @@ SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause] ### TAIL ```sql -SELECT TAIL(field_name, k, offset_val) FROM {tb_name | stb_name} [WHERE clause]; +TAIL(expr, k [, offset_rows]) ``` **功能说明**:返回跳过最后 offset_val 个,然后取连续 k 个记录,不忽略 NULL 值。offset_val 可以不输入。此时返回最后的 k 个记录。当有 offset_val 输入的情况下,该函数功能等效于 `order by ts desc LIMIT k OFFSET offset_val`。 @@ -995,7 +997,7 @@ SELECT TAIL(field_name, k, offset_val) FROM {tb_name | stb_name} [WHERE clause]; ### TOP ```sql -SELECT TOP(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; +TOP(expr, k) ``` **功能说明**: 统计表/超级表中某列的值最大 _k_ 个非 NULL 值。如果多条数据取值一样,全部取用又会超出 k 条限制时,系统会从相同值中随机选取符合要求的数量返回。 @@ -1015,7 +1017,7 @@ SELECT TOP(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; ### UNIQUE ```sql -SELECT UNIQUE(field_name) FROM {tb_name | stb_name} [WHERE clause]; +UNIQUE(expr) ``` **功能说明**:返回该列的数值首次出现的值。该函数功能与 distinct 相似,但是可以匹配标签和时间戳信息。可以针对除时间列以外的字段进行查询,可以匹配标签和时间戳,其中的标签和时间戳是第一次出现时刻的标签和时间戳。 @@ -1034,7 +1036,7 @@ SELECT UNIQUE(field_name) FROM {tb_name | stb_name} [WHERE clause]; ### CSUM ```sql -SELECT CSUM(field_name) FROM { tb_name | stb_name } [WHERE clause] +CSUM(expr) ``` **功能说明**:累加和(Cumulative sum),输出行与输入行数相同。 @@ -1057,7 +1059,12 @@ SELECT CSUM(field_name) FROM { tb_name | stb_name } [WHERE clause] ### DERIVATIVE ```sql -SELECT DERIVATIVE(field_name, time_interval, ignore_negative) FROM tb_name [WHERE clause]; +DERIVATIVE(expr, time_interval, ignore_negative) + +ignore_negative: { + 0 + | 1 +} ``` **功能说明**:统计表中某列数值的单位变化率。其中单位时间区间的长度可以通过 time_interval 参数指定,最小可以是 1 秒(1s);ignore_negative 参数的值可以是 0 或 1,为 1 时表示忽略负值。 @@ -1076,7 +1083,12 @@ SELECT DERIVATIVE(field_name, time_interval, ignore_negative) FROM tb_name [WHER ### DIFF ```sql -SELECT {DIFF(field_name, ignore_negative) | DIFF(field_name)} FROM tb_name [WHERE clause]; +DIFF(expr [, ignore_negative]) + +ignore_negative: { + 0 + | 1 +} ``` **功能说明**:统计表中某列的值与前一行对应值的差。 ignore_negative 取值为 0|1 , 可以不填,默认值为 0. 不忽略负值。ignore_negative 为 1 时表示忽略负数。 @@ -1096,7 +1108,7 @@ SELECT {DIFF(field_name, ignore_negative) | DIFF(field_name)} FROM tb_name [WHER ### IRATE ```sql -SELECT IRATE(field_name) FROM tb_name WHERE clause; +IRATE(expr) ``` **功能说明**:计算瞬时增长率。使用时间区间中最后两个样本数据来计算瞬时增长速率;如果这两个值呈递减关系,那么只取最后一个数用于计算,而不是使用二者差值。 @@ -1111,7 +1123,7 @@ SELECT IRATE(field_name) FROM tb_name WHERE clause; ### MAVG ```sql -SELECT MAVG(field_name, K) FROM { tb_name | stb_name } [WHERE clause] +MAVG(expr, k) ``` **功能说明**: 计算连续 k 个值的移动平均数(moving average)。如果输入行数小于 k,则无结果输出。参数 k 的合法输入范围是 1≤ k ≤ 1000。 @@ -1134,7 +1146,7 @@ SELECT MAVG(field_name, K) FROM { tb_name | stb_name } [WHERE clause] ### STATECOUNT ```sql -SELECT STATECOUNT(field_name, oper, val) FROM { tb_name | stb_name } [WHERE clause]; +STATECOUNT(expr, oper, val) ``` **功能说明**:返回满足某个条件的连续记录的个数,结果作为新的一列追加在每行后面。条件根据参数计算,如果条件为 true 则加 1,条件为 false 则重置为-1,如果数据为 NULL,跳过该条数据。 @@ -1161,7 +1173,7 @@ SELECT STATECOUNT(field_name, oper, val) FROM { tb_name | stb_name } [WHERE clau ### STATEDURATION ```sql -SELECT stateDuration(field_name, oper, val, unit) FROM { tb_name | stb_name } [WHERE clause]; +STATEDURATION(expr, oper, val, unit) ``` **功能说明**:返回满足某个条件的连续记录的时间长度,结果作为新的一列追加在每行后面。条件根据参数计算,如果条件为 true 则加上两个记录之间的时间长度(第一个满足条件的记录时间长度记为 0),条件为 false 则重置为-1,如果数据为 NULL,跳过该条数据。 @@ -1189,7 +1201,7 @@ SELECT stateDuration(field_name, oper, val, unit) FROM { tb_name | stb_name } [W ### TWA ```sql -SELECT TWA(field_name) FROM tb_name WHERE clause; +TWA(expr) ``` **功能说明**:时间加权平均函数。统计表中某列在一段时间内的时间加权平均。 diff --git a/docs/zh/12-taos-sql/20-keywords.md b/docs/zh/12-taos-sql/20-keywords.md index 7530e803db..8013698fce 100644 --- a/docs/zh/12-taos-sql/20-keywords.md +++ b/docs/zh/12-taos-sql/20-keywords.md @@ -344,6 +344,7 @@ description: TDengine 保留关键字的详细列表 ### \_ - \_C0 +- \_IROWTS - \_QDURATION - \_QEND - \_QSTART diff --git a/docs/zh/12-taos-sql/22-meta.md b/docs/zh/12-taos-sql/22-meta.md index c1ffc4a757..c192d0e5e8 100644 --- a/docs/zh/12-taos-sql/22-meta.md +++ b/docs/zh/12-taos-sql/22-meta.md @@ -12,7 +12,15 @@ TDengine 内置了一个名为 `INFORMATION_SCHEMA` 的数据库,提供对数 4. TDengine 在后续演进中可以灵活的添加已有 INFORMATION_SCHEMA 中表的列,而不用担心对既有业务系统造成影响 5. 与其他数据库系统更具互操作性。例如,Oracle 数据库用户熟悉查询 Oracle 数据字典中的表 -Note: 由于 SHOW 语句已经被开发者熟悉和广泛使用,所以它们仍然被保留。 +:::info + +- 由于 SHOW 语句已经被开发者熟悉和广泛使用,所以它们仍然被保留。 +- 系统表中的一些列可能是关键字,在查询时需要使用转义符'\`',例如查询数据库 test 有几个 VGROUP: +```sql + select `vgroups` from ins_databases where name = 'test'; +``` + +::: 本章将详细介绍 `INFORMATION_SCHEMA` 这个内置元数据库中的表和表结构。 @@ -103,7 +111,11 @@ Note: 由于 SHOW 语句已经被开发者熟悉和广泛使用,所以它们 | 24 | wal_retention_period | INT | WAL 的保存时长 | | 25 | wal_retention_size | INT | WAL 的保存上限 | | 26 | wal_roll_period | INT | wal 文件切换时长 | -| 27 | wal_segment_size | wal 单个文件大小 | +| 27 | wal_segment_size | BIGINT | wal 单个文件大小 | +| 28 | stt_trigger | SMALLINT | 触发文件合并的落盘文件的个数 | +| 29 | table_prefix | SMALLINT | 内部存储引擎根据表名分配存储该表数据的 VNODE 时要忽略的前缀的长度 | +| 30 | table_suffix | SMALLINT | 内部存储引擎根据表名分配存储该表数据的 VNODE 时要忽略的后缀的长度 | +| 31 | tsdb_pagesize | INT | 时序数据存储引擎中的页大小 | ## INS_FUNCTIONS diff --git a/docs/zh/12-taos-sql/29-changes.md b/docs/zh/12-taos-sql/29-changes.md index e63825045d..7da8e9f331 100644 --- a/docs/zh/12-taos-sql/29-changes.md +++ b/docs/zh/12-taos-sql/29-changes.md @@ -11,12 +11,13 @@ description: "TDengine 3.0 版本的语法变更说明" | 1 | VARCHAR | 新增 | BINARY类型的别名。 | 2 | TIMESTAMP字面量 | 新增 | 新增支持 TIMESTAMP 'timestamp format' 语法。 | 3 | _ROWTS伪列 | 新增 | 表示时间戳主键。是_C0伪列的别名。 -| 4 | INFORMATION_SCHEMA | 新增 | 包含各种SCHEMA定义的系统数据库。 -| 5 | PERFORMANCE_SCHEMA | 新增 | 包含运行信息的系统数据库。 -| 6 | 连续查询 | 废除 | 不再支持连续查询。相关的各种语法和接口废除。 -| 7 | 混合运算 | 增强 | 查询中的混合运算(标量运算和矢量运算混合)全面增强,SELECT的各个子句均全面支持符合语法语义的混合运算。 -| 8 | 标签运算 | 新增 |在查询中,标签列可以像普通列一样参与各种运算,用于各种子句。 -| 9 | 时间线子句和时间函数用于超级表查询 | 增强 |没有PARTITION BY时,超级表的数据会被合并成一条时间线。 +| 4 | _IROWTS伪列 | 新增 | 用于返回 interp 函数插值结果对应的时间戳列。 +| 5 | INFORMATION_SCHEMA | 新增 | 包含各种SCHEMA定义的系统数据库。 +| 6 | PERFORMANCE_SCHEMA | 新增 | 包含运行信息的系统数据库。 +| 7 | 连续查询 | 废除 | 不再支持连续查询。相关的各种语法和接口废除。 +| 8 | 混合运算 | 增强 | 查询中的混合运算(标量运算和矢量运算混合)全面增强,SELECT的各个子句均全面支持符合语法语义的混合运算。 +| 9 | 标签运算 | 新增 |在查询中,标签列可以像普通列一样参与各种运算,用于各种子句。 +| 10 | 时间线子句和时间函数用于超级表查询 | 增强 |没有PARTITION BY时,超级表的数据会被合并成一条时间线。 ## SQL 语句变更 diff --git a/docs/zh/14-reference/12-config/index.md b/docs/zh/14-reference/12-config/index.md index 179a3c6df0..6f26878cdd 100644 --- a/docs/zh/14-reference/12-config/index.md +++ b/docs/zh/14-reference/12-config/index.md @@ -177,12 +177,21 @@ taos --dump-config ### maxNumOfDistinctRes | 属性 | 说明 | -| -------- | -------------------------------- | --- | +| -------- | -------------------------------- | | 适用范围 | 仅服务端适用 | | 含义 | 允许返回的 distinct 结果最大行数 | | 取值范围 | 默认值为 10 万,最大值 1 亿 | | 缺省值 | 10 万 | +### keepColumnName + +| 属性 | 说明 | +| -------- | -------------------------------- | +| 适用范围 | 仅客户端适用 | +| 含义 | Last、First、LastRow 函数查询时,返回的列名是否包含函数名。 | +| 取值范围 | 0 表示包含函数名,1 表示不包含函数名。 | +| 缺省值 | 0 | + ## 区域相关 ### timezone diff --git a/docs/zh/14-reference/13-schemaless/13-schemaless.md b/docs/zh/14-reference/13-schemaless/13-schemaless.md index a33abafaf8..07d5b0692b 100644 --- a/docs/zh/14-reference/13-schemaless/13-schemaless.md +++ b/docs/zh/14-reference/13-schemaless/13-schemaless.md @@ -67,9 +67,12 @@ st,t1=3,t2=4,t3=t3 c1=3i64,c3="passit",c2=false,c4=4f64 1626006833639000000 "measurement,tag_key1=tag_value1,tag_key2=tag_value2" ``` +:::tip 需要注意的是,这里的 tag_key1, tag_key2 并不是用户输入的标签的原始顺序,而是使用了标签名称按照字符串升序排列后的结果。所以,tag_key1 并不是在行协议中输入的第一个标签。 排列完成以后计算该字符串的 MD5 散列值 "md5_val"。然后将计算的结果与字符串组合生成表名:“t_md5_val”。其中的 “t_” 是固定的前缀,每个通过该映射关系自动生成的表都具有该前缀。 -为了让用户可以指定生成的表名,可以通过配置 smlChildTableName 来指定(比如 配置 smlChildTableName=tname 插入数据为 st,tname=cpu1,t1=4 c1=3 1626006833639000000 则创建的表名为 cpu1,注意如果多行数据 tname 相同,但是后面的 tag_set 不同,则使用第一次自动建表时指定的 tag_set,其他的会忽略)。 +:::tip +为了让用户可以指定生成的表名,可以通过在taos.cfg里配置 smlChildTableName 参数来指定。 +举例如下:配置 smlChildTableName=tname 插入数据为 st,tname=cpu1,t1=4 c1=3 1626006833639000000 则创建的表名为 cpu1,注意如果多行数据 tname 相同,但是后面的 tag_set 不同,则使用第一行自动建表时指定的 tag_set,其他的行会忽略)。 2. 如果解析行协议获得的超级表不存在,则会创建这个超级表(不建议手动创建超级表,不然插入数据可能异常)。 3. 如果解析行协议获得子表不存在,则 Schemaless 会按照步骤 1 或 2 确定的子表名来创建子表。 diff --git a/docs/zh/14-reference/_statsd.mdx b/docs/zh/14-reference/_statsd.mdx index b225c44267..dc4f19b37c 100644 --- a/docs/zh/14-reference/_statsd.mdx +++ b/docs/zh/14-reference/_statsd.mdx @@ -51,5 +51,6 @@ port: 8125 增加如下内容后启动 StatsD(假设配置文件修改为 config.js)。 ``` +npm install node stats.js config.js & ``` diff --git a/docs/zh/14-reference/_telegraf.mdx b/docs/zh/14-reference/_telegraf.mdx index bae46d6606..3f92e5dde0 100644 --- a/docs/zh/14-reference/_telegraf.mdx +++ b/docs/zh/14-reference/_telegraf.mdx @@ -22,6 +22,5 @@ username = "root" password = "taosdata" data_format = "influx" - influx_max_line_bytes = 250 ``` diff --git a/docs/zh/20-third-party/02-prometheus.md b/docs/zh/20-third-party/02-prometheus.md index eb6c3bf1d0..0f95053a78 100644 --- a/docs/zh/20-third-party/02-prometheus.md +++ b/docs/zh/20-third-party/02-prometheus.md @@ -29,21 +29,20 @@ Prometheus 提供了 `remote_write` 和 `remote_read` 接口来利用其它数 ### 使用 TDengine CLI 查询写入数据 ``` taos> show databases; - name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | -==================================================================================================================================================================================================================================================================================== - test | 2022-04-12 08:07:58.756 | 1 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | - log | 2022-04-20 07:19:50.260 | 2 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | - prometheus_data | 2022-04-20 07:21:09.202 | 158 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | - db | 2022-04-15 06:37:08.512 | 1 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | -Query OK, 4 row(s) in set (0.000585s) + name | +================================= + information_schema | + performance_schema | + prometheus_data | +Query OK, 3 row(s) in set (0.000585s) taos> use prometheus_data; Database changed. taos> show stables; - name | created_time | columns | tags | tables | -============================================================================================ - metrics | 2022-04-20 07:21:09.209 | 2 | 1 | 1389 | + name | +================================= + metrics | Query OK, 1 row(s) in set (0.000487s) taos> select * from metrics limit 10; @@ -88,3 +87,7 @@ VALUE TIMESTAMP ``` +:::note + +- TDengine 默认生成的子表名是根据规则生成的唯一 ID 值。 +::: diff --git a/docs/zh/20-third-party/03-telegraf.md b/docs/zh/20-third-party/03-telegraf.md index 84883e665a..bb688a6ab6 100644 --- a/docs/zh/20-third-party/03-telegraf.md +++ b/docs/zh/20-third-party/03-telegraf.md @@ -16,6 +16,7 @@ Telegraf 是一款十分流行的指标采集开源软件。在数据采集和 - TDengine 集群已经部署并正常运行 - taosAdapter 已经安装并正常运行。具体细节请参考 [taosAdapter 的使用手册](/reference/taosadapter) - Telegraf 已经安装。安装 Telegraf 请参考[官方文档](https://docs.influxdata.com/telegraf/v1.22/install/) +- Telegraf 默认采集系统运行状态数据。通过使能[输入插件](https://docs.influxdata.com/telegraf/v1.22/plugins/)方式可以输出[其他格式](https://docs.influxdata.com/telegraf/v1.24/data_formats/input/)的数据到 Telegraf 再写入到 TDengine中。 ## 配置步骤 @@ -32,26 +33,27 @@ sudo systemctl restart telegraf ``` taos> show databases; - name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | -==================================================================================================================================================================================================================================================================================== - telegraf | 2022-04-20 08:47:53.488 | 22 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | - log | 2022-04-20 07:19:50.260 | 9 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | -Query OK, 2 row(s) in set (0.002401s) + name | +================================= + information_schema | + performance_schema | + telegraf | +Query OK, 3 rows in database (0.010568s) taos> use telegraf; Database changed. taos> show stables; - name | created_time | columns | tags | tables | -============================================================================================ - swap | 2022-04-20 08:47:53.532 | 7 | 1 | 1 | - cpu | 2022-04-20 08:48:03.488 | 11 | 2 | 5 | - system | 2022-04-20 08:47:53.512 | 8 | 1 | 1 | - diskio | 2022-04-20 08:47:53.550 | 12 | 2 | 15 | - kernel | 2022-04-20 08:47:53.503 | 6 | 1 | 1 | - mem | 2022-04-20 08:47:53.521 | 35 | 1 | 1 | - processes | 2022-04-20 08:47:53.555 | 12 | 1 | 1 | - disk | 2022-04-20 08:47:53.541 | 8 | 5 | 2 | + name | +================================= + swap | + cpu | + system | + diskio | + kernel | + mem | + processes | + disk | Query OK, 8 row(s) in set (0.000521s) taos> select * from telegraf.system limit 10; @@ -66,3 +68,11 @@ taos> select * from telegraf.system limit 10; | Query OK, 3 row(s) in set (0.013269s) ``` + +:::note + +- TDengine 接收 influxdb 格式数据默认生成的子表名是根据规则生成的唯一 ID 值。 +用户如需指定生成的表名,可以通过在 taos.cfg 里配置 smlChildTableName 参数来指定。如果通过控制输入数据格式,即可利用 TDengine 这个功能指定生成的表名。 +举例如下:配置 smlChildTableName=tname 插入数据为 st,tname=cpu1,t1=4 c1=3 1626006833639000000 则创建的表名为 cpu1。如果多行数据 tname 相同,但是后面的 tag_set 不同,则使用第一行自动建表时指定的 tag_set,其他的行会忽略)。[TDengine 无模式写入参考指南](/reference/schemaless/#无模式写入行协议) +::: + diff --git a/docs/zh/20-third-party/05-collectd.md b/docs/zh/20-third-party/05-collectd.md index cc2235f260..bda66b3cce 100644 --- a/docs/zh/20-third-party/05-collectd.md +++ b/docs/zh/20-third-party/05-collectd.md @@ -32,28 +32,29 @@ sudo systemctl restart collectd ``` taos> show databases; - name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | -==================================================================================================================================================================================================================================================================================== - collectd | 2022-04-20 09:27:45.460 | 95 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | - log | 2022-04-20 07:19:50.260 | 11 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | -Query OK, 2 row(s) in set (0.003266s) + name | +================================= + information_schema | + performance_schema | + collectd | +Query OK, 3 row(s) in set (0.003266s) taos> use collectd; Database changed. taos> show stables; - name | created_time | columns | tags | tables | -============================================================================================ - load_1 | 2022-04-20 09:27:45.492 | 2 | 2 | 1 | - memory_value | 2022-04-20 09:27:45.463 | 2 | 3 | 6 | - df_value | 2022-04-20 09:27:45.463 | 2 | 4 | 25 | - load_2 | 2022-04-20 09:27:45.501 | 2 | 2 | 1 | - load_0 | 2022-04-20 09:27:45.485 | 2 | 2 | 1 | - interface_1 | 2022-04-20 09:27:45.488 | 2 | 3 | 12 | - irq_value | 2022-04-20 09:27:45.476 | 2 | 3 | 31 | - interface_0 | 2022-04-20 09:27:45.480 | 2 | 3 | 12 | - entropy_value | 2022-04-20 09:27:45.473 | 2 | 2 | 1 | - swap_value | 2022-04-20 09:27:45.477 | 2 | 3 | 5 | + name | +================================= + load_1 | + memory_value | + df_value | + load_2 | + load_0 | + interface_1 | + irq_value | + interface_0 | + entropy_value | + swap_value | Query OK, 10 row(s) in set (0.002236s) taos> select * from collectd.memory_value limit 10; @@ -72,3 +73,7 @@ taos> select * from collectd.memory_value limit 10; Query OK, 10 row(s) in set (0.010348s) ``` +:::note + +- TDengine 默认生成的子表名是根据规则生成的唯一 ID 值。 +::: diff --git a/docs/zh/20-third-party/06-statsd.md b/docs/zh/20-third-party/06-statsd.md index 122c9fd94c..20b4d800be 100644 --- a/docs/zh/20-third-party/06-statsd.md +++ b/docs/zh/20-third-party/06-statsd.md @@ -27,7 +27,7 @@ StatsD 是汇总和总结应用指标的一个简单的守护进程,近些年 ``` $ node stats.js config.js & [1] 8546 -$ 20 Apr 09:54:41 - [8546] reading config file: exampleConfig.js +$ 20 Apr 09:54:41 - [8546] reading config file: config.js 20 Apr 09:54:41 - server is up INFO ``` @@ -41,19 +41,20 @@ $ echo "foo:1|c" | nc -u -w0 127.0.0.1 8125 ``` taos> show databases; - name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | -==================================================================================================================================================================================================================================================================================== - log | 2022-04-20 07:19:50.260 | 11 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | - statsd | 2022-04-20 09:54:51.220 | 1 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | -Query OK, 2 row(s) in set (0.003142s) + name | +================================= + information_schema | + performance_schema | + statsd | +Query OK, 3 row(s) in set (0.003142s) taos> use statsd; Database changed. taos> show stables; - name | created_time | columns | tags | tables | -============================================================================================ - foo | 2022-04-20 09:54:51.234 | 2 | 1 | 1 | + name | +================================= + foo | Query OK, 1 row(s) in set (0.002161s) taos> select * from foo; @@ -64,3 +65,8 @@ Query OK, 1 row(s) in set (0.004179s) taos> ``` + +:::note + +- TDengine will automatically create unique IDs for sub-table names by the rule. +::: diff --git a/docs/zh/20-third-party/07-icinga2.md b/docs/zh/20-third-party/07-icinga2.md index 06ead57655..d112a7a5e6 100644 --- a/docs/zh/20-third-party/07-icinga2.md +++ b/docs/zh/20-third-party/07-icinga2.md @@ -37,39 +37,46 @@ sudo systemctl restart icinga2 ``` taos> show databases; - name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | -==================================================================================================================================================================================================================================================================================== - log | 2022-04-20 07:19:50.260 | 11 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | - icinga2 | 2022-04-20 12:11:39.697 | 13 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | -Query OK, 2 row(s) in set (0.001867s) + name | +================================= + information_schema | + performance_schema | + icinga2 | +Query OK, 3 row(s) in set (0.001867s) taos> use icinga2; Database changed. taos> show stables; - name | created_time | columns | tags | tables | -============================================================================================ - icinga.service.users.state_... | 2022-04-20 12:11:39.726 | 2 | 1 | 1 | - icinga.service.users.acknow... | 2022-04-20 12:11:39.756 | 2 | 1 | 1 | - icinga.service.procs.downti... | 2022-04-20 12:11:44.541 | 2 | 1 | 1 | - icinga.service.users.users | 2022-04-20 12:11:39.770 | 2 | 1 | 1 | - icinga.service.procs.procs_min | 2022-04-20 12:11:44.599 | 2 | 1 | 1 | - icinga.service.users.users_min | 2022-04-20 12:11:39.809 | 2 | 1 | 1 | - icinga.check.max_check_atte... | 2022-04-20 12:11:39.847 | 2 | 3 | 2 | - icinga.service.procs.state_... | 2022-04-20 12:11:44.522 | 2 | 1 | 1 | - icinga.service.procs.procs_... | 2022-04-20 12:11:44.576 | 2 | 1 | 1 | - icinga.service.users.users_... | 2022-04-20 12:11:39.796 | 2 | 1 | 1 | - icinga.check.latency | 2022-04-20 12:11:39.869 | 2 | 3 | 2 | - icinga.service.procs.procs_... | 2022-04-20 12:11:44.588 | 2 | 1 | 1 | - icinga.service.users.downti... | 2022-04-20 12:11:39.746 | 2 | 1 | 1 | - icinga.service.users.users_... | 2022-04-20 12:11:39.783 | 2 | 1 | 1 | - icinga.service.users.reachable | 2022-04-20 12:11:39.736 | 2 | 1 | 1 | - icinga.service.procs.procs | 2022-04-20 12:11:44.565 | 2 | 1 | 1 | - icinga.service.procs.acknow... | 2022-04-20 12:11:44.554 | 2 | 1 | 1 | - icinga.service.procs.state | 2022-04-20 12:11:44.509 | 2 | 1 | 1 | - icinga.service.procs.reachable | 2022-04-20 12:11:44.532 | 2 | 1 | 1 | - icinga.check.current_attempt | 2022-04-20 12:11:39.825 | 2 | 3 | 2 | - icinga.check.execution_time | 2022-04-20 12:11:39.898 | 2 | 3 | 2 | - icinga.service.users.state | 2022-04-20 12:11:39.704 | 2 | 1 | 1 | + name | +================================= + icinga.service.users.state_... | + icinga.service.users.acknow... | + icinga.service.procs.downti... | + icinga.service.users.users | + icinga.service.procs.procs_min | + icinga.service.users.users_min | + icinga.check.max_check_atte... | + icinga.service.procs.state_... | + icinga.service.procs.procs_... | + icinga.service.users.users_... | + icinga.check.latency | + icinga.service.procs.procs_... | + icinga.service.users.downti... | + icinga.service.users.users_... | + icinga.service.users.reachable | + icinga.service.procs.procs | + icinga.service.procs.acknow... | + icinga.service.procs.state | + icinga.service.procs.reachable | + icinga.check.current_attempt | + icinga.check.execution_time | + icinga.service.users.state | Query OK, 22 row(s) in set (0.002317s) ``` + + +:::note + +- TDengine 默认生成的子表名是根据规则生成的唯一 ID 值。 +::: diff --git a/docs/zh/20-third-party/08-tcollector.md b/docs/zh/20-third-party/08-tcollector.md index 78d0b4a5df..a6ed0f89e2 100644 --- a/docs/zh/20-third-party/08-tcollector.md +++ b/docs/zh/20-third-party/08-tcollector.md @@ -34,35 +34,42 @@ sudo systemctl restart taosadapter ``` taos> show databases; - name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | -==================================================================================================================================================================================================================================================================================== - tcollector | 2022-04-20 12:44:49.604 | 88 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | - log | 2022-04-20 07:19:50.260 | 11 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | -Query OK, 2 row(s) in set (0.002679s) + name | +================================= + information_schema | + performance_schema | + tcollector | +Query OK, 3 rows in database (0.001647s) + taos> use tcollector; Database changed. taos> show stables; - name | created_time | columns | tags | tables | -============================================================================================ - proc.meminfo.hugepages_rsvd | 2022-04-20 12:44:53.945 | 2 | 1 | 1 | - proc.meminfo.directmap1g | 2022-04-20 12:44:54.110 | 2 | 1 | 1 | - proc.meminfo.vmallocchunk | 2022-04-20 12:44:53.724 | 2 | 1 | 1 | - proc.meminfo.hugepagesize | 2022-04-20 12:44:54.004 | 2 | 1 | 1 | - tcollector.reader.lines_dro... | 2022-04-20 12:44:49.675 | 2 | 1 | 1 | - proc.meminfo.sunreclaim | 2022-04-20 12:44:53.437 | 2 | 1 | 1 | - proc.stat.ctxt | 2022-04-20 12:44:55.363 | 2 | 1 | 1 | - proc.meminfo.swaptotal | 2022-04-20 12:44:53.158 | 2 | 1 | 1 | - proc.uptime.total | 2022-04-20 12:44:52.813 | 2 | 1 | 1 | - tcollector.collector.lines_... | 2022-04-20 12:44:49.895 | 2 | 2 | 51 | - proc.meminfo.vmallocused | 2022-04-20 12:44:53.704 | 2 | 1 | 1 | - proc.meminfo.memavailable | 2022-04-20 12:44:52.939 | 2 | 1 | 1 | - sys.numa.foreign_allocs | 2022-04-20 12:44:57.929 | 2 | 2 | 1 | - proc.meminfo.committed_as | 2022-04-20 12:44:53.639 | 2 | 1 | 1 | - proc.vmstat.pswpin | 2022-04-20 12:44:54.177 | 2 | 1 | 1 | - proc.meminfo.cmafree | 2022-04-20 12:44:53.865 | 2 | 1 | 1 | - proc.meminfo.mapped | 2022-04-20 12:44:53.349 | 2 | 1 | 1 | - proc.vmstat.pgmajfault | 2022-04-20 12:44:54.251 | 2 | 1 | 1 | + name | +================================= + proc.meminfo.hugepages_rsvd | + proc.meminfo.directmap1g | + proc.meminfo.vmallocchunk | + proc.meminfo.hugepagesize | + tcollector.reader.lines_dro... | + proc.meminfo.sunreclaim | + proc.stat.ctxt | + proc.meminfo.swaptotal | + proc.uptime.total | + tcollector.collector.lines_... | + proc.meminfo.vmallocused | + proc.meminfo.memavailable | + sys.numa.foreign_allocs | + proc.meminfo.committed_as | + proc.vmstat.pswpin | + proc.meminfo.cmafree | + proc.meminfo.mapped | + proc.vmstat.pgmajfault | ... ``` + +:::note + +- TDengine 默认生成的子表名是根据规则生成的唯一 ID 值。 +::: diff --git a/docs/zh/25-application/01-telegraf.md b/docs/zh/25-application/01-telegraf.md index 4e9597f964..6338264d17 100644 --- a/docs/zh/25-application/01-telegraf.md +++ b/docs/zh/25-application/01-telegraf.md @@ -61,7 +61,6 @@ IT 运维监测数据通常都是对时间特性比较敏感的数据,例如 username = "" password = "" data_format = "influx" - influx_max_line_bytes = 250 ``` 然后重启 Telegraf: diff --git a/docs/zh/28-releases/01-tdengine.md b/docs/zh/28-releases/01-tdengine.md index b05cf7a942..59e0d0f761 100644 --- a/docs/zh/28-releases/01-tdengine.md +++ b/docs/zh/28-releases/01-tdengine.md @@ -6,6 +6,14 @@ description: TDengine 发布历史、Release Notes 及下载链接 import Release from "/components/ReleaseV3"; +## 3.0.1.4 + + + +## 3.0.1.3 + + + ## 3.0.1.2 diff --git a/docs/zh/28-releases/02-tools.md b/docs/zh/28-releases/02-tools.md index f793981d06..83ccdec387 100644 --- a/docs/zh/28-releases/02-tools.md +++ b/docs/zh/28-releases/02-tools.md @@ -6,6 +6,14 @@ description: taosTools 的发布历史、Release Notes 和下载链接 import Release from "/components/ReleaseV3"; +## 2.2.4 + + + +## 2.2.3 + + + ## 2.2.2 diff --git a/examples/lua/README.md b/examples/lua/README.md index 32d6a4cace..5abf0c1aab 100644 --- a/examples/lua/README.md +++ b/examples/lua/README.md @@ -1,6 +1,12 @@ # TDengine driver connector for Lua It's a Lua implementation for [TDengine](https://github.com/taosdata/TDengine), an open-sourced big data platform designed and optimized for the Internet of Things (IoT), Connected Cars, Industrial IoT, and IT Infrastructure and Application Monitoring. You may need to install Lua5.3 . +As TDengine is built with lua-enable with default configure, the built-in lua lib conflicts with external lua lib. The following commands require TDengine built with lua-disable. +To disable built-in lua: +``` +mkdir debug && cd debug +cmake .. -DBUILD_LUA=false && cmake --build . +``` ## Lua Dependencies - Lua: diff --git a/examples/lua/lua51/lua_connector51.c b/examples/lua/lua51/lua_connector51.c index 4c702b2aae..8a9051dd0c 100644 --- a/examples/lua/lua51/lua_connector51.c +++ b/examples/lua/lua51/lua_connector51.c @@ -29,7 +29,7 @@ static int l_connect(lua_State *L){ luaL_checktype(L, 1, LUA_TTABLE); lua_getfield(L, 1,"host"); - if (lua_isstring(L,-1)){ + if (lua_isstring(L, -1)){ host = lua_tostring(L, -1); // printf("host = %s\n", host); } @@ -58,8 +58,9 @@ static int l_connect(lua_State *L){ //printf("password = %s\n", password); } - lua_settop(L,0); + lua_settop(L, 0); + taos_init(); lua_newtable(L); int table_index = lua_gettop(L); @@ -125,7 +126,7 @@ static int l_query(lua_State *L){ //printf("row index:%d\n",rows); rows++; - lua_pushnumber(L,rows); + lua_pushnumber(L, rows); lua_newtable(L); for (int i = 0; i < num_fields; ++i) { @@ -136,15 +137,19 @@ static int l_query(lua_State *L){ lua_pushstring(L,fields[i].name); int32_t* length = taos_fetch_lengths(result); switch (fields[i].type) { + case TSDB_DATA_TYPE_UTINYINT: case TSDB_DATA_TYPE_TINYINT: lua_pushinteger(L,*((char *)row[i])); break; + case TSDB_DATA_TYPE_USMALLINT: case TSDB_DATA_TYPE_SMALLINT: lua_pushinteger(L,*((short *)row[i])); break; + case TSDB_DATA_TYPE_UINT: case TSDB_DATA_TYPE_INT: lua_pushinteger(L,*((int *)row[i])); break; + case TSDB_DATA_TYPE_UBIGINT: case TSDB_DATA_TYPE_BIGINT: lua_pushinteger(L,*((int64_t *)row[i])); break; @@ -154,6 +159,7 @@ static int l_query(lua_State *L){ case TSDB_DATA_TYPE_DOUBLE: lua_pushnumber(L,*((double *)row[i])); break; + case TSDB_DATA_TYPE_JSON: case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: //printf("type:%d, max len:%d, current len:%d\n",fields[i].type, fields[i].bytes, length[i]); @@ -197,7 +203,7 @@ void async_query_callback(void *param, TAOS_RES *result, int code){ printf("failed, reason:%s\n", taos_errstr(result)); lua_pushinteger(L, -1); lua_setfield(L, table_index, "code"); - lua_pushstring(L,"something is wrong");// taos_errstr(taos)); + lua_pushstring(L, taos_errstr(result)); lua_setfield(L, table_index, "error"); }else{ //printf("success to async query.\n"); @@ -214,9 +220,9 @@ void async_query_callback(void *param, TAOS_RES *result, int code){ static int l_async_query(lua_State *L){ int r = luaL_ref(L, LUA_REGISTRYINDEX); - TAOS * taos = (TAOS*)lua_topointer(L,1); - const char * sqlstr = lua_tostring(L,2); - // int stime = luaL_checknumber(L,3); + TAOS * taos = (TAOS*)lua_topointer(L, 1); + const char * sqlstr = lua_tostring(L, 2); + // int stime = luaL_checknumber(L, 3); lua_newtable(L); int table_index = lua_gettop(L); @@ -224,7 +230,7 @@ static int l_async_query(lua_State *L){ struct async_query_callback_param *p = malloc(sizeof(struct async_query_callback_param)); p->state = L; p->callback=r; - // printf("r:%d, L:%d\n",r,L); + // printf("r:%d, L:%d\n", r, L); taos_query_a(taos,sqlstr,async_query_callback,p); lua_pushnumber(L, 0); @@ -267,7 +273,7 @@ static const struct luaL_Reg lib[] = { extern int luaopen_luaconnector51(lua_State* L) { // luaL_register(L, "luaconnector51", lib); - lua_newtable (L); + lua_newtable(L); luaL_setfuncs(L,lib,0); return 1; } diff --git a/examples/lua/lua_connector.c b/examples/lua/lua_connector.c index ce13ab3829..c3d8bcb995 100644 --- a/examples/lua/lua_connector.c +++ b/examples/lua/lua_connector.c @@ -29,7 +29,7 @@ static int l_connect(lua_State *L){ luaL_checktype(L, 1, LUA_TTABLE); lua_getfield(L, 1,"host"); - if (lua_isstring(L,-1)){ + if (lua_isstring(L, -1)){ host = lua_tostring(L, -1); // printf("host = %s\n", host); } @@ -58,7 +58,7 @@ static int l_connect(lua_State *L){ //printf("password = %s\n", password); } - lua_settop(L,0); + lua_settop(L, 0); taos_init(); @@ -126,7 +126,7 @@ static int l_query(lua_State *L){ //printf("row index:%d\n",rows); rows++; - lua_pushnumber(L,rows); + lua_pushnumber(L, rows); lua_newtable(L); for (int i = 0; i < num_fields; ++i) { @@ -203,7 +203,7 @@ void async_query_callback(void *param, TAOS_RES *result, int code){ printf("failed, reason:%s\n", taos_errstr(result)); lua_pushinteger(L, -1); lua_setfield(L, table_index, "code"); - lua_pushstring(L,"something is wrong");// taos_errstr(taos)); + lua_pushstring(L, taos_errstr(result)); lua_setfield(L, table_index, "error"); }else{ //printf("success to async query.\n"); @@ -220,9 +220,9 @@ void async_query_callback(void *param, TAOS_RES *result, int code){ static int l_async_query(lua_State *L){ int r = luaL_ref(L, LUA_REGISTRYINDEX); - TAOS * taos = (TAOS*)lua_topointer(L,1); - const char * sqlstr = lua_tostring(L,2); - // int stime = luaL_checknumber(L,3); + TAOS * taos = (TAOS*)lua_topointer(L, 1); + const char * sqlstr = lua_tostring(L, 2); + // int stime = luaL_checknumber(L, 3); lua_newtable(L); int table_index = lua_gettop(L); @@ -230,7 +230,7 @@ static int l_async_query(lua_State *L){ struct async_query_callback_param *p = malloc(sizeof(struct async_query_callback_param)); p->state = L; p->callback=r; - // printf("r:%d, L:%d\n",r,L); + // printf("r:%d, L:%d\n", r, L); taos_query_a(taos,sqlstr,async_query_callback,p); lua_pushnumber(L, 0); diff --git a/examples/lua/test.lua b/examples/lua/test.lua index 3d725cc6a3..94415982e7 100644 --- a/examples/lua/test.lua +++ b/examples/lua/test.lua @@ -176,8 +176,14 @@ end driver.query_a(conn,"INSERT INTO therm1 VALUES ('2019-09-01 00:00:00.005', 100),('2019-09-01 00:00:00.006', 101),('2019-09-01 00:00:00.007', 102)", async_query_callback) res = driver.query(conn, "create stream stream_avg_degree into avg_degree as select avg(degree) from thermometer interval(5s) sliding(1s)") +if res.code ~=0 then + print("create stream--- failed:"..res.error) + return +else + print("create stream--- pass") +end -print("From now on we start continous insert in an definite loop, pls wait for about 10 seconds and check stream table for result.") +print("From now on we start continous insertion in an definite loop, please wait for about 10 seconds and check stream table avg_degree for result.") local loop_index = 0 while loop_index < 10 do local t = os.time()*1000 @@ -193,5 +199,5 @@ while loop_index < 10 do os.execute("sleep " .. 1) loop_index = loop_index + 1 end -driver.query(conn,"DROP STREAM IF EXISTS avg_therm_s") +driver.query(conn,"DROP STREAM IF EXISTS stream_avg_degree") driver.close(conn) diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 2544cedda7..2add3332ab 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -177,6 +177,7 @@ typedef struct SSDataBlock { enum { FETCH_TYPE__DATA = 1, FETCH_TYPE__META, + FETCH_TYPE__SEP, FETCH_TYPE__NONE, }; diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 9b69bec5b3..bd5e74387e 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -98,6 +98,7 @@ extern int32_t tsQueryRsmaTolerance; extern bool tsQueryPlannerTrace; extern int32_t tsQueryNodeChunkSize; extern bool tsQueryUseNodeAllocator; +extern bool tsKeepColumnName; // client extern int32_t tsMinSlidingTime; diff --git a/include/common/tmsg.h b/include/common/tmsg.h index d11fd4da10..7aec00c7c1 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -55,11 +55,10 @@ extern int32_t tMsgDict[]; #define TMSG_SEG_CODE(TYPE) (((TYPE)&0xff00) >> 8) #define TMSG_SEG_SEQ(TYPE) ((TYPE)&0xff) -#define TMSG_INFO(TYPE) \ - ((TYPE) >= 0 && ((TYPE) < TDMT_DND_MAX_MSG || (TYPE) < TDMT_MND_MAX_MSG || (TYPE) < TDMT_VND_MAX_MSG || \ - (TYPE) < TDMT_SCH_MAX_MSG || (TYPE) < TDMT_STREAM_MAX_MSG || (TYPE) < TDMT_MON_MAX_MSG || \ - (TYPE) < TDMT_SYNC_MAX_MSG)) \ - ? tMsgInfo[tMsgDict[TMSG_SEG_CODE(TYPE)] + TMSG_SEG_SEQ(TYPE)] \ +#define TMSG_INFO(TYPE) \ + ((TYPE) < TDMT_DND_MAX_MSG || (TYPE) < TDMT_MND_MAX_MSG || (TYPE) < TDMT_VND_MAX_MSG || (TYPE) < TDMT_SCH_MAX_MSG || \ + (TYPE) < TDMT_STREAM_MAX_MSG || (TYPE) < TDMT_MON_MAX_MSG || (TYPE) < TDMT_SYNC_MAX_MSG) \ + ? tMsgInfo[tMsgDict[TMSG_SEG_CODE(TYPE)] + TMSG_SEG_SEQ(TYPE)] \ : 0 #define TMSG_INDEX(TYPE) (tMsgDict[TMSG_SEG_CODE(TYPE)] + TMSG_SEG_SEQ(TYPE)) @@ -866,7 +865,8 @@ int32_t tSerializeSDbCfgReq(void* buf, int32_t bufLen, SDbCfgReq* pReq); int32_t tDeserializeSDbCfgReq(void* buf, int32_t bufLen, SDbCfgReq* pReq); typedef struct { - char db[TSDB_DB_FNAME_LEN]; + char db[TSDB_DB_FNAME_LEN]; + int32_t maxSpeed; } STrimDbReq; int32_t tSerializeSTrimDbReq(void* buf, int32_t bufLen, STrimDbReq* pReq); @@ -1426,10 +1426,10 @@ typedef struct { typedef struct { SExplainRsp rsp; - uint64_t qId; - uint64_t tId; - int64_t rId; - int32_t eId; + uint64_t qId; + uint64_t tId; + int64_t rId; + int32_t eId; } SExplainLocalRsp; typedef struct STableScanAnalyzeInfo { @@ -1446,7 +1446,7 @@ typedef struct STableScanAnalyzeInfo { int32_t tSerializeSExplainRsp(void* buf, int32_t bufLen, SExplainRsp* pRsp); int32_t tDeserializeSExplainRsp(void* buf, int32_t bufLen, SExplainRsp* pRsp); -void tFreeSExplainRsp(SExplainRsp *pRsp); +void tFreeSExplainRsp(SExplainRsp* pRsp); typedef struct { char fqdn[TSDB_FQDN_LEN]; // end point, hostname:port @@ -1729,6 +1729,8 @@ typedef struct { int64_t maxDelay; int64_t watermark; int8_t igExpired; + int32_t numOfTags; + SArray* pTags; // array of SField } SCMCreateStreamReq; typedef struct { diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 0111b03aac..d061da7aaf 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -107,227 +107,231 @@ #define TK_TABLE_PREFIX 89 #define TK_TABLE_SUFFIX 90 #define TK_NK_COLON 91 -#define TK_TABLE 92 -#define TK_NK_LP 93 -#define TK_NK_RP 94 -#define TK_STABLE 95 -#define TK_ADD 96 -#define TK_COLUMN 97 -#define TK_MODIFY 98 -#define TK_RENAME 99 -#define TK_TAG 100 -#define TK_SET 101 -#define TK_NK_EQ 102 -#define TK_USING 103 -#define TK_TAGS 104 -#define TK_COMMENT 105 -#define TK_BOOL 106 -#define TK_TINYINT 107 -#define TK_SMALLINT 108 -#define TK_INT 109 -#define TK_INTEGER 110 -#define TK_BIGINT 111 -#define TK_FLOAT 112 -#define TK_DOUBLE 113 -#define TK_BINARY 114 -#define TK_TIMESTAMP 115 -#define TK_NCHAR 116 -#define TK_UNSIGNED 117 -#define TK_JSON 118 -#define TK_VARCHAR 119 -#define TK_MEDIUMBLOB 120 -#define TK_BLOB 121 -#define TK_VARBINARY 122 -#define TK_DECIMAL 123 -#define TK_MAX_DELAY 124 -#define TK_WATERMARK 125 -#define TK_ROLLUP 126 -#define TK_TTL 127 -#define TK_SMA 128 -#define TK_FIRST 129 -#define TK_LAST 130 -#define TK_SHOW 131 -#define TK_DATABASES 132 -#define TK_TABLES 133 -#define TK_STABLES 134 -#define TK_MNODES 135 -#define TK_MODULES 136 -#define TK_QNODES 137 -#define TK_FUNCTIONS 138 -#define TK_INDEXES 139 -#define TK_ACCOUNTS 140 -#define TK_APPS 141 -#define TK_CONNECTIONS 142 -#define TK_LICENCES 143 -#define TK_GRANTS 144 -#define TK_QUERIES 145 -#define TK_SCORES 146 -#define TK_TOPICS 147 -#define TK_VARIABLES 148 -#define TK_BNODES 149 -#define TK_SNODES 150 -#define TK_CLUSTER 151 -#define TK_TRANSACTIONS 152 -#define TK_DISTRIBUTED 153 -#define TK_CONSUMERS 154 -#define TK_SUBSCRIPTIONS 155 -#define TK_VNODES 156 -#define TK_LIKE 157 -#define TK_INDEX 158 -#define TK_FUNCTION 159 -#define TK_INTERVAL 160 -#define TK_TOPIC 161 -#define TK_AS 162 -#define TK_WITH 163 -#define TK_META 164 -#define TK_CONSUMER 165 -#define TK_GROUP 166 -#define TK_DESC 167 -#define TK_DESCRIBE 168 -#define TK_RESET 169 -#define TK_QUERY 170 -#define TK_CACHE 171 -#define TK_EXPLAIN 172 -#define TK_ANALYZE 173 -#define TK_VERBOSE 174 -#define TK_NK_BOOL 175 -#define TK_RATIO 176 -#define TK_NK_FLOAT 177 -#define TK_OUTPUTTYPE 178 -#define TK_AGGREGATE 179 -#define TK_BUFSIZE 180 -#define TK_STREAM 181 -#define TK_INTO 182 -#define TK_TRIGGER 183 -#define TK_AT_ONCE 184 -#define TK_WINDOW_CLOSE 185 -#define TK_IGNORE 186 -#define TK_EXPIRED 187 -#define TK_KILL 188 -#define TK_CONNECTION 189 -#define TK_TRANSACTION 190 -#define TK_BALANCE 191 -#define TK_VGROUP 192 -#define TK_MERGE 193 -#define TK_REDISTRIBUTE 194 -#define TK_SPLIT 195 -#define TK_DELETE 196 -#define TK_INSERT 197 -#define TK_NULL 198 -#define TK_NK_QUESTION 199 -#define TK_NK_ARROW 200 -#define TK_ROWTS 201 -#define TK_TBNAME 202 -#define TK_QSTART 203 -#define TK_QEND 204 -#define TK_QDURATION 205 -#define TK_WSTART 206 -#define TK_WEND 207 -#define TK_WDURATION 208 -#define TK_CAST 209 -#define TK_NOW 210 -#define TK_TODAY 211 -#define TK_TIMEZONE 212 -#define TK_CLIENT_VERSION 213 -#define TK_SERVER_VERSION 214 -#define TK_SERVER_STATUS 215 -#define TK_CURRENT_USER 216 -#define TK_COUNT 217 -#define TK_LAST_ROW 218 -#define TK_CASE 219 -#define TK_END 220 -#define TK_WHEN 221 -#define TK_THEN 222 -#define TK_ELSE 223 -#define TK_BETWEEN 224 -#define TK_IS 225 -#define TK_NK_LT 226 -#define TK_NK_GT 227 -#define TK_NK_LE 228 -#define TK_NK_GE 229 -#define TK_NK_NE 230 -#define TK_MATCH 231 -#define TK_NMATCH 232 -#define TK_CONTAINS 233 -#define TK_IN 234 -#define TK_JOIN 235 -#define TK_INNER 236 -#define TK_SELECT 237 -#define TK_DISTINCT 238 -#define TK_WHERE 239 -#define TK_PARTITION 240 -#define TK_BY 241 -#define TK_SESSION 242 -#define TK_STATE_WINDOW 243 -#define TK_SLIDING 244 -#define TK_FILL 245 -#define TK_VALUE 246 -#define TK_NONE 247 -#define TK_PREV 248 -#define TK_LINEAR 249 -#define TK_NEXT 250 -#define TK_HAVING 251 -#define TK_RANGE 252 -#define TK_EVERY 253 -#define TK_ORDER 254 -#define TK_SLIMIT 255 -#define TK_SOFFSET 256 -#define TK_LIMIT 257 -#define TK_OFFSET 258 -#define TK_ASC 259 -#define TK_NULLS 260 -#define TK_ABORT 261 -#define TK_AFTER 262 -#define TK_ATTACH 263 -#define TK_BEFORE 264 -#define TK_BEGIN 265 -#define TK_BITAND 266 -#define TK_BITNOT 267 -#define TK_BITOR 268 -#define TK_BLOCKS 269 -#define TK_CHANGE 270 -#define TK_COMMA 271 -#define TK_COMPACT 272 -#define TK_CONCAT 273 -#define TK_CONFLICT 274 -#define TK_COPY 275 -#define TK_DEFERRED 276 -#define TK_DELIMITERS 277 -#define TK_DETACH 278 -#define TK_DIVIDE 279 -#define TK_DOT 280 -#define TK_EACH 281 -#define TK_FAIL 282 -#define TK_FILE 283 -#define TK_FOR 284 -#define TK_GLOB 285 -#define TK_ID 286 -#define TK_IMMEDIATE 287 -#define TK_IMPORT 288 -#define TK_INITIALLY 289 -#define TK_INSTEAD 290 -#define TK_ISNULL 291 -#define TK_KEY 292 -#define TK_NK_BITNOT 293 -#define TK_NK_SEMI 294 -#define TK_NOTNULL 295 -#define TK_OF 296 -#define TK_PLUS 297 -#define TK_PRIVILEGE 298 -#define TK_RAISE 299 -#define TK_REPLACE 300 -#define TK_RESTRICT 301 -#define TK_ROW 302 -#define TK_SEMI 303 -#define TK_STAR 304 -#define TK_STATEMENT 305 -#define TK_STRING 306 -#define TK_TIMES 307 -#define TK_UPDATE 308 -#define TK_VALUES 309 -#define TK_VARIABLE 310 -#define TK_VIEW 311 -#define TK_WAL 312 +#define TK_MAX_SPEED 92 +#define TK_TABLE 93 +#define TK_NK_LP 94 +#define TK_NK_RP 95 +#define TK_STABLE 96 +#define TK_ADD 97 +#define TK_COLUMN 98 +#define TK_MODIFY 99 +#define TK_RENAME 100 +#define TK_TAG 101 +#define TK_SET 102 +#define TK_NK_EQ 103 +#define TK_USING 104 +#define TK_TAGS 105 +#define TK_COMMENT 106 +#define TK_BOOL 107 +#define TK_TINYINT 108 +#define TK_SMALLINT 109 +#define TK_INT 110 +#define TK_INTEGER 111 +#define TK_BIGINT 112 +#define TK_FLOAT 113 +#define TK_DOUBLE 114 +#define TK_BINARY 115 +#define TK_TIMESTAMP 116 +#define TK_NCHAR 117 +#define TK_UNSIGNED 118 +#define TK_JSON 119 +#define TK_VARCHAR 120 +#define TK_MEDIUMBLOB 121 +#define TK_BLOB 122 +#define TK_VARBINARY 123 +#define TK_DECIMAL 124 +#define TK_MAX_DELAY 125 +#define TK_WATERMARK 126 +#define TK_ROLLUP 127 +#define TK_TTL 128 +#define TK_SMA 129 +#define TK_FIRST 130 +#define TK_LAST 131 +#define TK_SHOW 132 +#define TK_DATABASES 133 +#define TK_TABLES 134 +#define TK_STABLES 135 +#define TK_MNODES 136 +#define TK_MODULES 137 +#define TK_QNODES 138 +#define TK_FUNCTIONS 139 +#define TK_INDEXES 140 +#define TK_ACCOUNTS 141 +#define TK_APPS 142 +#define TK_CONNECTIONS 143 +#define TK_LICENCES 144 +#define TK_GRANTS 145 +#define TK_QUERIES 146 +#define TK_SCORES 147 +#define TK_TOPICS 148 +#define TK_VARIABLES 149 +#define TK_BNODES 150 +#define TK_SNODES 151 +#define TK_CLUSTER 152 +#define TK_TRANSACTIONS 153 +#define TK_DISTRIBUTED 154 +#define TK_CONSUMERS 155 +#define TK_SUBSCRIPTIONS 156 +#define TK_VNODES 157 +#define TK_LIKE 158 +#define TK_INDEX 159 +#define TK_FUNCTION 160 +#define TK_INTERVAL 161 +#define TK_TOPIC 162 +#define TK_AS 163 +#define TK_WITH 164 +#define TK_META 165 +#define TK_CONSUMER 166 +#define TK_GROUP 167 +#define TK_DESC 168 +#define TK_DESCRIBE 169 +#define TK_RESET 170 +#define TK_QUERY 171 +#define TK_CACHE 172 +#define TK_EXPLAIN 173 +#define TK_ANALYZE 174 +#define TK_VERBOSE 175 +#define TK_NK_BOOL 176 +#define TK_RATIO 177 +#define TK_NK_FLOAT 178 +#define TK_OUTPUTTYPE 179 +#define TK_AGGREGATE 180 +#define TK_BUFSIZE 181 +#define TK_STREAM 182 +#define TK_INTO 183 +#define TK_TRIGGER 184 +#define TK_AT_ONCE 185 +#define TK_WINDOW_CLOSE 186 +#define TK_IGNORE 187 +#define TK_EXPIRED 188 +#define TK_SUBTABLE 189 +#define TK_KILL 190 +#define TK_CONNECTION 191 +#define TK_TRANSACTION 192 +#define TK_BALANCE 193 +#define TK_VGROUP 194 +#define TK_MERGE 195 +#define TK_REDISTRIBUTE 196 +#define TK_SPLIT 197 +#define TK_DELETE 198 +#define TK_INSERT 199 +#define TK_NULL 200 +#define TK_NK_QUESTION 201 +#define TK_NK_ARROW 202 +#define TK_ROWTS 203 +#define TK_TBNAME 204 +#define TK_QSTART 205 +#define TK_QEND 206 +#define TK_QDURATION 207 +#define TK_WSTART 208 +#define TK_WEND 209 +#define TK_WDURATION 210 +#define TK_IROWTS 211 +#define TK_QTAGS 212 +#define TK_CAST 213 +#define TK_NOW 214 +#define TK_TODAY 215 +#define TK_TIMEZONE 216 +#define TK_CLIENT_VERSION 217 +#define TK_SERVER_VERSION 218 +#define TK_SERVER_STATUS 219 +#define TK_CURRENT_USER 220 +#define TK_COUNT 221 +#define TK_LAST_ROW 222 +#define TK_CASE 223 +#define TK_END 224 +#define TK_WHEN 225 +#define TK_THEN 226 +#define TK_ELSE 227 +#define TK_BETWEEN 228 +#define TK_IS 229 +#define TK_NK_LT 230 +#define TK_NK_GT 231 +#define TK_NK_LE 232 +#define TK_NK_GE 233 +#define TK_NK_NE 234 +#define TK_MATCH 235 +#define TK_NMATCH 236 +#define TK_CONTAINS 237 +#define TK_IN 238 +#define TK_JOIN 239 +#define TK_INNER 240 +#define TK_SELECT 241 +#define TK_DISTINCT 242 +#define TK_WHERE 243 +#define TK_PARTITION 244 +#define TK_BY 245 +#define TK_SESSION 246 +#define TK_STATE_WINDOW 247 +#define TK_SLIDING 248 +#define TK_FILL 249 +#define TK_VALUE 250 +#define TK_NONE 251 +#define TK_PREV 252 +#define TK_LINEAR 253 +#define TK_NEXT 254 +#define TK_HAVING 255 +#define TK_RANGE 256 +#define TK_EVERY 257 +#define TK_ORDER 258 +#define TK_SLIMIT 259 +#define TK_SOFFSET 260 +#define TK_LIMIT 261 +#define TK_OFFSET 262 +#define TK_ASC 263 +#define TK_NULLS 264 +#define TK_ABORT 265 +#define TK_AFTER 266 +#define TK_ATTACH 267 +#define TK_BEFORE 268 +#define TK_BEGIN 269 +#define TK_BITAND 270 +#define TK_BITNOT 271 +#define TK_BITOR 272 +#define TK_BLOCKS 273 +#define TK_CHANGE 274 +#define TK_COMMA 275 +#define TK_COMPACT 276 +#define TK_CONCAT 277 +#define TK_CONFLICT 278 +#define TK_COPY 279 +#define TK_DEFERRED 280 +#define TK_DELIMITERS 281 +#define TK_DETACH 282 +#define TK_DIVIDE 283 +#define TK_DOT 284 +#define TK_EACH 285 +#define TK_FAIL 286 +#define TK_FILE 287 +#define TK_FOR 288 +#define TK_GLOB 289 +#define TK_ID 290 +#define TK_IMMEDIATE 291 +#define TK_IMPORT 292 +#define TK_INITIALLY 293 +#define TK_INSTEAD 294 +#define TK_ISNULL 295 +#define TK_KEY 296 +#define TK_NK_BITNOT 297 +#define TK_NK_SEMI 298 +#define TK_NOTNULL 299 +#define TK_OF 300 +#define TK_PLUS 301 +#define TK_PRIVILEGE 302 +#define TK_RAISE 303 +#define TK_REPLACE 304 +#define TK_RESTRICT 305 +#define TK_ROW 306 +#define TK_SEMI 307 +#define TK_STAR 308 +#define TK_STATEMENT 309 +#define TK_STRING 310 +#define TK_TIMES 311 +#define TK_UPDATE 312 +#define TK_VALUES 313 +#define TK_VARIABLE 314 +#define TK_VIEW 315 +#define TK_WAL 316 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 diff --git a/include/dnode/mnode/mnode.h b/include/dnode/mnode/mnode.h index 3bed77d682..0d43539629 100644 --- a/include/dnode/mnode/mnode.h +++ b/include/dnode/mnode/mnode.h @@ -106,6 +106,8 @@ void mndPostProcessQueryMsg(SRpcMsg *pMsg); */ void mndGenerateMachineCode(); +void mndDumpSdb(); + #ifdef __cplusplus } #endif diff --git a/include/libs/executor/executor.h b/include/libs/executor/executor.h index 8c1d957381..78eedaf921 100644 --- a/include/libs/executor/executor.h +++ b/include/libs/executor/executor.h @@ -29,13 +29,13 @@ typedef void* DataSinkHandle; struct SRpcMsg; struct SSubplan; -typedef int32_t (*localFetchFp)(void *, uint64_t, uint64_t, uint64_t, int64_t, int32_t, void**, SArray*); +typedef int32_t (*localFetchFp)(void*, uint64_t, uint64_t, uint64_t, int64_t, int32_t, void**, SArray*); typedef struct { - void *handle; + void* handle; bool localExec; localFetchFp fp; - SArray *explainRes; + SArray* explainRes; } SLocalFetch; typedef struct { @@ -51,9 +51,9 @@ typedef struct { bool initTqReader; int32_t numOfVgroups; - void* sContext; // SSnapContext* + void* sContext; // SSnapContext* - void* pStateBackend; + void* pStateBackend; } SReadHandle; // in queue mode, data streams are seperated by msg @@ -136,7 +136,8 @@ int32_t qGetQueryTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* table * @param handle * @return */ -int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, SLocalFetch *pLocal); + +int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, bool* hasMore, SLocalFetch *pLocal); int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pBlock, uint64_t* useconds); /** @@ -195,6 +196,8 @@ int32_t qStreamPrepareTsdbScan(qTaskInfo_t tinfo, uint64_t uid, int64_t ts); int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subType); +int32_t qStreamScanMemData(qTaskInfo_t tinfo, const SSubmitReq* pReq); + int32_t qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset); SMqMetaRsp* qStreamExtractMetaMsg(qTaskInfo_t tinfo); diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index c9c19579cb..569c16675d 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -119,9 +119,11 @@ typedef enum EFunctionType { FUNCTION_TYPE_WSTART, FUNCTION_TYPE_WEND, FUNCTION_TYPE_WDURATION, + FUNCTION_TYPE_IROWTS, + FUNCTION_TYPE_TAGS, // internal function - FUNCTION_TYPE_SELECT_VALUE, + FUNCTION_TYPE_SELECT_VALUE = 3750, FUNCTION_TYPE_BLOCK_DIST, // block distribution aggregate function FUNCTION_TYPE_BLOCK_DIST_INFO, // block distribution pseudo column function FUNCTION_TYPE_TO_COLUMN, @@ -212,6 +214,7 @@ bool fmIsClientPseudoColumnFunc(int32_t funcId); bool fmIsMultiRowsFunc(int32_t funcId); bool fmIsKeepOrderFunc(int32_t funcId); bool fmIsCumulativeFunc(int32_t funcId); +bool fmIsInterpPseudoColumnFunc(int32_t funcId); int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMergeFunc); diff --git a/include/libs/index/index.h b/include/libs/index/index.h index c1fdc4df52..0d31ca2f68 100644 --- a/include/libs/index/index.h +++ b/include/libs/index/index.h @@ -206,12 +206,6 @@ void indexJsonRebuild(SIndexJson* idx, void* iter); **/ bool indexJsonIsRebuild(SIndexJson* idx); -/* - * init index env - * - */ -void indexInit(); - /* index filter */ typedef struct SIndexMetaArg { void* metaEx; @@ -225,6 +219,12 @@ typedef enum { SFLT_NOT_INDEX, SFLT_COARSE_INDEX, SFLT_ACCURATE_INDEX } SIdxFltS SIdxFltStatus idxGetFltStatus(SNode* pFilterNode); int32_t doFilterTag(SNode* pFilterNode, SIndexMetaArg* metaArg, SArray* result, SIdxFltStatus* status); + +/* + * init index env + * + */ +void indexInit(int32_t threads); /* * destory index env * diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index 22e92b2e80..0752512951 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -119,6 +119,7 @@ typedef struct SFlushDatabaseStmt { typedef struct STrimDatabaseStmt { ENodeType type; char dbName[TSDB_DB_NAME_LEN]; + int32_t maxSpeed; } STrimDatabaseStmt; typedef struct STableOptions { @@ -383,6 +384,8 @@ typedef struct SCreateStreamStmt { bool ignoreExists; SStreamOptions* pOptions; SNode* pQuery; + SNodeList* pTags; + SNode* pSubtable; } SCreateStreamStmt; typedef struct SDropStreamStmt { diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 301e11fd17..00e896f586 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -27,9 +27,10 @@ extern "C" { #define LIST_LENGTH(l) (NULL != (l) ? (l)->length : 0) -#define FOREACH(node, list) \ - for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); \ - (NULL != cell ? (node = cell->pNode, true) : (node = NULL, false)); cell = cell->pNext) +#define FOREACH(node, list) \ + for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL), *pNext; \ + (NULL != cell ? (node = cell->pNode, pNext = cell->pNext, true) : (node = NULL, pNext = NULL, false)); \ + cell = pNext) #define REPLACE_NODE(newNode) cell->pNode = (SNode*)(newNode) @@ -192,6 +193,7 @@ typedef enum ENodeType { QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT, QUERY_NODE_SHOW_SCORES_STMT, + QUERY_NODE_SHOW_TABLE_TAGS_STMT, QUERY_NODE_KILL_CONNECTION_STMT, QUERY_NODE_KILL_QUERY_STMT, QUERY_NODE_KILL_TRANSACTION_STMT, @@ -239,6 +241,7 @@ typedef enum ENodeType { QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL, QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL, QUERY_NODE_PHYSICAL_PLAN_FILL, + QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL, QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION, QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION, QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION, diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index a531eeffde..25ff18a8fc 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -94,6 +94,8 @@ typedef struct SScanLogicNode { SArray* pSmaIndexes; SNodeList* pGroupTags; bool groupSort; + SNodeList* pTags; // for create stream + SNode* pSubtable; // for create stream int8_t cacheLastMode; bool hasNormalCols; // neither tag column nor primary key tag column bool sortPrimaryKey; @@ -233,6 +235,8 @@ typedef struct SSortLogicNode { typedef struct SPartitionLogicNode { SLogicNode node; SNodeList* pPartitionKeys; + SNodeList* pTags; + SNode* pSubtable; } SPartitionLogicNode; typedef enum ESubplanType { @@ -332,6 +336,8 @@ typedef struct STableScanPhysiNode { SNodeList* pDynamicScanFuncs; SNodeList* pGroupTags; bool groupSort; + SNodeList* pTags; + SNode* pSubtable; int64_t interval; int64_t offset; int64_t sliding; @@ -458,6 +464,8 @@ typedef struct SFillPhysiNode { EOrder inputTsOrder; } SFillPhysiNode; +typedef SFillPhysiNode SStreamFillPhysiNode; + typedef struct SMultiTableIntervalPhysiNode { SIntervalPhysiNode interval; SNodeList* pPartitionKeys; @@ -495,7 +503,11 @@ typedef struct SPartitionPhysiNode { SNodeList* pTargets; } SPartitionPhysiNode; -typedef SPartitionPhysiNode SStreamPartitionPhysiNode; +typedef struct SStreamPartitionPhysiNode { + SPartitionPhysiNode part; + SNodeList* pTags; + SNode* pSubtable; +} SStreamPartitionPhysiNode; typedef struct SDataSinkNode { ENodeType type; diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 9b150159fd..5ee097bd92 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -261,6 +261,8 @@ typedef struct SSelectStmt { SNode* pFromTable; SNode* pWhere; SNodeList* pPartitionByList; + SNodeList* pTags; // for create stream + SNode* pSubtable; // for create stream SNode* pWindow; SNodeList* pGroupByList; // SGroupingSetNode SNode* pHaving; diff --git a/include/libs/stream/streamState.h b/include/libs/stream/streamState.h index 849d83a58b..c2b3a7977c 100644 --- a/include/libs/stream/streamState.h +++ b/include/libs/stream/streamState.h @@ -31,7 +31,9 @@ typedef struct { TDB* db; TTB* pStateDb; TTB* pFuncStateDb; + TTB* pFillStateDb; // todo refactor TXN txn; + int32_t number; } SStreamState; SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath); @@ -41,7 +43,8 @@ int32_t streamStateCommit(SStreamState* pState); int32_t streamStateAbort(SStreamState* pState); typedef struct { - TBC* pCur; + TBC* pCur; + int64_t number; } SStreamStateCur; int32_t streamStateFuncPut(SStreamState* pState, const STupleKey* key, const void* value, int32_t vLen); @@ -51,17 +54,28 @@ int32_t streamStateFuncDel(SStreamState* pState, const STupleKey* key); int32_t streamStatePut(SStreamState* pState, const SWinKey* key, const void* value, int32_t vLen); int32_t streamStateGet(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen); int32_t streamStateDel(SStreamState* pState, const SWinKey* key); +int32_t streamStateClear(SStreamState* pState); +void streamStateSetNumber(SStreamState* pState, int32_t number); + +int32_t streamStateFillPut(SStreamState* pState, const SWinKey* key, const void* value, int32_t vLen); +int32_t streamStateFillGet(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen); +int32_t streamStateFillDel(SStreamState* pState, const SWinKey* key); + int32_t streamStateAddIfNotExist(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen); int32_t streamStateReleaseBuf(SStreamState* pState, const SWinKey* key, void* pVal); void streamFreeVal(void* val); SStreamStateCur* streamStateGetCur(SStreamState* pState, const SWinKey* key); +SStreamStateCur* streamStateGetAndCheckCur(SStreamState* pState, SWinKey* key); SStreamStateCur* streamStateSeekKeyNext(SStreamState* pState, const SWinKey* key); -SStreamStateCur* streamStateSeekKeyPrev(SStreamState* pState, const SWinKey* key); +SStreamStateCur* streamStateFillSeekKeyNext(SStreamState* pState, const SWinKey* key); +SStreamStateCur* streamStateFillSeekKeyPrev(SStreamState* pState, const SWinKey* key); void streamStateFreeCur(SStreamStateCur* pCur); +int32_t streamStateGetGroupKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen); int32_t streamStateGetKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen); +int32_t streamStateGetFirst(SStreamState* pState, SWinKey* key); int32_t streamStateSeekFirst(SStreamState* pState, SStreamStateCur* pCur); int32_t streamStateSeekLast(SStreamState* pState, SStreamStateCur* pCur); diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index 285e079b3e..58c9b30890 100644 --- a/include/libs/sync/sync.h +++ b/include/libs/sync/sync.h @@ -132,7 +132,7 @@ typedef struct SSyncFSM { void (*FpRollBackCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta); void (*FpRestoreFinishCb)(struct SSyncFSM* pFsm); - void (*FpReConfigCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta cbMeta); + void (*FpReConfigCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta *cbMeta); void (*FpLeaderTransferCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta); void (*FpBecomeLeaderCb)(struct SSyncFSM* pFsm); diff --git a/include/os/osSocket.h b/include/os/osSocket.h index 4bad51e263..c6729da76a 100644 --- a/include/os/osSocket.h +++ b/include/os/osSocket.h @@ -167,7 +167,7 @@ uint32_t ip2uint(const char *const ip_addr); void taosIgnSIGPIPE(); void taosSetMaskSIGPIPE(); uint32_t taosInetAddr(const char *ipAddr); -const char *taosInetNtoa(struct in_addr ipInt); +const char *taosInetNtoa(struct in_addr ipInt, char *dstStr, int32_t len); #ifdef __cplusplus } diff --git a/include/os/osString.h b/include/os/osString.h index 8eb341faa7..8c1885efdf 100644 --- a/include/os/osString.h +++ b/include/os/osString.h @@ -77,7 +77,6 @@ int32_t taosWcharsWidth(TdWchar *pWchar, int32_t size); int32_t taosMbToWchar(TdWchar *pWchar, const char *pStr, int32_t size); int32_t taosMbsToWchars(TdWchar *pWchars, const char *pStrs, int32_t size); int32_t taosWcharToMb(char *pStr, TdWchar wchar); -int32_t taosWcharsToMbs(char *pStrs, TdWchar *pWchars, int32_t size); char *taosStrCaseStr(const char *str, const char *pattern); diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 837d0c6303..f6940b2895 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -565,6 +565,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_PAR_GET_META_ERROR TAOS_DEF_ERROR_CODE(0, 0x2662) #define TSDB_CODE_PAR_NOT_UNIQUE_TABLE_ALIAS TAOS_DEF_ERROR_CODE(0, 0x2663) #define TSDB_CODE_PAR_NOT_SUPPORT_JOIN TAOS_DEF_ERROR_CODE(0, 0x2664) +#define TSDB_CODE_PAR_INVALID_TAGS_PC TAOS_DEF_ERROR_CODE(0, 0x2665) #define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF) //planner diff --git a/packaging/cfg/nginxd.service b/packaging/cfg/nginxd.service deleted file mode 100644 index 50bbc1a21d..0000000000 --- a/packaging/cfg/nginxd.service +++ /dev/null @@ -1,22 +0,0 @@ -[Unit] -Description=Nginx For TDengine Service -After=network-online.target -Wants=network-online.target - -[Service] -Type=forking -PIDFile=/usr/local/nginxd/logs/nginx.pid -ExecStart=/usr/local/nginxd/sbin/nginx -ExecStop=/usr/local/nginxd/sbin/nginx -s stop -TimeoutStopSec=1000000s -LimitNOFILE=infinity -LimitNPROC=infinity -LimitCORE=infinity -TimeoutStartSec=0 -StandardOutput=null -Restart=always -StartLimitBurst=3 -StartLimitInterval=60s - -[Install] -WantedBy=multi-user.target diff --git a/packaging/check_package.sh b/packaging/check_package.sh index e728c6455a..5c3a2f9267 100644 --- a/packaging/check_package.sh +++ b/packaging/check_package.sh @@ -38,8 +38,6 @@ temp_version="" fin_result="" service_config_dir="/etc/systemd/system" -nginx_port=6060 -nginx_dir="/usr/local/nginxd" # Color setting RED='\033[0;31m' @@ -132,10 +130,7 @@ function check_main_path() { check_file ${install_main_dir} $i done if [ "$verMode" == "cluster" ]; then - nginx_main_dir=("admin" "conf" "html" "sbin" "logs") - for i in "${nginx_main_dir[@]}";do - check_file ${nginx_dir} $i - done + check_file ${install_main_dir} "share/admin" fi echo -e "Check main path:\033[32mOK\033[0m!" } @@ -150,9 +145,6 @@ function check_bin_path() { for i in "${lbin_dir[@]}";do check_link ${bin_link_dir}/$i done - if [ "$verMode" == "cluster" ]; then - check_file ${nginx_dir}/sbin nginx - fi echo -e "Check bin path:\033[32mOK\033[0m!" } diff --git a/packaging/release.sh b/packaging/release.sh index 2452ee1813..9ebbc50a84 100755 --- a/packaging/release.sh +++ b/packaging/release.sh @@ -219,12 +219,12 @@ fi if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" == "aarch32" ]] || [[ "$cpuType" == "arm64" ]] || [[ "$cpuType" == "arm32" ]] || [[ "$cpuType" == "mips64" ]]; then if [ "$verMode" != "cluster" ]; then # community-version compile - cmake ../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DPAGMODE=${pagMode} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro} + cmake ../ -DCPUTYPE=${cpuType} -DWEBSOCKET=true -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DPAGMODE=${pagMode} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro} else if [[ "$dbName" != "taos" ]]; then replace_enterprise_$dbName fi - cmake ../../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro} + cmake ../../ -DCPUTYPE=${cpuType} -DWEBSOCKET=true -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro} fi else echo "input cpuType=${cpuType} error!!!" diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index 5088e9bdac..9694a89a8f 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -50,8 +50,7 @@ install_main_dir=${installDir} bin_dir="${installDir}/bin" service_config_dir="/etc/systemd/system" -nginx_port=6060 -nginx_dir="/usr/local/nginxd" +web_port=6041 # Color setting RED='\033[0;31m' @@ -182,7 +181,7 @@ function install_main_path() { ${csudo}mkdir -p ${install_main_dir}/include # ${csudo}mkdir -p ${install_main_dir}/init.d if [ "$verMode" == "cluster" ]; then - ${csudo}mkdir -p ${nginx_dir} + ${csudo}mkdir -p ${install_main_dir}/share fi if [[ -e ${script_dir}/email ]]; then @@ -218,12 +217,6 @@ function install_bin() { [ -x ${install_main_dir}/bin/TDinsight.sh ] && ${csudo}ln -s ${install_main_dir}/bin/TDinsight.sh ${bin_link_dir}/TDinsight.sh || : [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript} || : [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : - - if [ "$verMode" == "cluster" ]; then - ${csudo}cp -r ${script_dir}/nginxd/* ${nginx_dir} && ${csudo}chmod 0555 ${nginx_dir}/* - ${csudo}mkdir -p ${nginx_dir}/logs - ${csudo}chmod 777 ${nginx_dir}/sbin/nginx - fi } function install_lib() { @@ -574,6 +567,13 @@ function install_examples() { fi } +function install_web() { + if [ -d "${script_dir}/share" ]; then + ${csudo}cp -rf ${script_dir}/share/* ${install_main_dir}/share + fi +} + + function clean_service_on_sysvinit() { if pidof ${serverName} &>/dev/null; then ${csudo}service ${serverName} stop || : @@ -654,16 +654,6 @@ function clean_service_on_systemd() { fi ${csudo}systemctl disable tarbitratord &>/dev/null || echo &>/dev/null ${csudo}rm -f ${tarbitratord_service_config} - - if [ "$verMode" == "cluster" ]; then - nginx_service_config="${service_config_dir}/nginxd.service" - if systemctl is-active --quiet nginxd; then - echo "Nginx for ${productName} is running, stopping it..." - ${csudo}systemctl stop nginxd &>/dev/null || echo &>/dev/null - fi - ${csudo}systemctl disable nginxd &>/dev/null || echo &>/dev/null - ${csudo}rm -f ${nginx_service_config} - fi } function install_service_on_systemd() { @@ -677,19 +667,6 @@ function install_service_on_systemd() { ${csudo}systemctl enable ${serverName} ${csudo}systemctl daemon-reload - - if [ "$verMode" == "cluster" ]; then - [ -f ${script_dir}/cfg/nginxd.service ] && - ${csudo}cp ${script_dir}/cfg/nginxd.service \ - ${service_config_dir}/ || : - ${csudo}systemctl daemon-reload - - if ! ${csudo}systemctl enable nginxd &>/dev/null; then - ${csudo}systemctl daemon-reexec - ${csudo}systemctl enable nginxd - fi - ${csudo}systemctl start nginxd - fi } function install_adapter_service() { @@ -793,19 +770,6 @@ function updateProduct() { sleep 1 fi - if [ "$verMode" == "cluster" ]; then - if pidof nginx &>/dev/null; then - if ((${service_mod} == 0)); then - ${csudo}systemctl stop nginxd || : - elif ((${service_mod} == 1)); then - ${csudo}service nginxd stop || : - else - kill_process nginx - fi - sleep 1 - fi - fi - install_main_path install_log @@ -817,6 +781,7 @@ function updateProduct() { fi install_examples + install_web if [ -z $1 ]; then install_bin install_service @@ -825,18 +790,6 @@ function updateProduct() { install_adapter_config openresty_work=false - if [ "$verMode" == "cluster" ]; then - # Check if openresty is installed - # Check if nginx is installed successfully - if type curl &>/dev/null; then - if curl -sSf http://127.0.0.1:${nginx_port} &>/dev/null; then - echo -e "\033[44;32;1mNginx for ${productName} is updated successfully!${NC}" - openresty_work=true - else - echo -e "\033[44;31;5mNginx for ${productName} does not work! Please try again!\033[0m" - fi - fi - fi echo echo -e "${GREEN_DARK}To configure ${productName} ${NC}: edit ${cfg_install_dir}/${configFile}" @@ -857,7 +810,7 @@ function updateProduct() { fi if [ ${openresty_work} = 'true' ]; then - echo -e "${GREEN_DARK}To access ${productName} ${NC}: use ${GREEN_UNDERLINE}${clientName} -h $serverFqdn${NC} in shell OR from ${GREEN_UNDERLINE}http://127.0.0.1:${nginx_port}${NC}" + echo -e "${GREEN_DARK}To access ${productName} ${NC}: use ${GREEN_UNDERLINE}${clientName} -h $serverFqdn${NC} in shell OR from ${GREEN_UNDERLINE}http://127.0.0.1:${web_port}${NC}" else echo -e "${GREEN_DARK}To access ${productName} ${NC}: use ${GREEN_UNDERLINE}${clientName} -h $serverFqdn${NC} in shell${NC}" fi @@ -906,6 +859,7 @@ function installProduct() { install_connector fi install_examples + install_web if [ -z $1 ]; then # install service and client # For installing new @@ -915,17 +869,6 @@ function installProduct() { install_adapter_config openresty_work=false - if [ "$verMode" == "cluster" ]; then - # Check if nginx is installed successfully - if type curl &>/dev/null; then - if curl -sSf http://127.0.0.1:${nginx_port} &>/dev/null; then - echo -e "\033[44;32;1mNginx for ${productName} is installed successfully!${NC}" - openresty_work=true - else - echo -e "\033[44;31;5mNginx for ${productName} does not work! Please try again!\033[0m" - fi - fi - fi install_config diff --git a/packaging/tools/make_install.sh b/packaging/tools/make_install.sh index d1e7a222cc..58b4385001 100755 --- a/packaging/tools/make_install.sh +++ b/packaging/tools/make_install.sh @@ -151,6 +151,7 @@ function install_main_path() { ${csudo}mkdir -p ${install_main_dir}/driver ${csudo}mkdir -p ${install_main_dir}/examples ${csudo}mkdir -p ${install_main_dir}/include + ${csudo}mkdir -p ${install_main_dir}/share # ${csudo}mkdir -p ${install_main_dir}/init.d else ${csudo}rm -rf ${install_main_dir} || ${csudo}rm -rf ${install_main_2_dir} || : @@ -161,6 +162,7 @@ function install_main_path() { ${csudo}mkdir -p ${install_main_dir}/driver || ${csudo}mkdir -p ${install_main_2_dir}/driver ${csudo}mkdir -p ${install_main_dir}/examples || ${csudo}mkdir -p ${install_main_2_dir}/examples ${csudo}mkdir -p ${install_main_dir}/include || ${csudo}mkdir -p ${install_main_2_dir}/include + ${csudo}mkdir -p ${install_main_dir}/share || ${csudo}mkdir -p ${install_main_2_dir}/share fi } @@ -469,6 +471,16 @@ function install_examples() { fi } +function install_web() { + if [ -d "${binary_dir}/build/share" ]; then + if [ "$osType" != "Darwin" ]; then + ${csudo}cp -rf ${binary_dir}/build/share/* ${install_main_dir}/share || : + else + ${csudo}cp -rf ${binary_dir}/build/share/* ${install_main_dir}/share || ${csudo}cp -rf ${binary_dir}/build/share/* ${install_main_2_dir}/share || : + fi + fi +} + function clean_service_on_sysvinit() { if pidof ${serverName} &>/dev/null; then ${csudo}service ${serverName} stop || : @@ -596,6 +608,7 @@ function update_TDengine() { install_lib # install_connector install_examples + install_web install_bin install_service diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh index 2305b96b36..fb0ef4f9a3 100755 --- a/packaging/tools/makepkg.sh +++ b/packaging/tools/makepkg.sh @@ -107,7 +107,7 @@ else fi install_files="${script_dir}/install.sh" -nginx_dir="${top_dir}/../enterprise/src/plugins/web" +web_dir="${top_dir}/../enterprise/src/plugins/web" init_file_deb=${script_dir}/../deb/taosd init_file_rpm=${script_dir}/../rpm/taosd @@ -132,10 +132,6 @@ if [ -f "${cfg_dir}/${serverName}.service" ]; then cp ${cfg_dir}/${serverName}.service ${install_dir}/cfg || : fi -if [ -f "${top_dir}/packaging/cfg/nginxd.service" ]; then - cp ${top_dir}/packaging/cfg/nginxd.service ${install_dir}/cfg || : -fi - mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x ${install_dir}/bin/* || : mkdir -p ${install_dir}/init.d && cp ${init_file_deb} ${install_dir}/init.d/${serverName}.deb mkdir -p ${install_dir}/init.d && cp ${init_file_rpm} ${install_dir}/init.d/${serverName}.rpm @@ -222,16 +218,6 @@ if [ "$verMode" == "cluster" ]; then sed 's/verMode=edge/verMode=cluster/g' ${install_dir}/bin/remove.sh >>remove_temp.sh mv remove_temp.sh ${install_dir}/bin/remove.sh - mkdir -p ${install_dir}/nginxd && cp -r ${nginx_dir}/* ${install_dir}/nginxd - cp ${nginx_dir}/png/taos.png ${install_dir}/nginxd/admin/images/taos.png - rm -rf ${install_dir}/nginxd/png - - if [ "$cpuType" == "aarch64" ]; then - cp -f ${install_dir}/nginxd/sbin/arm/64bit/nginx ${install_dir}/nginxd/sbin/ - elif [ "$cpuType" == "aarch32" ]; then - cp -f ${install_dir}/nginxd/sbin/arm/32bit/nginx ${install_dir}/nginxd/sbin/ - fi - rm -rf ${install_dir}/nginxd/sbin/arm fi cd ${install_dir} @@ -288,6 +274,13 @@ if [[ $dbName == "taos" ]]; then cp -r ${examples_dir}/C# ${install_dir}/examples mkdir -p ${install_dir}/examples/taosbenchmark-json && cp ${examples_dir}/../tools/taos-tools/example/* ${install_dir}/examples/taosbenchmark-json fi + + # Add web files + if [ -d "${web_dir}/admin" ]; then + mkdir -p ${install_dir}/share/ + cp ${web_dir}/admin ${install_dir}/share/ -r + cp ${web_dir}/png/taos.png ${install_dir}/share/admin/images/taos.png + fi fi # Copy driver diff --git a/packaging/tools/remove.sh b/packaging/tools/remove.sh index bf4ff564f5..a648750904 100755 --- a/packaging/tools/remove.sh +++ b/packaging/tools/remove.sh @@ -27,13 +27,11 @@ local_bin_link_dir="/usr/local/bin" lib_link_dir="/usr/lib" lib64_link_dir="/usr/lib64" inc_link_dir="/usr/include" -install_nginxd_dir="/usr/local/nginxd" service_config_dir="/etc/systemd/system" taos_service_name=${serverName} taosadapter_service_name="taosadapter" tarbitrator_service_name="tarbitratord" -nginx_service_name="nginxd" csudo="" if command -v sudo >/dev/null; then csudo="sudo " @@ -153,18 +151,6 @@ function clean_service_on_systemd() { fi ${csudo}systemctl disable ${tarbitrator_service_name} &>/dev/null || echo &>/dev/null ${csudo}rm -f ${tarbitratord_service_config} - - if [ "$verMode" == "cluster" ]; then - nginx_service_config="${service_config_dir}/${nginx_service_name}.service" - if [ -d ${install_nginxd_dir} ]; then - if systemctl is-active --quiet ${nginx_service_name}; then - echo "Nginx for ${productName} is running, stopping it..." - ${csudo}systemctl stop ${nginx_service_name} &>/dev/null || echo &>/dev/null - fi - ${csudo}systemctl disable ${nginx_service_name} &>/dev/null || echo &>/dev/null - ${csudo}rm -f ${nginx_service_config} - fi - fi } function clean_service_on_sysvinit() { @@ -239,7 +225,6 @@ clean_config ${csudo}rm -rf ${data_link_dir} || : ${csudo}rm -rf ${install_main_dir} -${csudo}rm -rf ${install_nginxd_dir} if [[ -e /etc/os-release ]]; then osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release) else diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index 6a4ef3d821..5792f498ef 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -19,6 +19,7 @@ #include "functionMgt.h" #include "os.h" #include "query.h" +#include "qworker.h" #include "scheduler.h" #include "tcache.h" #include "tglobal.h" @@ -27,7 +28,6 @@ #include "trpc.h" #include "tsched.h" #include "ttime.h" -#include "qworker.h" #define TSC_VAR_NOT_RELEASE 1 #define TSC_VAR_RELEASED 0 @@ -70,11 +70,10 @@ static void deregisterRequest(SRequestObj *pRequest) { int32_t currentInst = atomic_sub_fetch_64((int64_t *)&pActivity->currentRequests, 1); int32_t num = atomic_sub_fetch_32(&pTscObj->numOfReqs, 1); - int64_t nowUs = taosGetTimestampUs(); - int64_t duration = nowUs - pRequest->metric.start; - tscDebug("0x%" PRIx64 " free Request from connObj: 0x%" PRIx64 ", reqId:0x%" PRIx64 " elapsed:%" PRIu64 - " ms, current:%d, app current:%d", - pRequest->self, pTscObj->id, pRequest->requestId, duration / 1000, num, currentInst); + int64_t duration = taosGetTimestampUs() - pRequest->metric.start; + tscDebug("0x%" PRIx64 " free Request from connObj: 0x%" PRIx64 ", reqId:0x%" PRIx64 " elapsed:%.2f ms, " + "current:%d, app current:%d", + pRequest->self, pTscObj->id, pRequest->requestId, duration / 1000.0, num, currentInst); if (QUERY_NODE_VNODE_MODIF_STMT == pRequest->stmtType) { tscPerf("insert duration %" PRId64 "us: syntax:%" PRId64 "us, ctg:%" PRId64 "us, semantic:%" PRId64 @@ -85,11 +84,12 @@ static void deregisterRequest(SRequestObj *pRequest) { atomic_add_fetch_64((int64_t *)&pActivity->insertElapsedTime, duration); } else if (QUERY_NODE_SELECT_STMT == pRequest->stmtType) { tscPerf("select duration %" PRId64 "us: syntax:%" PRId64 "us, ctg:%" PRId64 "us, semantic:%" PRId64 - "us, planner:%" PRId64 "us, exec:%" PRId64 "us", + "us, planner:%" PRId64 "us, exec:%" PRId64 "us, reqId:0x%"PRIx64, duration, pRequest->metric.syntaxEnd - pRequest->metric.syntaxStart, pRequest->metric.ctgEnd - pRequest->metric.ctgStart, pRequest->metric.semanticEnd - pRequest->metric.ctgEnd, pRequest->metric.planEnd - pRequest->metric.semanticEnd, - pRequest->metric.resultReady - pRequest->metric.planEnd); + pRequest->metric.resultReady - pRequest->metric.planEnd, pRequest->requestId); + atomic_add_fetch_64((int64_t *)&pActivity->queryElapsedTime, duration); } diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index be907ea1e2..8ffc88ec28 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -483,8 +483,8 @@ void setResPrecision(SReqResultInfo* pResInfo, int32_t precision) { int32_t buildVnodePolicyNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray* pMnodeList, SArray* pDbVgList) { SArray* nodeList = taosArrayInit(4, sizeof(SQueryNodeLoad)); - char *policy = (tsQueryPolicy == QUERY_POLICY_VNODE) ? "vnode" : "client"; - + char* policy = (tsQueryPolicy == QUERY_POLICY_VNODE) ? "vnode" : "client"; + int32_t dbNum = taosArrayGetSize(pDbVgList); for (int32_t i = 0; i < dbNum; ++i) { SArray* pVg = taosArrayGetP(pDbVgList, i); @@ -815,7 +815,7 @@ int32_t handleCreateTbExecRes(void* res, SCatalog* pCatalog) { int32_t handleQueryExecRsp(SRequestObj* pRequest) { if (NULL == pRequest->body.resInfo.execRes.res) { - return TSDB_CODE_SUCCESS; + return pRequest->code; } SCatalog* pCatalog = NULL; @@ -868,44 +868,43 @@ int32_t handleQueryExecRsp(SRequestObj* pRequest) { return code; } +//todo refacto the error code mgmt void schedulerExecCb(SExecResult* pResult, void* param, int32_t code) { SRequestObj* pRequest = (SRequestObj*)param; + STscObj* pTscObj = pRequest->pTscObj; + pRequest->code = code; - - pRequest->metric.resultReady = taosGetTimestampUs(); - if (pResult) { destroyQueryExecRes(&pRequest->body.resInfo.execRes); memcpy(&pRequest->body.resInfo.execRes, pResult, sizeof(*pResult)); } - if (TDMT_VND_SUBMIT == pRequest->type || TDMT_VND_DELETE == pRequest->type || - TDMT_VND_CREATE_TABLE == pRequest->type) { + int32_t type = pRequest->type; + if (TDMT_VND_SUBMIT == type || TDMT_VND_DELETE == type || TDMT_VND_CREATE_TABLE == type) { if (pResult) { pRequest->body.resInfo.numOfRows = pResult->numOfRows; - if (TDMT_VND_SUBMIT == pRequest->type) { - STscObj* pTscObj = pRequest->pTscObj; + + // record the insert rows + if (TDMT_VND_SUBMIT == type) { SAppClusterSummary* pActivity = &pTscObj->pAppInfo->summary; atomic_add_fetch_64((int64_t*)&pActivity->numOfInsertRows, pResult->numOfRows); } } schedulerFreeJob(&pRequest->body.queryJob, 0); - - pRequest->metric.execEnd = taosGetTimestampUs(); } taosMemoryFree(pResult); + tscDebug("0x%" PRIx64 " enter scheduler exec cb, code:%s, reqId:0x%" PRIx64, pRequest->self, tstrerror(code), + pRequest->requestId); - tscDebug("0x%" PRIx64 " enter scheduler exec cb, code:%d - %s, reqId:0x%" PRIx64, pRequest->self, code, - tstrerror(code), pRequest->requestId); - - STscObj* pTscObj = pRequest->pTscObj; if (code != TSDB_CODE_SUCCESS && NEED_CLIENT_HANDLE_ERROR(code) && pRequest->sqlstr != NULL) { - tscDebug("0x%" PRIx64 " client retry to handle the error, code:%d - %s, tryCount:%d, reqId:0x%" PRIx64, - pRequest->self, code, tstrerror(code), pRequest->retry, pRequest->requestId); + tscDebug("0x%" PRIx64 " client retry to handle the error, code:%s, tryCount:%d, reqId:0x%" PRIx64, + pRequest->self, tstrerror(code), pRequest->retry, pRequest->requestId); pRequest->prevCode = code; schedulerFreeJob(&pRequest->body.queryJob, 0); + qDestroyQuery(pRequest->pQuery); + pRequest->pQuery = NULL; doAsyncQuery(pRequest, true); return; } @@ -915,7 +914,11 @@ void schedulerExecCb(SExecResult* pResult, void* param, int32_t code) { removeMeta(pTscObj, pRequest->targetTableList); } - handleQueryExecRsp(pRequest); + pRequest->metric.execEnd = taosGetTimestampUs(); + int32_t code1 = handleQueryExecRsp(pRequest); + if (pRequest->code == TSDB_CODE_SUCCESS && pRequest->code != code1) { + pRequest->code = code1; + } // return to client pRequest->body.queryFp(pRequest->body.param, pRequest, code); @@ -1056,7 +1059,6 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultM } pRequest->metric.planEnd = taosGetTimestampUs(); - if (TSDB_CODE_SUCCESS == code && !pRequest->validateOnly) { SArray* pNodeList = NULL; buildAsyncExecNodeList(pRequest, &pNodeList, pMnodeList, pResultMeta); diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 650b16f855..5b255a28ea 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -20,13 +20,13 @@ #include "functionMgt.h" #include "os.h" #include "query.h" +#include "qworker.h" #include "scheduler.h" #include "tglobal.h" #include "tmsg.h" #include "tref.h" #include "trpc.h" #include "version.h" -#include "qworker.h" #define TSC_VAR_NOT_RELEASE 1 #define TSC_VAR_RELEASED 0 @@ -700,6 +700,7 @@ void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) { SQuery *pQuery = pRequest->pQuery; pRequest->metric.ctgEnd = taosGetTimestampUs(); + qDebug("0x%" PRIx64 " start to semantic analysis, reqId:0x%" PRIx64, pRequest->self, pRequest->requestId); if (code == TSDB_CODE_SUCCESS) { code = qAnalyseSqlSemantic(pWrapper->pCtx, &pWrapper->catalogReq, pResultMeta, pQuery); @@ -723,13 +724,16 @@ void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) { destorySqlParseWrapper(pWrapper); - tscDebug("0x%" PRIx64 " analysis semantics completed, start async query, reqId:0x%" PRIx64, pRequest->self, - pRequest->requestId); + double el = (pRequest->metric.semanticEnd - pRequest->metric.ctgEnd)/1000.0; + tscDebug("0x%" PRIx64 " analysis semantics completed, start async query, elapsed time:%.2f ms, reqId:0x%" PRIx64, + pRequest->self, el, pRequest->requestId); + launchAsyncQuery(pRequest, pQuery, pResultMeta); } else { destorySqlParseWrapper(pWrapper); qDestroyQuery(pRequest->pQuery); pRequest->pQuery = NULL; + if (NEED_CLIENT_HANDLE_ERROR(code)) { tscDebug("0x%" PRIx64 " client retry to handle the error, code:%d - %s, tryCount:%d, reqId:0x%" PRIx64, pRequest->self, code, tstrerror(code), pRequest->retry, pRequest->requestId); @@ -813,7 +817,6 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) { pRequest->metric.syntaxEnd = taosGetTimestampUs(); if (!updateMetaForce) { - STscObj *pTscObj = pRequest->pTscObj; SAppClusterSummary *pActivity = &pTscObj->pAppInfo->summary; if (NULL == pRequest->pQuery->pRoot) { atomic_add_fetch_64((int64_t *)&pActivity->numOfInsertsReq, 1); @@ -860,6 +863,7 @@ static void fetchCallback(void *pResult, void *param, int32_t code) { SRequestObj *pRequest = (SRequestObj *)param; SReqResultInfo *pResultInfo = &pRequest->body.resInfo; + pRequest->metric.resultReady = taosGetTimestampUs(); tscDebug("0x%" PRIx64 " enter scheduler fetch cb, code:%d - %s, reqId:0x%" PRIx64, pRequest->self, code, tstrerror(code), pRequest->requestId); diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index f2493f6c57..195466061d 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -79,7 +79,7 @@ #define NCHAR_ADD_LEN 3 // L"nchar" 3 means L" " #define MAX_RETRY_TIMES 5 -#define LINE_BATCH 20000 +#define LINE_BATCH 2000 //================================================================================================= typedef TSDB_SML_PROTOCOL_TYPE SMLProtocolType; @@ -151,13 +151,14 @@ typedef struct { typedef struct { SRequestObj *request; tsem_t sem; + int32_t cnt; + int32_t total; TdThreadSpinlock lock; } Params; typedef struct { int64_t id; Params *params; - bool isLast; SMLProtocolType protocol; int8_t precision; @@ -1531,6 +1532,7 @@ static SSmlHandle* smlBuildSmlInfo(STscObj* pTscObj, SRequestObj* request, SMLPr info->pRequest = request; info->msgBuf.buf = info->pRequest->msgBuf; info->msgBuf.len = ERROR_MSG_BUF_DEFAULT_SIZE; + info->pRequest->stmtType = info->pQuery->pRoot->type; } info->exec = smlInitHandle(info->pQuery); @@ -2331,6 +2333,9 @@ static int32_t smlInsertData(SSmlHandle *info) { // info->affectedRows = taos_affected_rows(info->pRequest); // return info->pRequest->code; + SAppClusterSummary *pActivity = &info->taos->pAppInfo->summary; + atomic_add_fetch_64((int64_t *)&pActivity->numOfInsertsReq, 1); + launchAsyncQuery(info->pRequest, info->pQuery, NULL); return TSDB_CODE_SUCCESS; } @@ -2449,28 +2454,26 @@ static void smlInsertCallback(void *param, void *res, int32_t code) { int32_t rows = taos_affected_rows(pRequest); uDebug("SML:0x%" PRIx64 " result. code:%d, msg:%s", info->id, pRequest->code, pRequest->msgBuf); - // lock - taosThreadSpinLock(&info->params->lock); - if (code != TSDB_CODE_SUCCESS) { - info->params->request->code = code; - info->params->request->body.resInfo.numOfRows += rows; - }else{ - info->params->request->body.resInfo.numOfRows += info->affectedRows; - } - taosThreadSpinUnlock(&info->params->lock); - // unlock - - uDebug("SML:0x%" PRIx64 " insert finished, code: %d, rows: %d, total: %d", info->id, code, rows, info->affectedRows); Params *pParam = info->params; - bool isLast = info->isLast; + // lock + taosThreadSpinLock(&pParam->lock); + pParam->cnt++; + if (code != TSDB_CODE_SUCCESS) { + pParam->request->code = code; + pParam->request->body.resInfo.numOfRows += rows; + }else{ + pParam->request->body.resInfo.numOfRows += info->affectedRows; + } + if (pParam->cnt == pParam->total) { + tsem_post(&pParam->sem); + } + taosThreadSpinUnlock(&pParam->lock); + // unlock + uDebug("SML:0x%" PRIx64 " insert finished, code: %d, rows: %d, total: %d", info->id, code, rows, info->affectedRows); info->cost.endTime = taosGetTimestampUs(); info->cost.code = code; smlPrintStatisticInfo(info); smlDestroyInfo(info); - - if (isLast) { - tsem_post(&pParam->sem); - } } /** @@ -2512,7 +2515,7 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr pTscObj->schemalessType = 1; SSmlMsgBuf msg = {ERROR_MSG_BUF_DEFAULT_SIZE, request->msgBuf}; - Params params; + Params params = {0}; params.request = request; tsem_init(¶ms.sem, 0, 0); taosThreadSpinInit(&(params.lock), 0); @@ -2557,6 +2560,7 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr } batchs = ceil(((double)numLines) / LINE_BATCH); + params.total = batchs; for (int i = 0; i < batchs; ++i) { SRequestObj* req = (SRequestObj*)createRequest(pTscObj->id, TSDB_SQL_INSERT); if(!req){ @@ -2575,11 +2579,9 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr if (numLines > perBatch) { numLines -= perBatch; - info->isLast = false; } else { perBatch = numLines; numLines = 0; - info->isLast = true; } info->params = ¶ms; diff --git a/source/client/src/clientTmq.c b/source/client/src/clientTmq.c index c9c02a77e1..66f992f05f 100644 --- a/source/client/src/clientTmq.c +++ b/source/client/src/clientTmq.c @@ -515,7 +515,7 @@ int32_t tmqCommitMsgImpl(tmq_t* tmq, const TAOS_RES* msg, int8_t async, tmq_comm SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)msg; topic = pMetaRspObj->topic; vgId = pMetaRspObj->vgId; - } else if(TD_RES_TMQ_METADATA(msg)) { + } else if (TD_RES_TMQ_METADATA(msg)) { SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)msg; topic = pRspObj->topic; vgId = pRspObj->vgId; @@ -715,7 +715,7 @@ void tmqSendHbReq(void* param, void* tmrId) { int32_t epoch = tmq->epoch; SMqHbReq* pReq = taosMemoryMalloc(sizeof(SMqHbReq)); if (pReq == NULL) goto OVER; - pReq->consumerId = consumerId; + pReq->consumerId = htobe64(consumerId); pReq->epoch = epoch; SMsgSendInfo* sendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); @@ -1603,6 +1603,7 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) { return NULL; } else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_RSP) { SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)rspWrapper; + tscDebug("consumer %ld actual process poll rsp", tmq->consumerId); /*atomic_sub_fetch_32(&tmq->readyRequest, 1);*/ int32_t consumerEpoch = atomic_load_32(&tmq->epoch); if (pollRspWrapper->dataRsp.head.epoch == consumerEpoch) { @@ -1661,9 +1662,9 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) { // build rsp void* pRsp = NULL; - if(pollRspWrapper->taosxRsp.createTableNum == 0){ + if (pollRspWrapper->taosxRsp.createTableNum == 0) { pRsp = tmqBuildRspFromWrapper(pollRspWrapper); - }else{ + } else { pRsp = tmqBuildTaosxRspFromWrapper(pollRspWrapper); } taosFreeQitem(pollRspWrapper); @@ -1718,7 +1719,10 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) { while (1) { tmqHandleAllDelayedTask(tmq); - if (tmqPollImpl(tmq, timeout) < 0) return NULL; + if (tmqPollImpl(tmq, timeout) < 0) { + tscDebug("return since poll err"); + /*return NULL;*/ + } rspObj = tmqHandleAllRsp(tmq, timeout, false); if (rspObj) { @@ -1850,12 +1854,12 @@ const char* tmq_get_table_name(TAOS_RES* res) { return (const char*)taosArrayGetP(pRspObj->rsp.blockTbName, pRspObj->resIter); } else if (TD_RES_TMQ_METADATA(res)) { SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)res; - if (!pRspObj->rsp.withTbName || pRspObj->rsp.blockTbName == NULL || pRspObj->resIter < 0 || - pRspObj->resIter >= pRspObj->rsp.blockNum) { - return NULL; - } - return (const char*)taosArrayGetP(pRspObj->rsp.blockTbName, pRspObj->resIter); + if (!pRspObj->rsp.withTbName || pRspObj->rsp.blockTbName == NULL || pRspObj->resIter < 0 || + pRspObj->resIter >= pRspObj->rsp.blockNum) { + return NULL; } + return (const char*)taosArrayGetP(pRspObj->rsp.blockTbName, pRspObj->resIter); + } return NULL; } diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index e2e59108aa..c0203dadb8 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -85,8 +85,7 @@ uint16_t tsTelemPort = 80; char tsSmlTagName[TSDB_COL_NAME_LEN] = "_tag_null"; char tsSmlChildTableName[TSDB_TABLE_NAME_LEN] = ""; // user defined child table name can be specified in tag value. // If set to empty system will generate table name using MD5 hash. -bool tsSmlDataFormat = - true; // true means that the name and order of cols in each line are the same(only for influx protocol) +bool tsSmlDataFormat = false; // true means that the name and order of cols in each line are the same(only for influx protocol) // query int32_t tsQueryPolicy = 1; @@ -95,6 +94,7 @@ int32_t tsQueryRsmaTolerance = 1000; // the tolerance time (ms) to judge from w bool tsQueryPlannerTrace = false; int32_t tsQueryNodeChunkSize = 32 * 1024; bool tsQueryUseNodeAllocator = true; +bool tsKeepColumnName = false; /* * denote if the server needs to compress response message at the application layer to client, including query rsp, @@ -205,7 +205,9 @@ static int32_t taosLoadCfg(SConfig *pCfg, const char **envCmd, const char *input tstrncpy(cfgFile, cfgDir, sizeof(cfgDir)); } - if (apolloUrl == NULL || apolloUrl[0] == '\0') cfgGetApollUrl(envCmd, envFile, apolloUrl); + if (apolloUrl != NULL && apolloUrl[0] == '\0') { + cfgGetApollUrl(envCmd, envFile, apolloUrl); + } if (cfgLoad(pCfg, CFG_STYPE_APOLLO_URL, apolloUrl) != 0) { uError("failed to load from apollo url:%s since %s", apolloUrl, terrstr()); @@ -290,6 +292,7 @@ static int32_t taosAddClientCfg(SConfig *pCfg) { if (cfgAddBool(pCfg, "queryPlannerTrace", tsQueryPlannerTrace, true) != 0) return -1; if (cfgAddInt32(pCfg, "queryNodeChunkSize", tsQueryNodeChunkSize, 1024, 128 * 1024, true) != 0) return -1; if (cfgAddBool(pCfg, "queryUseNodeAllocator", tsQueryUseNodeAllocator, true) != 0) return -1; + if (cfgAddBool(pCfg, "keepColumnName", tsKeepColumnName, true) != 0) return -1; if (cfgAddString(pCfg, "smlChildTableName", "", 1) != 0) return -1; if (cfgAddString(pCfg, "smlTagName", tsSmlTagName, 1) != 0) return -1; if (cfgAddBool(pCfg, "smlDataFormat", tsSmlDataFormat, 1) != 0) return -1; @@ -652,6 +655,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) { tsQueryPlannerTrace = cfgGetItem(pCfg, "queryPlannerTrace")->bval; tsQueryNodeChunkSize = cfgGetItem(pCfg, "queryNodeChunkSize")->i32; tsQueryUseNodeAllocator = cfgGetItem(pCfg, "queryUseNodeAllocator")->bval; + tsKeepColumnName = cfgGetItem(pCfg, "keepColumnName")->bval; return 0; } @@ -685,7 +689,9 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsQueryBufferSize = cfgGetItem(pCfg, "queryBufferSize")->i32; tsPrintAuth = cfgGetItem(pCfg, "printAuth")->bval; +#if !defined(WINDOWS) && !defined(DARWIN) tsMultiProcess = cfgGetItem(pCfg, "multiProcess")->bval; +#endif tsMnodeShmSize = cfgGetItem(pCfg, "mnodeShmSize")->i32; tsVnodeShmSize = cfgGetItem(pCfg, "vnodeShmSize")->i32; tsQnodeShmSize = cfgGetItem(pCfg, "qnodeShmSize")->i32; @@ -843,6 +849,9 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { break; } case 'k': { + if (strcasecmp("keepColumnName", name) == 0) { + tsKeepColumnName = cfgGetItem(pCfg, "keepColumnName")->bval; + } break; } case 'l': { @@ -919,7 +928,9 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { } case 'u': { if (strcasecmp("multiProcess", name) == 0) { +#if !defined(WINDOWS) && !defined(DARWIN) tsMultiProcess = cfgGetItem(pCfg, "multiProcess")->bval; +#endif } else if (strcasecmp("udfDebugFlag", name) == 0) { udfDebugFlag = cfgGetItem(pCfg, "udfDebugFlag")->i32; } @@ -1122,11 +1133,20 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi if (tsc) { tsLogEmbedded = 0; - if (taosAddClientLogCfg(pCfg) != 0) return -1; + if (taosAddClientLogCfg(pCfg) != 0) { + cfgCleanup(pCfg); + return -1; + } } else { tsLogEmbedded = 1; - if (taosAddClientLogCfg(pCfg) != 0) return -1; - if (taosAddServerLogCfg(pCfg) != 0) return -1; + if (taosAddClientLogCfg(pCfg) != 0) { + cfgCleanup(pCfg); + return -1; + } + if (taosAddServerLogCfg(pCfg) != 0) { + cfgCleanup(pCfg); + return -1; + } } if (taosLoadCfg(pCfg, envCmd, cfgDir, envFile, apolloUrl) != 0) { diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index e4f3a89272..f4ffc4c996 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -2682,6 +2682,7 @@ int32_t tSerializeSTrimDbReq(void *buf, int32_t bufLen, STrimDbReq *pReq) { if (tStartEncode(&encoder) < 0) return -1; if (tEncodeCStr(&encoder, pReq->db) < 0) return -1; + if (tEncodeI32(&encoder, pReq->maxSpeed) < 0) return -1; tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -2695,6 +2696,7 @@ int32_t tDeserializeSTrimDbReq(void *buf, int32_t bufLen, STrimDbReq *pReq) { if (tStartDecode(&decoder) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->maxSpeed) < 0) return -1; tEndDecode(&decoder); tDecoderClear(&decoder); @@ -3347,12 +3349,12 @@ int32_t tDeserializeSSTbHbRsp(void *buf, int32_t bufLen, SSTbHbRsp *pRsp) { return 0; } -void tFreeSTableMetaRsp(void *pRsp) { +void tFreeSTableMetaRsp(void *pRsp) { if (NULL == pRsp) { return; } - - taosMemoryFreeClear(((STableMetaRsp *)pRsp)->pSchemas); + + taosMemoryFreeClear(((STableMetaRsp *)pRsp)->pSchemas); } void tFreeSTableIndexRsp(void *info) { @@ -4373,8 +4375,7 @@ int32_t tDeserializeSExplainRsp(void *buf, int32_t bufLen, SExplainRsp *pRsp) { if (tDecodeDouble(&decoder, &pRsp->subplanInfo[i].totalCost) < 0) return -1; if (tDecodeU64(&decoder, &pRsp->subplanInfo[i].numOfRows) < 0) return -1; if (tDecodeU32(&decoder, &pRsp->subplanInfo[i].verboseLen) < 0) return -1; - if (tDecodeBinaryAlloc(&decoder, &pRsp->subplanInfo[i].verboseInfo, NULL) < 0) - return -1; + if (tDecodeBinaryAlloc(&decoder, &pRsp->subplanInfo[i].verboseInfo, NULL) < 0) return -1; } tEndDecode(&decoder); @@ -4826,6 +4827,14 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS if (tEncodeI8(&encoder, pReq->igExpired) < 0) return -1; if (sqlLen > 0 && tEncodeCStr(&encoder, pReq->sql) < 0) return -1; if (astLen > 0 && tEncodeCStr(&encoder, pReq->ast) < 0) return -1; + if (tEncodeI32(&encoder, pReq->numOfTags) < 0) return -1; + for (int32_t i = 0; i < pReq->numOfTags; ++i) { + SField *pField = taosArrayGet(pReq->pTags, i); + if (tEncodeI8(&encoder, pField->type) < 0) return -1; + if (tEncodeI8(&encoder, pField->flags) < 0) return -1; + if (tEncodeI32(&encoder, pField->bytes) < 0) return -1; + if (tEncodeCStr(&encoder, pField->name) < 0) return -1; + } tEndEncode(&encoder); @@ -4864,6 +4873,28 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea if (pReq->ast == NULL) return -1; if (tDecodeCStrTo(&decoder, pReq->ast) < 0) return -1; } + + if (tDecodeI32(&decoder, &pReq->numOfTags) < 0) return -1; + if (pReq->numOfTags > 0) { + pReq->pTags = taosArrayInit(pReq->numOfTags, sizeof(SField)); + if (pReq->pTags == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + for (int32_t i = 0; i < pReq->numOfTags; ++i) { + SField field = {0}; + if (tDecodeI8(&decoder, &field.type) < 0) return -1; + if (tDecodeI8(&decoder, &field.flags) < 0) return -1; + if (tDecodeI32(&decoder, &field.bytes) < 0) return -1; + if (tDecodeCStrTo(&decoder, field.name) < 0) return -1; + if (taosArrayPush(pReq->pTags, &field) == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + } + } + tEndDecode(&decoder); tDecoderClear(&decoder); diff --git a/source/dnode/mgmt/exe/dmMain.c b/source/dnode/mgmt/exe/dmMain.c index 4030eaa6fe..6406ae560f 100644 --- a/source/dnode/mgmt/exe/dmMain.c +++ b/source/dnode/mgmt/exe/dmMain.c @@ -16,10 +16,12 @@ #define _DEFAULT_SOURCE #include "dmMgmt.h" #include "tconfig.h" +#include "mnode.h" #define DM_APOLLO_URL "The apollo string to use when configuring the server, such as: -a 'jsonFile:./tests/cfg.json', cfg.json text can be '{\"fqdn\":\"td1\"}'." #define DM_CFG_DIR "Configuration directory." #define DM_DMP_CFG "Dump configuration." +#define DM_SDB_INFO "Dump sdb info." #define DM_ENV_CMD "The env cmd variable string to use when configuring the server, such as: -e 'TAOS_FQDN=td1'." #define DM_ENV_FILE "The env variable file path to use when configuring the server, default is './.env', .env text can be 'TAOS_FQDN=td1'." #define DM_NODE_TYPE "Startup type of the node, default is 0." @@ -31,6 +33,7 @@ static struct { bool winServiceMode; #endif bool dumpConfig; + bool dumpSdb; bool generateGrant; bool printAuth; bool printVersion; @@ -82,6 +85,8 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) { } } else if (strcmp(argv[i], "-a") == 0) { tstrncpy(global.apolloUrl, argv[++i], PATH_MAX); + } else if (strcmp(argv[i], "-s") == 0) { + global.dumpSdb = true; } else if (strcmp(argv[i], "-E") == 0) { tstrncpy(global.envFile, argv[++i], PATH_MAX); } else if (strcmp(argv[i], "-n") == 0) { @@ -131,6 +136,7 @@ static void dmPrintHelp() { printf("Usage: taosd [OPTION...] \n\n"); printf("%s%s%s%s\n", indent, "-a,", indent, DM_APOLLO_URL); printf("%s%s%s%s\n", indent, "-c,", indent, DM_CFG_DIR); + printf("%s%s%s%s\n", indent, "-s,", indent, DM_SDB_INFO); printf("%s%s%s%s\n", indent, "-C,", indent, DM_DMP_CFG); printf("%s%s%s%s\n", indent, "-e,", indent, DM_ENV_CMD); printf("%s%s%s%s\n", indent, "-E,", indent, DM_ENV_FILE); @@ -229,6 +235,14 @@ int mainWindows(int argc,char** argv) { return 0; } + if (global.dumpSdb) { + mndDumpSdb(); + taosCleanupCfg(); + taosCloseLog(); + taosCleanupArgs(); + return 0; + } + dmSetProcInfo(argc, (char **)argv); taosCleanupArgs(); diff --git a/source/dnode/mgmt/mgmt_qnode/src/qmWorker.c b/source/dnode/mgmt/mgmt_qnode/src/qmWorker.c index 1c7edbe6be..66386b0ee0 100644 --- a/source/dnode/mgmt/mgmt_qnode/src/qmWorker.c +++ b/source/dnode/mgmt/mgmt_qnode/src/qmWorker.c @@ -87,6 +87,7 @@ int32_t qmPutRpcMsgToQueue(SQnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) { return 0; default: terrno = TSDB_CODE_INVALID_PARA; + taosFreeQitem(pMsg); return -1; } } diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmFile.c b/source/dnode/mgmt/mgmt_vnode/src/vmFile.c index cbcb541200..82fc286a94 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmFile.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmFile.c @@ -135,12 +135,14 @@ _OVER: if (content != NULL) taosMemoryFree(content); if (root != NULL) cJSON_Delete(root); if (pFile != NULL) taosCloseFile(&pFile); + if (*ppCfgs == NULL && pCfgs != NULL) taosMemoryFree(pCfgs); terrno = code; return code; } int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) { + int32_t ret = 0; char file[PATH_MAX] = {0}; char realfile[PATH_MAX] = {0}; snprintf(file, sizeof(file), "%s%svnodes.json.bak", pMgmt->path, TD_DIRSEP); @@ -161,13 +163,16 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) { char *content = taosMemoryCalloc(1, maxLen + 1); if (content == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; + ret = -1; + goto _OVER; } len += snprintf(content + len, maxLen - len, "{\n"); len += snprintf(content + len, maxLen - len, " \"vnodes\": [\n"); for (int32_t i = 0; i < numOfVnodes; ++i) { SVnodeObj *pVnode = pVnodes[i]; + if (pVnode == NULL) continue; + len += snprintf(content + len, maxLen - len, " {\n"); len += snprintf(content + len, maxLen - len, " \"vgId\": %d,\n", pVnode->vgId); len += snprintf(content + len, maxLen - len, " \"dropped\": %d,\n", pVnode->dropped); @@ -180,12 +185,13 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) { } len += snprintf(content + len, maxLen - len, " ]\n"); len += snprintf(content + len, maxLen - len, "}\n"); + terrno = 0; +_OVER: taosWriteFile(pFile, content, len); taosFsyncFile(pFile); taosCloseFile(&pFile); taosMemoryFree(content); - terrno = 0; for (int32_t i = 0; i < numOfVnodes; ++i) { SVnodeObj *pVnode = pVnodes[i]; @@ -196,6 +202,8 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) { taosMemoryFree(pVnodes); } + if (ret != 0) return -1; + dDebug("successed to write %s, numOfVnodes:%d", realfile, numOfVnodes); return taosRenameFile(file, realfile); } \ No newline at end of file diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index e3ad1b9389..4047bc2340 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -175,7 +175,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) { pCfg->hashSuffix = pCreate->hashSuffix; pCfg->tsdbPageSize = pCreate->tsdbPageSize * 1024; - pCfg->standby = pCfg->standby; + pCfg->standby = 0; pCfg->syncCfg.myIndex = pCreate->selfIndex; pCfg->syncCfg.replicaNum = pCreate->replica; memset(&pCfg->syncCfg.nodeInfo, 0, sizeof(pCfg->syncCfg.nodeInfo)); diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c index f0c43d8b36..19ed2cbc88 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c @@ -58,11 +58,14 @@ int32_t vmOpenVnode(SVnodeMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) { if (pVnode->path == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; + taosMemoryFree(pVnode); return -1; } if (vmAllocQueue(pMgmt, pVnode) != 0) { terrno = TSDB_CODE_OUT_OF_MEMORY; + taosMemoryFree(pVnode->path); + taosMemoryFree(pVnode); return -1; } @@ -221,6 +224,7 @@ static void vmCloseVnodes(SVnodeMgmt *pMgmt) { SVnodeObj **ppVnodes = vmGetVnodeListFromHash(pMgmt, &numOfVnodes); for (int32_t i = 0; i < numOfVnodes; ++i) { + if (ppVnodes == NULL || ppVnodes[i] == NULL) continue; vmCloseVnode(pMgmt, ppVnodes[i]); } @@ -380,7 +384,9 @@ static int32_t vmStartVnodes(SVnodeMgmt *pMgmt) { for (int32_t v = 0; v < numOfVnodes; ++v) { int32_t t = v % threadNum; SVnodeThread *pThread = &threads[t]; - pThread->ppVnodes[pThread->vnodeNum++] = ppVnodes[v]; + if (pThread->ppVnodes != NULL) { + pThread->ppVnodes[pThread->vnodeNum++] = ppVnodes[v]; + } } pMgmt->state.openVnodes = 0; @@ -411,8 +417,8 @@ static int32_t vmStartVnodes(SVnodeMgmt *pMgmt) { taosMemoryFree(threads); for (int32_t i = 0; i < numOfVnodes; ++i) { - SVnodeObj *pVnode = ppVnodes[i]; - vmReleaseVnode(pMgmt, pVnode); + if (ppVnodes == NULL || ppVnodes[i] == NULL) continue; + vmReleaseVnode(pMgmt, ppVnodes[i]); } if (ppVnodes != NULL) { diff --git a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c index 582b16ce99..2e149be3b6 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c +++ b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c @@ -193,6 +193,8 @@ int32_t dmInitDnode(SDnode *pDnode, EDndNodeType rtype) { goto _OVER; } + indexInit(tsNumOfCommitThreads); + dmReportStartup("dnode-transport", "initialized"); dDebug("dnode is created, ptr:%p", pDnode); code = 0; diff --git a/source/dnode/mgmt/node_mgmt/src/dmProc.c b/source/dnode/mgmt/node_mgmt/src/dmProc.c index cbf13924d7..bb71044dd6 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmProc.c +++ b/source/dnode/mgmt/node_mgmt/src/dmProc.c @@ -74,11 +74,14 @@ static SProcQueue *dmInitProcQueue(SProc *proc, char *ptr, int32_t size) { } tstrncpy(queue->name, proc->name, sizeof(queue->name)); + + taosThreadMutexLock(&queue->mutex); queue->head = 0; queue->tail = 0; queue->total = bufSize; queue->avail = bufSize; queue->items = 0; + taosThreadMutexUnlock(&queue->mutex); } return queue; diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index f57943b9dd..e83f1f7cab 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -301,7 +301,7 @@ int32_t dmInitServer(SDnode *pDnode) { SDnodeTrans *pTrans = &pDnode->trans; SRpcInit rpcInit = {0}; - strncpy(rpcInit.localFqdn, tsLocalFqdn, TSDB_FQDN_LEN); + tstrncpy(rpcInit.localFqdn, tsLocalFqdn, TSDB_FQDN_LEN); rpcInit.localPort = tsServerPort; rpcInit.label = "DND-S"; rpcInit.numOfThreads = tsNumOfRpcThreads; diff --git a/source/dnode/mnode/impl/inc/mndStb.h b/source/dnode/mnode/impl/inc/mndStb.h index 8f0d55e100..ba9acdbd8f 100644 --- a/source/dnode/mnode/impl/inc/mndStb.h +++ b/source/dnode/mnode/impl/inc/mndStb.h @@ -40,6 +40,8 @@ int32_t mndBuildSMCreateStbRsp(SMnode *pMnode, char* dbFName, char* stbFName, vo void mndExtractDbNameFromStbFullName(const char *stbFullName, char *dst); void mndExtractTbNameFromStbFullName(const char *stbFullName, char *dst, int32_t dstSize); +const char *mndGetStbStr(const char *src); + #ifdef __cplusplus } #endif diff --git a/source/dnode/mnode/impl/src/mndAcct.c b/source/dnode/mnode/impl/src/mndAcct.c index 5279a86d83..65857367f9 100644 --- a/source/dnode/mnode/impl/src/mndAcct.c +++ b/source/dnode/mnode/impl/src/mndAcct.c @@ -83,6 +83,7 @@ static int32_t mndCreateDefaultAcct(SMnode *pMnode) { STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, "create-acct"); if (pTrans == NULL) { + sdbFreeRaw(pRaw); mError("acct:%s, failed to create since %s", acctObj.acct, terrstr()); return -1; } diff --git a/source/dnode/mnode/impl/src/mndCluster.c b/source/dnode/mnode/impl/src/mndCluster.c index 7a3dde3cf3..3502ecf604 100644 --- a/source/dnode/mnode/impl/src/mndCluster.c +++ b/source/dnode/mnode/impl/src/mndCluster.c @@ -237,6 +237,7 @@ static int32_t mndCreateDefaultCluster(SMnode *pMnode) { STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, "create-cluster"); if (pTrans == NULL) { + sdbFreeRaw(pRaw); mError("cluster:%" PRId64 ", failed to create since %s", clusterObj.id, terrstr()); return -1; } @@ -315,7 +316,7 @@ static int32_t mndProcessUptimeTimer(SRpcMsg *pReq) { return 0; } - mTrace("update cluster uptime to %" PRId64, clusterObj.upTime); + mInfo("update cluster uptime to %d", clusterObj.upTime); STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "update-uptime"); if (pTrans == NULL) return -1; diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index e0dbc26122..3dfc10e554 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -54,13 +54,15 @@ static int32_t mndProcessConsumerLostMsg(SRpcMsg *pMsg); static int32_t mndProcessConsumerRecoverMsg(SRpcMsg *pMsg); int32_t mndInitConsumer(SMnode *pMnode) { - SSdbTable table = {.sdbType = SDB_CONSUMER, - .keyType = SDB_KEY_INT64, - .encodeFp = (SdbEncodeFp)mndConsumerActionEncode, - .decodeFp = (SdbDecodeFp)mndConsumerActionDecode, - .insertFp = (SdbInsertFp)mndConsumerActionInsert, - .updateFp = (SdbUpdateFp)mndConsumerActionUpdate, - .deleteFp = (SdbDeleteFp)mndConsumerActionDelete}; + SSdbTable table = { + .sdbType = SDB_CONSUMER, + .keyType = SDB_KEY_INT64, + .encodeFp = (SdbEncodeFp)mndConsumerActionEncode, + .decodeFp = (SdbDecodeFp)mndConsumerActionDecode, + .insertFp = (SdbInsertFp)mndConsumerActionInsert, + .updateFp = (SdbUpdateFp)mndConsumerActionUpdate, + .deleteFp = (SdbDeleteFp)mndConsumerActionDelete, + }; mndSetMsgHandle(pMnode, TDMT_MND_SUBSCRIBE, mndProcessSubscribeReq); mndSetMsgHandle(pMnode, TDMT_MND_MQ_HB, mndProcessMqHbReq); @@ -176,6 +178,8 @@ static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) { SMqConsumerObj *pConsumer; void *pIter = NULL; + mTrace("start to process mq timer"); + // rebalance cannot be parallel if (!mndRebTryStart()) { mInfo("mq rebalance already in progress, do nothing"); @@ -268,6 +272,7 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) { SMqConsumerObj *pConsumer = mndAcquireConsumer(pMnode, consumerId); if (pConsumer == NULL) { + mError("consumer %ld not exist", consumerId); terrno = TSDB_CODE_MND_CONSUMER_NOT_EXIST; return -1; } diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index a05d8dd739..1d70f43834 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -1594,7 +1594,7 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb, break; } char precVstr[10] = {0}; - STR_WITH_SIZE_TO_VARSTR(precVstr, precStr, 2); + STR_WITH_MAXSIZE_TO_VARSTR(precVstr, precStr, 10); char *statusStr = "ready"; if (objStatus == SDB_STATUS_CREATING) { @@ -1607,7 +1607,7 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb, } } char statusVstr[24] = {0}; - STR_WITH_SIZE_TO_VARSTR(statusVstr, statusStr, strlen(statusStr)); + STR_WITH_MAXSIZE_TO_VARSTR(statusVstr, statusStr, 24); if (sysDb || !sysinfo) { for (int32_t i = 0; i < pShow->numOfColumns; ++i) { @@ -1644,7 +1644,7 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb, const char *strictStr = pDb->cfg.strict ? "on" : "off"; char strictVstr[24] = {0}; - STR_WITH_SIZE_TO_VARSTR(strictVstr, strictStr, strlen(strictStr)); + STR_WITH_MAXSIZE_TO_VARSTR(strictVstr, strictStr, 24); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, rows, (const char *)strictVstr, false); @@ -1704,7 +1704,7 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb, const char *cacheModelStr = getCacheModelStr(pDb->cfg.cacheLast); char cacheModelVstr[24] = {0}; - STR_WITH_SIZE_TO_VARSTR(cacheModelVstr, cacheModelStr, strlen(cacheModelStr)); + STR_WITH_MAXSIZE_TO_VARSTR(cacheModelVstr, cacheModelStr, 24); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, rows, (const char *)cacheModelVstr, false); diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 4a8436513f..c8995eb6bc 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -102,7 +102,7 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) { dnodeObj.updateTime = dnodeObj.createdTime; dnodeObj.port = tsServerPort; memcpy(&dnodeObj.fqdn, tsLocalFqdn, TSDB_FQDN_LEN); - snprintf(dnodeObj.ep, TSDB_EP_LEN, "%s:%u", dnodeObj.fqdn, dnodeObj.port); + snprintf(dnodeObj.ep, TSDB_EP_LEN - 1, "%s:%u", dnodeObj.fqdn, dnodeObj.port); pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL, "create-dnode"); if (pTrans == NULL) goto _OVER; @@ -190,7 +190,7 @@ _OVER: static int32_t mndDnodeActionInsert(SSdb *pSdb, SDnodeObj *pDnode) { mTrace("dnode:%d, perform insert action, row:%p", pDnode->id, pDnode); pDnode->offlineReason = DND_REASON_STATUS_NOT_RECEIVED; - snprintf(pDnode->ep, TSDB_EP_LEN, "%s:%u", pDnode->fqdn, pDnode->port); + snprintf(pDnode->ep, TSDB_EP_LEN - 1, "%s:%u", pDnode->fqdn, pDnode->port); return 0; } @@ -253,7 +253,7 @@ int32_t mndGetDnodeSize(SMnode *pMnode) { bool mndIsDnodeOnline(SDnodeObj *pDnode, int64_t curMs) { int64_t interval = TABS(pDnode->lastAccessTime - curMs); - if (interval > 5000 * tsStatusInterval) { + if (interval > 5000 * (int64_t)tsStatusInterval) { if (pDnode->rebootTime > 0) { pDnode->offlineReason = DND_REASON_STATUS_MSG_TIMEOUT; } @@ -486,7 +486,7 @@ static int32_t mndCreateDnode(SMnode *pMnode, SRpcMsg *pReq, SCreateDnodeReq *pC dnodeObj.updateTime = dnodeObj.createdTime; dnodeObj.port = pCreate->port; memcpy(dnodeObj.fqdn, pCreate->fqdn, TSDB_FQDN_LEN); - snprintf(dnodeObj.ep, TSDB_EP_LEN, "%s:%u", dnodeObj.fqdn, dnodeObj.port); + snprintf(dnodeObj.ep, TSDB_EP_LEN - 1, "%s:%u", dnodeObj.fqdn, dnodeObj.port); pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_GLOBAL, pReq, "create-dnode"); if (pTrans == NULL) goto _OVER; @@ -673,12 +673,14 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM mInfo("trans:%d, used to drop dnode:%d", pTrans->id, pDnode->id); pRaw = mndDnodeActionEncode(pDnode); - if (pRaw == NULL || mndTransAppendRedolog(pTrans, pRaw) != 0) goto _OVER; + if (pRaw == NULL) goto _OVER; + if (mndTransAppendRedolog(pTrans, pRaw) != 0) goto _OVER; sdbSetRawStatus(pRaw, SDB_STATUS_DROPPING); pRaw = NULL; pRaw = mndDnodeActionEncode(pDnode); - if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER; + if (pRaw == NULL) goto _OVER; + if (mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER; sdbSetRawStatus(pRaw, SDB_STATUS_DROPPED); pRaw = NULL; diff --git a/source/dnode/mnode/impl/src/mndDump.c b/source/dnode/mnode/impl/src/mndDump.c new file mode 100644 index 0000000000..881ebbbf9d --- /dev/null +++ b/source/dnode/mnode/impl/src/mndDump.c @@ -0,0 +1,645 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "mndDb.h" +#include "mndInt.h" +#include "mndStb.h" +#include "sdb.h" +#include "tconfig.h" +#include "tjson.h" +#include "ttypes.h" + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +void reportStartup(const char *name, const char *desc) {} +void sendRsp(SRpcMsg *pMsg) { rpcFreeCont(pMsg->pCont); } + +int32_t sendReq(const SEpSet *pEpSet, SRpcMsg *pMsg) { + terrno = TSDB_CODE_INVALID_PTR; + return -1; +} + +char *i642str(int64_t val) { + static char str[24] = {0}; + snprintf(str, sizeof(str), "%" PRId64, val); + return str; +} + +void dumpFunc(SSdb *pSdb, SJson *json) { + void *pIter = NULL; + SJson *items = tjsonAddArrayToObject(json, "funcs"); + + while (1) { + SFuncObj *pObj = NULL; + pIter = sdbFetch(pSdb, SDB_FUNC, pIter, (void **)&pObj); + if (pIter == NULL) break; + + SJson *item = tjsonCreateObject(); + tjsonAddItemToArray(items, item); + tjsonAddStringToObject(item, "name", pObj->name); + tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); + tjsonAddStringToObject(item, "funcType", i642str(pObj->funcType)); + tjsonAddStringToObject(item, "scriptType", i642str(pObj->scriptType)); + tjsonAddStringToObject(item, "align", i642str(pObj->align)); + tjsonAddStringToObject(item, "outputType", i642str(pObj->outputType)); + tjsonAddStringToObject(item, "outputLen", i642str(pObj->outputLen)); + tjsonAddStringToObject(item, "bufSize", i642str(pObj->bufSize)); + tjsonAddStringToObject(item, "signature", i642str(pObj->signature)); + tjsonAddStringToObject(item, "commentSize", i642str(pObj->commentSize)); + tjsonAddStringToObject(item, "codeSize", i642str(pObj->codeSize)); + sdbRelease(pSdb, pObj); + } +} + +void dumpDb(SSdb *pSdb, SJson *json) { + void *pIter = NULL; + SJson *items = tjsonCreateObject(); + tjsonAddItemToObject(json, "dbs", items); + + while (1) { + SDbObj *pObj = NULL; + pIter = sdbFetch(pSdb, SDB_DB, pIter, (void **)&pObj); + if (pIter == NULL) break; + + SJson *item = tjsonCreateObject(); + tjsonAddItemToObject(items, "db", item); + + tjsonAddStringToObject(item, "name", mndGetDbStr(pObj->name)); + tjsonAddStringToObject(item, "acct", pObj->acct); + tjsonAddStringToObject(item, "createUser", pObj->createUser); + tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); + tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); + tjsonAddStringToObject(item, "uid", i642str(pObj->uid)); + tjsonAddStringToObject(item, "cfgVersion", i642str(pObj->cfgVersion)); + tjsonAddStringToObject(item, "vgVersion", i642str(pObj->vgVersion)); + tjsonAddStringToObject(item, "numOfVgroups", i642str(pObj->cfg.numOfVgroups)); + tjsonAddStringToObject(item, "numOfStables", i642str(pObj->cfg.numOfStables)); + tjsonAddStringToObject(item, "buffer", i642str(pObj->cfg.buffer)); + tjsonAddStringToObject(item, "pageSize", i642str(pObj->cfg.pageSize)); + tjsonAddStringToObject(item, "pages", i642str(pObj->cfg.pages)); + tjsonAddStringToObject(item, "cacheLastSize", i642str(pObj->cfg.cacheLastSize)); + tjsonAddStringToObject(item, "daysPerFile", i642str(pObj->cfg.daysPerFile)); + tjsonAddStringToObject(item, "daysToKeep0", i642str(pObj->cfg.daysToKeep0)); + tjsonAddStringToObject(item, "daysToKeep1", i642str(pObj->cfg.daysToKeep1)); + tjsonAddStringToObject(item, "daysToKeep2", i642str(pObj->cfg.daysToKeep2)); + tjsonAddStringToObject(item, "minRows", i642str(pObj->cfg.minRows)); + tjsonAddStringToObject(item, "maxRows", i642str(pObj->cfg.maxRows)); + tjsonAddStringToObject(item, "precision", i642str(pObj->cfg.precision)); + tjsonAddStringToObject(item, "compression", i642str(pObj->cfg.compression)); + tjsonAddStringToObject(item, "replications", i642str(pObj->cfg.replications)); + tjsonAddStringToObject(item, "strict", i642str(pObj->cfg.strict)); + tjsonAddStringToObject(item, "cacheLast",i642str( pObj->cfg.cacheLast)); + tjsonAddStringToObject(item, "hashMethod", i642str(pObj->cfg.hashMethod)); + tjsonAddStringToObject(item, "hashPrefix", i642str(pObj->cfg.hashPrefix)); + tjsonAddStringToObject(item, "hashSuffix", i642str(pObj->cfg.hashSuffix)); + tjsonAddStringToObject(item, "sstTrigger", i642str(pObj->cfg.sstTrigger)); + tjsonAddStringToObject(item, "tsdbPageSize",i642str( pObj->cfg.tsdbPageSize)); + tjsonAddStringToObject(item, "schemaless", i642str(pObj->cfg.schemaless)); + tjsonAddStringToObject(item, "walLevel",i642str( pObj->cfg.walLevel)); + tjsonAddStringToObject(item, "walFsyncPeriod", i642str(pObj->cfg.walFsyncPeriod)); + tjsonAddStringToObject(item, "walRetentionPeriod", i642str(pObj->cfg.walRetentionPeriod)); + tjsonAddStringToObject(item, "walRetentionSize",i642str( pObj->cfg.walRetentionSize)); + tjsonAddStringToObject(item, "walRollPeriod", i642str(pObj->cfg.walRollPeriod)); + tjsonAddStringToObject(item, "walSegmentSize", i642str(pObj->cfg.walSegmentSize)); + + tjsonAddStringToObject(item, "numOfRetensions",i642str( pObj->cfg.numOfRetensions)); + for (int32_t i = 0; i < pObj->cfg.numOfRetensions; ++i) { + SJson *rentensions = tjsonAddArrayToObject(item, "rentensions"); + SJson *rentension = tjsonCreateObject(); + tjsonAddItemToArray(rentensions, rentension); + + SRetention *pRetension = taosArrayGet(pObj->cfg.pRetensions, i); + tjsonAddStringToObject(item, "freq", i642str(pRetension->freq)); + tjsonAddStringToObject(item, "freqUnit", i642str(pRetension->freqUnit)); + tjsonAddStringToObject(item, "keep", i642str(pRetension->keep)); + tjsonAddStringToObject(item, "keepUnit",i642str( pRetension->keepUnit)); + } + + sdbRelease(pSdb, pObj); + } +} + +void dumpStb(SSdb *pSdb, SJson *json) { + void *pIter = NULL; + SJson *items = tjsonAddArrayToObject(json, "stbs"); + + while (1) { + SStbObj *pObj = NULL; + pIter = sdbFetch(pSdb, SDB_STB, pIter, (void **)&pObj); + if (pIter == NULL) break; + + SJson *item = tjsonCreateObject(); + tjsonAddItemToArray(items, item); + tjsonAddStringToObject(item, "name", mndGetStbStr(pObj->name)); + tjsonAddStringToObject(item, "db", mndGetDbStr(pObj->db)); + tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); + tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); + tjsonAddStringToObject(item, "uid", i642str(pObj->uid)); + tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid)); + tjsonAddStringToObject(item, "tagVer",i642str( pObj->tagVer)); + tjsonAddStringToObject(item, "colVer", i642str(pObj->colVer)); + tjsonAddStringToObject(item, "smaVer", i642str(pObj->smaVer)); + tjsonAddStringToObject(item, "nextColId", i642str(pObj->nextColId)); + tjsonAddStringToObject(item, "watermark1", i642str(pObj->watermark[0])); + tjsonAddStringToObject(item, "watermark2", i642str(pObj->watermark[1])); + tjsonAddStringToObject(item, "maxdelay0",i642str( pObj->maxdelay[0])); + tjsonAddStringToObject(item, "maxdelay1",i642str( pObj->maxdelay[1])); + tjsonAddStringToObject(item, "ttl",i642str( pObj->ttl)); + tjsonAddStringToObject(item, "numOfFuncs",i642str( pObj->numOfFuncs)); + tjsonAddStringToObject(item, "commentLen", i642str(pObj->commentLen)); + tjsonAddStringToObject(item, "ast1Len", i642str(pObj->ast1Len)); + tjsonAddStringToObject(item, "ast2Len",i642str( pObj->ast2Len)); + + tjsonAddStringToObject(item, "numOfColumns",i642str( pObj->numOfColumns)); + SJson *columns = tjsonAddArrayToObject(item, "columns"); + for (int32_t i = 0; i < pObj->numOfColumns; ++i) { + SJson *column = tjsonCreateObject(); + tjsonAddItemToArray(columns, column); + + SSchema *pColumn = &pObj->pColumns[i]; + tjsonAddStringToObject(column, "type", i642str(pColumn->type)); + tjsonAddStringToObject(column, "typestr", tDataTypes[pColumn->type].name); + tjsonAddStringToObject(column, "flags", i642str(pColumn->flags)); + tjsonAddStringToObject(column, "colId", i642str(pColumn->colId)); + tjsonAddStringToObject(column, "bytes", i642str(pColumn->bytes)); + tjsonAddStringToObject(column, "name", pColumn->name); + } + + tjsonAddStringToObject(item, "numOfTags", i642str(pObj->numOfTags)); + SJson *tags = tjsonAddArrayToObject(item, "tags"); + for (int32_t i = 0; i < pObj->numOfTags; ++i) { + SJson *tag = tjsonCreateObject(); + tjsonAddItemToArray(tags, tag); + + SSchema *pTag = &pObj->pTags[i]; + tjsonAddStringToObject(tag, "type", i642str(pTag->type)); + tjsonAddStringToObject(tag, "typestr", tDataTypes[pTag->type].name); + tjsonAddStringToObject(tag, "flags",i642str( pTag->flags)); + tjsonAddStringToObject(tag, "colId", i642str(pTag->colId)); + tjsonAddStringToObject(tag, "bytes", i642str(pTag->bytes)); + tjsonAddStringToObject(tag, "name", pTag->name); + } + + sdbRelease(pSdb, pObj); + } +} + +void dumpSma(SSdb *pSdb, SJson *json) { + void *pIter = NULL; + SJson *items = tjsonAddArrayToObject(json, "smas"); + + while (1) { + SSmaObj *pObj = NULL; + pIter = sdbFetch(pSdb, SDB_SMA, pIter, (void **)&pObj); + if (pIter == NULL) break; + + SJson *item = tjsonCreateObject(); + tjsonAddItemToArray(items, item); + tjsonAddStringToObject(item, "name", mndGetStbStr(pObj->name)); + tjsonAddStringToObject(item, "stb", mndGetStbStr(pObj->stb)); + tjsonAddStringToObject(item, "db", mndGetDbStr(pObj->db)); + tjsonAddStringToObject(item, "dstTbName", mndGetStbStr(pObj->dstTbName)); + tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); + tjsonAddStringToObject(item, "uid", i642str(pObj->uid)); + tjsonAddStringToObject(item, "stbUid", i642str(pObj->stbUid)); + tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid)); + tjsonAddStringToObject(item, "dstTbUid", i642str(pObj->dstTbUid)); + tjsonAddStringToObject(item, "intervalUnit", i642str(pObj->intervalUnit)); + tjsonAddStringToObject(item, "slidingUnit",i642str( pObj->slidingUnit)); + tjsonAddStringToObject(item, "timezone", i642str(pObj->timezone)); + tjsonAddStringToObject(item, "dstVgId",i642str( pObj->dstVgId)); + tjsonAddStringToObject(item, "interval", i642str(pObj->interval)); + tjsonAddStringToObject(item, "offset", i642str(pObj->offset)); + tjsonAddStringToObject(item, "sliding", i642str(pObj->sliding)); + tjsonAddStringToObject(item, "exprLen",i642str( pObj->exprLen)); + tjsonAddStringToObject(item, "tagsFilterLen", i642str(pObj->tagsFilterLen)); + tjsonAddStringToObject(item, "sqlLen",i642str( pObj->sqlLen)); + tjsonAddStringToObject(item, "astLen",i642str( pObj->astLen)); + sdbRelease(pSdb, pObj); + } +} + +void dumpVgroup(SSdb *pSdb, SJson *json) { + void *pIter = NULL; + SJson *items = tjsonAddArrayToObject(json, "vgroups"); + + while (1) { + SVgObj *pObj = NULL; + pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pObj); + if (pIter == NULL) break; + + SJson *item = tjsonCreateObject(); + tjsonAddItemToArray(items, item); + tjsonAddStringToObject(item, "vgId", i642str(pObj->vgId)); + tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); + tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); + tjsonAddStringToObject(item, "version",i642str(pObj->version)); + tjsonAddStringToObject(item, "hashBegin", i642str(pObj->hashBegin)); + tjsonAddStringToObject(item, "hashEnd", i642str(pObj->hashEnd)); + tjsonAddStringToObject(item, "db", mndGetDbStr(pObj->dbName)); + tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid)); + tjsonAddStringToObject(item, "isTsma", i642str(pObj->isTsma)); + tjsonAddStringToObject(item, "replica",i642str( pObj->replica)); + for (int32_t i = 0; i < pObj->replica; ++i) { + SJson *replicas = tjsonAddArrayToObject(item, "replicas"); + SJson *replica = tjsonCreateObject(); + tjsonAddItemToArray(replicas, replica); + tjsonAddStringToObject(replica, "dnodeId", i642str(pObj->vnodeGid[i].dnodeId)); + } + sdbRelease(pSdb, pObj); + } +} + +void dumpTopic(SSdb *pSdb, SJson *json) { + void *pIter = NULL; + SJson *items = tjsonAddArrayToObject(json, "topics"); + + while (1) { + SMqTopicObj *pObj = NULL; + pIter = sdbFetch(pSdb, SDB_TOPIC, pIter, (void **)&pObj); + if (pIter == NULL) break; + + SJson *item = tjsonCreateObject(); + tjsonAddItemToArray(items, item); + tjsonAddStringToObject(item, "name", mndGetDbStr(pObj->name)); + tjsonAddStringToObject(item, "name", mndGetDbStr(pObj->db)); + tjsonAddStringToObject(item, "createTime", i642str(pObj->createTime)); + tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); + tjsonAddStringToObject(item, "uid", i642str(pObj->uid)); + tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid)); + tjsonAddStringToObject(item, "version",i642str( pObj->version)); + tjsonAddStringToObject(item, "subType",i642str( pObj->subType)); + tjsonAddStringToObject(item, "withMeta", i642str(pObj->withMeta)); + tjsonAddStringToObject(item, "stbUid", i642str(pObj->stbUid)); + tjsonAddStringToObject(item, "sqlLen", i642str(pObj->sqlLen)); + tjsonAddStringToObject(item, "astLen",i642str( pObj->astLen)); + tjsonAddStringToObject(item, "sqlLen",i642str( pObj->sqlLen)); + tjsonAddStringToObject(item, "ntbUid", i642str(pObj->ntbUid)); + tjsonAddStringToObject(item, "ctbStbUid", i642str(pObj->ctbStbUid)); + sdbRelease(pSdb, pObj); + } +} + +void dumpConsumer(SSdb *pSdb, SJson *json) { + void *pIter = NULL; + SJson *items = tjsonAddArrayToObject(json, "consumers"); + + while (1) { + SMqConsumerObj *pObj = NULL; + pIter = sdbFetch(pSdb, SDB_CONSUMER, pIter, (void **)&pObj); + if (pIter == NULL) break; + + SJson *item = tjsonCreateObject(); + tjsonAddItemToArray(items, item); + tjsonAddStringToObject(item, "consumerId", i642str(pObj->consumerId)); + tjsonAddStringToObject(item, "cgroup", pObj->cgroup); + sdbRelease(pSdb, pObj); + } +} + +void dumpSubscribe(SSdb *pSdb, SJson *json) { + void *pIter = NULL; + SJson *items = tjsonAddArrayToObject(json, "subscribes"); + + while (1) { + SMqSubscribeObj *pObj = NULL; + pIter = sdbFetch(pSdb, SDB_SUBSCRIBE, pIter, (void **)&pObj); + if (pIter == NULL) break; + + SJson *item = tjsonCreateObject(); + tjsonAddItemToArray(items, item); + tjsonAddStringToObject(item, "key", pObj->key); + tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid)); + tjsonAddStringToObject(item, "stbUid", i642str(pObj->stbUid)); + sdbRelease(pSdb, pObj); + } +} + +void dumpOffset(SSdb *pSdb, SJson *json) { + void *pIter = NULL; + SJson *items = tjsonAddArrayToObject(json, "offsets"); + + while (1) { + SMqOffsetObj *pObj = NULL; + pIter = sdbFetch(pSdb, SDB_OFFSET, pIter, (void **)&pObj); + if (pIter == NULL) break; + + SJson *item = tjsonCreateObject(); + tjsonAddItemToArray(items, item); + tjsonAddStringToObject(item, "key", pObj->key); + tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid)); + tjsonAddStringToObject(item, "offset", i642str(pObj->offset)); + sdbRelease(pSdb, pObj); + } +} + +void dumpStream(SSdb *pSdb, SJson *json) { + void *pIter = NULL; + SJson *items = tjsonAddArrayToObject(json, "streams"); + + while (1) { + SStreamObj *pObj = NULL; + pIter = sdbFetch(pSdb, SDB_STREAM, pIter, (void **)&pObj); + if (pIter == NULL) break; + + SJson *item = tjsonCreateObject(); + tjsonAddItemToArray(items, item); + tjsonAddStringToObject(item, "name", mndGetDbStr(pObj->name)); + tjsonAddStringToObject(item, "createTime", i642str(pObj->createTime)); + tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); + tjsonAddStringToObject(item, "version", i642str(pObj->version)); + tjsonAddStringToObject(item, "totalLevel", i642str(pObj->totalLevel)); + tjsonAddStringToObject(item, "smaId", i642str(pObj->smaId)); + tjsonAddStringToObject(item, "uid", i642str(pObj->uid)); + tjsonAddStringToObject(item, "status",i642str( pObj->status)); + tjsonAddStringToObject(item, "igExpired",i642str( pObj->igExpired)); + tjsonAddStringToObject(item, "trigger",i642str( pObj->trigger)); + tjsonAddStringToObject(item, "triggerParam", i642str(pObj->triggerParam)); + tjsonAddStringToObject(item, "watermark", i642str(pObj->watermark)); + tjsonAddStringToObject(item, "sourceDbUid", i642str(pObj->sourceDbUid)); + tjsonAddStringToObject(item, "targetDbUid", i642str(pObj->targetDbUid)); + tjsonAddStringToObject(item, "sourceDb", mndGetDbStr(pObj->sourceDb)); + tjsonAddStringToObject(item, "targetDb", mndGetDbStr(pObj->targetDb)); + tjsonAddStringToObject(item, "targetSTbName", mndGetStbStr(pObj->targetSTbName)); + tjsonAddStringToObject(item, "targetStbUid", i642str(pObj->targetStbUid)); + tjsonAddStringToObject(item, "fixedSinkVgId", i642str(pObj->fixedSinkVgId)); + sdbRelease(pSdb, pObj); + } +} + +void dumpAcct(SSdb *pSdb, SJson *json) { + void *pIter = NULL; + SJson *items = tjsonAddArrayToObject(json, "accts"); + + while (1) { + SAcctObj *pObj = NULL; + pIter = sdbFetch(pSdb, SDB_ACCT, pIter, (void **)&pObj); + if (pIter == NULL) break; + + SJson *item = tjsonCreateObject(); + tjsonAddItemToArray(items, item); + tjsonAddStringToObject(item, "acct", pObj->acct); + tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); + tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); + tjsonAddStringToObject(item, "acctId", i642str(pObj->acctId)); + sdbRelease(pSdb, pObj); + } +} + +void dumpAuth(SSdb *pSdb, SJson *json) { + // todo +} + +void dumpUser(SSdb *pSdb, SJson *json) { + void *pIter = NULL; + SJson *items = tjsonAddArrayToObject(json, "users"); + + while (1) { + SUserObj *pObj = NULL; + pIter = sdbFetch(pSdb, SDB_USER, pIter, (void **)&pObj); + if (pIter == NULL) break; + + SJson *item = tjsonCreateObject(); + tjsonAddItemToArray(items, item); + tjsonAddStringToObject(item, "name", pObj->user); + tjsonAddStringToObject(item, "acct", pObj->acct); + tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); + tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); + tjsonAddStringToObject(item, "superUser",i642str( pObj->superUser)); + tjsonAddStringToObject(item, "authVersion", i642str(pObj->authVersion)); + tjsonAddStringToObject(item, "numOfReadDbs",i642str( taosHashGetSize(pObj->readDbs))); + tjsonAddStringToObject(item, "numOfWriteDbs", i642str(taosHashGetSize(pObj->writeDbs))); + sdbRelease(pSdb, pObj); + } +} + +void dumpDnode(SSdb *pSdb, SJson *json) { + void *pIter = NULL; + SJson *items = tjsonAddArrayToObject(json, "dnodes"); + + while (1) { + SDnodeObj *pObj = NULL; + pIter = sdbFetch(pSdb, SDB_DNODE, pIter, (void **)&pObj); + if (pIter == NULL) break; + + SJson *item = tjsonCreateObject(); + tjsonAddItemToArray(items, item); + tjsonAddStringToObject(item, "id",i642str( pObj->id)); + tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); + tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); + tjsonAddStringToObject(item, "port",i642str( pObj->port)); + tjsonAddStringToObject(item, "fqdn", pObj->fqdn); + sdbRelease(pSdb, pObj); + } +} + +void dumpBnode(SSdb *pSdb, SJson *json) { + // not implemented yet +} + +void dumpSnode(SSdb *pSdb, SJson *json) { + void *pIter = NULL; + SJson *items = tjsonAddArrayToObject(json, "snodes"); + + while (1) { + SSnodeObj *pObj = NULL; + pIter = sdbFetch(pSdb, SDB_QNODE, pIter, (void **)&pObj); + if (pIter == NULL) break; + + SJson *item = tjsonCreateObject(); + tjsonAddItemToArray(items, item); + tjsonAddStringToObject(item, "id",i642str( pObj->id)); + tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); + tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); + sdbRelease(pSdb, pObj); + } +} + +void dumpQnode(SSdb *pSdb, SJson *json) { + void *pIter = NULL; + SJson *items = tjsonAddArrayToObject(json, "qnodes"); + + while (1) { + SQnodeObj *pObj = NULL; + pIter = sdbFetch(pSdb, SDB_QNODE, pIter, (void **)&pObj); + if (pIter == NULL) break; + + SJson *item = tjsonCreateObject(); + tjsonAddItemToArray(items, item); + tjsonAddStringToObject(item, "id", i642str(pObj->id)); + tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); + tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); + sdbRelease(pSdb, pObj); + } +} + +void dumpMnode(SSdb *pSdb, SJson *json) { + void *pIter = NULL; + SJson *items = tjsonAddArrayToObject(json, "mnodes"); + + while (1) { + SMnodeObj *pObj = NULL; + pIter = sdbFetch(pSdb, SDB_MNODE, pIter, (void **)&pObj); + if (pIter == NULL) break; + + SJson *item = tjsonCreateObject(); + tjsonAddItemToArray(items, item); + tjsonAddStringToObject(item, "id", i642str(pObj->id)); + tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); + tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); + sdbRelease(pSdb, pObj); + } +} + +void dumpCluster(SSdb *pSdb, SJson *json) { + void *pIter = NULL; + SJson *items = tjsonAddArrayToObject(json, "clusters"); + + while (1) { + SClusterObj *pObj = NULL; + pIter = sdbFetch(pSdb, SDB_CLUSTER, pIter, (void **)&pObj); + if (pIter == NULL) break; + + SJson *item = tjsonCreateObject(); + tjsonAddItemToArray(items, item); + tjsonAddStringToObject(item, "id", i642str(pObj->id)); + tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); + tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); + tjsonAddStringToObject(item, "name", pObj->name); + sdbRelease(pSdb, pObj); + } +} + +void dumpTrans(SSdb *pSdb, SJson *json) { + void *pIter = NULL; + SJson *items = tjsonAddArrayToObject(json, "transactions"); + + while (1) { + STrans *pObj = NULL; + pIter = sdbFetch(pSdb, SDB_TRANS, pIter, (void **)&pObj); + if (pIter == NULL) break; + + SJson *item = tjsonCreateObject(); + tjsonAddItemToArray(items, item); + tjsonAddStringToObject(item, "id", i642str(pObj->id)); + tjsonAddStringToObject(item, "stage", i642str(pObj->stage)); + tjsonAddStringToObject(item, "policy", i642str(pObj->policy)); + tjsonAddStringToObject(item, "conflict",i642str( pObj->conflict)); + tjsonAddStringToObject(item, "exec", i642str(pObj->exec)); + tjsonAddStringToObject(item, "oper", i642str(pObj->oper)); + tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); + tjsonAddStringToObject(item, "dbname", pObj->dbname); + tjsonAddStringToObject(item, "stbname", pObj->stbname); + tjsonAddStringToObject(item, "opername", pObj->opername); + tjsonAddStringToObject(item, "commitLogNum",i642str( taosArrayGetSize(pObj->commitActions))); + tjsonAddStringToObject(item, "redoActionNum",i642str(taosArrayGetSize(pObj->redoActions))); + tjsonAddStringToObject(item, "undoActionNum", i642str(taosArrayGetSize(pObj->undoActions))); + sdbRelease(pSdb, pObj); + } +} + +void dumpHeader(SSdb *pSdb, SJson *json) { + tjsonAddStringToObject(json, "sver", i642str(1)); + tjsonAddStringToObject(json, "applyIndex", i642str(pSdb->applyIndex)); + tjsonAddStringToObject(json, "applyTerm", i642str(pSdb->applyTerm)); + tjsonAddStringToObject(json, "applyConfig", i642str(pSdb->applyConfig)); + + SJson *maxIdsJson = tjsonCreateObject(); + tjsonAddItemToObject(json, "maxIds", maxIdsJson); + for (int32_t i = 0; i < SDB_MAX; ++i) { + int64_t maxId = 0; + if (i < SDB_MAX) { + maxId = pSdb->maxId[i]; + } + tjsonAddStringToObject(maxIdsJson, sdbTableName(i), i642str(maxId)); + } + + SJson *tableVersJson = tjsonCreateObject(); + tjsonAddItemToObject(json, "tableVers", tableVersJson); + for (int32_t i = 0; i < SDB_MAX; ++i) { + int64_t tableVer = 0; + if (i < SDB_MAX) { + tableVer = pSdb->tableVer[i]; + } + tjsonAddStringToObject(tableVersJson, sdbTableName(i), i642str(tableVer)); + } +} + +void mndDumpSdb() { + mInfo("start to dump sdb info to sdb.json"); + + char path[PATH_MAX * 2] = {0}; + snprintf(path, sizeof(path), "%s%smnode", tsDataDir, TD_DIRSEP); + + SMsgCb msgCb = {0}; + msgCb.reportStartupFp = reportStartup; + msgCb.sendReqFp = sendReq; + msgCb.sendRspFp = sendRsp; + msgCb.mgmt = (SMgmtWrapper *)(&msgCb); // hack + tmsgSetDefault(&msgCb); + + walInit(); + syncInit(); + + SMnodeOpt opt = {.msgCb = msgCb}; + SMnode *pMnode = mndOpen(path, &opt); + if (pMnode == NULL) return; + + SSdb *pSdb = pMnode->pSdb; + SJson *json = tjsonCreateObject(); + dumpHeader(pSdb, json); + dumpFunc(pSdb, json); + dumpDb(pSdb, json); + dumpStb(pSdb, json); + dumpSma(pSdb, json); + dumpVgroup(pSdb, json); + dumpTopic(pSdb, json); + dumpConsumer(pSdb, json); + dumpSubscribe(pSdb, json); + dumpOffset(pSdb, json); + dumpStream(pSdb, json); + dumpAcct(pSdb, json); + dumpAuth(pSdb, json); + dumpUser(pSdb, json); + dumpDnode(pSdb, json); + dumpBnode(pSdb, json); + dumpSnode(pSdb, json); + dumpQnode(pSdb, json); + dumpMnode(pSdb, json); + dumpCluster(pSdb, json); + dumpTrans(pSdb, json); + + char *pCont = tjsonToString(json); + int32_t contLen = strlen(pCont); + char file[] = "sdb.json"; + TdFilePtr pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC); + if (pFile == NULL) { + terrno = TAOS_SYSTEM_ERROR(errno); + mError("failed to write %s since %s", file, terrstr()); + return; + } + taosWriteFile(pFile, pCont, contLen); + taosWriteFile(pFile, "\n", 1); + taosFsyncFile(pFile); + taosCloseFile(&pFile); + tjsonDelete(json); + taosMemoryFree(pCont); + + mInfo("dump sdb info success"); +} + +#pragma GCC diagnostic pop diff --git a/source/dnode/mnode/impl/src/mndFunc.c b/source/dnode/mnode/impl/src/mndFunc.c index 48ab485a2c..ccab4774e2 100644 --- a/source/dnode/mnode/impl/src/mndFunc.c +++ b/source/dnode/mnode/impl/src/mndFunc.c @@ -38,13 +38,15 @@ static int32_t mndRetrieveFuncs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB static void mndCancelGetNextFunc(SMnode *pMnode, void *pIter); int32_t mndInitFunc(SMnode *pMnode) { - SSdbTable table = {.sdbType = SDB_FUNC, - .keyType = SDB_KEY_BINARY, - .encodeFp = (SdbEncodeFp)mndFuncActionEncode, - .decodeFp = (SdbDecodeFp)mndFuncActionDecode, - .insertFp = (SdbInsertFp)mndFuncActionInsert, - .updateFp = (SdbUpdateFp)mndFuncActionUpdate, - .deleteFp = (SdbDeleteFp)mndFuncActionDelete}; + SSdbTable table = { + .sdbType = SDB_FUNC, + .keyType = SDB_KEY_BINARY, + .encodeFp = (SdbEncodeFp)mndFuncActionEncode, + .decodeFp = (SdbDecodeFp)mndFuncActionDecode, + .insertFp = (SdbInsertFp)mndFuncActionInsert, + .updateFp = (SdbUpdateFp)mndFuncActionUpdate, + .deleteFp = (SdbDeleteFp)mndFuncActionDelete, + }; mndSetMsgHandle(pMnode, TDMT_MND_CREATE_FUNC, mndProcessCreateFuncReq); mndSetMsgHandle(pMnode, TDMT_MND_DROP_FUNC, mndProcessDropFuncReq); @@ -255,15 +257,18 @@ static int32_t mndDropFunc(SMnode *pMnode, SRpcMsg *pReq, SFuncObj *pFunc) { mInfo("trans:%d, used to drop user:%s", pTrans->id, pFunc->name); SSdbRaw *pRedoRaw = mndFuncActionEncode(pFunc); - if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) goto _OVER; + if (pRedoRaw == NULL) goto _OVER; + if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) goto _OVER; sdbSetRawStatus(pRedoRaw, SDB_STATUS_DROPPING); SSdbRaw *pUndoRaw = mndFuncActionEncode(pFunc); - if (pUndoRaw == NULL || mndTransAppendUndolog(pTrans, pUndoRaw) != 0) goto _OVER; + if (pUndoRaw == NULL) goto _OVER; + if (mndTransAppendUndolog(pTrans, pUndoRaw) != 0) goto _OVER; sdbSetRawStatus(pUndoRaw, SDB_STATUS_READY); SSdbRaw *pCommitRaw = mndFuncActionEncode(pFunc); - if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) goto _OVER; + if (pCommitRaw == NULL) goto _OVER; + if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) goto _OVER; sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED); if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; diff --git a/source/dnode/mnode/impl/src/mndGrant.c b/source/dnode/mnode/impl/src/mndGrant.c index a608a1e40f..7262f23657 100644 --- a/source/dnode/mnode/impl/src/mndGrant.c +++ b/source/dnode/mnode/impl/src/mndGrant.c @@ -30,85 +30,85 @@ static int32_t mndRetrieveGrant(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl cols = 0; SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols); const char *src = "community"; - STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32); colDataAppend(pColInfo, numOfRows, tmp, false); cols++; pColInfo = taosArrayGet(pBlock->pDataBlock, cols); src = "unlimited"; - STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32); colDataAppend(pColInfo, numOfRows, tmp, false); cols++; pColInfo = taosArrayGet(pBlock->pDataBlock, cols); src = "false"; - STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32); colDataAppend(pColInfo, numOfRows, tmp, false); cols++; pColInfo = taosArrayGet(pBlock->pDataBlock, cols); src = "unlimited"; - STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32); colDataAppend(pColInfo, numOfRows, tmp, false); cols++; pColInfo = taosArrayGet(pBlock->pDataBlock, cols); src = "unlimited"; - STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32); colDataAppend(pColInfo, numOfRows, tmp, false); cols++; pColInfo = taosArrayGet(pBlock->pDataBlock, cols); src = "unlimited"; - STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32); colDataAppend(pColInfo, numOfRows, tmp, false); cols++; pColInfo = taosArrayGet(pBlock->pDataBlock, cols); src = "unlimited"; - STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32); colDataAppend(pColInfo, numOfRows, tmp, false); cols++; pColInfo = taosArrayGet(pBlock->pDataBlock, cols); src = "unlimited"; - STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32); colDataAppend(pColInfo, numOfRows, tmp, false); cols++; pColInfo = taosArrayGet(pBlock->pDataBlock, cols); src = "unlimited"; - STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32); colDataAppend(pColInfo, numOfRows, tmp, false); cols++; pColInfo = taosArrayGet(pBlock->pDataBlock, cols); src = "unlimited"; - STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32); colDataAppend(pColInfo, numOfRows, tmp, false); cols++; pColInfo = taosArrayGet(pBlock->pDataBlock, cols); src = "unlimited"; - STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32); colDataAppend(pColInfo, numOfRows, tmp, false); cols++; pColInfo = taosArrayGet(pBlock->pDataBlock, cols); src = "unlimited"; - STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32); colDataAppend(pColInfo, numOfRows, tmp, false); cols++; pColInfo = taosArrayGet(pBlock->pDataBlock, cols); src = "unlimited"; - STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32); colDataAppend(pColInfo, numOfRows, tmp, false); cols++; pColInfo = taosArrayGet(pBlock->pDataBlock, cols); src = "unlimited"; - STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); + STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32); colDataAppend(pColInfo, numOfRows, tmp, false); numOfRows++; diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index 5aad4af9ac..b3b9927a34 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -119,28 +119,30 @@ static void *mndThreadFp(void *param) { lastTime++; taosMsleep(100); if (mndGetStop(pMnode)) break; + if (lastTime % 10 != 0) continue; - if (lastTime % (tsTtlPushInterval * 10) == 1) { + int64_t sec = lastTime / 10; + if (sec % tsTtlPushInterval == 0) { mndPullupTtl(pMnode); } - if (lastTime % (tsTransPullupInterval * 10) == 0) { + if (sec % tsTransPullupInterval == 0) { mndPullupTrans(pMnode); } - if (lastTime % (tsMqRebalanceInterval * 10) == 0) { + if (sec % tsMqRebalanceInterval == 0) { mndCalMqRebalance(pMnode); } - if (lastTime % (tsTelemInterval * 10) == ((tsTelemInterval - 1) * 10)) { + if (sec % tsTelemInterval == (TMIN(60, (tsTelemInterval - 1)))) { mndPullupTelem(pMnode); } - if (lastTime % (tsGrantHBInterval * 10) == 0) { + if (sec % tsGrantHBInterval == 0) { mndPullupGrant(pMnode); } - if ((lastTime % (tsUptimeInterval * 10)) == ((tsUptimeInterval - 1) * 10)) { + if (sec % tsUptimeInterval == 0) { mndIncreaseUpTime(pMnode); } } @@ -399,15 +401,15 @@ void mndPreClose(SMnode *pMnode) { atomic_store_8(&(pMnode->syncMgmt.leaderTransferFinish), 0); syncLeaderTransfer(pMnode->syncMgmt.sync); - /* - mInfo("vgId:1, mnode start leader transfer"); - // wait for leader transfer finish - while (!atomic_load_8(&(pMnode->syncMgmt.leaderTransferFinish))) { - taosMsleep(10); - mInfo("vgId:1, mnode waiting for leader transfer"); - } - mInfo("vgId:1, mnode finish leader transfer"); - */ +#if 0 + mInfo("vgId:1, mnode start leader transfer"); + // wait for leader transfer finish + while (!atomic_load_8(&(pMnode->syncMgmt.leaderTransferFinish))) { + taosMsleep(10); + mInfo("vgId:1, mnode waiting for leader transfer"); + } + mInfo("vgId:1, mnode finish leader transfer"); +#endif } } @@ -647,7 +649,7 @@ int32_t mndProcessRpcMsg(SRpcMsg *pMsg) { void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp) { tmsg_t type = TMSG_INDEX(msgType); - if (type >= 0 && type < TDMT_MAX) { + if (type < TDMT_MAX) { pMnode->msgFp[type] = fp; } } diff --git a/source/dnode/mnode/impl/src/mndMnode.c b/source/dnode/mnode/impl/src/mndMnode.c index a41f958c0f..cfb362c51c 100644 --- a/source/dnode/mnode/impl/src/mndMnode.c +++ b/source/dnode/mnode/impl/src/mndMnode.c @@ -93,6 +93,7 @@ static int32_t mndCreateDefaultMnode(SMnode *pMnode) { STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL, "create-mnode"); if (pTrans == NULL) { + sdbFreeRaw(pRaw); mError("mnode:%d, failed to create since %s", mnodeObj.id, terrstr()); return -1; } @@ -220,8 +221,12 @@ bool mndIsMnode(SMnode *pMnode, int32_t dnodeId) { void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) { SSdb *pSdb = pMnode->pSdb; int32_t totalMnodes = sdbGetSize(pSdb, SDB_MNODE); - void *pIter = NULL; + if (totalMnodes == 0) { + syncGetRetryEpSet(pMnode->syncMgmt.sync, pEpSet); + return; + } + void *pIter = NULL; while (1) { SMnodeObj *pObj = NULL; pIter = sdbFetch(pSdb, SDB_MNODE, pIter, (void **)&pObj); @@ -658,7 +663,7 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB colDataAppend(pColInfo, numOfRows, (const char *)&pObj->id, false); char b1[TSDB_EP_LEN + VARSTR_HEADER_SIZE] = {0}; - STR_WITH_MAXSIZE_TO_VARSTR(b1, pObj->pDnode->ep, pShow->pMeta->pSchemas[cols].bytes); + STR_WITH_MAXSIZE_TO_VARSTR(b1, pObj->pDnode->ep, TSDB_EP_LEN + VARSTR_HEADER_SIZE); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, numOfRows, b1, false); @@ -667,7 +672,7 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB if (pObj->id == pMnode->selfDnodeId) { roles = syncStr(TAOS_SYNC_STATE_LEADER); } - if (pObj->pDnode && mndIsDnodeOnline(pObj->pDnode, curMs)) { + if (mndIsDnodeOnline(pObj->pDnode, curMs)) { roles = syncStr(pObj->state); if (pObj->state == TAOS_SYNC_STATE_LEADER && pObj->id != pMnode->selfDnodeId) { roles = syncStr(TAOS_SYNC_STATE_ERROR); diff --git a/source/dnode/mnode/impl/src/mndPerfSchema.c b/source/dnode/mnode/impl/src/mndPerfSchema.c index fe8d1a0a0e..cb636dc037 100644 --- a/source/dnode/mnode/impl/src/mndPerfSchema.c +++ b/source/dnode/mnode/impl/src/mndPerfSchema.c @@ -26,7 +26,7 @@ int32_t mndInitPerfsTableSchema(const SSysDbTableSchema *pSrc, int32_t colNum, S } for (int32_t i = 0; i < colNum; ++i) { - strcpy(schema[i].name, pSrc[i].name); + tstrncpy(schema[i].name, pSrc[i].name, sizeof(schema[i].name)); schema[i].type = pSrc[i].type; schema[i].colId = i + 1; @@ -40,7 +40,7 @@ int32_t mndInitPerfsTableSchema(const SSysDbTableSchema *pSrc, int32_t colNum, S int32_t mndPerfsInitMeta(SHashObj *hash) { STableMetaRsp meta = {0}; - strcpy(meta.dbFName, TSDB_INFORMATION_SCHEMA_DB); + tstrncpy(meta.dbFName, TSDB_INFORMATION_SCHEMA_DB, sizeof(meta.dbFName)); meta.tableType = TSDB_SYSTEM_TABLE; meta.sversion = 1; meta.tversion = 1; @@ -50,7 +50,7 @@ int32_t mndPerfsInitMeta(SHashObj *hash) { getPerfDbMeta(&pSysDbTableMeta, &size); for (int32_t i = 0; i < size; ++i) { - strcpy(meta.tbName, pSysDbTableMeta[i].name); + tstrncpy(meta.tbName, pSysDbTableMeta[i].name, sizeof(meta.tbName)); meta.numOfColumns = pSysDbTableMeta[i].colNum; if (mndInitPerfsTableSchema(pSysDbTableMeta[i].schema, pSysDbTableMeta[i].colNum, &meta.pSchemas)) { diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index e8737e30c9..1909b168bd 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -664,7 +664,7 @@ static int32_t mndProcessKillConnReq(SRpcMsg *pReq) { static int32_t mndProcessSvrVerReq(SRpcMsg *pReq) { int32_t code = -1; SServerVerRsp rsp = {0}; - strcpy(rsp.ver, version); + tstrncpy(rsp.ver, version, sizeof(rsp.ver)); int32_t contLen = tSerializeSServerVerRsp(NULL, 0, &rsp); if (contLen < 0) goto _over; @@ -702,7 +702,7 @@ static int32_t mndRetrieveConns(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl break; } - if ((taosGetTimestampMs() - pConn->lastAccessTimeMs) > (keepTime * 1000)) { + if ((taosGetTimestampMs() - pConn->lastAccessTimeMs) > ((int64_t)keepTime * 1000)) { continue; } diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index e0b5bb1abf..38c7850e6c 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -834,6 +834,8 @@ static int32_t mndProcessTtlTimer(SRpcMsg *pReq) { int32_t reqLen = tSerializeSVDropTtlTableReq(NULL, 0, &ttlReq); int32_t contLen = reqLen + sizeof(SMsgHead); + mInfo("start to process ttl timer"); + while (1) { pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); if (pIter == NULL) break; @@ -2579,3 +2581,14 @@ static void mndCancelGetNextStb(SMnode *pMnode, void *pIter) { SSdb *pSdb = pMnode->pSdb; sdbCancelFetch(pSdb, pIter); } + +const char *mndGetStbStr(const char *src) { + char *posDb = strstr(src, TS_PATH_DELIMITER); + if (posDb != NULL) ++posDb; + if (posDb == NULL) return src; + + char *posStb = strstr(posDb, TS_PATH_DELIMITER); + if (posStb != NULL) ++posStb; + if (posStb == NULL) return posDb; + return posStb; +} \ No newline at end of file diff --git a/source/dnode/mnode/impl/src/mndSubscribe.c b/source/dnode/mnode/impl/src/mndSubscribe.c index 21e45407fd..f2fec27bc5 100644 --- a/source/dnode/mnode/impl/src/mndSubscribe.c +++ b/source/dnode/mnode/impl/src/mndSubscribe.c @@ -123,7 +123,7 @@ static int32_t mndBuildSubChangeReq(void **pBuf, int32_t *pLen, const SMqSubscri req.subType = pSub->subType; req.withMeta = pSub->withMeta; req.suid = pSub->stbUid; - strncpy(req.subKey, pSub->key, TSDB_SUBSCRIBE_KEY_LEN); + tstrncpy(req.subKey, pSub->key, TSDB_SUBSCRIBE_KEY_LEN); int32_t tlen = sizeof(SMsgHead) + tEncodeSMqRebVgReq(NULL, &req); void *buf = taosMemoryMalloc(tlen); diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index 3655289f99..aabde3fed2 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -68,7 +68,7 @@ void mndSyncCommitMsg(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbM if (pMgmt->errCode != 0) { mError("trans:%d, failed to propose since %s, post sem", transId, tstrerror(pMgmt->errCode)); } else { - mInfo("trans:%d, is proposed and post sem", transId, tstrerror(pMgmt->errCode)); + mInfo("trans:%d, is proposed and post sem", transId); } pMgmt->transId = 0; taosWUnLockLatch(&pMgmt->lock); @@ -113,13 +113,13 @@ void mndRestoreFinish(struct SSyncFSM *pFsm) { } } -void mndReConfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReConfigCbMeta cbMeta) { +void mndReConfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReConfigCbMeta *cbMeta) { SMnode *pMnode = pFsm->data; SSyncMgmt *pMgmt = &pMnode->syncMgmt; - pMgmt->errCode = cbMeta.code; + pMgmt->errCode = cbMeta->code; mInfo("trans:-1, sync reconfig is proposed, saved:%d code:0x%x, index:%" PRId64 " term:%" PRId64, pMgmt->transId, - cbMeta.code, cbMeta.index, cbMeta.term); + cbMeta->code, cbMeta->index, cbMeta->term); taosWLockLatch(&pMgmt->lock); if (pMgmt->transId == -1) { @@ -127,7 +127,7 @@ void mndReConfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReConfigCbMeta cbM mError("trans:-1, failed to propose sync reconfig since %s, post sem", tstrerror(pMgmt->errCode)); } else { mInfo("trans:-1, sync reconfig is proposed, saved:%d code:0x%x, index:%" PRId64 " term:%" PRId64 " post sem", - pMgmt->transId, cbMeta.code, cbMeta.index, cbMeta.term); + pMgmt->transId, cbMeta->code, cbMeta->index, cbMeta->term); } pMgmt->transId = 0; tsem_post(&pMgmt->syncSem); @@ -271,6 +271,11 @@ void mndCleanupSync(SMnode *pMnode) { int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) { SSyncMgmt *pMgmt = &pMnode->syncMgmt; SRpcMsg req = {.msgType = TDMT_MND_APPLY_MSG, .contLen = sdbGetRawTotalSize(pRaw)}; + if (req.contLen <= 0) { + terrno = TSDB_CODE_APP_ERROR; + return -1; + } + req.pCont = rpcMallocCont(req.contLen); if (req.pCont == NULL) return -1; memcpy(req.pCont, pRaw, req.contLen); @@ -278,7 +283,7 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) { pMgmt->errCode = 0; taosWLockLatch(&pMgmt->lock); if (pMgmt->transId != 0) { - mError("trans:%d, can't be proposed since trans:%s alrady waiting for confirm", transId, pMgmt->transId); + mError("trans:%d, can't be proposed since trans:%d alrady waiting for confirm", transId, pMgmt->transId); taosWUnLockLatch(&pMgmt->lock); terrno = TSDB_CODE_APP_NOT_READY; return -1; diff --git a/source/dnode/mnode/impl/src/mndTelem.c b/source/dnode/mnode/impl/src/mndTelem.c index 93f7531a27..ff2461b63b 100644 --- a/source/dnode/mnode/impl/src/mndTelem.c +++ b/source/dnode/mnode/impl/src/mndTelem.c @@ -133,7 +133,7 @@ static int32_t mndProcessTelemTimer(SRpcMsg* pReq) { if (taosSendHttpReport(tsTelemServer, tsTelemPort, pCont, strlen(pCont), HTTP_FLAT) != 0) { mError("failed to send telemetry report"); } else { - mTrace("succeed to send telemetry report"); + mInfo("succeed to send telemetry report"); } taosMemoryFree(pCont); } diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index b9647a28fb..ce195454f8 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -379,6 +379,8 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq * topicObj.ast = strdup(pCreate->ast); topicObj.astLen = strlen(pCreate->ast) + 1; + qDebugL("ast %s", topicObj.ast); + SNode *pAst = NULL; if (nodesStringToNode(pCreate->ast, &pAst) != 0) { taosMemoryFree(topicObj.ast); @@ -774,7 +776,7 @@ static int32_t mndRetrieveTopic(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl SName n; int32_t cols = 0; - char topicName[TSDB_TOPIC_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; + char topicName[TSDB_TOPIC_NAME_LEN + VARSTR_HEADER_SIZE + 5] = {0}; strcpy(varDataVal(topicName), mndGetDbStr(pTopic->name)); /*tNameFromString(&n, pTopic->name, T_NAME_ACCT | T_NAME_DB);*/ /*tNameGetDbName(&n, varDataVal(topicName));*/ diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index b26fb16043..455b71ace9 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -427,7 +427,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { terrno = 0; _OVER: - if (terrno != 0) { + if (terrno != 0 && pTrans != NULL) { mError("trans:%d, failed to parse from raw:%p since %s", pTrans->id, pRaw, terrstr()); mndTransDropData(pTrans); taosMemoryFreeClear(pRow); @@ -629,6 +629,7 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict, pTrans->pRpcArray == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; mError("failed to create transaction since %s", terrstr()); + mndTransDrop(pTrans); return NULL; } @@ -1428,6 +1429,7 @@ static bool mndTransPerfromFinishedStage(SMnode *pMnode, STrans *pTrans) { SSdbRaw *pRaw = mndTransActionEncode(pTrans); if (pRaw == NULL) { mError("trans:%d, failed to encode while finish trans since %s", pTrans->id, terrstr()); + return false; } sdbSetRawStatus(pRaw, SDB_STATUS_DROPPED); @@ -1478,6 +1480,7 @@ void mndTransExecute(SMnode *pMnode, STrans *pTrans) { } static int32_t mndProcessTransTimer(SRpcMsg *pReq) { + mTrace("start to process trans timer"); mndTransPullup(pReq->info.node); return 0; } @@ -1604,7 +1607,7 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, numOfRows, (const char *)dbname, false); - char stbname[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; + char stbname[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(stbname, mndGetDbStr(pTrans->stbname), pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, numOfRows, (const char *)stbname, false); @@ -1616,7 +1619,7 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl colDataAppend(pColInfo, numOfRows, (const char *)&pTrans->lastExecTime, false); char lastInfo[TSDB_TRANS_ERROR_LEN + VARSTR_HEADER_SIZE] = {0}; - char detail[TSDB_TRANS_ERROR_LEN] = {0}; + char detail[TSDB_TRANS_ERROR_LEN + 1] = {0}; int32_t len = snprintf(detail, sizeof(detail), "action:%d code:0x%x(%s) ", pTrans->lastAction, pTrans->lastErrorNo & 0xFFFF, tstrerror(pTrans->lastErrorNo)); SEpSet epset = pTrans->lastEpset; diff --git a/source/dnode/mnode/impl/src/mndUser.c b/source/dnode/mnode/impl/src/mndUser.c index 5512fa4107..fecdfb12ba 100644 --- a/source/dnode/mnode/impl/src/mndUser.c +++ b/source/dnode/mnode/impl/src/mndUser.c @@ -83,6 +83,7 @@ static int32_t mndCreateDefaultUser(SMnode *pMnode, char *acct, char *user, char STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, "create-user"); if (pTrans == NULL) { + sdbFreeRaw(pRaw); mError("user:%s, failed to create since %s", userObj.user, terrstr()); return -1; } diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index c1bc340819..a0f01f41d8 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -1250,7 +1250,7 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, mError("db:%s, vgId:%d, no enough memory:%" PRId64 " in dnode:%d avail:%" PRId64 " used:%" PRId64, pVgroup->dbName, pVgroup->vgId, vgMem, pNew1->id, pNew1->memAvail, pNew1->memUsed); terrno = TSDB_CODE_MND_NO_ENOUGH_MEM_IN_DNODE; - return -1; + goto _OVER; } else { pNew1->memUsed += vgMem; } @@ -1272,7 +1272,7 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, mError("db:%s, vgId:%d, no enough memory:%" PRId64 " in dnode:%d avail:%" PRId64 " used:%" PRId64, pVgroup->dbName, pVgroup->vgId, vgMem, pNew2->id, pNew2->memAvail, pNew2->memUsed); terrno = TSDB_CODE_MND_NO_ENOUGH_MEM_IN_DNODE; - return -1; + goto _OVER; } else { pNew2->memUsed += vgMem; } @@ -1293,7 +1293,7 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, mError("db:%s, vgId:%d, no enough memory:%" PRId64 " in dnode:%d avail:%" PRId64 " used:%" PRId64, pVgroup->dbName, pVgroup->vgId, vgMem, pNew3->id, pNew3->memAvail, pNew3->memUsed); terrno = TSDB_CODE_MND_NO_ENOUGH_MEM_IN_DNODE; - return -1; + goto _OVER; } else { pNew3->memUsed += vgMem; } @@ -1627,7 +1627,7 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj } else if (newVg1.replica == 3) { SVnodeGid del1 = {0}; if (mndRemoveVnodeFromVgroup(pMnode, &newVg1, pArray, &del1) != 0) goto _OVER; - if (mndAddSetVnodeStandByAction(pMnode, pTrans, pDb, pVgroup, &del1, true) != 0) return -1; + if (mndAddSetVnodeStandByAction(pMnode, pTrans, pDb, pVgroup, &del1, true) != 0) goto _OVER; if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVg1, TDMT_VND_ALTER_REPLICA) != 0) goto _OVER; if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg1, &del1, true) != 0) goto _OVER; if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg1) != 0) goto _OVER; diff --git a/source/dnode/mnode/sdb/src/sdbFile.c b/source/dnode/mnode/sdb/src/sdbFile.c index ff0c4b26ef..b5cfa7b0f6 100644 --- a/source/dnode/mnode/sdb/src/sdbFile.c +++ b/source/dnode/mnode/sdb/src/sdbFile.c @@ -514,7 +514,7 @@ static void sdbCloseIter(SSdbIter *pIter) { } if (pIter->name != NULL) { - taosRemoveFile(pIter->name); + (void)taosRemoveFile(pIter->name); taosMemoryFree(pIter->name); pIter->name = NULL; } @@ -606,6 +606,7 @@ int32_t sdbStartWrite(SSdb *pSdb, SSdbIter **ppIter) { if (pIter->file == NULL) { terrno = TAOS_SYSTEM_ERROR(errno); mError("failed to open %s since %s", pIter->name, terrstr()); + sdbCloseIter(pIter); return -1; } @@ -636,9 +637,9 @@ int32_t sdbStopWrite(SSdb *pSdb, SSdbIter *pIter, bool isApply, int64_t index, i return -1; } - sdbCloseIter(pIter); if (sdbReadFile(pSdb) != 0) { mError("sdbiter:%p, failed to read from %s since %s", pIter, datafile, terrstr()); + sdbCloseIter(pIter); return -1; } @@ -656,6 +657,7 @@ int32_t sdbStopWrite(SSdb *pSdb, SSdbIter *pIter, bool isApply, int64_t index, i } mInfo("sdbiter:%p, success applyed to sdb", pIter); + sdbCloseIter(pIter); return 0; } diff --git a/source/dnode/mnode/sdb/src/sdbHash.c b/source/dnode/mnode/sdb/src/sdbHash.c index a102541aca..ecdf8c71a7 100644 --- a/source/dnode/mnode/sdb/src/sdbHash.c +++ b/source/dnode/mnode/sdb/src/sdbHash.c @@ -40,6 +40,8 @@ const char *sdbTableName(ESdbType type) { return "auth"; case SDB_ACCT: return "acct"; + case SDB_STREAM_CK: + return "stream_ck"; case SDB_STREAM: return "stream"; case SDB_OFFSET: @@ -219,14 +221,15 @@ static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow * return terrno; } SSdbRow *pOldRow = *ppOldRow; - pOldRow->status = pRaw->status; + + atomic_add_fetch_32(&pOldRow->refCount, 1); sdbPrintOper(pSdb, pOldRow, "delete"); taosHashRemove(hash, pOldRow->pObj, keySize); + pSdb->tableVer[pOldRow->type]++; taosThreadRwlockUnlock(pLock); - pSdb->tableVer[pOldRow->type]++; sdbFreeRow(pSdb, pRow, false); sdbCheckRow(pSdb, pOldRow); @@ -315,7 +318,7 @@ static void sdbCheckRow(SSdb *pSdb, SSdbRow *pRow) { TdThreadRwlock *pLock = &pSdb->locks[pRow->type]; taosThreadRwlockWrlock(pLock); - int32_t ref = atomic_load_32(&pRow->refCount); + int32_t ref = atomic_sub_fetch_32(&pRow->refCount, 1); sdbPrintOper(pSdb, pRow, "check"); if (ref <= 0 && pRow->status == SDB_STATUS_DROPPED) { sdbFreeRow(pSdb, pRow, true); diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 6ba10641f5..fec050b5ea 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -62,7 +62,9 @@ void vnodeGetSnapshot(SVnode *pVnode, SSnapshot *pSnapshot); void vnodeGetInfo(SVnode *pVnode, const char **dbname, int32_t *vgId); int32_t vnodeProcessCreateTSma(SVnode *pVnode, void *pCont, uint32_t contLen); int32_t vnodeGetAllTableList(SVnode *pVnode, uint64_t uid, SArray *list); + int32_t vnodeGetCtbIdList(SVnode *pVnode, int64_t suid, SArray *list); +int32_t vnodeGetCtbIdListByFilter(SVnode *pVnode, int64_t suid, SArray *list, bool (*filter)(void *arg), void *arg); int32_t vnodeGetStbIdList(SVnode *pVnode, int64_t suid, SArray *list); void *vnodeGetIdx(SVnode *pVnode); void *vnodeGetIvtIdx(SVnode *pVnode); @@ -92,10 +94,14 @@ typedef struct SMetaEntry SMetaEntry; void metaReaderInit(SMetaReader *pReader, SMeta *pMeta, int32_t flags); void metaReaderClear(SMetaReader *pReader); int32_t metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid); +int metaGetTableEntryByName(SMetaReader *pReader, const char *name); int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj *tags); +int32_t metaGetTableTagsOpt(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj *tags); int32_t metaReadNext(SMetaReader *pReader); const void *metaGetTableTagVal(void *tag, int16_t type, STagVal *tagVal); int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName); +int metaGetTableUidByName(void *meta, char *tbName, uint64_t *uid); +int metaGetTableTypeByName(void *meta, char *tbName, ETableType *tbType); bool metaIsTableExist(SMeta *pMeta, tb_uid_t uid); typedef struct SMetaFltParam { @@ -153,7 +159,7 @@ uint64_t getReaderMaxVersion(STsdbReader *pReader); int32_t tsdbCacherowsReaderOpen(void *pVnode, int32_t type, SArray *pTableIdList, int32_t numOfCols, void **pReader); int32_t tsdbRetrieveCacheRows(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, SArray *pTableUids); -int32_t tsdbCacherowsReaderClose(void *pReader); +void* tsdbCacherowsReaderClose(void *pReader); int32_t tsdbGetTableSchema(SVnode *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid); void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity); @@ -217,7 +223,7 @@ int32_t tqReaderRemoveTbUidList(STqReader *pReader, const SArray *tbUidList); int32_t tqSeekVer(STqReader *pReader, int64_t ver); int32_t tqNextBlock(STqReader *pReader, SFetchRet *ret); -int32_t tqReaderSetDataMsg(STqReader *pReader, SSubmitReq *pMsg, int64_t ver); +int32_t tqReaderSetDataMsg(STqReader *pReader, const SSubmitReq *pMsg, int64_t ver); bool tqNextDataBlock(STqReader *pReader); bool tqNextDataBlockFilterOut(STqReader *pReader, SHashObj *filterOutUids); int32_t tqRetrieveDataBlock(SSDataBlock *pBlock, STqReader *pReader); diff --git a/source/dnode/vnode/src/inc/tq.h b/source/dnode/vnode/src/inc/tq.h index c3441a43f0..f96afe6fba 100644 --- a/source/dnode/vnode/src/inc/tq.h +++ b/source/dnode/vnode/src/inc/tq.h @@ -113,10 +113,20 @@ typedef struct { } STqHandle; +typedef struct { + SMqDataRsp dataRsp; + SMqRspHead rspHead; + char subKey[TSDB_SUBSCRIBE_KEY_LEN]; + SRpcHandleInfo pInfo; +} STqPushEntry; + struct STQ { - SVnode* pVnode; - char* path; - SHashObj* pPushMgr; // consumerId -> STqHandle* + SVnode* pVnode; + char* path; + + SRWLatch pushLock; + + SHashObj* pPushMgr; // consumerId -> STqPushEntry SHashObj* pHandle; // subKey -> STqHandle SHashObj* pCheckInfo; // topic -> SAlterCheckInfo @@ -146,7 +156,9 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHea // tqExec int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SSubmitReq* pReq, STaosxRsp* pRsp); +int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols); int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp); +int32_t tqPushDataRsp(STQ* pTq, STqPushEntry* pPushEntry); // tqMeta int32_t tqMetaOpen(STQ* pTq); diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index 817089f237..75b2f74096 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -32,6 +32,12 @@ extern "C" { #define tsdbTrace(...) do { if (tsdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TSD ", DEBUG_TRACE, tsdbDebugFlag, __VA_ARGS__); }} while(0) // clang-format on +#define TSDB_CHECK_CODE(CODE, LINO, LABEL) \ + if (CODE) { \ + LINO = __LINE__; \ + goto LABEL; \ + } + typedef struct TSDBROW TSDBROW; typedef struct TABLEID TABLEID; typedef struct TSDBKEY TSDBKEY; @@ -88,9 +94,8 @@ typedef struct SLDataIter SLDataIter; static FORCE_INLINE int64_t tsdbLogicToFileSize(int64_t lSize, int32_t szPage) { int64_t fOffSet = LOGIC_TO_FILE_OFFSET(lSize, szPage); int64_t pgno = OFFSET_PGNO(fOffSet, szPage); - int32_t szPageCont = PAGE_CONTENT_SIZE(szPage); - if (fOffSet % szPageCont == 0) { + if (fOffSet % szPage == 0) { pgno--; } @@ -151,7 +156,7 @@ int32_t tCmprBlockL(void const *lhs, void const *rhs); int32_t tBlockDataCreate(SBlockData *pBlockData); void tBlockDataDestroy(SBlockData *pBlockData, int8_t deepClear); -int32_t tBlockDataInit(SBlockData *pBlockData, int64_t suid, int64_t uid, STSchema *pTSchema); +int32_t tBlockDataInit(SBlockData *pBlockData, TABLEID *pId, STSchema *pTSchema, int16_t *aCid, int32_t nCid); int32_t tBlockDataInitEx(SBlockData *pBlockData, SBlockData *pBlockDataFrom); void tBlockDataReset(SBlockData *pBlockData); int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTSchema, int64_t uid); @@ -273,6 +278,7 @@ int32_t tsdbReadSttBlk(SDataFReader *pReader, int32_t iStt, SArray *aSttBlk); int32_t tsdbReadBlockSma(SDataFReader *pReader, SDataBlk *pBlock, SArray *aColumnDataAgg); int32_t tsdbReadDataBlock(SDataFReader *pReader, SDataBlk *pBlock, SBlockData *pBlockData); int32_t tsdbReadSttBlock(SDataFReader *pReader, int32_t iStt, SSttBlk *pSttBlk, SBlockData *pBlockData); +int32_t tsdbReadSttBlockEx(SDataFReader *pReader, int32_t iStt, SSttBlk *pSttBlk, SBlockData *pBlockData); // SDelFWriter int32_t tsdbDelFWriterOpen(SDelFWriter **ppWriter, SDelFile *pFile, STsdb *pTsdb); int32_t tsdbDelFWriterClose(SDelFWriter **ppWriter, int8_t sync); @@ -285,8 +291,8 @@ int32_t tsdbDelFReaderClose(SDelFReader **ppReader); int32_t tsdbReadDelData(SDelFReader *pReader, SDelIdx *pDelIdx, SArray *aDelData); int32_t tsdbReadDelIdx(SDelFReader *pReader, SArray *aDelIdx); // tsdbRead.c ============================================================================================== -int32_t tsdbTakeReadSnap(STsdb *pTsdb, STsdbReadSnap **ppSnap, const char* id); -void tsdbUntakeReadSnap(STsdb *pTsdb, STsdbReadSnap *pSnap, const char* id); +int32_t tsdbTakeReadSnap(STsdb *pTsdb, STsdbReadSnap **ppSnap, const char *id); +void tsdbUntakeReadSnap(STsdb *pTsdb, STsdbReadSnap *pSnap, const char *id); // tsdbMerge.c ============================================================================================== int32_t tsdbMerge(STsdb *pTsdb); @@ -634,6 +640,9 @@ typedef struct SSttBlockLoadInfo { int32_t currentLoadBlockIndex; int32_t loadBlocks; double elapsedTime; + STSchema *pSchema; + int16_t *colIds; + int32_t numOfCols; } SSttBlockLoadInfo; typedef struct SMergeTree { @@ -653,13 +662,14 @@ typedef struct { } SSkmInfo; int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFReader, uint64_t suid, uint64_t uid, - STimeWindow *pTimeWindow, SVersionRange *pVerRange, void *pLoadInfo, const char *idStr); + STimeWindow *pTimeWindow, SVersionRange *pVerRange, SSttBlockLoadInfo *pBlockLoadInfo, + bool destroyLoadInfo, const char *idStr); void tMergeTreeAddIter(SMergeTree *pMTree, SLDataIter *pIter); bool tMergeTreeNext(SMergeTree *pMTree); TSDBROW tMergeTreeGetRow(SMergeTree *pMTree); void tMergeTreeClose(SMergeTree *pMTree); -SSttBlockLoadInfo *tCreateLastBlockLoadInfo(); +SSttBlockLoadInfo *tCreateLastBlockLoadInfo(STSchema *pSchema, int16_t *colList, int32_t numOfCols); void resetLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo); void getLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo, int64_t *blocks, double *el); void *destroyLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo); diff --git a/source/dnode/vnode/src/inc/vnd.h b/source/dnode/vnode/src/inc/vnd.h index 898e79928b..900d29b97e 100644 --- a/source/dnode/vnode/src/inc/vnd.h +++ b/source/dnode/vnode/src/inc/vnd.h @@ -99,7 +99,6 @@ void vnodeSyncStart(SVnode* pVnode); void vnodeSyncClose(SVnode* pVnode); void vnodeRedirectRpcMsg(SVnode* pVnode, SRpcMsg* pMsg); bool vnodeIsLeader(SVnode* pVnode); -bool vnodeIsReadyForRead(SVnode* pVnode); bool vnodeIsRoleLeader(SVnode* pVnode); #ifdef __cplusplus diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index 4c8045d651..ec570b4540 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -111,22 +111,23 @@ SSchemaWrapper* metaGetTableSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver, boo STSchema* metaGetTbTSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver); int32_t metaGetTbTSchemaEx(SMeta* pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sver, STSchema** ppTSchema); int metaGetTableEntryByName(SMetaReader* pReader, const char* name); -tb_uid_t metaGetTableEntryUidByName(SMeta* pMeta, const char* name); -int64_t metaGetTbNum(SMeta* pMeta); -int64_t metaGetTimeSeriesNum(SMeta* pMeta); -SMCtbCursor* metaOpenCtbCursor(SMeta* pMeta, tb_uid_t uid); -void metaCloseCtbCursor(SMCtbCursor* pCtbCur); -tb_uid_t metaCtbCursorNext(SMCtbCursor* pCtbCur); -SMStbCursor* metaOpenStbCursor(SMeta* pMeta, tb_uid_t uid); -void metaCloseStbCursor(SMStbCursor* pStbCur); -tb_uid_t metaStbCursorNext(SMStbCursor* pStbCur); -STSma* metaGetSmaInfoByIndex(SMeta* pMeta, int64_t indexUid); -STSmaWrapper* metaGetSmaInfoByTable(SMeta* pMeta, tb_uid_t uid, bool deepCopy); -SArray* metaGetSmaIdsByTable(SMeta* pMeta, tb_uid_t uid); -SArray* metaGetSmaTbUids(SMeta* pMeta); -void* metaGetIdx(SMeta* pMeta); -void* metaGetIvtIdx(SMeta* pMeta); -int metaTtlSmaller(SMeta* pMeta, uint64_t time, SArray* uidList); + +tb_uid_t metaGetTableEntryUidByName(SMeta* pMeta, const char* name); +int64_t metaGetTbNum(SMeta* pMeta); +int64_t metaGetTimeSeriesNum(SMeta* pMeta); +SMCtbCursor* metaOpenCtbCursor(SMeta* pMeta, tb_uid_t uid); +void metaCloseCtbCursor(SMCtbCursor* pCtbCur); +tb_uid_t metaCtbCursorNext(SMCtbCursor* pCtbCur); +SMStbCursor* metaOpenStbCursor(SMeta* pMeta, tb_uid_t uid); +void metaCloseStbCursor(SMStbCursor* pStbCur); +tb_uid_t metaStbCursorNext(SMStbCursor* pStbCur); +STSma* metaGetSmaInfoByIndex(SMeta* pMeta, int64_t indexUid); +STSmaWrapper* metaGetSmaInfoByTable(SMeta* pMeta, tb_uid_t uid, bool deepCopy); +SArray* metaGetSmaIdsByTable(SMeta* pMeta, tb_uid_t uid); +SArray* metaGetSmaTbUids(SMeta* pMeta); +void* metaGetIdx(SMeta* pMeta); +void* metaGetIvtIdx(SMeta* pMeta); +int metaTtlSmaller(SMeta* pMeta, uint64_t time, SArray* uidList); int32_t metaCreateTSma(SMeta* pMeta, int64_t version, SSmaCfg* pCfg); int32_t metaDropTSma(SMeta* pMeta, int64_t indexUid); @@ -184,8 +185,9 @@ int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessTaskRetrieveReq(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessTaskRetrieveRsp(STQ* pTq, SRpcMsg* pMsg); -SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchema* pSchema, SSchemaWrapper* pTagSchemaWrapper, bool createTb, int64_t suid, - const char* stbFullName, SBatchDeleteReq* pDeleteReq); +SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchema* pSchema, + SSchemaWrapper* pTagSchemaWrapper, bool createTb, int64_t suid, const char* stbFullName, + SBatchDeleteReq* pDeleteReq); // sma int32_t smaInit(); diff --git a/source/dnode/vnode/src/meta/metaOpen.c b/source/dnode/vnode/src/meta/metaOpen.c index f8ecd17cb7..034d6260da 100644 --- a/source/dnode/vnode/src/meta/metaOpen.c +++ b/source/dnode/vnode/src/meta/metaOpen.c @@ -200,36 +200,30 @@ int metaClose(SMeta *pMeta) { int32_t metaRLock(SMeta *pMeta) { int32_t ret = 0; - metaTrace("meta rlock %p B", &pMeta->lock); + metaTrace("meta rlock %p", &pMeta->lock); ret = taosThreadRwlockRdlock(&pMeta->lock); - metaTrace("meta rlock %p E", &pMeta->lock); - return ret; } int32_t metaWLock(SMeta *pMeta) { int32_t ret = 0; - metaTrace("meta wlock %p B", &pMeta->lock); + metaTrace("meta wlock %p", &pMeta->lock); ret = taosThreadRwlockWrlock(&pMeta->lock); - metaTrace("meta wlock %p E", &pMeta->lock); - return ret; } int32_t metaULock(SMeta *pMeta) { int32_t ret = 0; - metaTrace("meta ulock %p B", &pMeta->lock); + metaTrace("meta ulock %p", &pMeta->lock); ret = taosThreadRwlockUnlock(&pMeta->lock); - metaTrace("meta ulock %p E", &pMeta->lock); - return ret; } diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index f549ef84f8..d499db4958 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -202,6 +202,38 @@ int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName) { return 0; } +int metaGetTableUidByName(void *meta, char *tbName, uint64_t *uid) { + int code = 0; + SMetaReader mr = {0}; + metaReaderInit(&mr, (SMeta *)meta, 0); + + SMeta *pMeta = mr.pMeta; + SMetaReader *pReader = &mr; + + // query name.idx + if (tdbTbGet(pMeta->pNameIdx, tbName, strlen(tbName) + 1, &pReader->pBuf, &pReader->szBuf) < 0) { + terrno = TSDB_CODE_PAR_TABLE_NOT_EXIST; + metaReaderClear(&mr); + return -1; + } + + *uid = *(tb_uid_t *)pReader->pBuf; + metaReaderClear(&mr); + + return 0; +} + +int metaGetTableTypeByName(void *meta, char *tbName, ETableType *tbType) { + int code = 0; + SMetaReader mr = {0}; + metaReaderInit(&mr, (SMeta *)meta, 0); + + if (metaGetTableEntryByName(&mr, tbName) == 0) { + *tbType = mr.me.type; + } + metaReaderClear(&mr); + return 0; +} int metaReadNext(SMetaReader *pReader) { SMeta *pMeta = pReader->pMeta; @@ -872,7 +904,7 @@ SArray *metaGetSmaIdsByTable(SMeta *pMeta, tb_uid_t uid) { pSmaIdxKey = (SSmaIdxKey *)pCur->pKey; - if (taosArrayPush(pUids, &pSmaIdxKey->smaUid) < 0) { + if (!taosArrayPush(pUids, &pSmaIdxKey->smaUid)) { terrno = TSDB_CODE_OUT_OF_MEMORY; metaCloseSmaCursor(pCur); taosArrayDestroy(pUids); @@ -915,7 +947,7 @@ SArray *metaGetSmaTbUids(SMeta *pMeta) { } } - if (taosArrayPush(pUids, &uid) < 0) { + if (!taosArrayPush(pUids, &uid)) { terrno = TSDB_CODE_OUT_OF_MEMORY; metaCloseSmaCursor(pCur); taosArrayDestroy(pUids); @@ -1102,6 +1134,21 @@ END: return ret; } +int32_t metaGetTableTagsOpt(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj *tags) { + int32_t sz = uidList ? taosArrayGetSize(uidList) : 0; + for (int i = 0; i < sz; i++) { + tb_uid_t *id = taosArrayGet(uidList, i); + SCtbIdxKey ctbIdxKey = {.suid = suid, .uid = *id}; + + void *val = NULL; + int32_t len = 0; + if (taosHashGet(tags, id, sizeof(tb_uid_t)) == NULL && + 0 == tdbTbGet(pMeta->pCtbIdx, &ctbIdxKey, sizeof(SCtbIdxKey), &val, &len)) { + taosHashPut(tags, id, sizeof(tb_uid_t), val, len); + } + } + return 0; +} int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj *tags) { SMCtbCursor *pCur = metaOpenCtbCursor(pMeta, suid); diff --git a/source/dnode/vnode/src/sma/smaCommit.c b/source/dnode/vnode/src/sma/smaCommit.c index 2b44cdcef1..fb5caad269 100644 --- a/source/dnode/vnode/src/sma/smaCommit.c +++ b/source/dnode/vnode/src/sma/smaCommit.c @@ -213,7 +213,7 @@ static int32_t tdUpdateQTaskInfoFiles(SSma *pSma, SRSmaStat *pStat) { tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), committed, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFullName); if (taosCheckExistFile(qTaskInfoFullName)) { SQTaskFile qFile = {.nRef = 1, .padding = 0, .version = committed, .size = 0}; - if (taosArrayPush(pFS->aQTaskInf, &qFile) < 0) { + if (!taosArrayPush(pFS->aQTaskInf, &qFile)) { taosWUnLockLatch(RSMA_FS_LOCK(pStat)); terrno = TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_FAILED; diff --git a/source/dnode/vnode/src/sma/smaEnv.c b/source/dnode/vnode/src/sma/smaEnv.c index ccf4ebb39f..64e5e49d0b 100644 --- a/source/dnode/vnode/src/sma/smaEnv.c +++ b/source/dnode/vnode/src/sma/smaEnv.c @@ -386,7 +386,7 @@ int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType) { } break; default: - smaError("vgId:%d, undefined smaType:%", SMA_VID(pSma), smaType); + smaError("vgId:%d, undefined smaType:%" PRIi8, SMA_VID(pSma), smaType); return TSDB_CODE_FAILED; } diff --git a/source/dnode/vnode/src/sma/smaFS.c b/source/dnode/vnode/src/sma/smaFS.c index a5f4e8d2e8..55378751eb 100644 --- a/source/dnode/vnode/src/sma/smaFS.c +++ b/source/dnode/vnode/src/sma/smaFS.c @@ -54,7 +54,7 @@ int32_t tdRSmaFSOpen(SSma *pSma, int64_t version) { if ((terrno = tdRSmaFSUpsertQTaskFile(RSMA_FS(pStat), &qTaskFile)) < 0) { goto _end; } - smaInfo("vgId:%d, open fs, version:%" PRIi64 ", ref:%" PRIi64, TD_VID(pVnode), qTaskFile.version, qTaskFile.nRef); + smaInfo("vgId:%d, open fs, version:%" PRIi64 ", ref:%d", TD_VID(pVnode), qTaskFile.version, qTaskFile.nRef); } _end: diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 8d1525e081..27da9da02c 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -196,7 +196,8 @@ static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids, if (!suid || !tbUids) { terrno = TSDB_CODE_INVALID_PTR; - smaError("vgId:%d, failed to get rsma info for uid:%" PRIi64 " since %s", SMA_VID(pSma), *suid, terrstr()); + smaError("vgId:%d, failed to get rsma info for uid:%" PRIi64 " since %s", SMA_VID(pSma), suid ? *suid : -1, + terrstr()); return TSDB_CODE_FAILED; } @@ -566,6 +567,7 @@ static int32_t tdUidStorePut(STbUidStore *pStore, tb_uid_t suid, tb_uid_t *uid) } if (!taosArrayPush(pUidArray, uid)) { terrno = TSDB_CODE_OUT_OF_MEMORY; + taosArrayDestroy(pUidArray); return TSDB_CODE_FAILED; } if (taosHashPut(pStore->uidHash, &suid, sizeof(suid), &pUidArray, sizeof(pUidArray)) < 0) { @@ -690,7 +692,8 @@ static int32_t tdRSmaExecAndSubmitResult(SSma *pSma, qTaskInfo_t taskInfo, SRSma while (1) { uint64_t ts; - int32_t code = qExecTaskOpt(taskInfo, pResList, &ts, NULL); + bool hasMore = false; + int32_t code = qExecTaskOpt(taskInfo, pResList, &ts, &hasMore, NULL); if (code < 0) { if (code == TSDB_CODE_QRY_IN_EXEC) { break; @@ -1677,13 +1680,13 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) { SRSmaInfoItem *pItem = NULL; if (!(pRSmaRef = taosHashGet(smaMgmt.refHash, ¶m, POINTER_BYTES))) { - smaDebug("rsma fetch task not start since rsma info item:%p not exist in refHash:%p, rsetId:%" PRIi64, param, - *(int64_t *)¶m, smaMgmt.refHash, smaMgmt.rsetId); + smaDebug("rsma fetch task not start since rsma info item:%p not exist in refHash:%p, rsetId:%d", param, + smaMgmt.refHash, smaMgmt.rsetId); return; } if (!(pStat = (SRSmaStat *)tdAcquireSmaRef(smaMgmt.rsetId, pRSmaRef->refId))) { - smaDebug("rsma fetch task not start since rsma stat already destroyed, rsetId:%" PRIi64 " refId:%d)", + smaDebug("rsma fetch task not start since rsma stat already destroyed, rsetId:%d refId:%" PRIi64 ")", smaMgmt.rsetId, pRSmaRef->refId); // pRSmaRef freed in taosHashRemove taosHashRemove(smaMgmt.refHash, ¶m, POINTER_BYTES); return; @@ -1692,7 +1695,7 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) { pSma = pStat->pSma; if (!(pRSmaInfo = tdAcquireRSmaInfoBySuid(pSma, pRSmaRef->suid))) { - smaDebug("rsma fetch task not start since rsma info not exist, rsetId:%" PRIi64 " refId:%d)", smaMgmt.rsetId, + smaDebug("rsma fetch task not start since rsma info not exist, rsetId:%d refId:%" PRIi64 ")", smaMgmt.rsetId, pRSmaRef->refId); // pRSmaRef freed in taosHashRemove tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId); taosHashRemove(smaMgmt.refHash, ¶m, POINTER_BYTES); @@ -1700,7 +1703,7 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) { } if (RSMA_INFO_IS_DEL(pRSmaInfo)) { - smaDebug("rsma fetch task not start since rsma info already deleted, rsetId:%" PRIi64 " refId:%d)", smaMgmt.rsetId, + smaDebug("rsma fetch task not start since rsma info already deleted, rsetId:%d refId:%" PRIi64 ")", smaMgmt.rsetId, pRSmaRef->refId); // pRSmaRef freed in taosHashRemove tdReleaseRSmaInfo(pSma, pRSmaInfo); tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId); @@ -1716,7 +1719,7 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) { case TASK_TRIGGER_STAT_PAUSED: case TASK_TRIGGER_STAT_CANCELLED: { smaDebug("vgId:%d, rsma fetch task not start for level %" PRIi8 " since stat is %" PRIi8 - ", rsetId rsetId:%" PRIi64 " refId:%d", + ", rsetId:%d refId:%" PRIi64, SMA_VID(pSma), pItem->level, rsmaTriggerStat, smaMgmt.rsetId, pRSmaRef->refId); if (rsmaTriggerStat == TASK_TRIGGER_STAT_PAUSED) { taosTmrReset(tdRSmaFetchTrigger, RSMA_FETCH_INTERVAL, pItem, smaMgmt.tmrHandle, &pItem->tmrId); @@ -1844,7 +1847,7 @@ static int32_t tdRSmaBatchExec(SSma *pSma, SRSmaInfo *pInfo, STaosQall *qall, SA void *msg = NULL; taosGetQitem(qall, (void **)&msg); if (msg) { - if (taosArrayPush(pSubmitArr, &msg) < 0) { + if (!taosArrayPush(pSubmitArr, &msg)) { tdFreeRSmaSubmitItems(pSubmitArr); goto _err; } diff --git a/source/dnode/vnode/src/sma/smaSnapshot.c b/source/dnode/vnode/src/sma/smaSnapshot.c index 5a0167a75f..4939fce20c 100644 --- a/source/dnode/vnode/src/sma/smaSnapshot.c +++ b/source/dnode/vnode/src/sma/smaSnapshot.c @@ -70,6 +70,8 @@ int32_t rsmaSnapReaderOpen(SSma* pSma, int64_t sver, int64_t ever, SRSmaSnapRead return TSDB_CODE_SUCCESS; _err: + if (pReader) rsmaSnapReaderClose(&pReader); + *ppReader = NULL; smaError("vgId:%d, vnode snapshot rsma reader open failed since %s", TD_VID(pVnode), tstrerror(code)); return TSDB_CODE_FAILED; } @@ -101,8 +103,8 @@ static int32_t rsmaQTaskInfSnapReaderOpen(SRSmaSnapReader* pReader, int64_t vers if (!taosCheckExistFile(qTaskInfoFullName)) { tdRSmaFSUnRef(pSma, pStat, version); - smaInfo("vgId:%d, vnode snapshot rsma reader for qtaskinfo version %" PRIi64 " not need as %s not exists", - TD_VID(pVnode), qTaskInfoFullName); + smaInfo("vgId:%d, vnode snapshot rsma reader for qtaskinfo version %" PRIi64 " not need as %s not exist", + TD_VID(pVnode), version, qTaskInfoFullName); return TSDB_CODE_SUCCESS; } @@ -336,6 +338,7 @@ int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRSmaSnapWrit tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), 0, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFullName); TdFilePtr qTaskF = taosCreateFile(qTaskInfoFullName, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC); if (!qTaskF) { + taosMemoryFree(qWriter); code = TAOS_SYSTEM_ERROR(errno); smaError("vgId:%d, rsma snapshot writer open %s failed since %s", TD_VID(pSma->pVnode), qTaskInfoFullName, tstrerror(code)); @@ -356,6 +359,7 @@ int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRSmaSnapWrit _err: smaError("vgId:%d, rsma snapshot writer open failed since %s", TD_VID(pSma->pVnode), tstrerror(code)); + if (pWriter) rsmaSnapWriterClose(&pWriter, 0); *ppWriter = NULL; return code; } @@ -449,11 +453,11 @@ static int32_t rsmaSnapWriteQTaskInfo(SRSmaSnapWriter* pWriter, uint8_t* pData, code = TAOS_SYSTEM_ERROR(errno); goto _err; } + smaInfo("vgId:%d, vnode snapshot rsma write qtaskinfo %s succeed", SMA_VID(pWriter->pSma), qWriter->fname); } else { smaInfo("vgId:%d, vnode snapshot rsma write qtaskinfo is not needed", SMA_VID(pWriter->pSma)); } - smaInfo("vgId:%d, vnode snapshot rsma write qtaskinfo %s succeed", SMA_VID(pWriter->pSma), qWriter->fname); _exit: return code; diff --git a/source/dnode/vnode/src/sma/smaUtil.c b/source/dnode/vnode/src/sma/smaUtil.c index a4ba0a61a5..6d7b7df1ee 100644 --- a/source/dnode/vnode/src/sma/smaUtil.c +++ b/source/dnode/vnode/src/sma/smaUtil.c @@ -290,19 +290,19 @@ int32_t tdRemoveTFile(STFile *pTFile) { void *tdAcquireSmaRef(int32_t rsetId, int64_t refId) { void *pResult = taosAcquireRef(rsetId, refId); if (!pResult) { - smaWarn("rsma acquire ref for rsetId:%" PRIi64 " refId:%d failed since %s", rsetId, refId, terrstr()); + smaWarn("rsma acquire ref for rsetId:%d refId:%" PRIi64 " failed since %s", rsetId, refId, terrstr()); } else { - smaDebug("rsma acquire ref for rsetId:%" PRIi64 " refId:%d success", rsetId, refId); + smaDebug("rsma acquire ref for rsetId:%d refId:%" PRIi64 " success", rsetId, refId); } return pResult; } int32_t tdReleaseSmaRef(int32_t rsetId, int64_t refId) { if (taosReleaseRef(rsetId, refId) < 0) { - smaWarn("rsma release ref for rsetId:%" PRIi64 " refId:%d failed since %s", rsetId, refId, terrstr()); + smaWarn("rsma release ref for rsetId:%d refId:%" PRIi64 " failed since %s", rsetId, refId, terrstr()); return TSDB_CODE_FAILED; } - smaDebug("rsma release ref for rsetId:%" PRIi64 " refId:%d success", rsetId, refId); + smaDebug("rsma release ref for rsetId:%d refId:%" PRIi64 " success", rsetId, refId); return TSDB_CODE_SUCCESS; } \ No newline at end of file diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index 76f3c1b12d..ed5a894416 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -65,6 +65,11 @@ static void destroySTqHandle(void* data) { } } +static void tqPushEntryFree(void* data) { + STqPushEntry* p = *(void**)data; + taosMemoryFree(p); +} + STQ* tqOpen(const char* path, SVnode* pVnode) { STQ* pTq = taosMemoryCalloc(1, sizeof(STQ)); if (pTq == NULL) { @@ -78,7 +83,9 @@ STQ* tqOpen(const char* path, SVnode* pVnode) { taosHashSetFreeFp(pTq->pHandle, destroySTqHandle); - pTq->pPushMgr = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK); + taosInitRWLatch(&pTq->pushLock); + pTq->pPushMgr = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK); + taosHashSetFreeFp(pTq->pPushMgr, tqPushEntryFree); pTq->pCheckInfo = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK); @@ -153,6 +160,65 @@ int32_t tqSendMetaPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, return 0; } +int32_t tqPushDataRsp(STQ* pTq, STqPushEntry* pPushEntry) { + SMqDataRsp* pRsp = &pPushEntry->dataRsp; + + ASSERT(taosArrayGetSize(pRsp->blockData) == pRsp->blockNum); + ASSERT(taosArrayGetSize(pRsp->blockDataLen) == pRsp->blockNum); + + ASSERT(!pRsp->withSchema); + ASSERT(taosArrayGetSize(pRsp->blockSchema) == 0); + + if (pRsp->reqOffset.type == TMQ_OFFSET__LOG) { + if (pRsp->blockNum > 0) { + ASSERT(pRsp->rspOffset.version > pRsp->reqOffset.version); + } else { + ASSERT(pRsp->rspOffset.version >= pRsp->reqOffset.version); + } + } + + int32_t len = 0; + int32_t code = 0; + tEncodeSize(tEncodeSMqDataRsp, pRsp, len, code); + + if (code < 0) { + return -1; + } + + int32_t tlen = sizeof(SMqRspHead) + len; + void* buf = rpcMallocCont(tlen); + if (buf == NULL) { + return -1; + } + + memcpy(buf, &pPushEntry->rspHead, sizeof(SMqRspHead)); + + void* abuf = POINTER_SHIFT(buf, sizeof(SMqRspHead)); + + SEncoder encoder = {0}; + tEncoderInit(&encoder, abuf, len); + tEncodeSMqDataRsp(&encoder, pRsp); + tEncoderClear(&encoder); + + SRpcMsg rsp = { + .info = pPushEntry->pInfo, + .pCont = buf, + .contLen = tlen, + .code = 0, + }; + + tmsgSendRsp(&rsp); + + char buf1[80] = {0}; + char buf2[80] = {0}; + tFormatOffset(buf1, 80, &pRsp->reqOffset); + tFormatOffset(buf2, 80, &pRsp->rspOffset); + tqDebug("vgId:%d, from consumer:%" PRId64 ", (epoch %d) push rsp, block num: %d, reqOffset:%s, rspOffset:%s", + TD_VID(pTq->pVnode), pPushEntry->rspHead.consumerId, pRsp->head.epoch, pRsp->blockNum, buf1, buf2); + + return 0; +} + int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp) { ASSERT(taosArrayGetSize(pRsp->blockData) == pRsp->blockNum); ASSERT(taosArrayGetSize(pRsp->blockDataLen) == pRsp->blockNum); @@ -354,6 +420,8 @@ static int32_t tqInitDataRsp(SMqDataRsp* pRsp, const SMqPollReq* pReq, int8_t su return -1; } + pRsp->withTbName = 0; +#if 0 pRsp->withTbName = pReq->withTbName; if (pRsp->withTbName) { pRsp->blockTbName = taosArrayInit(0, sizeof(void*)); @@ -362,6 +430,7 @@ static int32_t tqInitDataRsp(SMqDataRsp* pRsp, const SMqPollReq* pReq, int8_t su return -1; } } +#endif if (subType == TOPIC_SUB_TYPE__COLUMN) { pRsp->withSchema = false; @@ -477,11 +546,33 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { SMqDataRsp dataRsp = {0}; tqInitDataRsp(&dataRsp, pReq, pHandle->execHandle.subType); + // lock + taosWLockLatch(&pTq->pushLock); tqScanData(pTq, pHandle, &dataRsp, &fetchOffsetNew); #if 1 - + if (dataRsp.blockNum == 0 && dataRsp.reqOffset.type == TMQ_OFFSET__LOG && + dataRsp.reqOffset.version == dataRsp.rspOffset.version) { + STqPushEntry* pPushEntry = taosMemoryCalloc(1, sizeof(STqPushEntry)); + if (pPushEntry != NULL) { + pPushEntry->pInfo = pMsg->info; + memcpy(pPushEntry->subKey, pHandle->subKey, TSDB_SUBSCRIBE_KEY_LEN); + dataRsp.withTbName = 0; + memcpy(&pPushEntry->dataRsp, &dataRsp, sizeof(SMqDataRsp)); + pPushEntry->rspHead.consumerId = consumerId; + pPushEntry->rspHead.epoch = reqEpoch; + pPushEntry->rspHead.mqMsgType = TMQ_MSG_TYPE__POLL_RSP; + taosHashPut(pTq->pPushMgr, pHandle->subKey, strlen(pHandle->subKey) + 1, &pPushEntry, sizeof(void*)); + tqDebug("tmq poll: consumer %ld, subkey %s, vg %d save handle to push mgr", consumerId, pHandle->subKey, + TD_VID(pTq->pVnode)); + // unlock + taosWUnLockLatch(&pTq->pushLock); + return 0; + } + } + taosWUnLockLatch(&pTq->pushLock); #endif + if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) { code = -1; } @@ -614,10 +705,22 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { int32_t tqProcessVgDeleteReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen) { SMqVDeleteReq* pReq = (SMqVDeleteReq*)msg; - int32_t code = taosHashRemove(pTq->pHandle, pReq->subKey, strlen(pReq->subKey)); - ASSERT(code == 0); + taosWLockLatch(&pTq->pushLock); + int32_t code = taosHashRemove(pTq->pPushMgr, pReq->subKey, strlen(pReq->subKey)); + if (code != 0) { + tqDebug("vgId:%d, tq remove push handle %s", pTq->pVnode->config.vgId, pReq->subKey); + } + taosWUnLockLatch(&pTq->pushLock); - tqOffsetDelete(pTq->pOffsetStore, pReq->subKey); + code = taosHashRemove(pTq->pHandle, pReq->subKey, strlen(pReq->subKey)); + if (code != 0) { + tqError("cannot process tq delete req %s, since no such handle", pReq->subKey); + } + + code = tqOffsetDelete(pTq->pOffsetStore, pReq->subKey); + if (code != 0) { + tqError("cannot process tq delete req %s, since no such offset", pReq->subKey); + } if (tqMetaDeleteHandle(pTq, pReq->subKey) < 0) { ASSERT(0); @@ -756,7 +859,9 @@ int32_t tqProcessVgChangeReq(STQ* pTq, int64_t version, char* msg, int32_t msgLe atomic_add_fetch_32(&pHandle->epoch, 1); if (tqMetaSaveHandle(pTq, req.subKey, pHandle) < 0) { // TODO + ASSERT(0); } + // close handle } return 0; diff --git a/source/dnode/vnode/src/tq/tqExec.c b/source/dnode/vnode/src/tq/tqExec.c index a24f920235..58d051bec1 100644 --- a/source/dnode/vnode/src/tq/tqExec.c +++ b/source/dnode/vnode/src/tq/tqExec.c @@ -15,7 +15,7 @@ #include "tq.h" -static int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols) { +int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols) { int32_t dataStrLen = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock); void* buf = taosMemoryCalloc(1, dataStrLen); if (buf == NULL) return -1; @@ -243,7 +243,7 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SSubmitReq* pReq, STaosxRsp } if (pHandle->fetchMeta) { SSubmitBlk* pBlk = pReader->pBlock; - int32_t schemaLen = htonl(pBlk->schemaLen); + int32_t schemaLen = htonl(pBlk->schemaLen); if (schemaLen > 0) { if (pRsp->createTableNum == 0) { pRsp->createTableLen = taosArrayInit(0, sizeof(int32_t)); @@ -278,7 +278,7 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SSubmitReq* pReq, STaosxRsp } if (pHandle->fetchMeta) { SSubmitBlk* pBlk = pReader->pBlock; - int32_t schemaLen = htonl(pBlk->schemaLen); + int32_t schemaLen = htonl(pBlk->schemaLen); if (schemaLen > 0) { if (pRsp->createTableNum == 0) { pRsp->createTableLen = taosArrayInit(0, sizeof(int32_t)); diff --git a/source/dnode/vnode/src/tq/tqPush.c b/source/dnode/vnode/src/tq/tqPush.c index a57e8174fe..dcfb07f0ff 100644 --- a/source/dnode/vnode/src/tq/tqPush.c +++ b/source/dnode/vnode/src/tq/tqPush.c @@ -213,6 +213,97 @@ int32_t tqPushMsgNew(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_ #endif int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) { + tqDebug("vgId:%d tq push msg ver %ld, type: %s", pTq->pVnode->config.vgId, ver, TMSG_INFO(msgType)); + + if (msgType == TDMT_VND_SUBMIT) { + // lock push mgr to avoid potential msg lost + taosWLockLatch(&pTq->pushLock); + tqDebug("vgId:%d push handle num %d", pTq->pVnode->config.vgId, taosHashGetSize(pTq->pPushMgr)); + if (taosHashGetSize(pTq->pPushMgr) != 0) { + SArray* cachedKeys = taosArrayInit(0, sizeof(void*)); + SArray* cachedKeyLens = taosArrayInit(0, sizeof(size_t)); + void* data = taosMemoryMalloc(msgLen); + if (data == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + tqError("failed to copy data for stream since out of memory"); + return -1; + } + memcpy(data, msg, msgLen); + SSubmitReq* pReq = (SSubmitReq*)data; + pReq->version = ver; + + void* pIter = NULL; + while (1) { + pIter = taosHashIterate(pTq->pPushMgr, pIter); + if (pIter == NULL) break; + STqPushEntry* pPushEntry = *(STqPushEntry**)pIter; + + STqHandle* pHandle = taosHashGet(pTq->pHandle, pPushEntry->subKey, strlen(pPushEntry->subKey)); + if (pHandle == NULL) { + tqDebug("vgId:%d cannot find handle %s", pTq->pVnode->config.vgId, pPushEntry->subKey); + continue; + } + if (pPushEntry->dataRsp.reqOffset.version > ver) { + tqDebug("vgId:%d push entry req version %ld, while push version %ld, skip", pTq->pVnode->config.vgId, + pPushEntry->dataRsp.reqOffset.version, ver); + continue; + } + STqExecHandle* pExec = &pHandle->execHandle; + qTaskInfo_t task = pExec->task; + + SMqDataRsp* pRsp = &pPushEntry->dataRsp; + + // prepare scan mem data + qStreamScanMemData(task, pReq); + + // exec + while (1) { + SSDataBlock* pDataBlock = NULL; + uint64_t ts = 0; + if (qExecTask(task, &pDataBlock, &ts) < 0) { + ASSERT(0); + } + + if (pDataBlock == NULL) { + break; + } + + tqAddBlockDataToRsp(pDataBlock, pRsp, pExec->numOfCols); + pRsp->blockNum++; + } + + tqDebug("vgId:%d tq handle push, subkey: %s, block num: %d", pTq->pVnode->config.vgId, pPushEntry->subKey, + pRsp->blockNum); + if (pRsp->blockNum > 0) { + // set offset + tqOffsetResetToLog(&pRsp->rspOffset, ver); + // remove from hash + size_t kLen; + void* key = taosHashGetKey(pIter, &kLen); + void* keyCopy = taosMemoryMalloc(kLen); + memcpy(keyCopy, key, kLen); + + taosArrayPush(cachedKeys, &keyCopy); + taosArrayPush(cachedKeyLens, &kLen); + + tqPushDataRsp(pTq, pPushEntry); + } + } + // delete entry + for (int32_t i = 0; i < taosArrayGetSize(cachedKeys); i++) { + void* key = taosArrayGetP(cachedKeys, i); + size_t kLen = *(size_t*)taosArrayGet(cachedKeyLens, i); + if (taosHashRemove(pTq->pPushMgr, key, kLen) != 0) { + ASSERT(0); + } + } + taosArrayDestroyP(cachedKeys, (FDelete)taosMemoryFree); + taosArrayDestroy(cachedKeyLens); + } + // unlock + taosWUnLockLatch(&pTq->pushLock); + } + if (vnodeIsRoleLeader(pTq->pVnode)) { if (msgType == TDMT_VND_SUBMIT) { if (taosHashGetSize(pTq->pStreamMeta->pTasks) == 0) return 0; diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c index 8e5f328efa..3bd31e6660 100644 --- a/source/dnode/vnode/src/tq/tqRead.c +++ b/source/dnode/vnode/src/tq/tqRead.c @@ -15,21 +15,20 @@ #include "tq.h" - -bool isValValidForTable(STqHandle* pHandle, SWalCont *pHead){ - if(pHandle->execHandle.subType != TOPIC_SUB_TYPE__TABLE){ +bool isValValidForTable(STqHandle* pHandle, SWalCont* pHead) { + if (pHandle->execHandle.subType != TOPIC_SUB_TYPE__TABLE) { return true; } - int16_t msgType = pHead->msgType; - char* body = pHead->body; - int32_t bodyLen = pHead->bodyLen; + int16_t msgType = pHead->msgType; + char* body = pHead->body; + int32_t bodyLen = pHead->bodyLen; - int64_t tbSuid = pHandle->execHandle.execTb.suid; - int64_t realTbSuid = 0; - SDecoder coder; - void* data = POINTER_SHIFT(body, sizeof(SMsgHead)); - int32_t len = bodyLen - sizeof(SMsgHead); + int64_t tbSuid = pHandle->execHandle.execTb.suid; + int64_t realTbSuid = 0; + SDecoder coder; + void* data = POINTER_SHIFT(body, sizeof(SMsgHead)); + int32_t len = bodyLen - sizeof(SMsgHead); tDecoderInit(&coder, data, len); if (msgType == TDMT_VND_CREATE_STB || msgType == TDMT_VND_ALTER_STB) { @@ -43,38 +42,38 @@ bool isValValidForTable(STqHandle* pHandle, SWalCont *pHead){ if (tDecodeSVDropStbReq(&coder, &req) < 0) { goto end; } - realTbSuid = req.suid; + realTbSuid = req.suid; } else if (msgType == TDMT_VND_CREATE_TABLE) { SVCreateTbBatchReq req = {0}; if (tDecodeSVCreateTbBatchReq(&coder, &req) < 0) { goto end; } - int32_t needRebuild = 0; + int32_t needRebuild = 0; SVCreateTbReq* pCreateReq = NULL; for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { pCreateReq = req.pReqs + iReq; - if(pCreateReq->type == TSDB_CHILD_TABLE && pCreateReq->ctb.suid == tbSuid){ + if (pCreateReq->type == TSDB_CHILD_TABLE && pCreateReq->ctb.suid == tbSuid) { needRebuild++; } } - if(needRebuild == 0){ + if (needRebuild == 0) { // do nothing - }else if(needRebuild == req.nReqs){ + } else if (needRebuild == req.nReqs) { realTbSuid = tbSuid; - }else{ + } else { realTbSuid = tbSuid; SVCreateTbBatchReq reqNew = {0}; reqNew.pArray = taosArrayInit(req.nReqs, sizeof(struct SVCreateTbReq)); for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { pCreateReq = req.pReqs + iReq; - if(pCreateReq->type == TSDB_CHILD_TABLE && pCreateReq->ctb.suid == tbSuid){ + if (pCreateReq->type == TSDB_CHILD_TABLE && pCreateReq->ctb.suid == tbSuid) { reqNew.nReqs++; taosArrayPush(reqNew.pArray, pCreateReq); } } - int tlen; + int tlen; int32_t ret = 0; tEncodeSize(tEncodeSVCreateTbBatchReq, &reqNew, tlen, ret); void* buf = taosMemoryMalloc(tlen); @@ -107,7 +106,7 @@ bool isValValidForTable(STqHandle* pHandle, SWalCont *pHead){ } } } else if (msgType == TDMT_VND_ALTER_TABLE) { - SVAlterTbReq req = {0}; + SVAlterTbReq req = {0}; if (tDecodeSVAlterTbReq(&coder, &req) < 0) { goto end; @@ -129,32 +128,32 @@ bool isValValidForTable(STqHandle* pHandle, SWalCont *pHead){ goto end; } - int32_t needRebuild = 0; + int32_t needRebuild = 0; SVDropTbReq* pDropReq = NULL; for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { pDropReq = req.pReqs + iReq; - if(pDropReq->suid == tbSuid){ + if (pDropReq->suid == tbSuid) { needRebuild++; } } - if(needRebuild == 0){ + if (needRebuild == 0) { // do nothing - }else if(needRebuild == req.nReqs){ + } else if (needRebuild == req.nReqs) { realTbSuid = tbSuid; - }else{ + } else { realTbSuid = tbSuid; SVDropTbBatchReq reqNew = {0}; reqNew.pArray = taosArrayInit(req.nReqs, sizeof(SVDropTbReq)); for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { pDropReq = req.pReqs + iReq; - if(pDropReq->suid == tbSuid){ + if (pDropReq->suid == tbSuid) { reqNew.nReqs++; taosArrayPush(reqNew.pArray, pDropReq); } } - int tlen; + int tlen; int32_t ret = 0; tEncodeSize(tEncodeSVDropTbBatchReq, &reqNew, tlen, ret); void* buf = taosMemoryMalloc(tlen); @@ -177,11 +176,11 @@ bool isValValidForTable(STqHandle* pHandle, SWalCont *pHead){ goto end; } realTbSuid = req.suid; - } else{ + } else { ASSERT(0); } - end: +end: tDecoderClear(&coder); return tbSuid == realTbSuid; } @@ -224,7 +223,7 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHea code = -1; goto END; } - if(isValValidForTable(pHandle, pHead)){ + if (isValValidForTable(pHandle, pHead)) { *fetchOffset = offset; code = 0; goto END; @@ -241,7 +240,7 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHea offset++; } } - END: +END: taosThreadMutexUnlock(&pHandle->pWalReader->mutex); return code; } @@ -315,14 +314,18 @@ int32_t tqNextBlock(STqReader* pReader, SFetchRet* ret) { return -1; } void* body = pReader->pWalReader->pHead->head.body; +#if 0 if (pReader->pWalReader->pHead->head.msgType != TDMT_VND_SUBMIT) { // TODO do filter ret->fetchType = FETCH_TYPE__META; ret->meta = pReader->pWalReader->pHead->head.body; return 0; } else { - tqReaderSetDataMsg(pReader, body, pReader->pWalReader->pHead->head.version); +#endif + tqReaderSetDataMsg(pReader, body, pReader->pWalReader->pHead->head.version); +#if 0 } +#endif } while (tqNextDataBlock(pReader)) { @@ -334,6 +337,7 @@ int32_t tqNextBlock(STqReader* pReader, SFetchRet* ret) { continue; } ret->fetchType = FETCH_TYPE__DATA; + tqDebug("return data rows %d", ret->data.info.rows); return 0; } @@ -341,14 +345,14 @@ int32_t tqNextBlock(STqReader* pReader, SFetchRet* ret) { ret->offset.type = TMQ_OFFSET__LOG; ret->offset.version = pReader->ver; ASSERT(pReader->ver >= 0); - ret->fetchType = FETCH_TYPE__NONE; + ret->fetchType = FETCH_TYPE__SEP; tqDebug("return offset %" PRId64 ", processed finish", ret->offset.version); return 0; } } } -int32_t tqReaderSetDataMsg(STqReader* pReader, SSubmitReq* pMsg, int64_t ver) { +int32_t tqReaderSetDataMsg(STqReader* pReader, const SSubmitReq* pMsg, int64_t ver) { pReader->pMsg = pMsg; if (tInitSubmitMsgIter(pMsg, &pReader->msgIter) < 0) return -1; diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index 32272b541c..3a921349e6 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -420,6 +420,7 @@ typedef enum { typedef struct { SFSLASTNEXTROWSTATES state; // [input] STsdb *pTsdb; // [input] + STSchema *pTSchema;// [input] tb_uid_t suid; tb_uid_t uid; int32_t nFileSet; @@ -455,9 +456,10 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow) { code = tsdbDataFReaderOpen(&state->pDataFReader, state->pTsdb, pFileSet); if (code) goto _err; + SSttBlockLoadInfo* pLoadInfo = tCreateLastBlockLoadInfo(state->pTSchema, NULL, 0); tMergeTreeOpen(&state->mergeTree, 1, state->pDataFReader, state->suid, state->uid, &(STimeWindow){.skey = TSKEY_MIN, .ekey = TSKEY_MAX}, - &(SVersionRange){.minVer = 0, .maxVer = UINT64_MAX}, NULL, NULL); + &(SVersionRange){.minVer = 0, .maxVer = UINT64_MAX}, pLoadInfo,true, NULL); bool hasVal = tMergeTreeNext(&state->mergeTree); if (!hasVal) { state->state = SFSLASTNEXTROW_FILESET; @@ -612,7 +614,8 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) { tMapDataGetItemByIdx(&state->blockMap, state->iBlock, &block, tGetDataBlk); /* code = tsdbReadBlockData(state->pDataFReader, &state->blockIdx, &block, &state->blockData, NULL, NULL); */ tBlockDataReset(state->pBlockData); - code = tBlockDataInit(state->pBlockData, state->suid, state->uid, state->pTSchema); + TABLEID tid = {.suid = state->suid, .uid = state->uid}; + code = tBlockDataInit(state->pBlockData, &tid, state->pTSchema, NULL, 0); if (code) goto _err; code = tsdbReadDataBlock(state->pDataFReader, &block, state->pBlockData); @@ -891,6 +894,7 @@ static int32_t nextRowIterOpen(CacheNextRowIter *pIter, tb_uid_t uid, STsdb *pTs pIter->fsLastState.state = (SFSLASTNEXTROWSTATES)SFSNEXTROW_FS; pIter->fsLastState.pTsdb = pTsdb; pIter->fsLastState.aDFileSet = pIter->pReadSnap->fs.aDFileSet; + pIter->fsLastState.pTSchema = pTSchema; pIter->fsLastState.suid = suid; pIter->fsLastState.uid = uid; diff --git a/source/dnode/vnode/src/tsdb/tsdbCacheRead.c b/source/dnode/vnode/src/tsdb/tsdbCacheRead.c index 5f981649f3..7a000253d5 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCacheRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbCacheRead.c @@ -101,7 +101,7 @@ int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, SArray* pTableIdList return TSDB_CODE_SUCCESS; } -int32_t tsdbCacherowsReaderClose(void* pReader) { +void* tsdbCacherowsReaderClose(void* pReader) { SCacheRowsReader* p = pReader; if (p->pSchema != NULL) { @@ -114,7 +114,7 @@ int32_t tsdbCacherowsReaderClose(void* pReader) { } taosMemoryFree(pReader); - return TSDB_CODE_SUCCESS; + return NULL; } static int32_t doExtractCacheRow(SCacheRowsReader* pr, SLRUCache* lruCache, uint64_t uid, STSRow** pRow, diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index a619b9f2e4..5403395623 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -437,7 +437,7 @@ static int32_t tsdbOpenCommitIter(SCommitter *pCommitter) { pIter->iSttBlk = 0; SSttBlk *pSttBlk = (SSttBlk *)taosArrayGet(pIter->aSttBlk, 0); - code = tsdbReadSttBlock(pCommitter->dReader.pReader, iStt, pSttBlk, &pIter->bData); + code = tsdbReadSttBlockEx(pCommitter->dReader.pReader, iStt, pSttBlk, &pIter->bData); if (code) goto _err; pIter->iRow = 0; @@ -1049,7 +1049,7 @@ static int32_t tsdbNextCommitRow(SCommitter *pCommitter) { if (pIter->iSttBlk < taosArrayGetSize(pIter->aSttBlk)) { SSttBlk *pSttBlk = (SSttBlk *)taosArrayGet(pIter->aSttBlk, pIter->iSttBlk); - code = tsdbReadSttBlock(pCommitter->dReader.pReader, pIter->iStt, pSttBlk, &pIter->bData); + code = tsdbReadSttBlockEx(pCommitter->dReader.pReader, pIter->iStt, pSttBlk, &pIter->bData); if (code) goto _exit; pIter->iRow = 0; @@ -1305,7 +1305,8 @@ static int32_t tsdbInitLastBlockIfNeed(SCommitter *pCommitter, TABLEID id) { if (!pBDatal->suid && !pBDatal->uid) { ASSERT(pCommitter->skmTable.suid == id.suid); ASSERT(pCommitter->skmTable.uid == id.uid); - code = tBlockDataInit(pBDatal, id.suid, id.suid ? 0 : id.uid, pCommitter->skmTable.pTSchema); + TABLEID tid = {.suid = id.suid, .uid = id.suid ? 0 : id.uid}; + code = tBlockDataInit(pBDatal, &tid, pCommitter->skmTable.pTSchema, NULL, 0); if (code) goto _exit; } @@ -1428,9 +1429,9 @@ static int32_t tsdbCommitFileDataImpl(SCommitter *pCommitter) { // impl code = tsdbUpdateTableSchema(pCommitter->pTsdb->pVnode->pMeta, id.suid, id.uid, &pCommitter->skmTable); if (code) goto _err; - code = tBlockDataInit(&pCommitter->dReader.bData, id.suid, id.uid, pCommitter->skmTable.pTSchema); + code = tBlockDataInit(&pCommitter->dReader.bData, &id, pCommitter->skmTable.pTSchema, NULL, 0); if (code) goto _err; - code = tBlockDataInit(&pCommitter->dWriter.bData, id.suid, id.uid, pCommitter->skmTable.pTSchema); + code = tBlockDataInit(&pCommitter->dWriter.bData, &id, pCommitter->skmTable.pTSchema, NULL, 0); if (code) goto _err; /* merge with data in .data file */ diff --git a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c index 5f03a82bc0..7e6a0d04ff 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c +++ b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c @@ -28,11 +28,10 @@ struct SLDataIter { uint64_t uid; STimeWindow timeWindow; SVersionRange verRange; - SSttBlockLoadInfo* pBlockLoadInfo; }; -SSttBlockLoadInfo* tCreateLastBlockLoadInfo() { +SSttBlockLoadInfo* tCreateLastBlockLoadInfo(STSchema* pSchema, int16_t* colList, int32_t numOfCols) { SSttBlockLoadInfo* pLoadInfo = taosMemoryCalloc(TSDB_DEFAULT_STT_FILE, sizeof(SSttBlockLoadInfo)); if (pLoadInfo == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -55,6 +54,9 @@ SSttBlockLoadInfo* tCreateLastBlockLoadInfo() { } pLoadInfo[i].aSttBlk = taosArrayInit(4, sizeof(SSttBlk)); + pLoadInfo[i].pSchema = pSchema; + pLoadInfo[i].colIds = colList; + pLoadInfo[i].numOfCols = numOfCols; } return pLoadInfo; @@ -111,7 +113,19 @@ static SBlockData* loadLastBlock(SLDataIter *pIter, const char* idStr) { pInfo->currentLoadBlockIndex ^= 1; if (pIter->pSttBlk != NULL) { // current block not loaded yet int64_t st = taosGetTimestampUs(); - code = tsdbReadSttBlock(pIter->pReader, pIter->iStt, pIter->pSttBlk, &pInfo->blockData[pInfo->currentLoadBlockIndex]); + + SBlockData* pBlock = &pInfo->blockData[pInfo->currentLoadBlockIndex]; + + TABLEID id = {0}; + if (pIter->pSttBlk->suid != 0) { + id.suid = pIter->pSttBlk->suid; + } else { + id.uid = pIter->uid; + } + + tBlockDataInit(pBlock, &id, pInfo->pSchema, pInfo->colIds, pInfo->numOfCols); + code = tsdbReadSttBlock(pIter->pReader, pIter->iStt, pIter->pSttBlk, pBlock); + double el = (taosGetTimestampUs() - st)/ 1000.0; pInfo->elapsedTime += el; pInfo->loadBlocks += 1; @@ -460,7 +474,8 @@ static FORCE_INLINE int32_t tLDataIterCmprFn(const void *p1, const void *p2) { } int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFReader, uint64_t suid, uint64_t uid, - STimeWindow *pTimeWindow, SVersionRange *pVerRange, void* pBlockLoadInfo, const char* idStr) { + STimeWindow *pTimeWindow, SVersionRange *pVerRange, SSttBlockLoadInfo *pBlockLoadInfo, + bool destroyLoadInfo, const char *idStr) { pMTree->backward = backward; pMTree->pIter = NULL; pMTree->pIterList = taosArrayInit(4, POINTER_BYTES); @@ -473,21 +488,12 @@ int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFRead tRBTreeCreate(&pMTree->rbt, tLDataIterCmprFn); int32_t code = TSDB_CODE_SUCCESS; - SSttBlockLoadInfo* pLoadInfo = NULL; - if (pBlockLoadInfo == NULL) { - if (pMTree->pLoadInfo == NULL) { - pMTree->destroyLoadInfo = true; - pMTree->pLoadInfo = tCreateLastBlockLoadInfo(); - } - - pLoadInfo = pMTree->pLoadInfo; - } else { - pLoadInfo = pBlockLoadInfo; - } + pMTree->pLoadInfo = pBlockLoadInfo; + pMTree->destroyLoadInfo = destroyLoadInfo; for (int32_t i = 0; i < pFReader->pSet->nSttF; ++i) { // open all last file struct SLDataIter* pIter = NULL; - code = tLDataIterOpen(&pIter, pFReader, i, pMTree->backward, suid, uid, pTimeWindow, pVerRange, &pLoadInfo[i]); + code = tLDataIterOpen(&pIter, pFReader, i, pMTree->backward, suid, uid, pTimeWindow, pVerRange, &pMTree->pLoadInfo[i]); if (code != TSDB_CODE_SUCCESS) { goto _end; } diff --git a/source/dnode/vnode/src/tsdb/tsdbOpen.c b/source/dnode/vnode/src/tsdb/tsdbOpen.c index ec760e3c57..fcbcff9248 100644 --- a/source/dnode/vnode/src/tsdb/tsdbOpen.c +++ b/source/dnode/vnode/src/tsdb/tsdbOpen.c @@ -85,6 +85,8 @@ _err: int tsdbClose(STsdb **pTsdb) { if (*pTsdb) { taosThreadRwlockDestroy(&(*pTsdb)->rwLock); + tsdbMemTableDestroy((*pTsdb)->mem); + (*pTsdb)->mem = NULL; tsdbFSClose(*pTsdb); tsdbCloseCache(*pTsdb); taosMemoryFreeClear(*pTsdb); diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index a2f21d4f6e..c3cb5f9eb8 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -79,6 +79,7 @@ typedef struct SBlockLoadSuppInfo { SColumnDataAgg tsColAgg; SColumnDataAgg** plist; int16_t* colIds; // column ids for loading file block data + int32_t numOfCols; char** buildBuf; // build string tmp buffer, todo remove it later after all string format being updated. } SBlockLoadSuppInfo; @@ -203,6 +204,7 @@ static int32_t setColumnIdSlotList(STsdbReader* pReader, SSDataBlock* pBlock) { size_t numOfCols = blockDataGetNumOfCols(pBlock); + pSupInfo->numOfCols = numOfCols; pSupInfo->colIds = taosMemoryMalloc(numOfCols * sizeof(int16_t)); pSupInfo->buildBuf = taosMemoryCalloc(numOfCols, POINTER_BYTES); if (pSupInfo->buildBuf == NULL || pSupInfo->colIds == NULL) { @@ -352,7 +354,8 @@ static int32_t initFilesetIterator(SFilesetIter* pIter, SArray* aDFileSet, STsdb tMergeTreeClose(&pLReader->mergeTree); if (pLReader->pInfo == NULL) { - pLReader->pInfo = tCreateLastBlockLoadInfo(); + // here we ignore the first column, which is always be the primary timestamp column + pLReader->pInfo = tCreateLastBlockLoadInfo(pReader->pSchema, &pReader->suppInfo.colIds[1], pReader->suppInfo.numOfCols - 1); if (pLReader->pInfo == NULL) { tsdbDebug("init fileset iterator failed, code:%s %s", tstrerror(terrno), pReader->idStr); return terrno; @@ -483,7 +486,7 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd pReader->pTsdb = getTsdbByRetentions(pVnode, pCond->twindows.skey, pVnode->config.tsdbCfg.retentions, idstr, &level); pReader->suid = pCond->suid; pReader->order = pCond->order; - pReader->capacity = 4096; + pReader->capacity = capacity; pReader->idStr = (idstr != NULL) ? strdup(idstr) : NULL; pReader->verRange = getQueryVerRange(pVnode, pCond, level); pReader->type = pCond->type; @@ -838,14 +841,18 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn bool asc = ASCENDING_TRAVERSE(pReader->order); int32_t step = asc ? 1 : -1; - if (asc && pReader->window.skey <= pBlock->minKey.ts) { - pDumpInfo->rowIndex = 0; - } else if (!asc && pReader->window.ekey >= pBlock->maxKey.ts) { - pDumpInfo->rowIndex = pBlock->nRow - 1; - } else { - int32_t pos = asc ? pBlock->nRow - 1 : 0; - int32_t order = (pReader->order == TSDB_ORDER_ASC) ? TSDB_ORDER_DESC : TSDB_ORDER_ASC; - pDumpInfo->rowIndex = doBinarySearchKey(pBlockData->aTSKEY, pBlock->nRow, pos, pReader->window.skey, order); + + if ((pDumpInfo->rowIndex == 0 && asc) || (pDumpInfo->rowIndex == pBlock->nRow - 1 && (!asc))) { + if (asc && pReader->window.skey <= pBlock->minKey.ts) { + //pDumpInfo->rowIndex = 0; + } else + if (!asc && pReader->window.ekey >= pBlock->maxKey.ts) { + //pDumpInfo->rowIndex = pBlock->nRow - 1; + } else { + int32_t pos = asc ? pBlock->nRow - 1 : 0; + int32_t order = (pReader->order == TSDB_ORDER_ASC) ? TSDB_ORDER_DESC : TSDB_ORDER_ASC; + pDumpInfo->rowIndex = doBinarySearchKey(pBlockData->aTSKEY, pBlock->nRow, pos, pReader->window.skey, order); + } } // time window check @@ -929,8 +936,8 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn pDumpInfo->rowIndex += step * remain; if (pDumpInfo->rowIndex >= 0 && pDumpInfo->rowIndex < pBlock->nRow) { - int64_t ts = pBlockData->aTSKEY[pDumpInfo->rowIndex]; - setBlockAllDumped(pDumpInfo, ts, pReader->order); +// int64_t ts = pBlockData->aTSKEY[pDumpInfo->rowIndex]; +// setBlockAllDumped(pDumpInfo, ts, pReader->order); } else { int64_t k = asc ? pBlock->maxKey.ts : pBlock->minKey.ts; setBlockAllDumped(pDumpInfo, k, pReader->order); @@ -948,15 +955,22 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn return TSDB_CODE_SUCCESS; } -static int32_t doLoadFileBlockData(STsdbReader* pReader, SDataBlockIter* pBlockIter, SBlockData* pBlockData) { +static int32_t doLoadFileBlockData(STsdbReader* pReader, SDataBlockIter* pBlockIter, SBlockData* pBlockData, uint64_t uid) { int64_t st = taosGetTimestampUs(); + tBlockDataReset(pBlockData); + TABLEID tid = {.suid = pReader->suid, .uid = uid}; + int32_t code = tBlockDataInit(pBlockData, &tid, pReader->pSchema, &pReader->suppInfo.colIds[1], pReader->suppInfo.numOfCols-1); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(pBlockIter); SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; ASSERT(pBlockInfo != NULL); SDataBlk* pBlock = getCurrentBlock(pBlockIter); - int32_t code = tsdbReadDataBlock(pReader->pFileReader, pBlock, pBlockData); + code = tsdbReadDataBlock(pReader->pFileReader, pBlock, pBlockData); if (code != TSDB_CODE_SUCCESS) { tsdbError("%p error occurs in loading file block, global index:%d, table index:%d, brange:%" PRId64 "-%" PRId64 ", rows:%d, code:%s %s", @@ -1279,14 +1293,8 @@ static bool doCheckforDatablockOverlap(STableBlockScanInfo* pBlockScanInfo, cons if (p->version >= pBlock->minVer) { if (i < num - 1) { TSDBKEY* pnext = taosArrayGet(pBlockScanInfo->delSkyline, i + 1); - // if (i + 1 == num - 1) { // pnext is the last point if (pnext->ts >= pBlock->minKey.ts) { return true; - // } - // } else { - // if (pnext->ts >= pBlock->minKey.ts) { - // return true; - // } } } else { // it must be the last point ASSERT(p->version == 0); @@ -2001,7 +2009,7 @@ static bool initLastBlockReader(SLastBlockReader* pLBlockReader, STableBlockScan int32_t code = tMergeTreeOpen(&pLBlockReader->mergeTree, (pLBlockReader->order == TSDB_ORDER_DESC), pReader->pFileReader, - pReader->suid, pScanInfo->uid, &w, &pLBlockReader->verRange, pLBlockReader->pInfo, pReader->idStr); + pReader->suid, pScanInfo->uid, &w, &pLBlockReader->verRange, pLBlockReader->pInfo, false, pReader->idStr); if (code != TSDB_CODE_SUCCESS) { return false; } @@ -2457,13 +2465,7 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) { ASSERT(pBlockIter->numOfBlocks == 0); code = buildComposedDataBlock(pReader); } else if (fileBlockShouldLoad(pReader, pBlockInfo, pBlock, pScanInfo, keyInBuf, pLastBlockReader)) { - tBlockDataReset(&pStatus->fileBlockData); - code = tBlockDataInit(&pStatus->fileBlockData, pReader->suid, pScanInfo->uid, pReader->pSchema); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - code = doLoadFileBlockData(pReader, pBlockIter, &pStatus->fileBlockData); + code = doLoadFileBlockData(pReader, pBlockIter, &pStatus->fileBlockData, pScanInfo->uid); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -2937,13 +2939,7 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn setFileBlockActiveInBlockIter(pBlockIter, neighborIndex, step); // 3. load the neighbor block, and set it to be the currently accessed file data block - tBlockDataReset(&pStatus->fileBlockData); - int32_t code = tBlockDataInit(&pStatus->fileBlockData, pReader->suid, pFBlock->uid, pReader->pSchema); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - code = doLoadFileBlockData(pReader, pBlockIter, &pStatus->fileBlockData); + int32_t code = doLoadFileBlockData(pReader, pBlockIter, &pStatus->fileBlockData, pFBlock->uid); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -3221,8 +3217,8 @@ int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, S tColDataGetValue(pData, rowIndex, &cv); doCopyColVal(pCol, outputRowIndex, i, &cv, pSupInfo); j += 1; - } else if (pData->cid > - pCol->info.colId) { // the specified column does not exist in file block, fill with null data + } else if (pData->cid > pCol->info.colId) { + // the specified column does not exist in file block, fill with null data colDataAppendNULL(pCol, outputRowIndex); } @@ -3410,10 +3406,14 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl // we need only one row pPrevReader->capacity = 1; pPrevReader->status.pTableMap = pReader->status.pTableMap; + pPrevReader->pSchema = pReader->pSchema; + pPrevReader->pMemSchema = pReader->pMemSchema; pPrevReader->pReadSnap = pReader->pReadSnap; pNextReader->capacity = 1; pNextReader->status.pTableMap = pReader->status.pTableMap; + pNextReader->pSchema = pReader->pSchema; + pNextReader->pMemSchema = pReader->pMemSchema; pNextReader->pReadSnap = pReader->pReadSnap; code = doOpenReaderImpl(pPrevReader); @@ -3447,11 +3447,19 @@ void tsdbReaderClose(STsdbReader* pReader) { { if (pReader->innerReader[0] != NULL) { - pReader->innerReader[0]->status.pTableMap = NULL; - pReader->innerReader[0]->pReadSnap = NULL; + STsdbReader* p = pReader->innerReader[0]; - pReader->innerReader[1]->status.pTableMap = NULL; - pReader->innerReader[1]->pReadSnap = NULL; + p->status.pTableMap = NULL; + p->pReadSnap = NULL; + p->pSchema = NULL; + p->pMemSchema = NULL; + + p = pReader->innerReader[1]; + + p->status.pTableMap = NULL; + p->pReadSnap = NULL; + p->pSchema = NULL; + p->pMemSchema = NULL; tsdbReaderClose(pReader->innerReader[0]); tsdbReaderClose(pReader->innerReader[1]); @@ -3689,14 +3697,7 @@ static SArray* doRetrieveDataBlock(STsdbReader* pReader) { SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(&pStatus->blockIter); STableBlockScanInfo* pBlockScanInfo = taosHashGet(pStatus->pTableMap, &pFBlock->uid, sizeof(pFBlock->uid)); - tBlockDataReset(&pStatus->fileBlockData); - int32_t code = tBlockDataInit(&pStatus->fileBlockData, pReader->suid, pBlockScanInfo->uid, pReader->pSchema); - if (code != TSDB_CODE_SUCCESS) { - terrno = code; - return NULL; - } - - code = doLoadFileBlockData(pReader, &pStatus->blockIter, &pStatus->fileBlockData); + int32_t code = doLoadFileBlockData(pReader, &pStatus->blockIter, &pStatus->fileBlockData, pBlockScanInfo->uid); if (code != TSDB_CODE_SUCCESS) { tBlockDataDestroy(&pStatus->fileBlockData, 1); terrno = code; diff --git a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c index 5fe0b408b1..fc577e3962 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c +++ b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c @@ -926,12 +926,13 @@ _err: return code; } -static int32_t tsdbReadBlockDataImpl(SDataFReader *pReader, SBlockInfo *pBlkInfo, SBlockData *pBlockData) { +static int32_t tsdbReadBlockDataImpl(SDataFReader *pReader, SBlockInfo *pBlkInfo, SBlockData *pBlockData, + int32_t iStt) { int32_t code = 0; tBlockDataClear(pBlockData); - STsdbFD *pFD = pReader->pDataFD; + STsdbFD *pFD = (iStt < 0) ? pReader->pDataFD : pReader->aSttFD[iStt]; // uid + version + tskey code = tRealloc(&pReader->aBuf[0], pBlkInfo->szKey); @@ -1070,9 +1071,12 @@ _err: int32_t tsdbReadDataBlock(SDataFReader *pReader, SDataBlk *pDataBlk, SBlockData *pBlockData) { int32_t code = 0; - code = tsdbReadBlockDataImpl(pReader, &pDataBlk->aSubBlock[0], pBlockData); + code = tsdbReadBlockDataImpl(pReader, &pDataBlk->aSubBlock[0], pBlockData, -1); if (code) goto _err; + ASSERT(pDataBlk->nSubBlock == 1); + +#if 0 if (pDataBlk->nSubBlock > 1) { SBlockData bData1; SBlockData bData2; @@ -1113,6 +1117,7 @@ int32_t tsdbReadDataBlock(SDataFReader *pReader, SDataBlk *pDataBlk, SBlockData tBlockDataDestroy(&bData1, 1); tBlockDataDestroy(&bData2, 1); } +#endif return code; @@ -1123,23 +1128,38 @@ _err: int32_t tsdbReadSttBlock(SDataFReader *pReader, int32_t iStt, SSttBlk *pSttBlk, SBlockData *pBlockData) { int32_t code = 0; + int32_t lino = 0; + + code = tsdbReadBlockDataImpl(pReader, &pSttBlk->bInfo, pBlockData, iStt); + TSDB_CHECK_CODE(code, lino, _exit); + +_exit: + if (code) { + tsdbError("vgId:%d %s failed at %d since %s", TD_VID(pReader->pTsdb->pVnode), __func__, lino, tstrerror(code)); + } + return code; +} + +int32_t tsdbReadSttBlockEx(SDataFReader *pReader, int32_t iStt, SSttBlk *pSttBlk, SBlockData *pBlockData) { + int32_t code = 0; + int32_t lino = 0; // alloc code = tRealloc(&pReader->aBuf[0], pSttBlk->bInfo.szBlock); - if (code) goto _err; + TSDB_CHECK_CODE(code, lino, _exit); // read code = tsdbReadFile(pReader->aSttFD[iStt], pSttBlk->bInfo.offset, pReader->aBuf[0], pSttBlk->bInfo.szBlock); - if (code) goto _err; + TSDB_CHECK_CODE(code, lino, _exit); // decmpr code = tDecmprBlockData(pReader->aBuf[0], pSttBlk->bInfo.szBlock, pBlockData, &pReader->aBuf[1]); - if (code) goto _err; + TSDB_CHECK_CODE(code, lino, _exit); - return code; - -_err: - tsdbError("vgId:%d tsdb read stt block failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code)); +_exit: + if (code) { + tsdbError("vgId:%d %s failed at %d since %s", TD_VID(pReader->pTsdb->pVnode), __func__, lino, tstrerror(code)); + } return code; } diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c index 99e88a442c..a928dc3484 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -140,7 +140,7 @@ static int32_t tsdbSnapReadOpenFile(STsdbSnapReader* pReader) { if (pSttBlk->minVer > pReader->ever) continue; if (pSttBlk->maxVer < pReader->sver) continue; - code = tsdbReadSttBlock(pReader->pDataFReader, iStt, pSttBlk, &pIter->bData); + code = tsdbReadSttBlockEx(pReader->pDataFReader, iStt, pSttBlk, &pIter->bData); if (code) goto _err; for (pIter->iRow = 0; pIter->iRow < pIter->bData.nRow; pIter->iRow++) { @@ -223,7 +223,7 @@ static int32_t tsdbSnapNextRow(STsdbSnapReader* pReader) { if (pSttBlk->minVer > pReader->ever || pSttBlk->maxVer < pReader->sver) continue; - code = tsdbReadSttBlock(pReader->pDataFReader, pIter->iStt, pSttBlk, &pIter->bData); + code = tsdbReadSttBlockEx(pReader->pDataFReader, pIter->iStt, pSttBlk, &pIter->bData); if (code) goto _err; pIter->iRow = -1; @@ -319,7 +319,7 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) { code = tsdbUpdateTableSchema(pTsdb->pVnode->pMeta, id.suid, id.uid, &pReader->skmTable); if (code) goto _err; - code = tBlockDataInit(pBlockData, id.suid, id.uid, pReader->skmTable.pTSchema); + code = tBlockDataInit(pBlockData, &id, pReader->skmTable.pTSchema, NULL, 0); if (code) goto _err; while (pRowInfo->suid == id.suid && pRowInfo->uid == id.uid) { @@ -715,7 +715,7 @@ static int32_t tsdbSnapWriteTableDataStart(STsdbSnapWriter* pWriter, TABLEID* pI if (code) goto _err; tMapDataReset(&pWriter->dWriter.mDataBlk); - code = tBlockDataInit(&pWriter->dWriter.bData, pId->suid, pId->uid, pWriter->skmTable.pTSchema); + code = tBlockDataInit(&pWriter->dWriter.bData, pId, pWriter->skmTable.pTSchema, NULL, 0); if (code) goto _err; return code; @@ -1000,7 +1000,8 @@ static int32_t tsdbSnapWriteToSttFile(STsdbSnapWriter* pWriter, int32_t iRow) { code = tsdbUpdateTableSchema(pWriter->pTsdb->pVnode->pMeta, pWriter->id.suid, pWriter->id.uid, &pWriter->skmTable); if (code) goto _err; - code = tBlockDataInit(pBData, pWriter->id.suid, pWriter->id.suid ? 0 : pWriter->id.uid, pWriter->skmTable.pTSchema); + TABLEID tid = {.suid = pWriter->id.suid, .uid = pWriter->id.suid ? 0 : pWriter->id.uid}; + code = tBlockDataInit(pBData, &tid, pWriter->skmTable.pTSchema, NULL, 0); if (code) goto _err; } diff --git a/source/dnode/vnode/src/tsdb/tsdbUtil.c b/source/dnode/vnode/src/tsdb/tsdbUtil.c index 8026441cbc..4999e7a49a 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUtil.c +++ b/source/dnode/vnode/src/tsdb/tsdbUtil.c @@ -948,24 +948,47 @@ void tBlockDataDestroy(SBlockData *pBlockData, int8_t deepClear) { pBlockData->aColData = NULL; } -int32_t tBlockDataInit(SBlockData *pBlockData, int64_t suid, int64_t uid, STSchema *pTSchema) { +int32_t tBlockDataInit(SBlockData *pBlockData, TABLEID *pId, STSchema *pTSchema, int16_t *aCid, int32_t nCid) { int32_t code = 0; - ASSERT(suid || uid); + ASSERT(pId->suid || pId->uid); - pBlockData->suid = suid; - pBlockData->uid = uid; + pBlockData->suid = pId->suid; + pBlockData->uid = pId->uid; pBlockData->nRow = 0; taosArrayClear(pBlockData->aIdx); - for (int32_t iColumn = 1; iColumn < pTSchema->numOfCols; iColumn++) { + if (aCid) { + int32_t iColumn = 1; STColumn *pTColumn = &pTSchema->columns[iColumn]; + for (int32_t iCid = 0; iCid < nCid; iCid++) { + while (pTColumn && pTColumn->colId < aCid[iCid]) { + iColumn++; + pTColumn = (iColumn < pTSchema->numOfCols) ? &pTSchema->columns[iColumn] : NULL; + } - SColData *pColData; - code = tBlockDataAddColData(pBlockData, iColumn - 1, &pColData); - if (code) goto _exit; + if (pTColumn == NULL) { + break; + } else if (pTColumn->colId == aCid[iCid]) { + SColData *pColData; + code = tBlockDataAddColData(pBlockData, taosArrayGetSize(pBlockData->aIdx), &pColData); + if (code) goto _exit; + tColDataInit(pColData, pTColumn->colId, pTColumn->type, (pTColumn->flags & COL_SMA_ON) ? 1 : 0); - tColDataInit(pColData, pTColumn->colId, pTColumn->type, (pTColumn->flags & COL_SMA_ON) ? 1 : 0); + iColumn++; + pTColumn = (iColumn < pTSchema->numOfCols) ? &pTSchema->columns[iColumn] : NULL; + } + } + } else { + for (int32_t iColumn = 1; iColumn < pTSchema->numOfCols; iColumn++) { + STColumn *pTColumn = &pTSchema->columns[iColumn]; + + SColData *pColData; + code = tBlockDataAddColData(pBlockData, iColumn - 1, &pColData); + if (code) goto _exit; + + tColDataInit(pColData, pTColumn->colId, pTColumn->type, (pTColumn->flags & COL_SMA_ON) ? 1 : 0); + } } _exit: diff --git a/source/dnode/vnode/src/vnd/vnodeBufPool.c b/source/dnode/vnode/src/vnd/vnodeBufPool.c index 5a22114ab4..6e02425b55 100644 --- a/source/dnode/vnode/src/vnd/vnodeBufPool.c +++ b/source/dnode/vnode/src/vnd/vnodeBufPool.c @@ -53,6 +53,10 @@ int vnodeCloseBufPool(SVnode *pVnode) { vnodeBufPoolDestroy(pPool); } + if (pVnode->inUse) { + vnodeBufPoolDestroy(pVnode->inUse); + pVnode->inUse = NULL; + } vDebug("vgId:%d, vnode buffer pool is closed", TD_VID(pVnode)); return 0; @@ -177,4 +181,4 @@ void vnodeBufPoolUnRef(SVBufPool *pPool) { taosThreadMutexUnlock(&pVnode->mutex); } -} \ No newline at end of file +} diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c index 4ccfea4051..b5307cecf2 100644 --- a/source/dnode/vnode/src/vnd/vnodeOpen.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -161,7 +161,6 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) { // open sync if (vnodeSyncOpen(pVnode, dir)) { vError("vgId:%d, failed to open sync since %s", TD_VID(pVnode), tstrerror(terrno)); - terrno = TSDB_CODE_OUT_OF_MEMORY; goto _err; } @@ -174,6 +173,7 @@ _err: if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb); if (pVnode->pSma) smaClose(pVnode->pSma); if (pVnode->pMeta) metaClose(pVnode->pMeta); + if (pVnode->pPool) vnodeCloseBufPool(pVnode); tsem_destroy(&(pVnode->canCommit)); taosMemoryFree(pVnode); diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index 825bf8a0a7..6806c034dc 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -409,6 +409,9 @@ int32_t vnodeGetAllTableList(SVnode *pVnode, uint64_t uid, SArray *list) { return TSDB_CODE_SUCCESS; } +int32_t vnodeGetCtbIdListByFilter(SVnode *pVnode, int64_t suid, SArray *list, bool (*filter)(void *arg), void *arg) { + return 0; +} int32_t vnodeGetCtbIdList(SVnode *pVnode, int64_t suid, SArray *list) { SMCtbCursor *pCur = metaOpenCtbCursor(pVnode->pMeta, suid); diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 6e9eba306a..28093dfc70 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -289,7 +289,7 @@ int32_t vnodePreprocessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) { int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) { vTrace("message in vnode query queue is processing"); - if ((pMsg->msgType == TDMT_SCH_QUERY) && !vnodeIsReadyForRead(pVnode)) { + if ((pMsg->msgType == TDMT_SCH_QUERY) && !vnodeIsLeader(pVnode)) { vnodeRedirectRpcMsg(pVnode, pMsg); return 0; } @@ -311,7 +311,12 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) { vTrace("vgId:%d, msg:%p in fetch queue is processing", pVnode->config.vgId, pMsg); if ((pMsg->msgType == TDMT_SCH_FETCH || pMsg->msgType == TDMT_VND_TABLE_META || pMsg->msgType == TDMT_VND_TABLE_CFG || pMsg->msgType == TDMT_VND_BATCH_META) && - !vnodeIsReadyForRead(pVnode)) { + !vnodeIsLeader(pVnode)) { + vnodeRedirectRpcMsg(pVnode, pMsg); + return 0; + } + + if (pMsg->msgType == TDMT_VND_CONSUME && !pVnode->restored) { vnodeRedirectRpcMsg(pVnode, pMsg); return 0; } @@ -808,7 +813,6 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq SSubmitRsp submitRsp = {0}; SSubmitMsgIter msgIter = {0}; SSubmitBlk *pBlock; - SSubmitRsp rsp = {0}; SVCreateTbReq createTbReq = {0}; SDecoder decoder = {0}; int32_t nRows; @@ -921,7 +925,8 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq } if (taosArrayGetSize(newTbUids) > 0) { - vDebug("vgId:%d, add %d table into query table list in handling submit", TD_VID(pVnode), (int32_t)taosArrayGetSize(newTbUids)); + vDebug("vgId:%d, add %d table into query table list in handling submit", TD_VID(pVnode), + (int32_t)taosArrayGetSize(newTbUids)); } tqUpdateTbUidList(pVnode->pTq, newTbUids, true); diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index a941b5955c..aa3f72d281 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -240,7 +240,7 @@ void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) isWeak, isBlock, msg, numOfMsgs, arrayPos, pMsg->info.handle); if (!pVnode->restored) { - vGError("vgId:%d, msg:%p failed to process since not leader", vgId, pMsg); + vGError("vgId:%d, msg:%p failed to process since restore not finished", vgId, pMsg); terrno = TSDB_CODE_APP_NOT_READY; vnodeHandleProposeError(pVnode, pMsg, TSDB_CODE_APP_NOT_READY); rpcFreeCont(pMsg->pCont); @@ -496,16 +496,16 @@ static int32_t vnodeSyncGetSnapshot(SSyncFSM *pFsm, SSnapshot *pSnapshot) { return 0; } -static void vnodeSyncReconfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReConfigCbMeta cbMeta) { +static void vnodeSyncReconfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReConfigCbMeta *cbMeta) { SVnode *pVnode = pFsm->data; SRpcMsg rpcMsg = {.msgType = pMsg->msgType, .contLen = pMsg->contLen}; - syncGetAndDelRespRpc(pVnode->sync, cbMeta.newCfgSeqNum, &rpcMsg.info); - rpcMsg.info.conn.applyIndex = cbMeta.index; + syncGetAndDelRespRpc(pVnode->sync, cbMeta->newCfgSeqNum, &rpcMsg.info); + rpcMsg.info.conn.applyIndex = cbMeta->index; const STraceId *trace = (STraceId *)&pMsg->info.traceId; vGTrace("vgId:%d, alter vnode replica is confirmed, type:%s contLen:%d seq:%" PRIu64 " handle:%p", TD_VID(pVnode), - TMSG_INFO(pMsg->msgType), pMsg->contLen, cbMeta.seqNum, rpcMsg.info.handle); + TMSG_INFO(pMsg->msgType), pMsg->contLen, cbMeta->seqNum, rpcMsg.info.handle); if (rpcMsg.info.handle != NULL) { tmsgSendRsp(&rpcMsg); } @@ -688,6 +688,8 @@ static void vnodeRestoreFinish(struct SSyncFSM *pFsm) { } } while (true); + walApplyVer(pVnode->pWal, pVnode->state.applied); + pVnode->restored = true; vDebug("vgId:%d, sync restore finished", pVnode->config.vgId); } @@ -794,16 +796,3 @@ bool vnodeIsLeader(SVnode *pVnode) { return true; } -bool vnodeIsReadyForRead(SVnode *pVnode) { - if (syncIsReady(pVnode->sync)) { - return true; - } - - if (syncIsReadyForRead(pVnode->sync)) { - return true; - } - - vDebug("vgId:%d, vnode not ready for read, state:%s, last:%ld, cmt:%ld", pVnode->config.vgId, - syncGetMyRoleStr(pVnode->sync), syncGetLastIndex(pVnode->sync), syncGetCommitIndex(pVnode->sync)); - return false; -} diff --git a/source/libs/catalog/src/ctgAsync.c b/source/libs/catalog/src/ctgAsync.c index 3c4cc9f7a2..463ea9340a 100644 --- a/source/libs/catalog/src/ctgAsync.c +++ b/source/libs/catalog/src/ctgAsync.c @@ -487,6 +487,8 @@ int32_t ctgInitTask(SCtgJob* pJob, CTG_TASK_TYPE type, void* param, int32_t* tas int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const SCatalogReq* pReq, catalogCallback fp, void* param) { int32_t code = 0; + int64_t st = taosGetTimestampUs(); + int32_t tbMetaNum = (int32_t)ctgGetTablesReqNum(pReq->pTableMeta); int32_t dbVgNum = (int32_t)taosArrayGetSize(pReq->pDbVgroup); int32_t tbHashNum = (int32_t)ctgGetTablesReqNum(pReq->pTableHash); @@ -634,12 +636,12 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const taosAcquireRef(gCtgMgmt.jobPool, pJob->refId); - qDebug("QID:0x%" PRIx64 ", jobId: 0x%" PRIx64 " initialized, task num %d, forceUpdate %d", pJob->queryId, pJob->refId, - taskNum, pReq->forceUpdate); + double el = (taosGetTimestampUs() - st)/1000.0; + qDebug("QID:0x%" PRIx64 ", jobId: 0x%" PRIx64 " initialized, task num %d, forceUpdate %d, elapsed time:%.2f ms", + pJob->queryId, pJob->refId, taskNum, pReq->forceUpdate, el); return TSDB_CODE_SUCCESS; _return: - ctgFreeJob(*job); CTG_RET(code); } diff --git a/source/libs/executor/inc/executil.h b/source/libs/executor/inc/executil.h index baf7d447cc..9dba29811e 100644 --- a/source/libs/executor/inc/executil.h +++ b/source/libs/executor/inc/executil.h @@ -15,7 +15,6 @@ #ifndef TDENGINE_QUERYUTIL_H #define TDENGINE_QUERYUTIL_H -#include "vnode.h" #include "function.h" #include "nodes.h" #include "plannodes.h" @@ -23,6 +22,7 @@ #include "tcommon.h" #include "tpagedbuf.h" #include "tsimplehash.h" +#include "vnode.h" #define T_LONG_JMP(_obj, _c) \ do { \ @@ -93,7 +93,7 @@ void resetResultRow(SResultRow* pResultRow, size_t entrySize); struct SResultRowEntryInfo* getResultEntryInfo(const SResultRow* pRow, int32_t index, const int32_t* offset); static FORCE_INLINE SResultRow* getResultRowByPos(SDiskbasedBuf* pBuf, SResultRowPosition* pos, bool forUpdate) { - SFilePage* bufPage = (SFilePage*)getBufPage(pBuf, pos->pageId); + SFilePage* bufPage = (SFilePage*)getBufPage(pBuf, pos->pageId); if (forUpdate) { setBufPageDirty(bufPage, true); } @@ -101,11 +101,6 @@ static FORCE_INLINE SResultRow* getResultRowByPos(SDiskbasedBuf* pBuf, SResultRo return pRow; } -static FORCE_INLINE void setResultBufPageDirty(SDiskbasedBuf* pBuf, SResultRowPosition* pos) { - void* pPage = getBufPage(pBuf, pos->pageId); - setBufPageDirty(pPage, true); -} - void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap, int32_t order); void cleanupGroupResInfo(SGroupResInfo* pGroupResInfo); @@ -117,17 +112,18 @@ int32_t getNumOfTotalRes(SGroupResInfo* pGroupResInfo); SSDataBlock* createResDataBlock(SDataBlockDescNode* pNode); EDealRes doTranslateTagExpr(SNode** pNode, void* pContext); -int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode, SNode* pTagCond, SNode* pTagIndexCond, STableListInfo* pListInfo); -int32_t getGroupIdFromTagsVal(void* pMeta, uint64_t uid, SNodeList* pGroupNode, char* keyBuf, uint64_t* pGroupId); -int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableListInfo* pTableListInfo); -size_t getTableTagsBufLen(const SNodeList* pGroups); +int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode, SNode* pTagCond, SNode* pTagIndexCond, + STableListInfo* pListInfo); +int32_t getGroupIdFromTagsVal(void* pMeta, uint64_t uid, SNodeList* pGroupNode, char* keyBuf, uint64_t* pGroupId); +int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableListInfo* pTableListInfo); +size_t getTableTagsBufLen(const SNodeList* pGroups); -SArray* createSortInfo(SNodeList* pNodeList); -SArray* extractPartitionColInfo(SNodeList* pNodeList); -SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNodeList, int32_t* numOfOutputCols, - int32_t type); +SArray* createSortInfo(SNodeList* pNodeList); +SArray* extractPartitionColInfo(SNodeList* pNodeList); +SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNodeList, int32_t* numOfOutputCols, + int32_t type); -void createExprFromTargetNode(SExprInfo* pExp, STargetNode* pTargetNode); +void createExprFromTargetNode(SExprInfo* pExp, STargetNode* pTargetNode); SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* numOfExprs); SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, int32_t** rowEntryInfoOffset); diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index dc98b05479..897015c4d3 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -34,6 +34,7 @@ extern "C" { #include "scalar.h" #include "taosdef.h" #include "tarray.h" +#include "tfill.h" #include "thash.h" #include "tlockfree.h" #include "tmsg.h" @@ -145,6 +146,7 @@ typedef struct { SMqMetaRsp metaRsp; // for tmq fetching meta int8_t returned; int64_t snapshotVer; + const SSubmitReq* pReq; SSchemaWrapper* schema; char tbName[TSDB_TABLE_NAME_LEN]; @@ -191,6 +193,7 @@ enum { OP_OPENED = 0x1, OP_RES_TO_RETURN = 0x5, OP_EXEC_DONE = 0x9, + OP_EXEC_RECV = 0x11, }; typedef struct SOperatorFpSet { @@ -574,13 +577,7 @@ typedef struct SIntervalAggOperatorInfo { int32_t inputOrder; // input data ts order EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model] STimeWindowAggSupp twAggSup; - bool invertible; SArray* pPrevValues; // SArray used to keep the previous not null value for interpolation. - bool ignoreExpiredData; - SArray* pRecycledPages; - SArray* pDelWins; // SWinRes - int32_t delIndex; - SSDataBlock* pDelRes; SNode* pCondition; } SIntervalAggOperatorInfo; @@ -606,38 +603,21 @@ typedef struct SStreamIntervalOperatorInfo { STimeWindowAggSupp twAggSup; bool invertible; bool ignoreExpiredData; - SArray* pRecycledPages; SArray* pDelWins; // SWinRes int32_t delIndex; SSDataBlock* pDelRes; - bool isFinal; -} SStreamIntervalOperatorInfo; - -typedef struct SStreamFinalIntervalOperatorInfo { - // SOptrBasicInfo should be first, SAggSupporter should be second for stream encode - SOptrBasicInfo binfo; // basic info - SAggSupporter aggSup; // aggregate supporter - SExprSupp scalarSupp; // supporter for perform scalar function - SGroupResInfo groupResInfo; // multiple results build supporter - SInterval interval; // interval info - int32_t primaryTsIndex; // primary time stamp slot id from result of downstream operator. - int32_t order; // current SSDataBlock scan order - STimeWindowAggSupp twAggSup; - SArray* pChildren; SSDataBlock* pUpdateRes; bool returnUpdate; - SPhysiNode* pPhyNode; // create new child - bool isFinal; + SPhysiNode* pPhyNode; // create new child SHashObj* pPullDataMap; - SArray* pPullWins; // SPullWindowInfo + SArray* pPullWins; // SPullWindowInfo int32_t pullIndex; SSDataBlock* pPullDataRes; - bool ignoreExpiredData; - SArray* pRecycledPages; - SArray* pDelWins; // SWinRes - int32_t delIndex; - SSDataBlock* pDelRes; -} SStreamFinalIntervalOperatorInfo; + bool isFinal; + SArray* pChildren; + SStreamState* pState; + SWinKey delKey; +} SStreamIntervalOperatorInfo; typedef struct SAggOperatorInfo { // SOptrBasicInfo should be first, SAggSupporter should be second for stream encode @@ -798,6 +778,22 @@ typedef struct SStreamPartitionOperatorInfo { SSDataBlock* pDelRes; } SStreamPartitionOperatorInfo; +typedef struct SStreamFillOperatorInfo { + SStreamFillSupporter* pFillSup; + SSDataBlock* pRes; + SSDataBlock* pSrcBlock; + int32_t srcRowIndex; + SSDataBlock* pPrevSrcBlock; + SSDataBlock* pSrcDelBlock; + int32_t srcDelRowIndex; + SSDataBlock* pDelRes; + SNode* pCondition; + SArray* pColMatchColInfo; + int32_t primaryTsCol; + int32_t primarySrcSlotId; + SStreamFillInfo* pFillInfo; +} SStreamFillOperatorInfo; + typedef struct STimeSliceOperatorInfo { SSDataBlock* pRes; STimeWindow win; @@ -990,7 +986,7 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWi SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartitionPhysiNode* pPartNode, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SPartitionPhysiNode* pPartNode, +SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStreamPartitionPhysiNode* pPartNode, SExecTaskInfo* pTaskInfo); SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pNode, SExecTaskInfo* pTaskInfo); @@ -1006,6 +1002,8 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createStreamFillOperatorInfo(SOperatorInfo* downstream, SStreamFillPhysiNode* pPhyFillNode, + SExecTaskInfo* pTaskInfo); int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* pSrcBlock, SqlFunctionCtx* pCtx, int32_t numOfOutput, SArray* pPseudoList); @@ -1065,7 +1063,7 @@ bool functionNeedToExecute(SqlFunctionCtx* pCtx); bool isOverdue(TSKEY ts, STimeWindowAggSupp* pSup); bool isCloseWindow(STimeWindow* pWin, STimeWindowAggSupp* pSup); bool isDeletedWindow(STimeWindow* pWin, uint64_t groupId, SAggSupporter* pSup); -bool isDeletedStreamWindow(STimeWindow* pWin, uint64_t groupId, SOperatorInfo* pOperator, STimeWindowAggSupp* pTwSup); +bool isDeletedStreamWindow(STimeWindow* pWin, uint64_t groupId, SStreamState* pState, STimeWindowAggSupp* pTwSup); void appendOneRow(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* pUid, uint64_t* pGp); void printDataBlock(SSDataBlock* pBlock, const char* flag); uint64_t calGroupIdByData(SPartitionBySupporter* pParSup, SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t rowId); @@ -1087,13 +1085,13 @@ void copyUpdateDataBlock(SSDataBlock* pDest, SSDataBlock* pSource, int32_t tsCol bool groupbyTbname(SNodeList* pGroupList); int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, SNodeList* groupKey); void* destroySqlFunctionCtx(SqlFunctionCtx* pCtx, int32_t numOfOutput); -int32_t buildDataBlockFromGroupRes(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprSupp* pSup, +int32_t buildDataBlockFromGroupRes(SExecTaskInfo* pTaskInfo, SStreamState* pState, SSDataBlock* pBlock, SExprSupp* pSup, SGroupResInfo* pGroupResInfo); -int32_t setOutputBuf(STimeWindow* win, SResultRow** pResult, int64_t tableGroupId, SqlFunctionCtx* pCtx, - int32_t numOfOutput, int32_t* rowEntryInfoOffset, SAggSupporter* pAggSup, - SExecTaskInfo* pTaskInfo); -int32_t releaseOutputBuf(SExecTaskInfo* pTaskInfo, SWinKey* pKey, SResultRow* pResult); -int32_t saveOutputBuf(SExecTaskInfo* pTaskInfo, SWinKey* pKey, SResultRow* pResult, int32_t resSize); +int32_t setOutputBuf(SStreamState* pState, STimeWindow* win, SResultRow** pResult, int64_t tableGroupId, SqlFunctionCtx* pCtx, + int32_t numOfOutput, int32_t* rowEntryInfoOffset, SAggSupporter* pAggSup); +int32_t releaseOutputBuf(SStreamState* pState, SWinKey* pKey, SResultRow* pResult); +int32_t saveOutputBuf(SStreamState* pState, SWinKey* pKey, SResultRow* pResult, int32_t resSize); +void getNextIntervalWindow(SInterval* pInterval, STimeWindow* tw, int32_t order); #ifdef __cplusplus } diff --git a/source/libs/executor/inc/tfill.h b/source/libs/executor/inc/tfill.h index 63abfc019d..ed019be767 100644 --- a/source/libs/executor/inc/tfill.h +++ b/source/libs/executor/inc/tfill.h @@ -23,12 +23,13 @@ extern "C" { #include "os.h" #include "taosdef.h" #include "tcommon.h" +#include "tsimplehash.h" struct SSDataBlock; typedef struct SFillColInfo { - SExprInfo *pExpr; - bool notFillCol; // denote if this column needs fill operation + SExprInfo* pExpr; + bool notFillCol; // denote if this column needs fill operation SVariant fillVal; } SFillColInfo; @@ -51,46 +52,96 @@ typedef struct { } SRowVal; typedef struct SFillInfo { - TSKEY start; // start timestamp - TSKEY end; // endKey for fill - TSKEY currentKey; // current active timestamp, the value may be changed during the fill procedure. - int32_t tsSlotId; // primary time stamp slot id - int32_t srcTsSlotId; // timestamp column id in the source data block. - int32_t order; // order [TSDB_ORDER_ASC|TSDB_ORDER_DESC] - int32_t type; // fill type - int32_t numOfRows; // number of rows in the input data block - int32_t index; // active row index - int32_t numOfTotal; // number of filled rows in one round - int32_t numOfCurrent; // number of filled rows in current results - int32_t numOfCols; // number of columns, including the tags columns - SInterval interval; - SRowVal prev; - SRowVal next; - SSDataBlock *pSrcBlock; - int32_t alloc; // data buffer size in rows + TSKEY start; // start timestamp + TSKEY end; // endKey for fill + TSKEY currentKey; // current active timestamp, the value may be changed during the fill procedure. + int32_t tsSlotId; // primary time stamp slot id + int32_t srcTsSlotId; // timestamp column id in the source data block. + int32_t order; // order [TSDB_ORDER_ASC|TSDB_ORDER_DESC] + int32_t type; // fill type + int32_t numOfRows; // number of rows in the input data block + int32_t index; // active row index + int32_t numOfTotal; // number of filled rows in one round + int32_t numOfCurrent; // number of filled rows in current results + int32_t numOfCols; // number of columns, including the tags columns + SInterval interval; + SRowVal prev; + SRowVal next; + SSDataBlock* pSrcBlock; + int32_t alloc; // data buffer size in rows - SFillColInfo* pFillCol; // column info for fill operations - SFillTagColInfo* pTags; // tags value for filling gap - const char* id; + SFillColInfo* pFillCol; // column info for fill operations + SFillTagColInfo* pTags; // tags value for filling gap + const char* id; } SFillInfo; +typedef struct SResultCellData { + bool isNull; + int8_t type; + int32_t bytes; + char pData[]; +} SResultCellData; + +typedef struct SResultRowData { + TSKEY key; + SResultCellData* pRowVal; +} SResultRowData; + +typedef struct SStreamFillLinearInfo { + TSKEY nextEnd; + SArray* pDeltaVal; // double. value for Fill(linear). + SArray* pNextDeltaVal; // double. value for Fill(linear). + int64_t winIndex; + bool hasNext; +} SStreamFillLinearInfo; + +typedef struct SStreamFillInfo { + TSKEY start; // startKey for fill + TSKEY end; // endKey for fill + TSKEY current; // current Key for fill + TSKEY preRowKey; + TSKEY nextRowKey; + SResultRowData* pResRow; + SStreamFillLinearInfo* pLinearInfo; + bool needFill; + int32_t type; // fill type + int32_t pos; + SArray* delRanges; + int32_t delIndex; +} SStreamFillInfo; + +typedef struct SStreamFillSupporter { + int32_t type; // fill type + SInterval interval; + SResultRowData prev; + SResultRowData cur; + SResultRowData next; + SResultRowData nextNext; + SFillColInfo* pAllColInfo; // fill exprs and not fill exprs + int32_t numOfAllCols; // number of all exprs, including the tags columns + int32_t numOfFillCols; + int32_t numOfNotFillCols; + int32_t rowSize; + SSHashObj* pResMap; + bool hasDelete; +} SStreamFillSupporter; + int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, int64_t ekey, int32_t maxNumOfRows); - -void taosFillSetStartInfo(struct SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey); -void taosResetFillInfo(struct SFillInfo* pFillInfo, TSKEY startTimestamp); -void taosFillSetInputDataBlock(struct SFillInfo* pFillInfo, const struct SSDataBlock* pInput); -struct SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfFillExpr, SExprInfo* pNotFillExpr, int32_t numOfNotFillCols, const struct SNodeListNode* val); -bool taosFillHasMoreResults(struct SFillInfo* pFillInfo); +void taosFillSetStartInfo(struct SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey); +void taosResetFillInfo(struct SFillInfo* pFillInfo, TSKEY startTimestamp); +void taosFillSetInputDataBlock(struct SFillInfo* pFillInfo, const struct SSDataBlock* pInput); +struct SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfFillExpr, SExprInfo* pNotFillExpr, + int32_t numOfNotFillCols, const struct SNodeListNode* val); +bool taosFillHasMoreResults(struct SFillInfo* pFillInfo); SFillInfo* taosCreateFillInfo(TSKEY skey, int32_t numOfFillCols, int32_t numOfNotFillCols, int32_t capacity, SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol, int32_t slotId, int32_t order, const char* id); -void* taosDestroyFillInfo(struct SFillInfo *pFillInfo); +void* taosDestroyFillInfo(struct SFillInfo* pFillInfo); int64_t taosFillResultDataBlock(struct SFillInfo* pFillInfo, SSDataBlock* p, int32_t capacity); -int64_t getFillInfoStart(struct SFillInfo *pFillInfo); - +int64_t getFillInfoStart(struct SFillInfo* pFillInfo); #ifdef __cplusplus } diff --git a/source/libs/executor/src/cachescanoperator.c b/source/libs/executor/src/cachescanoperator.c index 94d9d0cadb..1b7448712e 100644 --- a/source/libs/executor/src/cachescanoperator.c +++ b/source/libs/executor/src/cachescanoperator.c @@ -207,7 +207,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) { } } - tsdbCacherowsReaderClose(pInfo->pLastrowReader); + pInfo->pLastrowReader = tsdbCacherowsReaderClose(pInfo->pLastrowReader); return pInfo->pRes; } } @@ -220,6 +220,15 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) { void destroyLastrowScanOperator(void* param) { SLastrowScanInfo* pInfo = (SLastrowScanInfo*)param; blockDataDestroy(pInfo->pRes); + blockDataDestroy(pInfo->pBufferredRes); + taosMemoryFree(pInfo->pSlotIds); + taosArrayDestroy(pInfo->pUidList); + taosArrayDestroy(pInfo->pColMatchInfo); + + if (pInfo->pLastrowReader != NULL) { + pInfo->pLastrowReader = tsdbCacherowsReaderClose(pInfo->pLastrowReader); + } + taosMemoryFreeClear(param); } diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index b26603b394..38304bcc76 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -26,6 +26,9 @@ #include "executorimpl.h" #include "tcompression.h" +static int32_t optimizeTbnameInCond(void* metaHandle, int64_t suid, SArray* list, SNode* pTagCond); +static int32_t optimizeTbnameInCondImpl(void* metaHandle, int64_t suid, SArray* list, SNode* pTagCond); + void initResultRowInfo(SResultRowInfo* pResultRowInfo) { pResultRowInfo->size = 0; pResultRowInfo->cur.pageId = -1; @@ -407,11 +410,18 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray // int64_t stt = taosGetTimestampUs(); tags = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); - code = metaGetTableTags(metaHandle, suid, uidList, tags); - if (code != TSDB_CODE_SUCCESS) { - qError("failed to get table tags from meta, reason:%s, suid:%" PRIu64, tstrerror(code), suid); - terrno = code; - goto end; + + int32_t filter = optimizeTbnameInCond(metaHandle, suid, uidList, pTagCond); + if (filter == -1) { + code = metaGetTableTags(metaHandle, suid, uidList, tags); + if (code != TSDB_CODE_SUCCESS) { + qError("failed to get table tags from meta, reason:%s, suid:%" PRIu64, tstrerror(code), suid); + terrno = code; + goto end; + } + } else { + metaGetTableTagsOpt(metaHandle, suid, uidList, tags); + qInfo("succ to get table from meta idx, suid:%" PRIu64, suid); } int32_t rows = taosArrayGetSize(uidList); @@ -742,6 +752,94 @@ end: return code; } +static int tableUidCompare(const void* a, const void* b) { + uint64_t u1 = *(uint64_t*)a; + uint64_t u2 = *(uint64_t*)b; + if (u1 == u2) { + return 0; + } + return u1 < u2 ? -1 : 1; +} +static int32_t optimizeTbnameInCond(void* metaHandle, int64_t suid, SArray* list, SNode* cond) { + if (nodeType(cond) == QUERY_NODE_OPERATOR) { + return optimizeTbnameInCondImpl(metaHandle, suid, list, cond); + } + + if (nodeType(cond) != QUERY_NODE_LOGIC_CONDITION || ((SLogicConditionNode*)cond)->condType != LOGIC_COND_TYPE_AND) { + return -1; + } + + bool hasTbnameCond = false; + SLogicConditionNode* pNode = (SLogicConditionNode*)cond; + SNodeList* pList = (SNodeList*)pNode->pParameterList; + + int32_t len = LIST_LENGTH(pList); + if (len <= 0) return -1; + + SListCell* cell = pList->pHead; + for (int i = 0; i < len; i++) { + if (cell == NULL) break; + if (optimizeTbnameInCondImpl(metaHandle, suid, list, cell->pNode) == 0) { + hasTbnameCond = true; + } + cell = cell->pNext; + } + taosArraySort(list, tableUidCompare); + taosArrayRemoveDuplicate(list, tableUidCompare, NULL); + + return hasTbnameCond == true ? 0 : -1; +} +static int32_t optimizeTbnameInCondImpl(void* metaHandle, int64_t suid, SArray* list, SNode* pTagCond) { + if (nodeType(pTagCond) != QUERY_NODE_OPERATOR) { + return -1; + } + SOperatorNode* pNode = (SOperatorNode*)pTagCond; + if (pNode->opType != OP_TYPE_IN) { + return -1; + } + if ((pNode->pLeft != NULL && nodeType(pNode->pLeft) == QUERY_NODE_COLUMN && + ((SColumnNode*)pNode->pLeft)->colType == COLUMN_TYPE_TBNAME) && + (pNode->pRight != NULL && nodeType(pNode->pRight) == QUERY_NODE_NODE_LIST)) { + SNodeListNode* pList = (SNodeListNode*)pNode->pRight; + + int32_t len = LIST_LENGTH(pList->pNodeList); + if (len <= 0) return -1; + + SListCell* cell = pList->pNodeList->pHead; + + SArray* pTbList = taosArrayInit(len, sizeof(void*)); + for (int i = 0; i < pList->pNodeList->length; i++) { + SValueNode* valueNode = (SValueNode*)cell->pNode; + if (!IS_VAR_DATA_TYPE(valueNode->node.resType.type)) { + taosArrayDestroy(pTbList); + return -1; + } + char* name = varDataVal(valueNode->datum.p); + taosArrayPush(pTbList, &name); + cell = cell->pNext; + } + + for (int i = 0; i < taosArrayGetSize(pTbList); i++) { + char* name = taosArrayGetP(pTbList, i); + uint64_t uid = 0; + if (metaGetTableUidByName(metaHandle, name, &uid) == 0) { + ETableType tbType = TSDB_TABLE_MAX; + if (metaGetTableTypeByName(metaHandle, name, &tbType) == 0 && tbType == TSDB_CHILD_TABLE) { + taosArrayPush(list, &uid); + } else { + taosArrayDestroy(pTbList); + return -1; + } + } else { + qWarn("failed to get tableIds from by table name: %s, reason: %s", name, tstrerror(terrno)); + terrno = 0; + } + } + taosArrayDestroy(pTbList); + return 0; + } + return -1; +} int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode, SNode* pTagCond, SNode* pTagIndexCond, STableListInfo* pListInfo) { int32_t code = TSDB_CODE_SUCCESS; @@ -767,9 +865,6 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode, qError("failed to get tableIds from index, reason:%s, suid:%" PRIu64, tstrerror(code), tableUid); code = TDB_CODE_SUCCESS; } - - // int64_t stt1 = taosGetTimestampUs(); - // qDebug("generate table list, cost:%ld us", stt1-stt); } else if (!pTagCond) { vnodeGetCtbIdList(pVnode, pScanNode->suid, res); } @@ -813,7 +908,7 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode, size_t numOfTables = taosArrayGetSize(res); for (int i = 0; i < numOfTables; i++) { STableKeyInfo info = {.uid = *(uint64_t*)taosArrayGet(res, i), .groupId = 0}; - void* p = taosArrayPush(pListInfo->pTableList, &info); + void* p = taosArrayPush(pListInfo->pTableList, &info); if (p == NULL) { taosArrayDestroy(res); return TSDB_CODE_OUT_OF_MEMORY; diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index 373cb451f4..a8c73f0170 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -479,14 +479,14 @@ static void freeBlock(void* param) { blockDataDestroy(pBlock); } -int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, SLocalFetch* pLocal) { +int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, bool* hasMore, SLocalFetch* pLocal) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; int64_t threadId = taosGetSelfPthreadId(); if (pLocal) { memcpy(&pTaskInfo->localFetch, pLocal, sizeof(*pLocal)); } - + taosArrayClearEx(pResList, freeBlock); int64_t curOwner = 0; @@ -536,6 +536,7 @@ int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, SL } } + *hasMore = (pRes != NULL); uint64_t el = (taosGetTimestampUs() - st); pTaskInfo->cost.elapsedTime += el; @@ -773,6 +774,14 @@ int32_t initQueryTableDataCondForTmq(SQueryTableDataCond* pCond, SSnapContext* s return TSDB_CODE_SUCCESS; } +int32_t qStreamScanMemData(qTaskInfo_t tinfo, const SSubmitReq* pReq) { + SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; + ASSERT(pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE); + ASSERT(pTaskInfo->streamInfo.pReq == NULL); + pTaskInfo->streamInfo.pReq = pReq; + return 0; +} + int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subType) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; SOperatorInfo* pOperator = pTaskInfo->pRoot; diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 7fcd41dc3e..5db55b02f8 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -1110,7 +1110,8 @@ void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numO } } -static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, bool keep, int32_t status); +static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, bool keep, + int32_t status); void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, const SArray* pColMatchInfo) { if (pFilterNode == NULL || pBlock->info.rows == 0) { @@ -1120,12 +1121,12 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, const SArray* pColM SFilterInfo* filter = NULL; // todo move to the initialization function - int32_t code = filterInitFromNode((SNode*)pFilterNode, &filter, 0); + int32_t code = filterInitFromNode((SNode*)pFilterNode, &filter, 0); SFilterColumnParam param1 = {.numOfCols = taosArrayGetSize(pBlock->pDataBlock), .pDataBlock = pBlock->pDataBlock}; code = filterSetDataFromSlotId(filter, ¶m1); SColumnInfoData* p = NULL; - int32_t status = 0; + int32_t status = 0; // todo the keep seems never to be True?? bool keep = filterExecute(filter, pBlock, &p, NULL, param1.numOfCols, &status); @@ -1201,7 +1202,7 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoD } } - void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId) { +void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId) { // for simple group by query without interval, all the tables belong to one group result. SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SAggOperatorInfo* pAggInfo = pOperator->info; @@ -1272,6 +1273,14 @@ static void doCopyResultToDataBlock(SExprInfo* pExprInfo, int32_t numOfExprs, SR pCtx[j].resultInfo = getResultEntryInfo(pRow, j, rowEntryOffset); if (pCtx[j].fpSet.finalize) { + if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_group_key") == 0) { + // for groupkey along with functions that output multiple lines(e.g. Histogram) + // need to match groupkey result for each output row of that function. + if (pCtx[j].resultInfo->numOfRes != 0) { + pCtx[j].resultInfo->numOfRes = pRow->numOfRows; + } + } + int32_t code = pCtx[j].fpSet.finalize(&pCtx[j], pBlock); if (TAOS_FAILED(code)) { qError("%s build result data block error, code %s", GET_TASKID(pTaskInfo), tstrerror(code)); @@ -1787,7 +1796,9 @@ static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInf if (pSource->localExec) { SDataBuf pBuf = {0}; - int32_t code = (*pTaskInfo->localFetch.fp)(pTaskInfo->localFetch.handle, pSource->schedId, pTaskInfo->id.queryId, pSource->taskId, 0, pSource->execId, &pBuf.pData, pTaskInfo->localFetch.explainRes); + int32_t code = + (*pTaskInfo->localFetch.fp)(pTaskInfo->localFetch.handle, pSource->schedId, pTaskInfo->id.queryId, + pSource->taskId, 0, pSource->execId, &pBuf.pData, pTaskInfo->localFetch.explainRes); loadRemoteDataCallback(pWrapper, &pBuf, code); taosMemoryFree(pWrapper); } else { @@ -1798,8 +1809,8 @@ static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInf } qDebug("%s build fetch msg and send to vgId:%d, ep:%s, taskId:0x%" PRIx64 ", execId:%d, %d/%" PRIzu, - GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->addr.epSet.eps[0].fqdn, pSource->taskId, pSource->execId, - sourceIndex, totalSources); + GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->addr.epSet.eps[0].fqdn, pSource->taskId, + pSource->execId, sourceIndex, totalSources); pMsg->header.vgId = htonl(pSource->addr.nodeId); pMsg->sId = htobe64(pSource->schedId); @@ -1824,9 +1835,10 @@ static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInf pMsgSendInfo->fp = loadRemoteDataCallback; int64_t transporterId = 0; - int32_t code = asyncSendMsgToServer(pExchangeInfo->pTransporter, &pSource->addr.epSet, &transporterId, pMsgSendInfo); + int32_t code = + asyncSendMsgToServer(pExchangeInfo->pTransporter, &pSource->addr.epSet, &transporterId, pMsgSendInfo); } - + return TSDB_CODE_SUCCESS; } @@ -3356,9 +3368,7 @@ static void cleanupTableSchemaInfo(SSchemaInfo* pSchemaInfo) { tDeleteSSchemaWrapper(pSchemaInfo->qsw); } -static void cleanupStreamInfo(SStreamTaskInfo* pStreamInfo) { - tDeleteSSchemaWrapper(pStreamInfo->schema); -} +static void cleanupStreamInfo(SStreamTaskInfo* pStreamInfo) { tDeleteSSchemaWrapper(pStreamInfo->schema); } static int32_t sortTableGroup(STableListInfo* pTableListInfo) { taosArrayClear(pTableListInfo->pGroupList); @@ -3539,7 +3549,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo STableScanInfo* pScanInfo = pOperator->info; pTaskInfo->cost.pRecoder = &pScanInfo->readRecorder; } else if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == type) { - pOperator = createExchangeOperatorInfo(pHandle ? pHandle->pMsgCb->clientRpc : NULL, (SExchangePhysiNode*)pPhyNode, pTaskInfo); + pOperator = createExchangeOperatorInfo(pHandle ? pHandle->pMsgCb->clientRpc : NULL, (SExchangePhysiNode*)pPhyNode, + pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN == type) { STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode; if (pHandle->vnode) { @@ -3729,7 +3740,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo } else if (QUERY_NODE_PHYSICAL_PLAN_PARTITION == type) { pOptr = createPartitionOperatorInfo(ops[0], (SPartitionPhysiNode*)pPhyNode, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION == type) { - pOptr = createStreamPartitionOperatorInfo(ops[0], (SPartitionPhysiNode*)pPhyNode, pTaskInfo); + pOptr = createStreamPartitionOperatorInfo(ops[0], (SStreamPartitionPhysiNode*)pPhyNode, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE == type) { SStateWinodwPhysiNode* pStateNode = (SStateWinodwPhysiNode*)pPhyNode; pOptr = createStatewindowOperatorInfo(ops[0], pStateNode, pTaskInfo); @@ -3739,6 +3750,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo pOptr = createMergeJoinOperatorInfo(ops, size, (SSortMergeJoinPhysiNode*)pPhyNode, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_FILL == type) { pOptr = createFillOperatorInfo(ops[0], (SFillPhysiNode*)pPhyNode, pTaskInfo); + } else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL == type) { + pOptr = createStreamFillOperatorInfo(ops[0], (SStreamFillPhysiNode*)pPhyNode, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC == type) { pOptr = createIndefinitOutputOperatorInfo(ops[0], pPhyNode, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC == type) { @@ -4058,7 +4071,7 @@ void doDestroyTask(SExecTaskInfo* pTaskInfo) { if (!pTaskInfo->localFetch.localExec) { nodesDestroyNode((SNode*)pTaskInfo->pSubplan); } - + taosMemoryFreeClear(pTaskInfo->sql); taosMemoryFreeClear(pTaskInfo->id.str); taosMemoryFreeClear(pTaskInfo); @@ -4170,9 +4183,8 @@ int32_t initStreamAggSupporter(SStreamAggSupporter* pSup, const char* pKey, SqlF return code; } -int32_t setOutputBuf(STimeWindow* win, SResultRow** pResult, int64_t tableGroupId, SqlFunctionCtx* pCtx, - int32_t numOfOutput, int32_t* rowEntryInfoOffset, SAggSupporter* pAggSup, - SExecTaskInfo* pTaskInfo) { +int32_t setOutputBuf(SStreamState* pState, STimeWindow* win, SResultRow** pResult, int64_t tableGroupId, + SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowEntryInfoOffset, SAggSupporter* pAggSup) { SWinKey key = { .ts = win->skey, .groupId = tableGroupId, @@ -4181,7 +4193,7 @@ int32_t setOutputBuf(STimeWindow* win, SResultRow** pResult, int64_t tableGroupI int32_t size = pAggSup->resultRowSize; tSimpleHashPut(pAggSup->pResultRowHashTable, &key, sizeof(SWinKey), NULL, 0); - if (streamStateAddIfNotExist(pTaskInfo->streamInfo.pState, &key, (void**)&value, &size) < 0) { + if (streamStateAddIfNotExist(pState, &key, (void**)&value, &size) < 0) { return TSDB_CODE_QRY_OUT_OF_MEMORY; } *pResult = (SResultRow*)value; @@ -4192,18 +4204,17 @@ int32_t setOutputBuf(STimeWindow* win, SResultRow** pResult, int64_t tableGroupI return TSDB_CODE_SUCCESS; } -int32_t releaseOutputBuf(SExecTaskInfo* pTaskInfo, SWinKey* pKey, SResultRow* pResult) { - streamStateReleaseBuf(pTaskInfo->streamInfo.pState, pKey, pResult); - /*taosMemoryFree((*(void**)pResult));*/ +int32_t releaseOutputBuf(SStreamState* pState, SWinKey* pKey, SResultRow* pResult) { + streamStateReleaseBuf(pState, pKey, pResult); return TSDB_CODE_SUCCESS; } -int32_t saveOutputBuf(SExecTaskInfo* pTaskInfo, SWinKey* pKey, SResultRow* pResult, int32_t resSize) { - streamStatePut(pTaskInfo->streamInfo.pState, pKey, pResult, resSize); +int32_t saveOutputBuf(SStreamState* pState, SWinKey* pKey, SResultRow* pResult, int32_t resSize) { + streamStatePut(pState, pKey, pResult, resSize); return TSDB_CODE_SUCCESS; } -int32_t buildDataBlockFromGroupRes(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprSupp* pSup, +int32_t buildDataBlockFromGroupRes(SExecTaskInfo* pTaskInfo, SStreamState* pState, SSDataBlock* pBlock, SExprSupp* pSup, SGroupResInfo* pGroupResInfo) { SExprInfo* pExprInfo = pSup->pExprInfo; int32_t numOfExprs = pSup->numOfExprs; @@ -4220,14 +4231,14 @@ int32_t buildDataBlockFromGroupRes(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock .ts = *(TSKEY*)pPos->key, .groupId = pPos->groupId, }; - int32_t code = streamStateGet(pTaskInfo->streamInfo.pState, &key, &pVal, &size); + int32_t code = streamStateGet(pState, &key, &pVal, &size); ASSERT(code == 0); SResultRow* pRow = (SResultRow*)pVal; doUpdateNumOfRows(pCtx, pRow, numOfExprs, rowEntryOffset); // no results, continue to check the next one if (pRow->numOfRows == 0) { pGroupResInfo->index += 1; - releaseOutputBuf(pTaskInfo, &key, pRow); + releaseOutputBuf(pState, &key, pRow); continue; } @@ -4236,14 +4247,14 @@ int32_t buildDataBlockFromGroupRes(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock } else { // current value belongs to different group, it can't be packed into one datablock if (pBlock->info.groupId != pPos->groupId) { - releaseOutputBuf(pTaskInfo, &key, pRow); + releaseOutputBuf(pState, &key, pRow); break; } } if (pBlock->info.rows + pRow->numOfRows > pBlock->info.capacity) { ASSERT(pBlock->info.rows > 0); - releaseOutputBuf(pTaskInfo, &key, pRow); + releaseOutputBuf(pState, &key, pRow); break; } @@ -4273,7 +4284,7 @@ int32_t buildDataBlockFromGroupRes(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock } pBlock->info.rows += pRow->numOfRows; - releaseOutputBuf(pTaskInfo, &key, pRow); + releaseOutputBuf(pState, &key, pRow); } blockDataUpdateTsWindow(pBlock, 0); return TSDB_CODE_SUCCESS; diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index 5eb6557dbd..7cb641a943 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -989,11 +989,11 @@ SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStr goto _error; } int32_t code = TSDB_CODE_SUCCESS; - pInfo->partitionSup.pGroupCols = extractPartitionColInfo(pPartNode->pPartitionKeys); + pInfo->partitionSup.pGroupCols = extractPartitionColInfo(pPartNode->part.pPartitionKeys); - if (pPartNode->pExprs != NULL) { + if (pPartNode->part.pExprs != NULL) { int32_t num = 0; - SExprInfo* pCalExprInfo = createExprInfo(pPartNode->pExprs, NULL, &num); + SExprInfo* pCalExprInfo = createExprInfo(pPartNode->part.pExprs, NULL, &num); code = initExprSupp(&pInfo->scalarSup, pCalExprInfo, num); if (code != TSDB_CODE_SUCCESS) { goto _error; @@ -1008,7 +1008,7 @@ SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStr } pInfo->partitionSup.needCalc = true; - SSDataBlock* pResBlock = createResDataBlock(pPartNode->node.pOutputDataBlockDesc); + SSDataBlock* pResBlock = createResDataBlock(pPartNode->part.node.pOutputDataBlockDesc); if (!pResBlock) { goto _error; } @@ -1022,7 +1022,7 @@ SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStr pInfo->pDelRes = createSpecialDataBlock(STREAM_DELETE_RESULT); int32_t numOfCols = 0; - SExprInfo* pExprInfo = createExprInfo(pPartNode->pTargets, NULL, &numOfCols); + SExprInfo* pExprInfo = createExprInfo(pPartNode->part.pTargets, NULL, &numOfCols); pOperator->name = "StreamPartitionOperator"; pOperator->blocking = false; diff --git a/source/libs/executor/src/projectoperator.c b/source/libs/executor/src/projectoperator.c index 2f12a0d19b..e9e6fed66a 100644 --- a/source/libs/executor/src/projectoperator.c +++ b/source/libs/executor/src/projectoperator.c @@ -53,7 +53,7 @@ static void destroyIndefinitOperatorInfo(void* param) { SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhysiNode* pProjPhyNode, SExecTaskInfo* pTaskInfo) { - int32_t code = TSDB_CODE_SUCCESS; + int32_t code = TSDB_CODE_SUCCESS; SProjectOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SProjectOperatorInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { @@ -184,7 +184,7 @@ static int32_t doIngroupLimitOffset(SLimitInfo* pLimitInfo, uint64_t groupId, SS if (pLimitInfo->limit.limit >= 0 && pLimitInfo->numOfOutputRows + pBlock->info.rows >= pLimitInfo->limit.limit) { int32_t keepRows = (int32_t)(pLimitInfo->limit.limit - pLimitInfo->numOfOutputRows); blockDataKeepFirstNRows(pBlock, keepRows); - //TODO: optimize it later when partition by + limit + // TODO: optimize it later when partition by + limit if ((pLimitInfo->slimit.limit == -1 && pLimitInfo->currentGroupId == 0) || (pLimitInfo->slimit.limit > 0 && pLimitInfo->slimit.limit <= pLimitInfo->numOfOutputGroups)) { doSetOperatorCompleted(pOperator); @@ -206,9 +206,16 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) { blockDataCleanup(pFinalRes); SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + if (pTaskInfo->streamInfo.pReq) { + pOperator->status = OP_OPENED; + } + + qDebug("enter project"); + if (pOperator->status == OP_EXEC_DONE) { if (pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE) { pOperator->status = OP_OPENED; + qDebug("projection in queue model, set status open and return null"); return NULL; } @@ -237,9 +244,23 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) { // The downstream exec may change the value of the newgroup, so use a local variable instead. SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); if (pBlock == NULL) { + if (pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE && pFinalRes->info.rows == 0) { + pOperator->status = OP_OPENED; + if (pOperator->status == OP_EXEC_RECV) { + continue; + } else { + return NULL; + } + } + qDebug("set op close, exec %d, status %d rows %d", pTaskInfo->execModel, pOperator->status, + pFinalRes->info.rows); doSetOperatorCompleted(pOperator); break; } + if (pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE) { + qDebug("set status recv"); + pOperator->status = OP_EXEC_RECV; + } // for stream interval if (pBlock->info.type == STREAM_RETRIEVE || pBlock->info.type == STREAM_DELETE_RESULT || @@ -298,6 +319,7 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) { // when apply the limit/offset for each group, pRes->info.rows may be 0, due to limit constraint. if (pFinalRes->info.rows > 0 || (pOperator->status == OP_EXEC_DONE)) { + qDebug("project return %d rows, status %d", pFinalRes->info.rows, pOperator->status); break; } } else { diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 6c5c33ae29..40fc8cb9a5 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -41,7 +41,12 @@ static int32_t buildDbTableInfoBlock(bool sysInfo, const SSDataBlock* p, const S static bool processBlockWithProbability(const SSampleExecInfo* pInfo); -bool processBlockWithProbability(const SSampleExecInfo* pInfo) { +static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo, SMetaReader* smr, const char* dbname, + const char* tableName, int32_t* pNumOfRows, + const SSDataBlock* dataBlock); + +static void relocateAndFilterSysTagsScanResult(SSysTableScanInfo* pInfo, int32_t numOfRows, SSDataBlock* dataBlock); +bool processBlockWithProbability(const SSampleExecInfo* pInfo) { #if 0 if (pInfo->sampleRatio == 1) { return true; @@ -1022,11 +1027,7 @@ static uint64_t getGroupIdByCol(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts, return calGroupIdByData(&pInfo->partitionSup, pInfo->pPartScalarSup, pPreRes, 0); } -static uint64_t getGroupIdByData(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts, int64_t maxVersion) { - if (pInfo->partitionSup.needCalc) { - return getGroupIdByCol(pInfo, uid, ts, maxVersion); - } - +static uint64_t getGroupIdByUid(SStreamScanInfo* pInfo, uint64_t uid) { SHashObj* map = pInfo->pTableScanOp->pTaskInfo->tableqinfoList.map; uint64_t* groupId = taosHashGet(map, &uid, sizeof(int64_t)); if (groupId) { @@ -1035,6 +1036,14 @@ static uint64_t getGroupIdByData(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts, return 0; } +static uint64_t getGroupIdByData(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts, int64_t maxVersion) { + if (pInfo->partitionSup.needCalc) { + return getGroupIdByCol(pInfo, uid, ts, maxVersion); + } + + return getGroupIdByUid(pInfo, uid); +} + static bool prepareRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_t* pRowIndex) { if ((*pRowIndex) == pBlock->info.rows) { return false; @@ -1081,26 +1090,32 @@ static bool prepareRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_ return true; } -static STimeWindow getSlidingWindow(TSKEY* startTsCol, TSKEY* endTsCol, SInterval* pInterval, +static STimeWindow getSlidingWindow(TSKEY* startTsCol, TSKEY* endTsCol, uint64_t* gpIdCol, SInterval* pInterval, SDataBlockInfo* pDataBlockInfo, int32_t* pRowIndex, bool hasGroup) { SResultRowInfo dumyInfo; dumyInfo.cur.pageId = -1; STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, startTsCol[*pRowIndex], pInterval, TSDB_ORDER_ASC); STimeWindow endWin = win; STimeWindow preWin = win; + uint64_t groupId = gpIdCol[*pRowIndex]; while (1) { if (hasGroup) { (*pRowIndex) += 1; } else { - (*pRowIndex) += getNumOfRowsInTimeWindow(pDataBlockInfo, startTsCol, *pRowIndex, endWin.ekey, binarySearchForKey, - NULL, TSDB_ORDER_ASC); + while ((groupId == gpIdCol[(*pRowIndex)] && startTsCol[*pRowIndex] < endWin.ekey)) { + (*pRowIndex) += 1; + if ((*pRowIndex) == pDataBlockInfo->rows) { + break; + } + } } + do { preWin = endWin; getNextTimeWindow(pInterval, &endWin, TSDB_ORDER_ASC); } while (endTsCol[(*pRowIndex) - 1] >= endWin.skey); endWin = preWin; - if (win.ekey == endWin.ekey || (*pRowIndex) == pDataBlockInfo->rows) { + if (win.ekey == endWin.ekey || (*pRowIndex) == pDataBlockInfo->rows || groupId != gpIdCol[*pRowIndex]) { win.ekey = endWin.ekey; return win; } @@ -1235,11 +1250,13 @@ static int32_t generateIntervalScanRange(SStreamScanInfo* pInfo, SSDataBlock* pS int64_t version = pSrcBlock->info.version - 1; for (int32_t i = 0; i < rows;) { uint64_t srcUid = srcUidData[i]; - uint64_t groupId = getGroupIdByData(pInfo, srcUid, srcStartTsCol[i], version); - uint64_t srcGpId = srcGp[i]; - TSKEY calStartTs = srcStartTsCol[i]; + uint64_t groupId = srcGp[i]; + if (groupId == 0) { + groupId = getGroupIdByData(pInfo, srcUid, srcStartTsCol[i], version); + } + TSKEY calStartTs = srcStartTsCol[i]; colDataAppend(pCalStartTsCol, pDestBlock->info.rows, (const char*)(&calStartTs), false); - STimeWindow win = getSlidingWindow(srcStartTsCol, srcEndTsCol, &pInfo->interval, &pSrcBlock->info, &i, + STimeWindow win = getSlidingWindow(srcStartTsCol, srcEndTsCol, srcGp, &pInfo->interval, &pSrcBlock->info, &i, pInfo->partitionSup.needCalc); TSKEY calEndTs = srcStartTsCol[i - 1]; colDataAppend(pCalEndTsCol, pDestBlock->info.rows, (const char*)(&calEndTs), false); @@ -1248,15 +1265,6 @@ static int32_t generateIntervalScanRange(SStreamScanInfo* pInfo, SSDataBlock* pS colDataAppend(pEndTsCol, pDestBlock->info.rows, (const char*)(&win.ekey), false); colDataAppend(pGpCol, pDestBlock->info.rows, (const char*)(&groupId), false); pDestBlock->info.rows++; - if (pInfo->partitionSup.needCalc && srcGpId != 0 && groupId != srcGpId) { - colDataAppend(pCalStartTsCol, pDestBlock->info.rows, (const char*)(&calStartTs), false); - colDataAppend(pCalEndTsCol, pDestBlock->info.rows, (const char*)(&calEndTs), false); - colDataAppend(pDeUidCol, pDestBlock->info.rows, (const char*)(&srcUid), false); - colDataAppend(pStartTsCol, pDestBlock->info.rows, (const char*)(&win.skey), false); - colDataAppend(pEndTsCol, pDestBlock->info.rows, (const char*)(&win.ekey), false); - colDataAppend(pGpCol, pDestBlock->info.rows, (const char*)(&srcGpId), false); - pDestBlock->info.rows++; - } } return TSDB_CODE_SUCCESS; } @@ -1331,7 +1339,7 @@ void appendOneRow(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* static void checkUpdateData(SStreamScanInfo* pInfo, bool invertible, SSDataBlock* pBlock, bool out) { if (out) { blockDataCleanup(pInfo->pUpdateDataRes); - blockDataEnsureCapacity(pInfo->pUpdateDataRes, pBlock->info.rows); + blockDataEnsureCapacity(pInfo->pUpdateDataRes, pBlock->info.rows * 2); } SColumnInfoData* pColDataInfo = taosArrayGet(pBlock->pDataBlock, pInfo->primaryTsIndex); ASSERT(pColDataInfo->info.type == TSDB_DATA_TYPE_TIMESTAMP); @@ -1349,13 +1357,16 @@ static void checkUpdateData(SStreamScanInfo* pInfo, bool invertible, SSDataBlock // must check update info first. bool update = updateInfoIsUpdated(pInfo->pUpdateInfo, pBlock->info.uid, tsCol[rowId]); bool closedWin = isClosed && isSignleIntervalWindow(pInfo) && - isDeletedStreamWindow(&win, pBlock->info.groupId, pInfo->pTableScanOp, &pInfo->twAggSup); + isDeletedStreamWindow(&win, pBlock->info.groupId, + pInfo->pTableScanOp->pTaskInfo->streamInfo.pState, &pInfo->twAggSup); if ((update || closedWin) && out) { qDebug("stream update check not pass, update %d, closedWin %d", update, closedWin); - uint64_t gpId = closedWin && pInfo->partitionSup.needCalc - ? calGroupIdByData(&pInfo->partitionSup, pInfo->pPartScalarSup, pBlock, rowId) - : 0; + uint64_t gpId = 0; appendOneRow(pInfo->pUpdateDataRes, tsCol + rowId, tsCol + rowId, &pBlock->info.uid, &gpId); + if (closedWin && pInfo->partitionSup.needCalc) { + gpId = calGroupIdByData(&pInfo->partitionSup, pInfo->pPartScalarSup, pBlock, rowId); + appendOneRow(pInfo->pUpdateDataRes, tsCol + rowId, tsCol + rowId, &pBlock->info.uid, &gpId); + } } } if (out && pInfo->pUpdateDataRes->info.rows > 0) { @@ -1430,6 +1441,43 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) { SStreamScanInfo* pInfo = pOperator->info; qDebug("queue scan called"); + + if (pTaskInfo->streamInfo.pReq != NULL) { + if (pInfo->tqReader->pMsg == NULL) { + pInfo->tqReader->pMsg = pTaskInfo->streamInfo.pReq; + const SSubmitReq* pSubmit = pInfo->tqReader->pMsg; + if (tqReaderSetDataMsg(pInfo->tqReader, pSubmit, 0) < 0) { + qError("submit msg messed up when initing stream submit block %p", pSubmit); + pInfo->tqReader->pMsg = NULL; + pTaskInfo->streamInfo.pReq = NULL; + ASSERT(0); + } + } + + blockDataCleanup(pInfo->pRes); + SDataBlockInfo* pBlockInfo = &pInfo->pRes->info; + + while (tqNextDataBlock(pInfo->tqReader)) { + SSDataBlock block = {0}; + + int32_t code = tqRetrieveDataBlock(&block, pInfo->tqReader); + + if (code != TSDB_CODE_SUCCESS || block.info.rows == 0) { + continue; + } + + setBlockIntoRes(pInfo, &block); + + if (pBlockInfo->rows > 0) { + return pInfo->pRes; + } + } + + pInfo->tqReader->pMsg = NULL; + pTaskInfo->streamInfo.pReq = NULL; + return NULL; + } + if (pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__SNAPSHOT_DATA) { SSDataBlock* pResult = doTableScan(pInfo->pTableScanOp); if (pResult && pResult->info.rows > 0) { @@ -1462,8 +1510,8 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) { if (setBlockIntoRes(pInfo, &ret.data) < 0) { ASSERT(0); } - // TODO clean data block if (pInfo->pRes->info.rows > 0) { + pOperator->status = OP_EXEC_RECV; qDebug("queue scan log return %d rows", pInfo->pRes->info.rows); return pInfo->pRes; } @@ -1472,18 +1520,19 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) { // pTaskInfo->streamInfo.lastStatus = ret.offset; // pTaskInfo->streamInfo.metaBlk = ret.meta; // return NULL; - } else if (ret.fetchType == FETCH_TYPE__NONE) { + } else if (ret.fetchType == FETCH_TYPE__NONE || + (ret.fetchType == FETCH_TYPE__SEP && pOperator->status == OP_EXEC_RECV)) { pTaskInfo->streamInfo.lastStatus = ret.offset; ASSERT(pTaskInfo->streamInfo.lastStatus.version >= pTaskInfo->streamInfo.prepareStatus.version); ASSERT(pTaskInfo->streamInfo.lastStatus.version + 1 == pInfo->tqReader->pWalReader->curVersion); char formatBuf[80]; tFormatOffset(formatBuf, 80, &ret.offset); qDebug("queue scan log return null, offset %s", formatBuf); + pOperator->status = OP_OPENED; return NULL; - } else { - ASSERT(0); } } +#if 0 } else if (pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__SNAPSHOT_DATA) { SSDataBlock* pResult = doTableScan(pInfo->pTableScanOp); if (pResult && pResult->info.rows > 0) { @@ -1492,6 +1541,7 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) { } qDebug("stream scan tsdb return null"); return NULL; +#endif } else { ASSERT(0); return NULL; @@ -1532,6 +1582,30 @@ static int32_t filterDelBlockByUid(SSDataBlock* pDst, const SSDataBlock* pSrc, S return 0; } +// for partition by tag +static void setBlockGroupIdByUid(SStreamScanInfo* pInfo, SSDataBlock* pBlock) { + SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); + TSKEY* startTsCol = (TSKEY*)pStartTsCol->pData; + SColumnInfoData* pGpCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX); + uint64_t* gpCol = (uint64_t*)pGpCol->pData; + SColumnInfoData* pUidCol = taosArrayGet(pBlock->pDataBlock, UID_COLUMN_INDEX); + uint64_t* uidCol = (uint64_t*)pUidCol->pData; + int32_t rows = pBlock->info.rows; + if (!pInfo->partitionSup.needCalc) { + for (int32_t i = 0; i < rows; i++) { + uint64_t groupId = getGroupIdByUid(pInfo, uidCol[i]); + colDataAppend(pGpCol, i, (const char*)&groupId, false); + } + } else { + // SSDataBlock* pPreRes = readPreVersionData(pInfo->pTableScanOp, uidCol[i], startTsCol, ts, maxVersion); + // if (!pPreRes || pPreRes->info.rows == 0) { + // return 0; + // } + // ASSERT(pPreRes->info.rows == 1); + // return calGroupIdByData(&pInfo->partitionSup, pInfo->pPartScalarSup, pPreRes, 0); + } +} + static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { // NOTE: this operator does never check if current status is done or not SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; @@ -1628,7 +1702,8 @@ FETCH_NEXT_BLOCK: } else { pDelBlock = pBlock; } - printDataBlock(pBlock, "stream scan delete recv filtered"); + setBlockGroupIdByUid(pInfo, pDelBlock); + printDataBlock(pDelBlock, "stream scan delete recv filtered"); if (!isIntervalWindow(pInfo) && !isSessionWindow(pInfo) && !isStateWindow(pInfo)) { generateDeleteResultBlock(pInfo, pDelBlock, pInfo->pDeleteDataRes); pInfo->pDeleteDataRes->info.type = STREAM_DELETE_RESULT; @@ -2061,6 +2136,9 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys pInfo->pUpdateInfo = NULL; pInfo->pTableScanOp = pTableScanOp; + if (pInfo->pTableScanOp->pTaskInfo->streamInfo.pState) { + streamStateSetNumber(pInfo->pTableScanOp->pTaskInfo->streamInfo.pState, -1); + } pInfo->readHandle = *pHandle; pInfo->tableUid = pScanPhyNode->uid; @@ -2330,6 +2408,48 @@ int32_t convertTagDataToStr(char* str, int type, void* buf, int32_t bufSize, int return TSDB_CODE_SUCCESS; } +static bool sysTableIsOperatorCondOnOneTable(SNode* pCond, char* condTable) { + SOperatorNode* node = (SOperatorNode*)pCond; + if (node->opType == OP_TYPE_EQUAL) { + if (nodeType(node->pLeft) == QUERY_NODE_COLUMN && + strcasecmp(nodesGetNameFromColumnNode(node->pLeft), "table_name") == 0 && + nodeType(node->pRight) == QUERY_NODE_VALUE) { + SValueNode* pValue = (SValueNode*)node->pRight; + if (pValue->node.type == TSDB_DATA_TYPE_NCHAR || pValue->node.type == TSDB_DATA_TYPE_VARCHAR || + pValue->node.type == TSDB_DATA_TYPE_BINARY) { + char* value = nodesGetStrValueFromNode(pValue); + strncpy(condTable, value, TSDB_TABLE_NAME_LEN); + taosMemoryFree(value); + return true; + } + } + } + return false; +} + +static bool sysTableIsCondOnOneTable(SNode* pCond, char* condTable) { + if (pCond == NULL) { + return false; + } + if (nodeType(pCond) == QUERY_NODE_LOGIC_CONDITION) { + SLogicConditionNode* node = (SLogicConditionNode*)pCond; + if (LOGIC_COND_TYPE_AND == node->condType) { + SNode* pChild = NULL; + FOREACH(pChild, node->pParameterList) { + if (QUERY_NODE_OPERATOR == nodeType(pChild) && sysTableIsOperatorCondOnOneTable(pChild, condTable)) { + return true; + } + } + } + } + + if (QUERY_NODE_OPERATOR == nodeType(pCond)) { + return sysTableIsOperatorCondOnOneTable(pCond, condTable); + } + + return false; +} + static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) { SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SSysTableScanInfo* pInfo = pOperator->info; @@ -2337,13 +2457,12 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) { return NULL; } - if (pInfo->pCur == NULL) { - pInfo->pCur = metaOpenTbCursor(pInfo->readHandle.meta); - } - blockDataCleanup(pInfo->pRes); int32_t numOfRows = 0; + SSDataBlock* dataBlock = buildInfoSchemaTableMetaBlock(TSDB_INS_TABLE_TAGS); + blockDataEnsureCapacity(dataBlock, pOperator->resultInfo.capacity); + const char* db = NULL; int32_t vgId = 0; vnodeGetInfo(pInfo->readHandle.vnode, &db, &vgId); @@ -2355,10 +2474,32 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) { tNameGetDbName(&sn, varDataVal(dbname)); varDataSetLen(dbname, strlen(varDataVal(dbname))); - SSDataBlock* p = buildInfoSchemaTableMetaBlock(TSDB_INS_TABLE_TAGS); - blockDataEnsureCapacity(p, pOperator->resultInfo.capacity); + char condTableName[TSDB_TABLE_NAME_LEN] = {0}; + // optimize when sql like where table_name='tablename' and xxx. + if (pInfo->pCondition && sysTableIsCondOnOneTable(pInfo->pCondition, condTableName)) { + char tableName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_TO_VARSTR(tableName, condTableName); + + SMetaReader smr = {0}; + metaReaderInit(&smr, pInfo->readHandle.meta, 0); + metaGetTableEntryByName(&smr, condTableName); + sysTableUserTagsFillOneTableTags(pInfo, &smr, dbname, tableName, &numOfRows, dataBlock); + metaReaderClear(&smr); + if (numOfRows > 0) { + relocateAndFilterSysTagsScanResult(pInfo, numOfRows, dataBlock); + numOfRows = 0; + } + blockDataDestroy(dataBlock); + + pInfo->loadInfo.totalRows += pInfo->pRes->info.rows; + return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes; + } int32_t ret = 0; + if (pInfo->pCur == NULL) { + pInfo->pCur = metaOpenTbCursor(pInfo->readHandle.meta); + } + while ((ret = metaTbCursorNext(pInfo->pCur)) == 0) { if (pInfo->pCur->mr.me.type != TSDB_CHILD_TABLE) { continue; @@ -2381,100 +2522,12 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) { T_LONG_JMP(pTaskInfo->env, terrno); } - char stableName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; - STR_TO_VARSTR(stableName, smr.me.name); + sysTableUserTagsFillOneTableTags(pInfo, &smr, dbname, tableName, &numOfRows, dataBlock); - int32_t numOfTags = smr.me.stbEntry.schemaTag.nCols; - for (int32_t i = 0; i < numOfTags; ++i) { - SColumnInfoData* pColInfoData = NULL; - - // table name - pColInfoData = taosArrayGet(p->pDataBlock, 0); - colDataAppend(pColInfoData, numOfRows, tableName, false); - - // database name - pColInfoData = taosArrayGet(p->pDataBlock, 1); - colDataAppend(pColInfoData, numOfRows, dbname, false); - - // super table name - pColInfoData = taosArrayGet(p->pDataBlock, 2); - colDataAppend(pColInfoData, numOfRows, stableName, false); - - // tag name - char tagName[TSDB_COL_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; - STR_TO_VARSTR(tagName, smr.me.stbEntry.schemaTag.pSchema[i].name); - pColInfoData = taosArrayGet(p->pDataBlock, 3); - colDataAppend(pColInfoData, numOfRows, tagName, false); - - // tag type - int8_t tagType = smr.me.stbEntry.schemaTag.pSchema[i].type; - pColInfoData = taosArrayGet(p->pDataBlock, 4); - char tagTypeStr[VARSTR_HEADER_SIZE + 32]; - int tagTypeLen = sprintf(varDataVal(tagTypeStr), "%s", tDataTypes[tagType].name); - if (tagType == TSDB_DATA_TYPE_VARCHAR) { - tagTypeLen += sprintf(varDataVal(tagTypeStr) + tagTypeLen, "(%d)", - (int32_t)(smr.me.stbEntry.schemaTag.pSchema[i].bytes - VARSTR_HEADER_SIZE)); - } else if (tagType == TSDB_DATA_TYPE_NCHAR) { - tagTypeLen += - sprintf(varDataVal(tagTypeStr) + tagTypeLen, "(%d)", - (int32_t)((smr.me.stbEntry.schemaTag.pSchema[i].bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE)); - } - varDataSetLen(tagTypeStr, tagTypeLen); - colDataAppend(pColInfoData, numOfRows, (char*)tagTypeStr, false); - - STagVal tagVal = {0}; - tagVal.cid = smr.me.stbEntry.schemaTag.pSchema[i].colId; - char* tagData = NULL; - uint32_t tagLen = 0; - - if (tagType == TSDB_DATA_TYPE_JSON) { - tagData = (char*)pInfo->pCur->mr.me.ctbEntry.pTags; - } else { - bool exist = tTagGet((STag*)pInfo->pCur->mr.me.ctbEntry.pTags, &tagVal); - if (exist) { - if (IS_VAR_DATA_TYPE(tagType)) { - tagData = (char*)tagVal.pData; - tagLen = tagVal.nData; - } else { - tagData = (char*)&tagVal.i64; - tagLen = tDataTypes[tagType].bytes; - } - } - } - - char* tagVarChar = NULL; - if (tagData != NULL) { - if (tagType == TSDB_DATA_TYPE_JSON) { - char* tagJson = parseTagDatatoJson(tagData); - tagVarChar = taosMemoryMalloc(strlen(tagJson) + VARSTR_HEADER_SIZE); - memcpy(varDataVal(tagVarChar), tagJson, strlen(tagJson)); - varDataSetLen(tagVarChar, strlen(tagJson)); - taosMemoryFree(tagJson); - } else { - int32_t bufSize = IS_VAR_DATA_TYPE(tagType) ? (tagLen + VARSTR_HEADER_SIZE) - : (3 + DBL_MANT_DIG - DBL_MIN_EXP + VARSTR_HEADER_SIZE); - tagVarChar = taosMemoryMalloc(bufSize); - int32_t len = -1; - convertTagDataToStr(varDataVal(tagVarChar), tagType, tagData, tagLen, &len); - varDataSetLen(tagVarChar, len); - } - } - pColInfoData = taosArrayGet(p->pDataBlock, 5); - colDataAppend(pColInfoData, numOfRows, tagVarChar, - (tagData == NULL) || (tagType == TSDB_DATA_TYPE_JSON && tTagIsJsonNull(tagData))); - taosMemoryFree(tagVarChar); - ++numOfRows; - } metaReaderClear(&smr); if (numOfRows >= pOperator->resultInfo.capacity) { - p->info.rows = numOfRows; - pInfo->pRes->info.rows = numOfRows; - - relocateColumnData(pInfo->pRes, pInfo->scanCols, p->pDataBlock, false); - doFilterResult(pInfo); - - blockDataCleanup(p); + relocateAndFilterSysTagsScanResult(pInfo, numOfRows, dataBlock); numOfRows = 0; if (pInfo->pRes->info.rows > 0) { @@ -2484,19 +2537,11 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) { } if (numOfRows > 0) { - p->info.rows = numOfRows; - pInfo->pRes->info.rows = numOfRows; - - relocateColumnData(pInfo->pRes, pInfo->scanCols, p->pDataBlock, false); - doFilterResult(pInfo); - - blockDataCleanup(p); + relocateAndFilterSysTagsScanResult(pInfo, numOfRows, dataBlock); numOfRows = 0; } - blockDataDestroy(p); - - // todo temporarily free the cursor here, the true reason why the free is not valid needs to be found + blockDataDestroy(dataBlock); if (ret != 0) { metaCloseTbCursor(pInfo->pCur); pInfo->pCur = NULL; @@ -2507,6 +2552,111 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) { return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes; } +static void relocateAndFilterSysTagsScanResult(SSysTableScanInfo* pInfo, int32_t numOfRows, SSDataBlock* dataBlock) { + dataBlock->info.rows = numOfRows; + pInfo->pRes->info.rows = numOfRows; + + relocateColumnData(pInfo->pRes, pInfo->scanCols, dataBlock->pDataBlock, false); + doFilterResult(pInfo); + + blockDataCleanup(dataBlock); +} + +static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo, SMetaReader* smr, const char* dbname, + const char* tableName, int32_t* pNumOfRows, + const SSDataBlock* dataBlock) { + char stableName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_TO_VARSTR(stableName, (*smr).me.name); + + int32_t numOfRows = *pNumOfRows; + + int32_t numOfTags = (*smr).me.stbEntry.schemaTag.nCols; + for (int32_t i = 0; i < numOfTags; ++i) { + SColumnInfoData* pColInfoData = NULL; + + // table name + pColInfoData = taosArrayGet(dataBlock->pDataBlock, 0); + colDataAppend(pColInfoData, numOfRows, tableName, false); + + // database name + pColInfoData = taosArrayGet(dataBlock->pDataBlock, 1); + colDataAppend(pColInfoData, numOfRows, dbname, false); + + // super table name + pColInfoData = taosArrayGet(dataBlock->pDataBlock, 2); + colDataAppend(pColInfoData, numOfRows, stableName, false); + + // tag name + char tagName[TSDB_COL_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_TO_VARSTR(tagName, (*smr).me.stbEntry.schemaTag.pSchema[i].name); + pColInfoData = taosArrayGet(dataBlock->pDataBlock, 3); + colDataAppend(pColInfoData, numOfRows, tagName, false); + + // tag type + int8_t tagType = (*smr).me.stbEntry.schemaTag.pSchema[i].type; + pColInfoData = taosArrayGet(dataBlock->pDataBlock, 4); + char tagTypeStr[VARSTR_HEADER_SIZE + 32]; + int tagTypeLen = sprintf(varDataVal(tagTypeStr), "%s", tDataTypes[tagType].name); + if (tagType == TSDB_DATA_TYPE_VARCHAR) { + tagTypeLen += sprintf(varDataVal(tagTypeStr) + tagTypeLen, "(%d)", + (int32_t)((*smr).me.stbEntry.schemaTag.pSchema[i].bytes - VARSTR_HEADER_SIZE)); + } else if (tagType == TSDB_DATA_TYPE_NCHAR) { + tagTypeLen += + sprintf(varDataVal(tagTypeStr) + tagTypeLen, "(%d)", + (int32_t)(((*smr).me.stbEntry.schemaTag.pSchema[i].bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE)); + } + varDataSetLen(tagTypeStr, tagTypeLen); + colDataAppend(pColInfoData, numOfRows, (char*)tagTypeStr, false); + + STagVal tagVal = {0}; + tagVal.cid = (*smr).me.stbEntry.schemaTag.pSchema[i].colId; + char* tagData = NULL; + uint32_t tagLen = 0; + + if (tagType == TSDB_DATA_TYPE_JSON) { + tagData = (char*)pInfo->pCur->mr.me.ctbEntry.pTags; + } else { + bool exist = tTagGet((STag*)pInfo->pCur->mr.me.ctbEntry.pTags, &tagVal); + if (exist) { + if (IS_VAR_DATA_TYPE(tagType)) { + tagData = (char*)tagVal.pData; + tagLen = tagVal.nData; + } else { + tagData = (char*)&tagVal.i64; + tagLen = tDataTypes[tagType].bytes; + } + } + } + + char* tagVarChar = NULL; + if (tagData != NULL) { + if (tagType == TSDB_DATA_TYPE_JSON) { + char* tagJson = parseTagDatatoJson(tagData); + tagVarChar = taosMemoryMalloc(strlen(tagJson) + VARSTR_HEADER_SIZE); + memcpy(varDataVal(tagVarChar), tagJson, strlen(tagJson)); + varDataSetLen(tagVarChar, strlen(tagJson)); + taosMemoryFree(tagJson); + } else { + int32_t bufSize = IS_VAR_DATA_TYPE(tagType) ? (tagLen + VARSTR_HEADER_SIZE) + : (3 + DBL_MANT_DIG - DBL_MIN_EXP + VARSTR_HEADER_SIZE); + tagVarChar = taosMemoryMalloc(bufSize); + int32_t len = -1; + convertTagDataToStr(varDataVal(tagVarChar), tagType, tagData, tagLen, &len); + varDataSetLen(tagVarChar, len); + } + } + pColInfoData = taosArrayGet(dataBlock->pDataBlock, 5); + colDataAppend(pColInfoData, numOfRows, tagVarChar, + (tagData == NULL) || (tagType == TSDB_DATA_TYPE_JSON && tTagIsJsonNull(tagData))); + taosMemoryFree(tagVarChar); + ++numOfRows; + } + + *pNumOfRows = numOfRows; + + return TSDB_CODE_SUCCESS; +} + static SSDataBlock* sysTableScanUserTables(SOperatorInfo* pOperator) { SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SSysTableScanInfo* pInfo = pOperator->info; diff --git a/source/libs/executor/src/tfill.c b/source/libs/executor/src/tfill.c index f23552c5a7..f6fd8c8920 100644 --- a/source/libs/executor/src/tfill.c +++ b/source/libs/executor/src/tfill.c @@ -19,6 +19,7 @@ #include "tmsg.h" #include "ttypes.h" +#include "executorimpl.h" #include "tcommon.h" #include "thash.h" #include "ttime.h" @@ -35,18 +36,30 @@ #define GET_DEST_SLOT_ID(_p) ((_p)->pExpr->base.resSchema.slotId) +#define FILL_POS_INVALID 0 +#define FILL_POS_START 1 +#define FILL_POS_MID 2 +#define FILL_POS_END 3 + +typedef struct STimeRange { + TSKEY skey; + TSKEY ekey; + uint64_t groupId; +} STimeRange; + static void doSetVal(SColumnInfoData* pDstColInfoData, int32_t rowIndex, const SGroupKeys* pKey); -static bool fillIfWindowPseudoColumn(SFillInfo* pFillInfo, SFillColInfo* pCol, SColumnInfoData* pDstColInfoData, int32_t rowIndex); +static bool fillIfWindowPseudoColumn(SFillInfo* pFillInfo, SFillColInfo* pCol, SColumnInfoData* pDstColInfoData, + int32_t rowIndex); static void setNullRow(SSDataBlock* pBlock, SFillInfo* pFillInfo, int32_t rowIndex) { - for(int32_t i = 0; i < pFillInfo->numOfCols; ++i) { - SFillColInfo* pCol = &pFillInfo->pFillCol[i]; - int32_t dstSlotId = GET_DEST_SLOT_ID(pCol); + for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) { + SFillColInfo* pCol = &pFillInfo->pFillCol[i]; + int32_t dstSlotId = GET_DEST_SLOT_ID(pCol); SColumnInfoData* pDstColInfo = taosArrayGet(pBlock->pDataBlock, dstSlotId); if (pCol->notFillCol) { bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfo, rowIndex); if (!filled) { - SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev.pRowVal : pFillInfo->next.pRowVal; + SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev.pRowVal : pFillInfo->next.pRowVal; SGroupKeys* pKey = taosArrayGet(p, i); doSetVal(pDstColInfo, rowIndex, pKey); } @@ -76,8 +89,9 @@ static void doSetUserSpecifiedValue(SColumnInfoData* pDst, SVariant* pVar, int32 } } -//fill windows pseudo column, _wstart, _wend, _wduration and return true, otherwise return false -static bool fillIfWindowPseudoColumn(SFillInfo* pFillInfo, SFillColInfo* pCol, SColumnInfoData* pDstColInfoData, int32_t rowIndex) { +// fill windows pseudo column, _wstart, _wend, _wduration and return true, otherwise return false +static bool fillIfWindowPseudoColumn(SFillInfo* pFillInfo, SFillColInfo* pCol, SColumnInfoData* pDstColInfoData, + int32_t rowIndex) { if (!pCol->notFillCol) { return false; } @@ -89,15 +103,15 @@ static bool fillIfWindowPseudoColumn(SFillInfo* pFillInfo, SFillColInfo* pCol, S colDataAppend(pDstColInfoData, rowIndex, (const char*)&pFillInfo->currentKey, false); return true; } else if (pCol->pExpr->base.pParam[0].pCol->colType == COLUMN_TYPE_WINDOW_END) { - //TODO: include endpoint + // TODO: include endpoint SInterval* pInterval = &pFillInfo->interval; - int32_t step = (pFillInfo->order == TSDB_ORDER_ASC) ? 1 : -1; - int64_t windowEnd = + int32_t step = (pFillInfo->order == TSDB_ORDER_ASC) ? 1 : -1; + int64_t windowEnd = taosTimeAdd(pFillInfo->currentKey, pInterval->sliding * step, pInterval->slidingUnit, pInterval->precision); colDataAppend(pDstColInfoData, rowIndex, (const char*)&windowEnd, false); return true; } else if (pCol->pExpr->base.pParam[0].pCol->colType == COLUMN_TYPE_WINDOW_DURATION) { - //TODO: include endpoint + // TODO: include endpoint colDataAppend(pDstColInfoData, rowIndex, (const char*)&pFillInfo->interval.sliding, false); return true; } @@ -115,13 +129,13 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock* // set the other values if (pFillInfo->type == TSDB_FILL_PREV) { - SArray* p = FILL_IS_ASC_FILL(pFillInfo)? pFillInfo->prev.pRowVal : pFillInfo->next.pRowVal; + SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev.pRowVal : pFillInfo->next.pRowVal; for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) { SFillColInfo* pCol = &pFillInfo->pFillCol[i]; SColumnInfoData* pDstColInfoData = taosArrayGet(pBlock->pDataBlock, GET_DEST_SLOT_ID(pCol)); - bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfoData, index); + bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfoData, index); if (!filled) { SGroupKeys* pKey = taosArrayGet(p, i); doSetVal(pDstColInfoData, index, pKey); @@ -131,9 +145,9 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock* SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->next.pRowVal : pFillInfo->prev.pRowVal; // todo refactor: start from 0 not 1 for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) { - SFillColInfo* pCol = &pFillInfo->pFillCol[i]; + SFillColInfo* pCol = &pFillInfo->pFillCol[i]; SColumnInfoData* pDstColInfoData = taosArrayGet(pBlock->pDataBlock, GET_DEST_SLOT_ID(pCol)); - bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfoData, index); + bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfoData, index); if (!filled) { SGroupKeys* pKey = taosArrayGet(p, i); doSetVal(pDstColInfoData, index, pKey); @@ -154,7 +168,7 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock* if (pCol->notFillCol) { bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstCol, index); if (!filled) { - SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev.pRowVal : pFillInfo->next.pRowVal; + SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev.pRowVal : pFillInfo->next.pRowVal; SGroupKeys* pKey = taosArrayGet(p, i); doSetVal(pDstCol, index, pKey); } @@ -190,13 +204,13 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock* for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) { SFillColInfo* pCol = &pFillInfo->pFillCol[i]; - int32_t slotId = GET_DEST_SLOT_ID(pCol); + int32_t slotId = GET_DEST_SLOT_ID(pCol); SColumnInfoData* pDst = taosArrayGet(pBlock->pDataBlock, slotId); if (pCol->notFillCol) { bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDst, index); if (!filled) { - SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev.pRowVal : pFillInfo->next.pRowVal; + SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev.pRowVal : pFillInfo->next.pRowVal; SGroupKeys* pKey = taosArrayGet(p, i); doSetVal(pDst, index, pKey); } @@ -261,8 +275,8 @@ static void copyCurrentRowIntoBuf(SFillInfo* pFillInfo, int32_t rowIndex, SArray } else if (type == QUERY_NODE_OPERATOR) { SColumnInfoData* pSrcCol = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, i); - bool isNull = colDataIsNull_s(pSrcCol, rowIndex); - char* p = colDataGetData(pSrcCol, rowIndex); + bool isNull = colDataIsNull_s(pSrcCol, rowIndex); + char* p = colDataGetData(pSrcCol, rowIndex); saveColData(pRow, i, p, isNull); } else { ASSERT(0); @@ -425,9 +439,9 @@ struct SFillInfo* taosCreateFillInfo(TSKEY skey, int32_t numOfFillCols, int32_t pFillInfo->order = order; pFillInfo->srcTsSlotId = primaryTsSlotId; - for(int32_t i = 0; i < numOfNotFillCols; ++i) { + for (int32_t i = 0; i < numOfNotFillCols; ++i) { SFillColInfo* p = &pCol[i + numOfFillCols]; - int32_t srcSlotId = GET_DEST_SLOT_ID(p); + int32_t srcSlotId = GET_DEST_SLOT_ID(p); if (srcSlotId == primaryTsSlotId) { pFillInfo->tsSlotId = i + numOfFillCols; break; @@ -499,9 +513,9 @@ void* taosDestroyFillInfo(SFillInfo* pFillInfo) { } taosArrayDestroy(pFillInfo->next.pRowVal); -// for (int32_t i = 0; i < pFillInfo->numOfTags; ++i) { -// taosMemoryFreeClear(pFillInfo->pTags[i].tagVal); -// } + // for (int32_t i = 0; i < pFillInfo->numOfTags; ++i) { + // taosMemoryFreeClear(pFillInfo->pTags[i].tagVal); + // } taosMemoryFreeClear(pFillInfo->pTags); taosMemoryFreeClear(pFillInfo->pFillCol); @@ -640,7 +654,7 @@ SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfFillExpr, SExprIn } } - for(int32_t i = 0; i < numOfNotFillExpr; ++i) { + for (int32_t i = 0; i < numOfNotFillExpr; ++i) { SExprInfo* pExprInfo = &pNotFillExpr[i]; pFillCol[i + numOfFillExpr].pExpr = pExprInfo; pFillCol[i + numOfFillExpr].notFillCol = true; @@ -648,3 +662,1048 @@ SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfFillExpr, SExprIn return pFillCol; } + +TSKEY getNextWindowTs(TSKEY ts, SInterval* pInterval) { + STimeWindow win = {.skey = ts, .ekey = ts}; + getNextIntervalWindow(pInterval, &win, TSDB_ORDER_ASC); + return win.skey; +} + +TSKEY getPrevWindowTs(TSKEY ts, SInterval* pInterval) { + STimeWindow win = {.skey = ts, .ekey = ts}; + getNextIntervalWindow(pInterval, &win, TSDB_ORDER_DESC); + return win.skey; +} + +void setRowCell(SColumnInfoData* pCol, int32_t rowId, const SResultCellData* pCell) { + colDataAppend(pCol, rowId, pCell->pData, pCell->isNull); +} + +SResultCellData* getResultCell(SResultRowData* pRaw, int32_t index) { + if (!pRaw || !pRaw->pRowVal) { + return NULL; + } + char* pData = (char*)pRaw->pRowVal; + SResultCellData* pCell = pRaw->pRowVal; + for (int32_t i = 0; i < index; i++) { + pData += (pCell->bytes + sizeof(SResultCellData)); + pCell = (SResultCellData*)pData; + } + return pCell; +} + +void* destroyFillColumnInfo(SFillColInfo* pFillCol, int32_t start, int32_t end) { + for (int32_t i = start; i < end; i++) { + destroyExprInfo(pFillCol[i].pExpr, 1); + taosMemoryFreeClear(pFillCol[i].pExpr); + taosVariantDestroy(&pFillCol[i].fillVal); + } + taosMemoryFree(pFillCol); + return NULL; +} + +void* destroyStreamFillSupporter(SStreamFillSupporter* pFillSup) { + pFillSup->pAllColInfo = destroyFillColumnInfo(pFillSup->pAllColInfo, pFillSup->numOfFillCols, pFillSup->numOfAllCols); + tSimpleHashCleanup(pFillSup->pResMap); + pFillSup->pResMap = NULL; + taosMemoryFree(pFillSup); + return NULL; +} + +void* destroyStreamFillLinearInfo(SStreamFillLinearInfo* pFillLinear) { + taosArrayDestroy(pFillLinear->pDeltaVal); + taosArrayDestroy(pFillLinear->pNextDeltaVal); + taosMemoryFree(pFillLinear); + return NULL; +} +void* destroyStreamFillInfo(SStreamFillInfo* pFillInfo) { + if (pFillInfo->type == TSDB_FILL_SET_VALUE || pFillInfo->type == TSDB_FILL_NULL) { + taosMemoryFreeClear(pFillInfo->pResRow->pRowVal); + taosMemoryFreeClear(pFillInfo->pResRow); + } + pFillInfo->pLinearInfo = destroyStreamFillLinearInfo(pFillInfo->pLinearInfo); + taosMemoryFree(pFillInfo); + return NULL; +} + +void destroyStreamFillOperatorInfo(void* param) { + SStreamFillOperatorInfo* pInfo = (SStreamFillOperatorInfo*)param; + pInfo->pFillInfo = destroyStreamFillInfo(pInfo->pFillInfo); + pInfo->pFillSup = destroyStreamFillSupporter(pInfo->pFillSup); + pInfo->pRes = blockDataDestroy(pInfo->pRes); + pInfo->pSrcBlock = blockDataDestroy(pInfo->pSrcBlock); + pInfo->pColMatchColInfo = taosArrayDestroy(pInfo->pColMatchColInfo); + taosMemoryFree(pInfo); +} + +static void resetFillWindow(SResultRowData* pRowData) { + pRowData->key = INT64_MIN; + pRowData->pRowVal = NULL; +} + +void resetPrevAndNextWindow(SStreamFillSupporter* pFillSup, SStreamState* pState) { + resetFillWindow(&pFillSup->prev); + resetFillWindow(&pFillSup->cur); + resetFillWindow(&pFillSup->next); + resetFillWindow(&pFillSup->nextNext); +} + +void getCurWindowFromDiscBuf(SOperatorInfo* pOperator, TSKEY ts, uint64_t groupId, SStreamFillSupporter* pFillSup) { + SStreamState* pState = pOperator->pTaskInfo->streamInfo.pState; + resetPrevAndNextWindow(pFillSup, pState); + + SWinKey key = {.ts = ts, .groupId = groupId}; + void* curVal = NULL; + int32_t curVLen = 0; + int32_t code = streamStateFillGet(pState, &key, (void**)&curVal, &curVLen); + ASSERT(code == TSDB_CODE_SUCCESS); + pFillSup->cur.key = key.ts; + pFillSup->cur.pRowVal = curVal; +} + +void getWindowFromDiscBuf(SOperatorInfo* pOperator, TSKEY ts, uint64_t groupId, SStreamFillSupporter* pFillSup) { + SStreamState* pState = pOperator->pTaskInfo->streamInfo.pState; + resetPrevAndNextWindow(pFillSup, pState); + + SWinKey key = {.ts = ts, .groupId = groupId}; + void* curVal = NULL; + int32_t curVLen = 0; + int32_t code = streamStateFillGet(pState, &key, (void**)&curVal, &curVLen); + ASSERT(code == TSDB_CODE_SUCCESS); + pFillSup->cur.key = key.ts; + pFillSup->cur.pRowVal = curVal; + + SStreamStateCur* pCur = streamStateFillSeekKeyPrev(pState, &key); + SWinKey preKey = {.groupId = groupId}; + void* preVal = NULL; + int32_t preVLen = 0; + if (pCur) { + code = streamStateGetGroupKVByCur(pCur, &preKey, (const void**)&preVal, &preVLen); + } + + if (pCur && code == TSDB_CODE_SUCCESS) { + pFillSup->prev.key = preKey.ts; + pFillSup->prev.pRowVal = preVal; + + code = streamStateCurNext(pState, pCur); + ASSERT(code == TSDB_CODE_SUCCESS); + + code = streamStateCurNext(pState, pCur); + if (code != TSDB_CODE_SUCCESS) { + pCur = NULL; + } + } else { + pCur = streamStateFillSeekKeyNext(pState, &key); + } + + if (pCur) { + SWinKey nextKey = {.groupId = groupId}; + void* nextVal = NULL; + int32_t nextVLen = 0; + code = streamStateGetGroupKVByCur(pCur, &nextKey, (const void**)&nextVal, &nextVLen); + if (code == TSDB_CODE_SUCCESS) { + pFillSup->next.key = nextKey.ts; + pFillSup->next.pRowVal = nextVal; + if (pFillSup->type == TSDB_FILL_PREV || pFillSup->type == TSDB_FILL_NEXT) { + code = streamStateCurNext(pState, pCur); + if (code == TSDB_CODE_SUCCESS) { + SWinKey nextNextKey = {.groupId = groupId}; + void* nextNextVal = NULL; + int32_t nextNextVLen = 0; + code = streamStateGetGroupKVByCur(pCur, &nextNextKey, (const void**)&nextNextVal, &nextNextVLen); + if (code == TSDB_CODE_SUCCESS) { + pFillSup->nextNext.key = nextNextKey.ts; + pFillSup->nextNext.pRowVal = nextNextVal; + } + } + } + } + } +} + +static bool hasPrevWindow(SStreamFillSupporter* pFillSup) { return pFillSup->prev.key != INT64_MIN; } +static bool hasNextWindow(SStreamFillSupporter* pFillSup) { return pFillSup->next.key != INT64_MIN; } +static bool hasNextNextWindow(SStreamFillSupporter* pFillSup) { + return pFillSup->nextNext.key != INT64_MIN; + return false; +} + +static void transBlockToResultRow(const SSDataBlock* pBlock, int32_t rowId, TSKEY ts, SResultRowData* pRowVal) { + int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); + for (int32_t i = 0; i < numOfCols; ++i) { + SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, i); + SResultCellData* pCell = getResultCell(pRowVal, i); + if (!colDataIsNull_s(pColData, rowId)) { + pCell->isNull = false; + pCell->type = pColData->info.type; + pCell->bytes = pColData->info.bytes; + char* val = colDataGetData(pColData, rowId); + if (IS_VAR_DATA_TYPE(pCell->type)) { + memcpy(pCell->pData, val, varDataTLen(val)); + } else { + memcpy(pCell->pData, val, pCell->bytes); + } + } else { + pCell->isNull = true; + } + } + pRowVal->key = ts; +} + +static void calcDeltaData(SSDataBlock* pBlock, int32_t rowId, SResultRowData* pRowVal, SArray* pDelta, + SFillColInfo* pFillCol, int32_t numOfCol, int32_t winCount, int32_t order) { + for (int32_t i = 0; i < numOfCol; i++) { + if (!pFillCol[i].notFillCol) { + int32_t slotId = GET_DEST_SLOT_ID(pFillCol + i); + SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); + char* var = colDataGetData(pCol, rowId); + double start = 0; + GET_TYPED_DATA(start, double, pCol->info.type, var); + SResultCellData* pCell = getResultCell(pRowVal, slotId); + double end = 0; + GET_TYPED_DATA(end, double, pCell->type, pCell->pData); + double delta = 0; + if (order == TSDB_ORDER_ASC) { + delta = (end - start) / winCount; + } else { + delta = (start - end) / winCount; + } + taosArraySet(pDelta, slotId, &delta); + } + } +} + +static void calcRowDeltaData(SResultRowData* pStartRow, SResultRowData* pEndRow, SArray* pDelta, SFillColInfo* pFillCol, + int32_t numOfCol, int32_t winCount) { + for (int32_t i = 0; i < numOfCol; i++) { + if (!pFillCol[i].notFillCol) { + int32_t slotId = GET_DEST_SLOT_ID(pFillCol + i); + SResultCellData* pSCell = getResultCell(pStartRow, slotId); + double start = 0.0; + GET_TYPED_DATA(start, double, pSCell->type, pSCell->pData); + SResultCellData* pECell = getResultCell(pEndRow, slotId); + double end = 0.0; + GET_TYPED_DATA(end, double, pECell->type, pECell->pData); + double delta = (end - start) / winCount; + taosArraySet(pDelta, slotId, &delta); + } + } +} + +static void setFillInfoStart(TSKEY ts, SInterval* pInterval, SStreamFillInfo* pFillInfo) { + ts = taosTimeAdd(ts, pInterval->sliding, pInterval->slidingUnit, pInterval->precision); + pFillInfo->start = ts; +} + +static void setFillInfoEnd(TSKEY ts, SInterval* pInterval, SStreamFillInfo* pFillInfo) { + ts = taosTimeAdd(ts, pInterval->sliding * -1, pInterval->slidingUnit, pInterval->precision); + pFillInfo->end = ts; +} + +static void setFillKeyInfo(TSKEY start, TSKEY end, SInterval* pInterval, SStreamFillInfo* pFillInfo) { + setFillInfoStart(start, pInterval, pFillInfo); + pFillInfo->current = pFillInfo->start; + setFillInfoEnd(end, pInterval, pFillInfo); +} + +void setDeleteFillValueInfo(TSKEY start, TSKEY end, SStreamFillSupporter* pFillSup, SStreamFillInfo* pFillInfo) { + if (!hasPrevWindow(pFillSup) || !hasNextWindow(pFillSup)) { + pFillInfo->needFill = false; + return; + } + + pFillInfo->needFill = true; + pFillInfo->start = start; + pFillInfo->current = pFillInfo->start; + pFillInfo->end = end; + pFillInfo->pos = FILL_POS_INVALID; + switch (pFillInfo->type) { + case TSDB_FILL_NULL: + case TSDB_FILL_SET_VALUE: + break; + case TSDB_FILL_PREV: + pFillInfo->pResRow = &pFillSup->prev; + break; + case TSDB_FILL_NEXT: + pFillInfo->pResRow = &pFillSup->next; + break; + case TSDB_FILL_LINEAR: { + setFillKeyInfo(pFillSup->prev.key, pFillSup->next.key, &pFillSup->interval, pFillInfo); + pFillInfo->pLinearInfo->hasNext = false; + pFillInfo->pLinearInfo->nextEnd = INT64_MIN; + int32_t numOfWins = taosTimeCountInterval(pFillSup->prev.key, pFillSup->next.key, pFillSup->interval.sliding, + pFillSup->interval.slidingUnit, pFillSup->interval.precision); + calcRowDeltaData(&pFillSup->prev, &pFillSup->next, pFillInfo->pLinearInfo->pDeltaVal, pFillSup->pAllColInfo, + pFillSup->numOfAllCols, numOfWins); + pFillInfo->pResRow = &pFillSup->prev; + pFillInfo->pLinearInfo->winIndex = 0; + } break; + default: + ASSERT(0); + break; + } +} + +void setFillValueInfo(SSDataBlock* pBlock, TSKEY ts, int32_t rowId, SStreamFillSupporter* pFillSup, + SStreamFillInfo* pFillInfo) { + pFillInfo->preRowKey = pFillSup->cur.key; + if (!hasPrevWindow(pFillSup) && !hasNextWindow(pFillSup)) { + pFillInfo->needFill = false; + pFillInfo->pos = FILL_POS_START; + return; + } + TSKEY prevWKey = INT64_MIN; + TSKEY nextWKey = INT64_MIN; + if (hasPrevWindow(pFillSup)) { + prevWKey = pFillSup->prev.key; + } + if (hasNextWindow(pFillSup)) { + nextWKey = pFillSup->next.key; + } + + pFillInfo->needFill = true; + pFillInfo->pos = FILL_POS_INVALID; + switch (pFillInfo->type) { + case TSDB_FILL_NULL: + case TSDB_FILL_SET_VALUE: { + if (pFillSup->prev.key == pFillInfo->preRowKey) { + resetFillWindow(&pFillSup->prev); + } + if (hasPrevWindow(pFillSup) && hasNextWindow(pFillSup)) { + if (pFillSup->next.key == pFillInfo->nextRowKey) { + pFillInfo->preRowKey = INT64_MIN; + setFillKeyInfo(prevWKey, ts, &pFillSup->interval, pFillInfo); + pFillInfo->pos = FILL_POS_END; + } else { + pFillInfo->needFill = false; + pFillInfo->pos = FILL_POS_START; + } + } else if (hasPrevWindow(pFillSup)) { + setFillKeyInfo(prevWKey, ts, &pFillSup->interval, pFillInfo); + pFillInfo->pos = FILL_POS_END; + } else { + setFillKeyInfo(ts, nextWKey, &pFillSup->interval, pFillInfo); + pFillInfo->pos = FILL_POS_START; + } + } break; + case TSDB_FILL_PREV: { + if (hasNextWindow(pFillSup) && ((pFillSup->next.key != pFillInfo->nextRowKey) || + (pFillSup->next.key == pFillInfo->nextRowKey && hasNextNextWindow(pFillSup)) || + (pFillSup->next.key == pFillInfo->nextRowKey && !hasPrevWindow(pFillSup)))) { + setFillKeyInfo(ts, nextWKey, &pFillSup->interval, pFillInfo); + pFillInfo->pos = FILL_POS_START; + pFillSup->prev.key = pFillSup->cur.key; + pFillSup->prev.pRowVal = pFillSup->cur.pRowVal; + } else if (hasPrevWindow(pFillSup)) { + setFillKeyInfo(prevWKey, ts, &pFillSup->interval, pFillInfo); + pFillInfo->pos = FILL_POS_END; + pFillInfo->preRowKey = INT64_MIN; + } + pFillInfo->pResRow = &pFillSup->prev; + } break; + case TSDB_FILL_NEXT: { + if (hasPrevWindow(pFillSup)) { + setFillKeyInfo(prevWKey, ts, &pFillSup->interval, pFillInfo); + pFillInfo->pos = FILL_POS_END; + pFillSup->next.key = pFillSup->cur.key; + pFillSup->next.pRowVal = pFillSup->cur.pRowVal; + pFillInfo->preRowKey = INT64_MIN; + } else { + ASSERT(hasNextWindow(pFillSup)); + setFillKeyInfo(ts, nextWKey, &pFillSup->interval, pFillInfo); + pFillInfo->pos = FILL_POS_START; + } + pFillInfo->pResRow = &pFillSup->next; + } break; + case TSDB_FILL_LINEAR: { + pFillInfo->pLinearInfo->winIndex = 0; + if (hasPrevWindow(pFillSup) && hasNextWindow(pFillSup)) { + setFillKeyInfo(prevWKey, ts, &pFillSup->interval, pFillInfo); + pFillInfo->pos = FILL_POS_MID; + pFillInfo->pLinearInfo->nextEnd = nextWKey; + int32_t numOfWins = taosTimeCountInterval(prevWKey, ts, pFillSup->interval.sliding, + pFillSup->interval.slidingUnit, pFillSup->interval.precision); + calcRowDeltaData(&pFillSup->prev, &pFillSup->cur, pFillInfo->pLinearInfo->pDeltaVal, pFillSup->pAllColInfo, + pFillSup->numOfAllCols, numOfWins); + pFillInfo->pResRow = &pFillSup->prev; + + numOfWins = taosTimeCountInterval(ts, nextWKey, pFillSup->interval.sliding, pFillSup->interval.slidingUnit, + pFillSup->interval.precision); + calcRowDeltaData(&pFillSup->cur, &pFillSup->next, pFillInfo->pLinearInfo->pNextDeltaVal, pFillSup->pAllColInfo, + pFillSup->numOfAllCols, numOfWins); + pFillInfo->pLinearInfo->hasNext = true; + } else if (hasPrevWindow(pFillSup)) { + setFillKeyInfo(prevWKey, ts, &pFillSup->interval, pFillInfo); + pFillInfo->pos = FILL_POS_END; + pFillInfo->pLinearInfo->nextEnd = INT64_MIN; + int32_t numOfWins = taosTimeCountInterval(prevWKey, ts, pFillSup->interval.sliding, + pFillSup->interval.slidingUnit, pFillSup->interval.precision); + calcRowDeltaData(&pFillSup->prev, &pFillSup->cur, pFillInfo->pLinearInfo->pDeltaVal, pFillSup->pAllColInfo, + pFillSup->numOfAllCols, numOfWins); + pFillInfo->pResRow = &pFillSup->prev; + pFillInfo->pLinearInfo->hasNext = false; + } else { + ASSERT(hasNextWindow(pFillSup)); + setFillKeyInfo(ts, nextWKey, &pFillSup->interval, pFillInfo); + pFillInfo->pos = FILL_POS_START; + pFillInfo->pLinearInfo->nextEnd = INT64_MIN; + int32_t numOfWins = taosTimeCountInterval(ts, nextWKey, pFillSup->interval.sliding, + pFillSup->interval.slidingUnit, pFillSup->interval.precision); + calcRowDeltaData(&pFillSup->cur, &pFillSup->next, pFillInfo->pLinearInfo->pDeltaVal, pFillSup->pAllColInfo, + pFillSup->numOfAllCols, numOfWins); + pFillInfo->pResRow = &pFillSup->cur; + pFillInfo->pLinearInfo->hasNext = false; + } + } break; + default: + ASSERT(0); + break; + } + ASSERT(pFillInfo->pos != FILL_POS_INVALID); +} + +static bool checkResult(SStreamFillSupporter* pFillSup, TSKEY ts, uint64_t groupId) { + SWinKey key = {.groupId = groupId, .ts = ts}; + if (tSimpleHashGet(pFillSup->pResMap, &key, sizeof(SWinKey)) != NULL) { + return false; + } + tSimpleHashPut(pFillSup->pResMap, &key, sizeof(SWinKey), NULL, 0); + return true; +} + +static void buildFillResult(SResultRowData* pResRow, SStreamFillSupporter* pFillSup, TSKEY ts, SSDataBlock* pBlock) { + uint64_t groupId = pBlock->info.groupId; + if (pFillSup->hasDelete && !checkResult(pFillSup, ts, groupId)) { + return; + } + for (int32_t i = 0; i < pFillSup->numOfAllCols; ++i) { + SFillColInfo* pFillCol = pFillSup->pAllColInfo + i; + int32_t slotId = GET_DEST_SLOT_ID(pFillCol); + SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, slotId); + SFillInfo tmpInfo = { + .currentKey = ts, + .order = TSDB_ORDER_ASC, + .interval = pFillSup->interval, + }; + bool filled = fillIfWindowPseudoColumn(&tmpInfo, pFillCol, pColData, pBlock->info.rows); + if (!filled) { + SResultCellData* pCell = getResultCell(pResRow, slotId); + setRowCell(pColData, pBlock->info.rows, pCell); + } + } + pBlock->info.rows++; +} + +static bool hasRemainCalc(SStreamFillInfo* pFillInfo) { + if (pFillInfo->current != INT64_MIN && pFillInfo->current <= pFillInfo->end) { + return true; + } + return false; +} + +static void doStreamFillNormal(SStreamFillSupporter* pFillSup, SStreamFillInfo* pFillInfo, SSDataBlock* pBlock) { + while (hasRemainCalc(pFillInfo) && pBlock->info.rows < pBlock->info.capacity) { + buildFillResult(pFillInfo->pResRow, pFillSup, pFillInfo->current, pBlock); + pFillInfo->current = taosTimeAdd(pFillInfo->current, pFillSup->interval.sliding, pFillSup->interval.slidingUnit, + pFillSup->interval.precision); + } +} + +static void doStreamFillLinear(SStreamFillSupporter* pFillSup, SStreamFillInfo* pFillInfo, SSDataBlock* pBlock) { + while (hasRemainCalc(pFillInfo) && pBlock->info.rows < pBlock->info.capacity) { + uint64_t groupId = pBlock->info.groupId; + SWinKey key = {.groupId = groupId, .ts = pFillInfo->current}; + if (pFillSup->hasDelete && !checkResult(pFillSup, pFillInfo->current, groupId)) { + pFillInfo->current = taosTimeAdd(pFillInfo->current, pFillSup->interval.sliding, pFillSup->interval.slidingUnit, + pFillSup->interval.precision); + pFillInfo->pLinearInfo->winIndex++; + continue; + } + pFillInfo->pLinearInfo->winIndex++; + for (int32_t i = 0; i < pFillSup->numOfAllCols; ++i) { + SFillColInfo* pFillCol = pFillSup->pAllColInfo + i; + SFillInfo tmp = { + .currentKey = pFillInfo->current, + .order = TSDB_ORDER_ASC, + .interval = pFillSup->interval, + }; + + int32_t slotId = GET_DEST_SLOT_ID(pFillCol); + SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, slotId); + int16_t type = pColData->info.type; + SResultCellData* pCell = getResultCell(pFillInfo->pResRow, slotId); + int32_t index = pBlock->info.rows; + if (pFillCol->notFillCol) { + bool filled = fillIfWindowPseudoColumn(&tmp, pFillCol, pColData, index); + if (!filled) { + setRowCell(pColData, index, pCell); + } + } else { + if (IS_VAR_DATA_TYPE(type) || type == TSDB_DATA_TYPE_BOOL || pCell->isNull) { + colDataAppendNULL(pColData, index); + continue; + } + double* pDelta = taosArrayGet(pFillInfo->pLinearInfo->pDeltaVal, slotId); + double vCell = 0; + GET_TYPED_DATA(vCell, double, pCell->type, pCell->pData); + vCell += (*pDelta) * pFillInfo->pLinearInfo->winIndex; + int64_t result = 0; + SET_TYPED_DATA(&result, pCell->type, vCell); + colDataAppend(pColData, index, (const char*)&result, false); + } + } + pFillInfo->current = taosTimeAdd(pFillInfo->current, pFillSup->interval.sliding, pFillSup->interval.slidingUnit, + pFillSup->interval.precision); + pBlock->info.rows++; + } +} + +static void keepResultInDiscBuf(SOperatorInfo* pOperator, uint64_t groupId, SResultRowData* pRow, int32_t len) { + SWinKey key = {.groupId = groupId, .ts = pRow->key}; + int32_t code = streamStateFillPut(pOperator->pTaskInfo->streamInfo.pState, &key, pRow->pRowVal, len); + ASSERT(code == TSDB_CODE_SUCCESS); +} + +static void doStreamFillRange(SStreamFillInfo* pFillInfo, SStreamFillSupporter* pFillSup, SSDataBlock* pRes) { + if (pFillInfo->needFill == false) { + buildFillResult(&pFillSup->cur, pFillSup, pFillSup->cur.key, pRes); + return; + } + + if (pFillInfo->pos == FILL_POS_START) { + buildFillResult(&pFillSup->cur, pFillSup, pFillSup->cur.key, pRes); + } + if (pFillInfo->type != TSDB_FILL_LINEAR) { + doStreamFillNormal(pFillSup, pFillInfo, pRes); + } else { + doStreamFillLinear(pFillSup, pFillInfo, pRes); + + if (pFillInfo->pos == FILL_POS_MID) { + buildFillResult(&pFillSup->cur, pFillSup, pFillSup->cur.key, pRes); + } + + if (pFillInfo->current > pFillInfo->end && pFillInfo->pLinearInfo->hasNext) { + pFillInfo->pLinearInfo->hasNext = false; + pFillInfo->pLinearInfo->winIndex = 0; + taosArrayClear(pFillInfo->pLinearInfo->pDeltaVal); + taosArrayAddAll(pFillInfo->pLinearInfo->pDeltaVal, pFillInfo->pLinearInfo->pNextDeltaVal); + pFillInfo->pResRow = &pFillSup->cur; + setFillKeyInfo(pFillSup->cur.key, pFillInfo->pLinearInfo->nextEnd, &pFillSup->interval, pFillInfo); + doStreamFillLinear(pFillSup, pFillInfo, pRes); + } + } + if (pFillInfo->pos == FILL_POS_END) { + buildFillResult(&pFillSup->cur, pFillSup, pFillSup->cur.key, pRes); + } +} + +void keepBlockRowInDiscBuf(SOperatorInfo* pOperator, SStreamFillInfo* pFillInfo, SSDataBlock* pBlock, TSKEY* tsCol, + int32_t rowId, uint64_t groupId, int32_t rowSize) { + TSKEY ts = tsCol[rowId]; + pFillInfo->nextRowKey = ts; + SResultRowData tmpNextRow = {.key = ts}; + tmpNextRow.pRowVal = taosMemoryCalloc(1, rowSize); + transBlockToResultRow(pBlock, rowId, ts, &tmpNextRow); + keepResultInDiscBuf(pOperator, groupId, &tmpNextRow, rowSize); + taosMemoryFreeClear(tmpNextRow.pRowVal); +} + +static void doFillResults(SOperatorInfo* pOperator, SStreamFillSupporter* pFillSup, SStreamFillInfo* pFillInfo, + SSDataBlock* pBlock, TSKEY* tsCol, int32_t rowId, SSDataBlock* pRes) { + uint64_t groupId = pBlock->info.groupId; + getWindowFromDiscBuf(pOperator, tsCol[rowId], groupId, pFillSup); + if (pFillSup->prev.key == pFillInfo->preRowKey) { + resetFillWindow(&pFillSup->prev); + } + setFillValueInfo(pBlock, tsCol[rowId], rowId, pFillSup, pFillInfo); + doStreamFillRange(pFillInfo, pFillSup, pRes); +} + +static void doStreamFillImpl(SOperatorInfo* pOperator) { + SStreamFillOperatorInfo* pInfo = pOperator->info; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SStreamFillSupporter* pFillSup = pInfo->pFillSup; + SStreamFillInfo* pFillInfo = pInfo->pFillInfo; + SSDataBlock* pBlock = pInfo->pSrcBlock; + uint64_t groupId = pBlock->info.groupId; + SSDataBlock* pRes = pInfo->pRes; + pRes->info.groupId = groupId; + if (hasRemainCalc(pFillInfo)) { + doStreamFillRange(pFillInfo, pFillSup, pRes); + } + + SColumnInfoData* pTsCol = taosArrayGet(pInfo->pSrcBlock->pDataBlock, pInfo->primaryTsCol); + TSKEY* tsCol = (TSKEY*)pTsCol->pData; + + if (pInfo->srcRowIndex == 0) { + keepBlockRowInDiscBuf(pOperator, pFillInfo, pBlock, tsCol, pInfo->srcRowIndex, groupId, pFillSup->rowSize); + SSDataBlock* preBlock = pInfo->pPrevSrcBlock; + if (preBlock->info.rows > 0) { + int preRowId = preBlock->info.rows - 1; + SColumnInfoData* pPreTsCol = taosArrayGet(preBlock->pDataBlock, pInfo->primaryTsCol); + doFillResults(pOperator, pFillSup, pFillInfo, preBlock, (TSKEY*)pPreTsCol->pData, preRowId, pRes); + } + pInfo->srcRowIndex++; + } + + while (pInfo->srcRowIndex < pBlock->info.rows) { + TSKEY ts = tsCol[pInfo->srcRowIndex]; + keepBlockRowInDiscBuf(pOperator, pFillInfo, pBlock, tsCol, pInfo->srcRowIndex, groupId, pFillSup->rowSize); + doFillResults(pOperator, pFillSup, pFillInfo, pBlock, tsCol, pInfo->srcRowIndex - 1, pRes); + if (pInfo->pRes->info.rows == pInfo->pRes->info.capacity) { + blockDataUpdateTsWindow(pRes, pInfo->primaryTsCol); + return; + } + pInfo->srcRowIndex++; + } + blockDataUpdateTsWindow(pRes, pInfo->primaryTsCol); + blockDataCleanup(pInfo->pPrevSrcBlock); + copyDataBlock(pInfo->pPrevSrcBlock, pInfo->pSrcBlock); + blockDataCleanup(pInfo->pSrcBlock); +} + +static void buildDeleteRange(TSKEY start, TSKEY end, uint64_t groupId, SSDataBlock* delRes) { + SSDataBlock* pBlock = delRes; + SColumnInfoData* pStartCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); + SColumnInfoData* pEndCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX); + SColumnInfoData* pUidCol = taosArrayGet(pBlock->pDataBlock, UID_COLUMN_INDEX); + SColumnInfoData* pGroupCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX); + SColumnInfoData* pCalStartCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX); + SColumnInfoData* pCalEndCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX); + colDataAppend(pStartCol, pBlock->info.rows, (const char*)&start, false); + colDataAppend(pEndCol, pBlock->info.rows, (const char*)&end, false); + colDataAppendNULL(pUidCol, pBlock->info.rows); + colDataAppend(pGroupCol, pBlock->info.rows, (const char*)&groupId, false); + colDataAppendNULL(pCalStartCol, pBlock->info.rows); + colDataAppendNULL(pCalEndCol, pBlock->info.rows); + pBlock->info.rows++; +} + +static void buildDeleteResult(SStreamFillSupporter* pFillSup, TSKEY startTs, TSKEY endTs, uint64_t groupId, + SSDataBlock* delRes) { + if (hasPrevWindow(pFillSup)) { + TSKEY start = getNextWindowTs(pFillSup->prev.key, &pFillSup->interval); + buildDeleteRange(start, endTs, groupId, delRes); + } else if (hasNextWindow(pFillSup)) { + TSKEY end = getPrevWindowTs(pFillSup->next.key, &pFillSup->interval); + buildDeleteRange(startTs, end, groupId, delRes); + } else { + buildDeleteRange(startTs, endTs, groupId, delRes); + } +} + +static void doDeleteFillResultImpl(SOperatorInfo* pOperator, TSKEY startTs, TSKEY endTs, uint64_t groupId) { + SStreamFillOperatorInfo* pInfo = pOperator->info; + getWindowFromDiscBuf(pOperator, startTs, groupId, pInfo->pFillSup); + setDeleteFillValueInfo(startTs, endTs, pInfo->pFillSup, pInfo->pFillInfo); + SWinKey key = {.ts = startTs, .groupId = groupId}; + if (!pInfo->pFillInfo->needFill) { + streamStateFillDel(pOperator->pTaskInfo->streamInfo.pState, &key); + buildDeleteResult(pInfo->pFillSup, startTs, endTs, groupId, pInfo->pDelRes); + } else { + STimeRange tw = { + .skey = startTs, + .ekey = endTs, + .groupId = groupId, + }; + taosArrayPush(pInfo->pFillInfo->delRanges, &tw); + while (key.ts <= endTs) { + key.ts = taosTimeAdd(key.ts, pInfo->pFillSup->interval.sliding, pInfo->pFillSup->interval.slidingUnit, + pInfo->pFillSup->interval.precision); + tSimpleHashPut(pInfo->pFillSup->pResMap, &key, sizeof(SWinKey), NULL, 0); + } + } +} + +static void doDeleteFillFinalize(SOperatorInfo* pOperator) { + SStreamFillOperatorInfo* pInfo = pOperator->info; + SStreamFillInfo* pFillInfo = pInfo->pFillInfo; + int32_t size = taosArrayGetSize(pFillInfo->delRanges); + tSimpleHashClear(pInfo->pFillSup->pResMap); + for (; pFillInfo->delIndex < size; pFillInfo->delIndex++) { + STimeRange* range = taosArrayGet(pFillInfo->delRanges, pFillInfo->delIndex); + if (pInfo->pRes->info.groupId != 0 && pInfo->pRes->info.groupId != range->groupId) { + return; + } + getWindowFromDiscBuf(pOperator, range->skey, range->groupId, pInfo->pFillSup); + setDeleteFillValueInfo(range->skey, range->ekey, pInfo->pFillSup, pInfo->pFillInfo); + if (pInfo->pFillInfo->needFill) { + doStreamFillRange(pInfo->pFillInfo, pInfo->pFillSup, pInfo->pRes); + pInfo->pRes->info.groupId = range->groupId; + } + SWinKey key = {.ts = range->skey, .groupId = range->groupId}; + streamStateFillDel(pOperator->pTaskInfo->streamInfo.pState, &key); + } +} + +static void doDeleteFillResult(SOperatorInfo* pOperator) { + SStreamFillOperatorInfo* pInfo = pOperator->info; + SStreamFillSupporter* pFillSup = pInfo->pFillSup; + SStreamFillInfo* pFillInfo = pInfo->pFillInfo; + SSDataBlock* pBlock = pInfo->pSrcDelBlock; + SSDataBlock* pRes = pInfo->pRes; + SSDataBlock* pDelRes = pInfo->pDelRes; + + SColumnInfoData* pStartCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); + TSKEY* tsStarts = (TSKEY*)pStartCol->pData; + SColumnInfoData* pGroupCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX); + uint64_t* groupIds = (uint64_t*)pGroupCol->pData; + while (pInfo->srcDelRowIndex < pBlock->info.rows) { + TSKEY ts = tsStarts[pInfo->srcDelRowIndex]; + TSKEY endTs = ts; + uint64_t groupId = groupIds[pInfo->srcDelRowIndex]; + SWinKey key = {.ts = ts, .groupId = groupId}; + SStreamStateCur* pCur = streamStateGetAndCheckCur(pOperator->pTaskInfo->streamInfo.pState, &key); + if (!pCur) { + pInfo->srcDelRowIndex++; + continue; + } + + SWinKey nextKey = {.groupId = groupId, .ts = ts}; + while (pInfo->srcDelRowIndex < pBlock->info.rows) { + void* nextVal = NULL; + int32_t nextLen = 0; + TSKEY delTs = tsStarts[pInfo->srcDelRowIndex]; + uint64_t delGroupId = groupIds[pInfo->srcDelRowIndex]; + int32_t code = TSDB_CODE_SUCCESS; + if (groupId != delGroupId) { + break; + } + if (delTs > nextKey.ts) { + break; + } + endTs = delTs; + SWinKey delKey = {.groupId = delGroupId, .ts = delTs}; + if (delTs == nextKey.ts) { + code = streamStateCurNext(pOperator->pTaskInfo->streamInfo.pState, pCur); + if (code == TSDB_CODE_SUCCESS) { + code = streamStateGetGroupKVByCur(pCur, &nextKey, (const void**)&nextVal, &nextLen); + } + if (delTs != ts) { + streamStateFillDel(pOperator->pTaskInfo->streamInfo.pState, &delKey); + } + if (code != TSDB_CODE_SUCCESS) { + break; + } + } + pInfo->srcDelRowIndex++; + } + doDeleteFillResultImpl(pOperator, ts, endTs, groupId); + } + pFillInfo->current = pFillInfo->end + 1; +} + +static void resetStreamFillInfo(SStreamFillOperatorInfo* pInfo) { + blockDataCleanup(pInfo->pPrevSrcBlock); + tSimpleHashClear(pInfo->pFillSup->pResMap); + pInfo->pFillSup->hasDelete = false; + taosArrayClear(pInfo->pFillInfo->delRanges); + pInfo->pFillInfo->delIndex = 0; +} + +static void doApplyStreamScalarCalculation(SOperatorInfo* pOperator, SSDataBlock* pSrcBlock, SSDataBlock* pDstBlock) { + SStreamFillOperatorInfo* pInfo = pOperator->info; + SExprSupp* pSup = &pOperator->exprSupp; + + blockDataCleanup(pDstBlock); + blockDataEnsureCapacity(pDstBlock, pSrcBlock->info.rows); + setInputDataBlock(pOperator, pSup->pCtx, pSrcBlock, TSDB_ORDER_ASC, MAIN_SCAN, false); + projectApplyFunctions(pSup->pExprInfo, pDstBlock, pSrcBlock, pSup->pCtx, pSup->numOfExprs, NULL); + pDstBlock->info.groupId = pSrcBlock->info.groupId; + + SColumnInfoData* pDst = taosArrayGet(pDstBlock->pDataBlock, pInfo->primaryTsCol); + SColumnInfoData* pSrc = taosArrayGet(pSrcBlock->pDataBlock, pInfo->primarySrcSlotId); + colDataAssign(pDst, pSrc, pDstBlock->info.rows, &pDstBlock->info); + + int32_t numOfNotFill = pInfo->pFillSup->numOfAllCols - pInfo->pFillSup->numOfFillCols; + for (int32_t i = 0; i < numOfNotFill; ++i) { + SFillColInfo* pCol = &pInfo->pFillSup->pAllColInfo[i + pInfo->pFillSup->numOfFillCols]; + ASSERT(pCol->notFillCol); + + SExprInfo* pExpr = pCol->pExpr; + int32_t srcSlotId = pExpr->base.pParam[0].pCol->slotId; + int32_t dstSlotId = pExpr->base.resSchema.slotId; + + SColumnInfoData* pDst1 = taosArrayGet(pDstBlock->pDataBlock, dstSlotId); + SColumnInfoData* pSrc1 = taosArrayGet(pSrcBlock->pDataBlock, srcSlotId); + colDataAssign(pDst1, pSrc1, pDstBlock->info.rows, &pDstBlock->info); + } + blockDataUpdateTsWindow(pDstBlock, pInfo->primaryTsCol); +} + +static SSDataBlock* doStreamFill(SOperatorInfo* pOperator) { + SStreamFillOperatorInfo* pInfo = pOperator->info; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + + if (pOperator->status == OP_EXEC_DONE) { + return NULL; + } + blockDataCleanup(pInfo->pRes); + if (pOperator->status == OP_RES_TO_RETURN) { + if (hasRemainCalc(pInfo->pFillInfo)) { + doStreamFillRange(pInfo->pFillInfo, pInfo->pFillSup, pInfo->pRes); + if (pInfo->pRes->info.rows > 0) { + return pInfo->pRes; + } + } + doDeleteFillFinalize(pOperator); + if (pInfo->pRes->info.rows > 0) { + printDataBlock(pInfo->pRes, "stream fill"); + return pInfo->pRes; + } + doSetOperatorCompleted(pOperator); + resetStreamFillInfo(pInfo); + return NULL; + } + + SSDataBlock* fillResult = NULL; + SOperatorInfo* downstream = pOperator->pDownstream[0]; + while (1) { + if (pInfo->srcRowIndex >= pInfo->pSrcBlock->info.rows) { + // If there are delete datablocks, we receive them first. + SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); + if (pBlock == NULL) { + pOperator->status = OP_RES_TO_RETURN; + SSDataBlock* preBlock = pInfo->pPrevSrcBlock; + if (preBlock->info.rows > 0) { + int preRowId = preBlock->info.rows - 1; + SColumnInfoData* pPreTsCol = taosArrayGet(preBlock->pDataBlock, pInfo->primaryTsCol); + doFillResults(pOperator, pInfo->pFillSup, pInfo->pFillInfo, preBlock, (TSKEY*)pPreTsCol->pData, preRowId, + pInfo->pRes); + } + pInfo->pFillInfo->preRowKey = INT64_MIN; + if (pInfo->pRes->info.rows > 0) { + printDataBlock(pInfo->pRes, "stream fill"); + return pInfo->pRes; + } + break; + } + printDataBlock(pBlock, "stream fill recv"); + + switch (pBlock->info.type) { + case STREAM_RETRIEVE: + return pBlock; + case STREAM_DELETE_RESULT: { + pInfo->pSrcDelBlock = pBlock; + pInfo->srcDelRowIndex = 0; + blockDataCleanup(pInfo->pDelRes); + pInfo->pFillSup->hasDelete = true; + doDeleteFillResult(pOperator); + if (pInfo->pDelRes->info.rows > 0) { + printDataBlock(pInfo->pDelRes, "stream fill delete"); + return pInfo->pDelRes; + } + continue; + } break; + case STREAM_NORMAL: + case STREAM_INVALID: { + doApplyStreamScalarCalculation(pOperator, pBlock, pInfo->pSrcBlock); + pInfo->srcRowIndex = 0; + } break; + default: + ASSERT(0); + break; + } + } + + doStreamFillImpl(pOperator); + doFilter(pInfo->pCondition, pInfo->pRes, pInfo->pColMatchColInfo); + pOperator->resultInfo.totalRows += pInfo->pRes->info.rows; + if (pInfo->pRes->info.rows > 0) { + break; + } + } + if (pOperator->status == OP_RES_TO_RETURN) { + doDeleteFillFinalize(pOperator); + } + + if (pInfo->pRes->info.rows == 0) { + doSetOperatorCompleted(pOperator); + resetStreamFillInfo(pInfo); + return NULL; + } + + pOperator->resultInfo.totalRows += pInfo->pRes->info.rows; + printDataBlock(pInfo->pRes, "stream fill"); + return pInfo->pRes; +} + +static int32_t initResultBuf(SStreamFillSupporter* pFillSup) { + pFillSup->rowSize = sizeof(SResultCellData) * pFillSup->numOfAllCols; + for (int i = 0; i < pFillSup->numOfAllCols; i++) { + SFillColInfo* pCol = &pFillSup->pAllColInfo[i]; + SResSchema* pSchema = &pCol->pExpr->base.resSchema; + pFillSup->rowSize += pSchema->bytes; + } + pFillSup->next.key = INT64_MIN; + pFillSup->nextNext.key = INT64_MIN; + pFillSup->prev.key = INT64_MIN; + pFillSup->next.pRowVal = NULL; + pFillSup->nextNext.pRowVal = NULL; + pFillSup->prev.pRowVal = NULL; + return TSDB_CODE_SUCCESS; +} + +static SStreamFillSupporter* initStreamFillSup(SStreamFillPhysiNode* pPhyFillNode, SInterval* pInterval, + SExprInfo* pFillExprInfo, int32_t numOfFillCols) { + SStreamFillSupporter* pFillSup = taosMemoryCalloc(1, sizeof(SStreamFillSupporter)); + if (!pFillSup) { + return NULL; + } + pFillSup->numOfFillCols = numOfFillCols; + int32_t numOfNotFillCols = 0; + SExprInfo* pNotFillExprInfo = createExprInfo(pPhyFillNode->pNotFillExprs, NULL, &numOfNotFillCols); + pFillSup->pAllColInfo = createFillColInfo(pFillExprInfo, pFillSup->numOfFillCols, pNotFillExprInfo, numOfNotFillCols, + (const SNodeListNode*)(pPhyFillNode->pValues)); + pFillSup->type = convertFillType(pPhyFillNode->mode); + pFillSup->numOfAllCols = pFillSup->numOfFillCols + numOfNotFillCols; + pFillSup->interval = *pInterval; + + int32_t code = initResultBuf(pFillSup); + if (code != TSDB_CODE_SUCCESS) { + destroyStreamFillSupporter(pFillSup); + return NULL; + } + _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); + pFillSup->pResMap = tSimpleHashInit(16, hashFn); + pFillSup->hasDelete = false; + return pFillSup; +} + +SStreamFillInfo* initStreamFillInfo(SStreamFillSupporter* pFillSup, SSDataBlock* pRes) { + SStreamFillInfo* pFillInfo = taosMemoryCalloc(1, sizeof(SStreamFillInfo)); + pFillInfo->start = INT64_MIN; + pFillInfo->current = INT64_MIN; + pFillInfo->end = INT64_MIN; + pFillInfo->preRowKey = INT64_MIN; + pFillInfo->needFill = false; + pFillInfo->pLinearInfo = taosMemoryCalloc(1, sizeof(SStreamFillLinearInfo)); + pFillInfo->pLinearInfo->hasNext = false; + pFillInfo->pLinearInfo->nextEnd = INT64_MIN; + pFillInfo->pLinearInfo->pDeltaVal = NULL; + pFillInfo->pLinearInfo->pNextDeltaVal = NULL; + if (pFillSup->type == TSDB_FILL_LINEAR) { + pFillInfo->pLinearInfo->pDeltaVal = taosArrayInit(pFillSup->numOfAllCols, sizeof(double)); + pFillInfo->pLinearInfo->pNextDeltaVal = taosArrayInit(pFillSup->numOfAllCols, sizeof(double)); + for (int32_t i = 0; i < pFillSup->numOfAllCols; i++) { + double value = 0.0; + taosArrayPush(pFillInfo->pLinearInfo->pDeltaVal, &value); + taosArrayPush(pFillInfo->pLinearInfo->pNextDeltaVal, &value); + } + } + pFillInfo->pLinearInfo->winIndex = 0; + + pFillInfo->pResRow = NULL; + if (pFillSup->type == TSDB_FILL_SET_VALUE || pFillSup->type == TSDB_FILL_NULL) { + pFillInfo->pResRow = taosMemoryCalloc(1, sizeof(SResultRowData)); + pFillInfo->pResRow->key = INT64_MIN; + pFillInfo->pResRow->pRowVal = taosMemoryCalloc(1, pFillSup->rowSize); + for (int32_t i = 0; i < pFillSup->numOfAllCols; ++i) { + SColumnInfoData* pColData = taosArrayGet(pRes->pDataBlock, i); + SResultCellData* pCell = getResultCell(pFillInfo->pResRow, i); + pCell->bytes = pColData->info.bytes; + pCell->type = pColData->info.type; + } + } + + pFillInfo->type = pFillSup->type; + pFillInfo->delRanges = taosArrayInit(16, sizeof(STimeRange)); + pFillInfo->delIndex = 0; + return pFillInfo; +} + +SOperatorInfo* createStreamFillOperatorInfo(SOperatorInfo* downstream, SStreamFillPhysiNode* pPhyFillNode, + SExecTaskInfo* pTaskInfo) { + SStreamFillOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamFillOperatorInfo)); + SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + if (pInfo == NULL || pOperator == NULL) { + goto _error; + } + + SInterval* pInterval = &((SStreamIntervalOperatorInfo*)downstream->info)->interval; + int32_t numOfFillCols = 0; + SExprInfo* pFillExprInfo = createExprInfo(pPhyFillNode->pFillExprs, NULL, &numOfFillCols); + pInfo->pFillSup = initStreamFillSup(pPhyFillNode, pInterval, pFillExprInfo, numOfFillCols); + if (!pInfo->pFillSup) { + goto _error; + } + + SResultInfo* pResultInfo = &pOperator->resultInfo; + initResultSizeInfo(&pOperator->resultInfo, 4096); + pInfo->pRes = createResDataBlock(pPhyFillNode->node.pOutputDataBlockDesc); + pInfo->pSrcBlock = createResDataBlock(pPhyFillNode->node.pOutputDataBlockDesc); + pInfo->pPrevSrcBlock = createResDataBlock(pPhyFillNode->node.pOutputDataBlockDesc); + blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity); + blockDataEnsureCapacity(pInfo->pSrcBlock, pOperator->resultInfo.capacity); + blockDataEnsureCapacity(pInfo->pPrevSrcBlock, pOperator->resultInfo.capacity); + + pInfo->pFillInfo = initStreamFillInfo(pInfo->pFillSup, pInfo->pRes); + if (!pInfo->pFillInfo) { + goto _error; + } + + if (pInfo->pFillInfo->type == TSDB_FILL_SET_VALUE) { + for (int32_t i = 0; i < pInfo->pFillSup->numOfAllCols; ++i) { + SFillColInfo* pFillCol = pInfo->pFillSup->pAllColInfo + i; + int32_t slotId = GET_DEST_SLOT_ID(pFillCol); + SResultCellData* pCell = getResultCell(pInfo->pFillInfo->pResRow, slotId); + SVariant* pVar = &(pFillCol->fillVal); + if (pCell->type == TSDB_DATA_TYPE_FLOAT) { + float v = 0; + GET_TYPED_DATA(v, float, pVar->nType, &pVar->i); + SET_TYPED_DATA(pCell->pData, pCell->type, v); + } else if (pCell->type == TSDB_DATA_TYPE_DOUBLE) { + double v = 0; + GET_TYPED_DATA(v, double, pVar->nType, &pVar->i); + SET_TYPED_DATA(pCell->pData, pCell->type, v); + } else if (IS_SIGNED_NUMERIC_TYPE(pCell->type)) { + int64_t v = 0; + GET_TYPED_DATA(v, int64_t, pVar->nType, &pVar->i); + SET_TYPED_DATA(pCell->pData, pCell->type, v); + } else { + pCell->isNull = true; + } + } + } else if (pInfo->pFillInfo->type == TSDB_FILL_NULL) { + for (int32_t i = 0; i < pInfo->pFillSup->numOfAllCols; ++i) { + SFillColInfo* pFillCol = pInfo->pFillSup->pAllColInfo + i; + int32_t slotId = GET_DEST_SLOT_ID(pFillCol); + SResultCellData* pCell = getResultCell(pInfo->pFillInfo->pResRow, slotId); + pCell->isNull = true; + } + } + + pInfo->pDelRes = createSpecialDataBlock(STREAM_DELETE_RESULT); + blockDataEnsureCapacity(pInfo->pDelRes, pOperator->resultInfo.capacity); + + pInfo->primaryTsCol = ((STargetNode*)pPhyFillNode->pWStartTs)->slotId; + pInfo->primarySrcSlotId = ((SColumnNode*)((STargetNode*)pPhyFillNode->pWStartTs)->pExpr)->slotId; + + int32_t numOfOutputCols = 0; + SArray* pColMatchColInfo = extractColMatchInfo(pPhyFillNode->pFillExprs, pPhyFillNode->node.pOutputDataBlockDesc, + &numOfOutputCols, COL_MATCH_FROM_SLOT_ID); + pInfo->pCondition = pPhyFillNode->node.pConditions; + pInfo->pColMatchColInfo = pColMatchColInfo; + initExprSupp(&pOperator->exprSupp, pFillExprInfo, numOfFillCols); + pInfo->srcRowIndex = 0; + + pOperator->name = "FillOperator"; + pOperator->blocking = false; + pOperator->status = OP_NOT_OPENED; + pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL; + pOperator->info = pInfo; + pOperator->pTaskInfo = pTaskInfo; + pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamFill, NULL, NULL, destroyStreamFillOperatorInfo, + NULL, NULL, NULL); + + int32_t code = appendDownstream(pOperator, &downstream, 1); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + return pOperator; + +_error: + destroyStreamFillOperatorInfo(pInfo); + taosMemoryFreeClear(pOperator); + return NULL; +} diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 4671570802..9b4b7f1ee8 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -271,6 +271,10 @@ static void getNextTimeWindow(SInterval* pInterval, int32_t precision, int32_t o tw->ekey -= 1; } +void getNextIntervalWindow(SInterval* pInterval, STimeWindow* tw, int32_t order) { + getNextTimeWindow(pInterval, pInterval->precision, order, tw); +} + void doTimeWindowInterpolation(SArray* pPrevValues, SArray* pDataBlock, TSKEY prevTs, int32_t prevRowIndex, TSKEY curTs, int32_t curRowIndex, TSKEY windowKey, int32_t type, SExprSupp* pSup) { SqlFunctionCtx* pCtx = pSup->pCtx; @@ -863,10 +867,6 @@ static int32_t saveWinResult(int64_t ts, int32_t pageId, int32_t offset, uint64_ return TSDB_CODE_SUCCESS; } -static int32_t saveWinResultRow(SResultRow* result, uint64_t groupId, SHashObj* pUpdatedMap) { - return saveWinResult(result->win.skey, result->pageId, result->offset, groupId, pUpdatedMap); -} - static int32_t saveWinResultInfo(TSKEY ts, uint64_t groupId, SHashObj* pUpdatedMap) { return saveWinResult(ts, -1, -1, groupId, pUpdatedMap); } @@ -1386,7 +1386,7 @@ static bool doDeleteWindow(SOperatorInfo* pOperator, TSKEY ts, uint64_t groupId, SStreamIntervalOperatorInfo* pInfo = pOperator->info; SWinKey key = {.ts = ts, .groupId = groupId}; tSimpleHashRemove(pInfo->aggSup.pResultRowHashTable, &key, sizeof(SWinKey)); - streamStateDel(pOperator->pTaskInfo->streamInfo.pState, &key); + streamStateDel(pInfo->pState, &key); return true; } @@ -1402,7 +1402,7 @@ static void doDeleteWindows(SOperatorInfo* pOperator, SInterval* pInterval, int3 SResultRowInfo dumyInfo; dumyInfo.cur.pageId = -1; STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, startTsCols[i], pInterval, TSDB_ORDER_ASC); - while (win.ekey <= endTsCols[i]) { + while (win.skey <= endTsCols[i]) { uint64_t winGpId = pGpDatas[i]; bool res = doDeleteWindow(pOperator, win.skey, winGpId, numOfOutput); SWinKey winRes = {.ts = win.skey, .groupId = winGpId}; @@ -1501,64 +1501,13 @@ static int32_t getAllIntervalWindow(SSHashObj* pHashMap, SHashObj* resWins) { return TSDB_CODE_SUCCESS; } -static int32_t closeIntervalWindow(SSHashObj* pHashMap, STimeWindowAggSupp* pSup, SInterval* pInterval, - SHashObj* pPullDataMap, SHashObj* closeWins, SArray* pRecyPages, - SDiskbasedBuf* pDiscBuf) { - qDebug("===stream===close interval window"); - void* pIte = NULL; - size_t keyLen = 0; - int32_t iter = 0; - while ((pIte = tSimpleHashIterate(pHashMap, pIte, &iter)) != NULL) { - void* key = tSimpleHashGetKey(pIte, &keyLen); - uint64_t groupId = *(uint64_t*)key; - ASSERT(keyLen == GET_RES_WINDOW_KEY_LEN(sizeof(TSKEY))); - TSKEY ts = *(int64_t*)((char*)key + sizeof(uint64_t)); - STimeWindow win; - win.skey = ts; - win.ekey = taosTimeAdd(win.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1; - SWinKey winRe = { - .ts = win.skey, - .groupId = groupId, - }; - void* chIds = taosHashGet(pPullDataMap, &winRe, sizeof(SWinKey)); - if (isCloseWindow(&win, pSup)) { - if (chIds && pPullDataMap) { - SArray* chAy = *(SArray**)chIds; - int32_t size = taosArrayGetSize(chAy); - qDebug("===stream===window %" PRId64 " wait child size:%d", win.skey, size); - for (int32_t i = 0; i < size; i++) { - qDebug("===stream===window %" PRId64 " wait child id:%d", win.skey, *(int32_t*)taosArrayGet(chAy, i)); - } - continue; - } else if (pPullDataMap) { - qDebug("===stream===close window %" PRId64, win.skey); - } - SResultRowPosition* pPos = (SResultRowPosition*)pIte; - if (pSup->calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) { - int32_t code = saveWinResult(ts, pPos->pageId, pPos->offset, groupId, closeWins); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - ASSERT(pRecyPages != NULL); - taosArrayPush(pRecyPages, &pPos->pageId); - } else { - // SFilePage* bufPage = getBufPage(pDiscBuf, pPos->pageId); - // dBufSetBufPageRecycled(pDiscBuf, bufPage); - } - char keyBuf[GET_RES_WINDOW_KEY_LEN(sizeof(TSKEY))]; - SET_RES_WINDOW_KEY(keyBuf, &ts, sizeof(TSKEY), groupId); - tSimpleHashIterateRemove(pHashMap, keyBuf, keyLen, &pIte, &iter); - } - } - return TSDB_CODE_SUCCESS; -} - static int32_t closeStreamIntervalWindow(SSHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SInterval* pInterval, SHashObj* pPullDataMap, SHashObj* closeWins, SOperatorInfo* pOperator) { qDebug("===stream===close interval window"); - void* pIte = NULL; - size_t keyLen = 0; - int32_t iter = 0; + void* pIte = NULL; + size_t keyLen = 0; + int32_t iter = 0; + SStreamIntervalOperatorInfo* pInfo = pOperator->info; while ((pIte = tSimpleHashIterate(pHashMap, pIte, &iter)) != NULL) { void* key = tSimpleHashGetKey(pIte, &keyLen); SWinKey* pWinKey = (SWinKey*)key; @@ -1587,24 +1536,85 @@ static int32_t closeStreamIntervalWindow(SSHashObj* pHashMap, STimeWindowAggSupp } } tSimpleHashIterateRemove(pHashMap, pWinKey, sizeof(SWinKey), &pIte, &iter); - - if (needDeleteWindowBuf(&win, pTwSup)) { - streamStateDel(pOperator->pTaskInfo->streamInfo.pState, pWinKey); - } } } return TSDB_CODE_SUCCESS; } -static void closeChildIntervalWindow(SArray* pChildren, TSKEY maxTs) { +STimeWindow getFinalTimeWindow(int64_t ts, SInterval* pInterval) { + STimeWindow w = {.skey = ts, .ekey = INT64_MAX}; + w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1; + return w; +} + +static void deleteIntervalDiscBuf(SStreamState* pState, SHashObj* pPullDataMap, TSKEY mark, SInterval* pInterval, + SWinKey* key) { + STimeWindow tw = getFinalTimeWindow(key->ts, pInterval); + SWinKey next = {0}; + while (tw.ekey < mark) { + SStreamStateCur* pCur = streamStateSeekKeyNext(pState, key); + int32_t code = streamStateGetKVByCur(pCur, &next, NULL, 0); + streamStateFreeCur(pCur); + + void* chIds = taosHashGet(pPullDataMap, key, sizeof(SWinKey)); + if (chIds && pPullDataMap) { + SArray* chAy = *(SArray**)chIds; + int32_t size = taosArrayGetSize(chAy); + qDebug("===stream===window %" PRId64 " wait child size:%d", key->ts, size); + for (int32_t i = 0; i < size; i++) { + qDebug("===stream===window %" PRId64 " wait child id:%d", key->ts, *(int32_t*)taosArrayGet(chAy, i)); + } + break; + } + qDebug("===stream===delete window %" PRId64, key->ts); + int32_t codeDel = streamStateDel(pState, key); + if (codeDel != TSDB_CODE_SUCCESS) { + code = streamStateGetFirst(pState, key); + if (code != TSDB_CODE_SUCCESS) { + qDebug("===stream===stream state first key: empty-empty"); + return; + } + continue; + } + if (code == TSDB_CODE_SUCCESS) { + *key = next; + tw = getFinalTimeWindow(key->ts, pInterval); + } + } + + if (qDebugFlag & DEBUG_DEBUG) { + SStreamStateCur* pCur = streamStateGetCur(pState, key); + int32_t code = streamStateCurPrev(pState, pCur); + if (code == TSDB_CODE_SUCCESS) { + SWinKey tmpKey = {0}; + code = streamStateGetKVByCur(pCur, &tmpKey, NULL, 0); + if (code == TSDB_CODE_SUCCESS) { + STimeWindow tw = getFinalTimeWindow(tmpKey.ts, pInterval); + qDebug("===stream===error stream state first key:%" PRId64 "-%" PRId64 ",%" PRId64 ",mark %" PRId64, tw.skey, + tw.ekey, tmpKey.groupId, mark); + } else { + STimeWindow tw = getFinalTimeWindow(key->ts, pInterval); + qDebug("===stream===stream state first key:%" PRId64 "-%" PRId64 ",%" PRId64 ",mark %" PRId64, tw.skey, tw.ekey, + key->groupId, mark); + } + } else { + STimeWindow tw = getFinalTimeWindow(key->ts, pInterval); + qDebug("===stream===stream state first key:%" PRId64 "-%" PRId64 ",%" PRId64 ",mark %" PRId64, tw.skey, tw.ekey, + key->groupId, mark); + } + streamStateFreeCur(pCur); + } +} + +static void closeChildIntervalWindow(SOperatorInfo* pOperator, SArray* pChildren, TSKEY maxTs) { int32_t size = taosArrayGetSize(pChildren); for (int32_t i = 0; i < size; i++) { - SOperatorInfo* pChildOp = taosArrayGetP(pChildren, i); - SStreamFinalIntervalOperatorInfo* pChInfo = pChildOp->info; + SOperatorInfo* pChildOp = taosArrayGetP(pChildren, i); + SStreamIntervalOperatorInfo* pChInfo = pChildOp->info; ASSERT(pChInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE); pChInfo->twAggSup.maxTs = TMAX(pChInfo->twAggSup.maxTs, maxTs); - closeIntervalWindow(pChInfo->aggSup.pResultRowHashTable, &pChInfo->twAggSup, &pChInfo->interval, NULL, NULL, NULL, - pChInfo->aggSup.pResultBuf); + closeStreamIntervalWindow(pChInfo->aggSup.pResultRowHashTable, &pChInfo->twAggSup, &pChInfo->interval, NULL, NULL, + pOperator); } } @@ -1656,13 +1666,10 @@ void destroyIntervalOperatorInfo(void* param) { tdListFree(pInfo->binfo.resultRowInfo.openWindow); - pInfo->pRecycledPages = taosArrayDestroy(pInfo->pRecycledPages); pInfo->pInterpCols = taosArrayDestroy(pInfo->pInterpCols); taosArrayDestroyEx(pInfo->pPrevValues, freeItem); pInfo->pPrevValues = NULL; - pInfo->pDelWins = taosArrayDestroy(pInfo->pDelWins); - pInfo->pDelRes = blockDataDestroy(pInfo->pDelRes); cleanupGroupResInfo(&pInfo->groupResInfo); colDataDestroy(&pInfo->twAggSup.timeWindowData); @@ -1670,17 +1677,17 @@ void destroyIntervalOperatorInfo(void* param) { } void destroyStreamFinalIntervalOperatorInfo(void* param) { - SStreamFinalIntervalOperatorInfo* pInfo = (SStreamFinalIntervalOperatorInfo*)param; + SStreamIntervalOperatorInfo* pInfo = (SStreamIntervalOperatorInfo*)param; cleanupBasicInfo(&pInfo->binfo); cleanupAggSup(&pInfo->aggSup); // it should be empty. taosHashCleanup(pInfo->pPullDataMap); taosArrayDestroy(pInfo->pPullWins); blockDataDestroy(pInfo->pPullDataRes); - taosArrayDestroy(pInfo->pRecycledPages); blockDataDestroy(pInfo->pUpdateRes); taosArrayDestroy(pInfo->pDelWins); blockDataDestroy(pInfo->pDelRes); + taosMemoryFreeClear(pInfo->pState); if (pInfo->pChildren) { int32_t size = taosArrayGetSize(pInfo->pChildren); @@ -1790,7 +1797,6 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pInfo->interval = *pInterval; pInfo->execModel = pTaskInfo->execModel; pInfo->twAggSup = *pTwAggSupp; - pInfo->ignoreExpiredData = pPhyNode->window.igExpired; pInfo->pCondition = pPhyNode->window.node.pConditions; pInfo->binfo.mergeResultBlock = pPhyNode->window.mergeDataBlock; @@ -1823,9 +1829,6 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pInfo->win); - pInfo->invertible = allInvertible(pSup->pCtx, numOfCols); - pInfo->invertible = false; // Todo(liuyao): Dependent TSDB API - pInfo->timeWindowInterpo = timeWindowinterpNeeded(pSup->pCtx, numOfCols, pInfo); if (pInfo->timeWindowInterpo) { pInfo->binfo.resultRowInfo.openWindow = tdListNew(sizeof(SOpenWindowInfo)); @@ -1834,10 +1837,6 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* } } - pInfo->pRecycledPages = taosArrayInit(4, sizeof(int32_t)); - pInfo->pDelWins = taosArrayInit(4, sizeof(SWinKey)); - pInfo->delIndex = 0; - pInfo->pDelRes = createSpecialDataBlock(STREAM_DELETE_RESULT); initResultRowInfo(&pInfo->binfo.resultRowInfo); pOperator->name = "TimeIntervalAggOperator"; @@ -2095,12 +2094,17 @@ static void genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp bool hasInterp = true; for (int32_t j = 0; j < pExprSup->numOfExprs; ++j) { SExprInfo* pExprInfo = &pExprSup->pExprInfo[j]; - int32_t srcSlot = pExprInfo->base.pParam[0].pCol->slotId; - int32_t dstSlot = pExprInfo->base.resSchema.slotId; - // SColumnInfoData* pSrc = taosArrayGet(pBlock->pDataBlock, srcSlot); + int32_t dstSlot = pExprInfo->base.resSchema.slotId; SColumnInfoData* pDst = taosArrayGet(pResBlock->pDataBlock, dstSlot); + if (IS_TIMESTAMP_TYPE(pExprInfo->base.resSchema.type)) { + colDataAppend(pDst, rows, (char*)&pSliceInfo->current, false); + continue; + } + + int32_t srcSlot = pExprInfo->base.pParam[0].pCol->slotId; + // SColumnInfoData* pSrc = taosArrayGet(pBlock->pDataBlock, srcSlot); switch (pSliceInfo->fillType) { case TSDB_FILL_NULL: { colDataAppendNULL(pDst, rows); @@ -2346,19 +2350,24 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { if (ts == pSliceInfo->current) { for (int32_t j = 0; j < pOperator->exprSupp.numOfExprs; ++j) { SExprInfo* pExprInfo = &pOperator->exprSupp.pExprInfo[j]; - int32_t dstSlot = pExprInfo->base.resSchema.slotId; - int32_t srcSlot = pExprInfo->base.pParam[0].pCol->slotId; - SColumnInfoData* pSrc = taosArrayGet(pBlock->pDataBlock, srcSlot); + int32_t dstSlot = pExprInfo->base.resSchema.slotId; SColumnInfoData* pDst = taosArrayGet(pResBlock->pDataBlock, dstSlot); - if (colDataIsNull_s(pSrc, i)) { - colDataAppendNULL(pDst, pResBlock->info.rows); - continue; - } + if (IS_TIMESTAMP_TYPE(pExprInfo->base.resSchema.type)) { + colDataAppend(pDst, pResBlock->info.rows, (char*)&pSliceInfo->current, false); + } else { + int32_t srcSlot = pExprInfo->base.pParam[0].pCol->slotId; + SColumnInfoData* pSrc = taosArrayGet(pBlock->pDataBlock, srcSlot); - char* v = colDataGetData(pSrc, i); - colDataAppend(pDst, pResBlock->info.rows, v, false); + if (colDataIsNull_s(pSrc, i)) { + colDataAppendNULL(pDst, pResBlock->info.rows); + continue; + } + + char* v = colDataGetData(pSrc, i); + colDataAppend(pDst, pResBlock->info.rows, v, false); + } } pResBlock->info.rows += 1; @@ -2478,14 +2487,24 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { if (ts == pSliceInfo->current && pSliceInfo->current <= pSliceInfo->win.ekey) { for (int32_t j = 0; j < pOperator->exprSupp.numOfExprs; ++j) { SExprInfo* pExprInfo = &pOperator->exprSupp.pExprInfo[j]; - int32_t dstSlot = pExprInfo->base.resSchema.slotId; - int32_t srcSlot = pExprInfo->base.pParam[0].pCol->slotId; - SColumnInfoData* pSrc = taosArrayGet(pBlock->pDataBlock, srcSlot); + int32_t dstSlot = pExprInfo->base.resSchema.slotId; SColumnInfoData* pDst = taosArrayGet(pResBlock->pDataBlock, dstSlot); - char* v = colDataGetData(pSrc, i); - colDataAppend(pDst, pResBlock->info.rows, v, false); + if (IS_TIMESTAMP_TYPE(pExprInfo->base.resSchema.type)) { + colDataAppend(pDst, pResBlock->info.rows, (char*)&pSliceInfo->current, false); + } else { + int32_t srcSlot = pExprInfo->base.pParam[0].pCol->slotId; + SColumnInfoData* pSrc = taosArrayGet(pBlock->pDataBlock, srcSlot); + + if (colDataIsNull_s(pSrc, i)) { + colDataAppendNULL(pDst, pResBlock->info.rows); + continue; + } + + char* v = colDataGetData(pSrc, i); + colDataAppend(pDst, pResBlock->info.rows, v, false); + } } pResBlock->info.rows += 1; @@ -2813,24 +2832,15 @@ void compactFunctions(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx, int3 } } -bool hasIntervalWindow(SAggSupporter* pSup, TSKEY ts, uint64_t groupId) { - int32_t bytes = sizeof(TSKEY); - SET_RES_WINDOW_KEY(pSup->keyBuf, &ts, bytes, groupId); - SResultRowPosition* p1 = - (SResultRowPosition*)tSimpleHashGet(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes)); - return p1 != NULL; +bool hasIntervalWindow(SStreamState* pState, SWinKey* pKey) { + return TSDB_CODE_SUCCESS == streamStateGet(pState, pKey, NULL, 0); } -STimeWindow getFinalTimeWindow(int64_t ts, SInterval* pInterval) { - STimeWindow w = {.skey = ts, .ekey = INT64_MAX}; - w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1; - return w; -} - -static void rebuildIntervalWindow(SStreamFinalIntervalOperatorInfo* pInfo, SExprSupp* pSup, SArray* pWinArray, - int32_t groupId, int32_t numOfOutput, SExecTaskInfo* pTaskInfo, - SHashObj* pUpdatedMap) { - int32_t size = taosArrayGetSize(pWinArray); +static void rebuildIntervalWindow(SOperatorInfo* pOperator, SExprSupp* pSup, SArray* pWinArray, SHashObj* pUpdatedMap) { + SStreamIntervalOperatorInfo* pInfo = pOperator->info; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + int32_t size = taosArrayGetSize(pWinArray); + int32_t numOfOutput = pOperator->exprSupp.numOfExprs; if (!pInfo->pChildren) { return; } @@ -2838,31 +2848,35 @@ static void rebuildIntervalWindow(SStreamFinalIntervalOperatorInfo* pInfo, SExpr SWinKey* pWinRes = taosArrayGet(pWinArray, i); SResultRow* pCurResult = NULL; STimeWindow parentWin = getFinalTimeWindow(pWinRes->ts, &pInfo->interval); - if (isDeletedWindow(&parentWin, pWinRes->groupId, &pInfo->aggSup) && isCloseWindow(&parentWin, &pInfo->twAggSup)) { + if (isDeletedStreamWindow(&parentWin, pWinRes->groupId, pInfo->pState, &pInfo->twAggSup) && + isCloseWindow(&parentWin, &pInfo->twAggSup)) { continue; } - setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, &parentWin, true, &pCurResult, pWinRes->groupId, pSup->pCtx, - numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); + int32_t code = setOutputBuf(pInfo->pState, &parentWin, &pCurResult, pWinRes->groupId, pSup->pCtx, numOfOutput, + pSup->rowEntryInfoOffset, &pInfo->aggSup); + if (code != TSDB_CODE_SUCCESS || pCurResult == NULL) { + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + } int32_t numOfChildren = taosArrayGetSize(pInfo->pChildren); int32_t num = 0; for (int32_t j = 0; j < numOfChildren; j++) { - SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, j); - SIntervalAggOperatorInfo* pChInfo = pChildOp->info; - SExprSupp* pChildSup = &pChildOp->exprSupp; - if (!hasIntervalWindow(&pChInfo->aggSup, pWinRes->ts, pWinRes->groupId)) { + SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, j); + SStreamIntervalOperatorInfo* pChInfo = pChildOp->info; + SExprSupp* pChildSup = &pChildOp->exprSupp; + if (!hasIntervalWindow(pChInfo->pState, pWinRes)) { continue; } num++; SResultRow* pChResult = NULL; - setTimeWindowOutputBuf(&pChInfo->binfo.resultRowInfo, &parentWin, true, &pChResult, pWinRes->groupId, - pChildSup->pCtx, pChildSup->numOfExprs, pChildSup->rowEntryInfoOffset, &pChInfo->aggSup, - pTaskInfo); + setOutputBuf(pChInfo->pState, &parentWin, &pChResult, pWinRes->groupId, pChildSup->pCtx, pChildSup->numOfExprs, + pChildSup->rowEntryInfoOffset, &pChInfo->aggSup); updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &parentWin, true); compactFunctions(pSup->pCtx, pChildSup->pCtx, numOfOutput, pTaskInfo, &pInfo->twAggSup.timeWindowData); } if (num > 0 && pUpdatedMap) { - saveWinResultRow(pCurResult, pWinRes->groupId, pUpdatedMap); - setResultBufPageDirty(pInfo->aggSup.pResultBuf, &pInfo->binfo.resultRowInfo.cur); + saveWinResultInfo(pCurResult->win.skey, pWinRes->groupId, pUpdatedMap); + saveOutputBuf(pInfo->pState, pWinRes, pCurResult, pInfo->aggSup.resultRowSize); + releaseOutputBuf(pInfo->pState, pWinRes, pCurResult); } } } @@ -2874,15 +2888,15 @@ bool isDeletedWindow(STimeWindow* pWin, uint64_t groupId, SAggSupporter* pSup) { return p1 == NULL; } -bool isDeletedStreamWindow(STimeWindow* pWin, uint64_t groupId, SOperatorInfo* pOperator, STimeWindowAggSupp* pTwSup) { +bool isDeletedStreamWindow(STimeWindow* pWin, uint64_t groupId, SStreamState* pState, STimeWindowAggSupp* pTwSup) { if (pWin->ekey < pTwSup->maxTs - pTwSup->deleteMark) { SWinKey key = {.ts = pWin->skey, .groupId = groupId}; void* pVal = NULL; int32_t size = 0; - if (streamStateGet(pOperator->pTaskInfo->streamInfo.pState, &key, &pVal, &size) < 0) { + if (streamStateGet(pState, &key, &pVal, &size) == TSDB_CODE_SUCCESS) { return false; } - streamStateReleaseBuf(pOperator->pTaskInfo->streamInfo.pState, &key, pVal); + return true; } return false; } @@ -2905,109 +2919,12 @@ void addPullWindow(SHashObj* pMap, SWinKey* pWinRes, int32_t size) { static int32_t getChildIndex(SSDataBlock* pBlock) { return pBlock->info.childId; } -static void doHashIntervalAgg(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBlock, uint64_t tableGroupId, - SHashObj* pUpdatedMap) { - SStreamFinalIntervalOperatorInfo* pInfo = (SStreamFinalIntervalOperatorInfo*)pOperatorInfo->info; - SResultRowInfo* pResultRowInfo = &(pInfo->binfo.resultRowInfo); - SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo; - SExprSupp* pSup = &pOperatorInfo->exprSupp; - int32_t numOfOutput = pSup->numOfExprs; - int32_t step = 1; - TSKEY* tsCols = NULL; - SResultRow* pResult = NULL; - int32_t forwardRows = 0; - - ASSERT(pSDataBlock->pDataBlock != NULL); - SColumnInfoData* pColDataInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex); - tsCols = (int64_t*)pColDataInfo->pData; - - int32_t startPos = 0; - TSKEY ts = getStartTsKey(&pSDataBlock->info.window, tsCols); - STimeWindow nextWin = {0}; - if (IS_FINAL_OP(pInfo)) { - nextWin = getFinalTimeWindow(ts, &pInfo->interval); - } else { - nextWin = getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, pInfo->order); - } - while (1) { - bool isClosed = isCloseWindow(&nextWin, &pInfo->twAggSup); - if ((pInfo->ignoreExpiredData && isClosed) || !inSlidingWindow(&pInfo->interval, &nextWin, &pSDataBlock->info)) { - startPos = getNexWindowPos(&pInfo->interval, &pSDataBlock->info, tsCols, startPos, nextWin.ekey, &nextWin); - if (startPos < 0) { - break; - } - continue; - } - if (IS_FINAL_OP(pInfo) && isClosed && pInfo->pChildren) { - bool ignore = true; - SWinKey winRes = { - .ts = nextWin.skey, - .groupId = tableGroupId, - }; - void* chIds = taosHashGet(pInfo->pPullDataMap, &winRes, sizeof(SWinKey)); - if (isDeletedWindow(&nextWin, tableGroupId, &pInfo->aggSup) && !chIds) { - SPullWindowInfo pull = {.window = nextWin, .groupId = tableGroupId}; - // add pull data request - savePullWindow(&pull, pInfo->pPullWins); - int32_t size = taosArrayGetSize(pInfo->pChildren); - addPullWindow(pInfo->pPullDataMap, &winRes, size); - qDebug("===stream===prepare retrive %" PRId64 ", size:%d", winRes.ts, size); - } else { - int32_t index = -1; - SArray* chArray = NULL; - int32_t chId = 0; - if (chIds) { - chArray = *(void**)chIds; - chId = getChildIndex(pSDataBlock); - index = taosArraySearchIdx(chArray, &chId, compareInt32Val, TD_EQ); - } - if (index == -1 || pSDataBlock->info.type == STREAM_PULL_DATA) { - ignore = false; - } - } - - if (ignore) { - startPos = getNexWindowPos(&pInfo->interval, &pSDataBlock->info, tsCols, startPos, nextWin.ekey, &nextWin); - if (startPos < 0) { - break; - } - continue; - } - } - - int32_t code = setTimeWindowOutputBuf(pResultRowInfo, &nextWin, true, &pResult, tableGroupId, pSup->pCtx, - numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); - if (code != TSDB_CODE_SUCCESS || pResult == NULL) { - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); - } - - if (IS_FINAL_OP(pInfo)) { - forwardRows = 1; - } else { - forwardRows = getNumOfRowsInTimeWindow(&pSDataBlock->info, tsCols, startPos, nextWin.ekey, binarySearchForKey, - NULL, TSDB_ORDER_ASC); - } - if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE && pUpdatedMap) { - saveWinResultRow(pResult, tableGroupId, pUpdatedMap); - setResultBufPageDirty(pInfo->aggSup.pResultBuf, &pResultRowInfo->cur); - } - updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &nextWin, true); - doApplyFunctions(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, - pSDataBlock->info.rows, numOfOutput); - int32_t prevEndPos = (forwardRows - 1) * step + startPos; - ASSERT(pSDataBlock->info.window.skey > 0 && pSDataBlock->info.window.ekey > 0); - startPos = getNextQualifiedWindow(&pInfo->interval, &nextWin, &pSDataBlock->info, tsCols, prevEndPos, pInfo->order); - if (startPos < 0) { - break; - } - } -} - -static void clearStreamIntervalOperator(SStreamFinalIntervalOperatorInfo* pInfo) { +static void clearStreamIntervalOperator(SStreamIntervalOperatorInfo* pInfo) { tSimpleHashClear(pInfo->aggSup.pResultRowHashTable); clearDiskbasedBuf(pInfo->aggSup.pResultBuf); initResultRowInfo(&pInfo->binfo.resultRowInfo); pInfo->aggSup.currentPageId = -1; + streamStateClear(pInfo->pState); } static void clearSpecialDataBlock(SSDataBlock* pBlock) { @@ -3091,12 +3008,12 @@ void processPullOver(SSDataBlock* pBlock, SHashObj* pMap) { } } -static void addRetriveWindow(SArray* wins, SStreamFinalIntervalOperatorInfo* pInfo) { +static void addRetriveWindow(SArray* wins, SStreamIntervalOperatorInfo* pInfo) { int32_t size = taosArrayGetSize(wins); for (int32_t i = 0; i < size; i++) { SWinKey* winKey = taosArrayGet(wins, i); STimeWindow nextWin = getFinalTimeWindow(winKey->ts, &pInfo->interval); - if (isCloseWindow(&nextWin, &pInfo->twAggSup) && !pInfo->ignoreExpiredData) { + if (needDeleteWindowBuf(&nextWin, &pInfo->twAggSup) && !pInfo->ignoreExpiredData) { void* chIds = taosHashGet(pInfo->pPullDataMap, winKey, sizeof(SWinKey)); if (!chIds) { SPullWindowInfo pull = {.window = nextWin, .groupId = winKey->groupId}; @@ -3116,8 +3033,124 @@ static void clearFunctionContext(SExprSupp* pSup) { } } +void doBuildResult(SOperatorInfo* pOperator, SStreamState* pState, SSDataBlock* pBlock, SGroupResInfo* pGroupResInfo) { + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + // set output datablock version + pBlock->info.version = pTaskInfo->version; + + blockDataCleanup(pBlock); + if (!hasRemainResults(pGroupResInfo)) { + return; + } + + // clear the existed group id + pBlock->info.groupId = 0; + buildDataBlockFromGroupRes(pTaskInfo, pState, pBlock, &pOperator->exprSupp, pGroupResInfo); +} + +static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBlock, uint64_t groupId, + SHashObj* pUpdatedMap) { + SStreamIntervalOperatorInfo* pInfo = (SStreamIntervalOperatorInfo*)pOperatorInfo->info; + + SResultRowInfo* pResultRowInfo = &(pInfo->binfo.resultRowInfo); + SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo; + SExprSupp* pSup = &pOperatorInfo->exprSupp; + int32_t numOfOutput = pSup->numOfExprs; + int32_t step = 1; + TSKEY* tsCols = NULL; + SResultRow* pResult = NULL; + int32_t forwardRows = 0; + + ASSERT(pSDataBlock->pDataBlock != NULL); + SColumnInfoData* pColDataInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex); + tsCols = (int64_t*)pColDataInfo->pData; + + int32_t startPos = 0; + TSKEY ts = getStartTsKey(&pSDataBlock->info.window, tsCols); + STimeWindow nextWin = + getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, TSDB_ORDER_ASC); + while (1) { + bool isClosed = isCloseWindow(&nextWin, &pInfo->twAggSup); + if ((pInfo->ignoreExpiredData && isClosed) || !inSlidingWindow(&pInfo->interval, &nextWin, &pSDataBlock->info)) { + startPos = getNexWindowPos(&pInfo->interval, &pSDataBlock->info, tsCols, startPos, nextWin.ekey, &nextWin); + if (startPos < 0) { + break; + } + continue; + } + + if (IS_FINAL_OP(pInfo) && isClosed && pInfo->pChildren) { + bool ignore = true; + SWinKey winRes = { + .ts = nextWin.skey, + .groupId = groupId, + }; + void* chIds = taosHashGet(pInfo->pPullDataMap, &winRes, sizeof(SWinKey)); + if (isDeletedStreamWindow(&nextWin, groupId, pInfo->pState, &pInfo->twAggSup) && !chIds) { + SPullWindowInfo pull = {.window = nextWin, .groupId = groupId}; + // add pull data request + savePullWindow(&pull, pInfo->pPullWins); + int32_t size = taosArrayGetSize(pInfo->pChildren); + addPullWindow(pInfo->pPullDataMap, &winRes, size); + qDebug("===stream===prepare retrive %" PRId64 ", size:%d", winRes.ts, size); + } else { + int32_t index = -1; + SArray* chArray = NULL; + int32_t chId = 0; + if (chIds) { + chArray = *(void**)chIds; + chId = getChildIndex(pSDataBlock); + index = taosArraySearchIdx(chArray, &chId, compareInt32Val, TD_EQ); + } + if (index == -1 || pSDataBlock->info.type == STREAM_PULL_DATA) { + ignore = false; + } + } + + if (ignore) { + startPos = getNexWindowPos(&pInfo->interval, &pSDataBlock->info, tsCols, startPos, nextWin.ekey, &nextWin); + if (startPos < 0) { + break; + } + continue; + } + } + + int32_t code = setOutputBuf(pInfo->pState, &nextWin, &pResult, groupId, pSup->pCtx, numOfOutput, + pSup->rowEntryInfoOffset, &pInfo->aggSup); + if (code != TSDB_CODE_SUCCESS || pResult == NULL) { + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + forwardRows = getNumOfRowsInTimeWindow(&pSDataBlock->info, tsCols, startPos, nextWin.ekey, binarySearchForKey, NULL, + TSDB_ORDER_ASC); + if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE && pUpdatedMap) { + saveWinResultInfo(pResult->win.skey, groupId, pUpdatedMap); + } + updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &nextWin, true); + doApplyFunctions(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, + pSDataBlock->info.rows, numOfOutput); + SWinKey key = { + .ts = nextWin.skey, + .groupId = groupId, + }; + saveOutputBuf(pInfo->pState, &key, pResult, pInfo->aggSup.resultRowSize); + releaseOutputBuf(pInfo->pState, &key, pResult); + if (pInfo->delKey.ts > key.ts) { + pInfo->delKey = key; + } + int32_t prevEndPos = (forwardRows - 1) * step + startPos; + ASSERT(pSDataBlock->info.window.skey > 0 && pSDataBlock->info.window.ekey > 0); + startPos = + getNextQualifiedWindow(&pInfo->interval, &nextWin, &pSDataBlock->info, tsCols, prevEndPos, TSDB_ORDER_ASC); + if (startPos < 0) { + break; + } + } +} + static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { - SStreamFinalIntervalOperatorInfo* pInfo = pOperator->info; + SStreamIntervalOperatorInfo* pInfo = pOperator->info; SOperatorInfo* downstream = pOperator->pDownstream[0]; TSKEY maxTs = INT64_MIN; @@ -3145,24 +3178,26 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { return pInfo->pDelRes; } - doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); - if (pInfo->binfo.pRes->info.rows == 0) { - pOperator->status = OP_EXEC_DONE; - if (!IS_FINAL_OP(pInfo)) { - clearFunctionContext(&pOperator->exprSupp); - // semi interval operator clear disk buffer - clearStreamIntervalOperator(pInfo); - qDebug("===stream===clear semi operator"); - } else { - freeAllPages(pInfo->pRecycledPages, pInfo->aggSup.pResultBuf); - } - return NULL; + doBuildResult(pOperator, pInfo->pState, pInfo->binfo.pRes, &pInfo->groupResInfo); + if (pInfo->binfo.pRes->info.rows != 0) { + printDataBlock(pInfo->binfo.pRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi"); + return pInfo->binfo.pRes; } - printDataBlock(pInfo->binfo.pRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi"); - return pInfo->binfo.pRes; + + doSetOperatorCompleted(pOperator); + if (!IS_FINAL_OP(pInfo)) { + clearFunctionContext(&pOperator->exprSupp); + // semi interval operator clear disk buffer + clearStreamIntervalOperator(pInfo); + qDebug("===stream===clear semi operator"); + } else { + deleteIntervalDiscBuf(pInfo->pState, pInfo->pPullDataMap, pInfo->twAggSup.maxTs - pInfo->twAggSup.deleteMark, + &pInfo->interval, &pInfo->delKey); + } + return NULL; } else { if (!IS_FINAL_OP(pInfo)) { - doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); + doBuildResult(pOperator, pInfo->pState, pInfo->binfo.pRes, &pInfo->groupResInfo); if (pInfo->binfo.pRes->info.rows != 0) { printDataBlock(pInfo->binfo.pRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi"); return pInfo->binfo.pRes; @@ -3202,16 +3237,15 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { pInfo->binfo.pRes->info.type = pBlock->info.type; } else if (pBlock->info.type == STREAM_CLEAR) { SArray* pUpWins = taosArrayInit(8, sizeof(SWinKey)); - doClearWindows(&pInfo->aggSup, pSup, &pInfo->interval, pOperator->exprSupp.numOfExprs, pBlock, pUpWins); + doDeleteWindows(pOperator, &pInfo->interval, pOperator->exprSupp.numOfExprs, pBlock, pUpWins, NULL); if (IS_FINAL_OP(pInfo)) { - int32_t childIndex = getChildIndex(pBlock); - SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, childIndex); - SStreamFinalIntervalOperatorInfo* pChildInfo = pChildOp->info; - SExprSupp* pChildSup = &pChildOp->exprSupp; + int32_t childIndex = getChildIndex(pBlock); + SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, childIndex); + SStreamIntervalOperatorInfo* pChildInfo = pChildOp->info; + SExprSupp* pChildSup = &pChildOp->exprSupp; - doClearWindows(&pChildInfo->aggSup, pChildSup, &pChildInfo->interval, pChildSup->numOfExprs, pBlock, NULL); - rebuildIntervalWindow(pInfo, pSup, pUpWins, pInfo->binfo.pRes->info.groupId, pOperator->exprSupp.numOfExprs, - pOperator->pTaskInfo, NULL); + doDeleteWindows(pChildOp, &pChildInfo->interval, pChildOp->exprSupp.numOfExprs, pBlock, NULL, NULL); + rebuildIntervalWindow(pOperator, pSup, pUpWins, pUpdatedMap); taosArrayDestroy(pUpWins); continue; } @@ -3222,15 +3256,14 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { break; } else if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT) { SArray* delWins = taosArrayInit(8, sizeof(SWinKey)); - doDeleteSpecifyIntervalWindow(&pInfo->aggSup, &pInfo->twAggSup, pBlock, delWins, &pInfo->interval, pUpdatedMap); + doDeleteWindows(pOperator, &pInfo->interval, pOperator->exprSupp.numOfExprs, pBlock, delWins, pUpdatedMap); if (IS_FINAL_OP(pInfo)) { - int32_t childIndex = getChildIndex(pBlock); - SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, childIndex); - SStreamFinalIntervalOperatorInfo* pChildInfo = pChildOp->info; - SExprSupp* pChildSup = &pChildOp->exprSupp; - doDeleteSpecifyIntervalWindow(&pChildInfo->aggSup, &pInfo->twAggSup, pBlock, NULL, &pChildInfo->interval, NULL); - rebuildIntervalWindow(pInfo, pSup, delWins, pInfo->binfo.pRes->info.groupId, pOperator->exprSupp.numOfExprs, - pOperator->pTaskInfo, pUpdatedMap); + int32_t childIndex = getChildIndex(pBlock); + SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, childIndex); + SStreamIntervalOperatorInfo* pChildInfo = pChildOp->info; + SExprSupp* pChildSup = &pChildOp->exprSupp; + doDeleteWindows(pChildOp, &pChildInfo->interval, pChildOp->exprSupp.numOfExprs, pBlock, NULL, NULL); + rebuildIntervalWindow(pOperator, pSup, delWins, pUpdatedMap); addRetriveWindow(delWins, pInfo); taosArrayAddAll(pInfo->pDelWins, delWins); taosArrayDestroy(delWins); @@ -3244,10 +3277,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { getAllIntervalWindow(pInfo->aggSup.pResultRowHashTable, pUpdatedMap); continue; } else if (pBlock->info.type == STREAM_RETRIEVE && !IS_FINAL_OP(pInfo)) { - SArray* pUpWins = taosArrayInit(8, sizeof(SWinKey)); - doClearWindows(&pInfo->aggSup, pSup, &pInfo->interval, pOperator->exprSupp.numOfExprs, pBlock, pUpWins); - removeResults(pUpWins, pUpdatedMap); - taosArrayDestroy(pUpWins); + doDeleteWindows(pOperator, &pInfo->interval, pOperator->exprSupp.numOfExprs, pBlock, NULL, pUpdatedMap); if (taosArrayGetSize(pUpdated) > 0) { break; } @@ -3261,8 +3291,8 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { SExprSupp* pExprSup = &pInfo->scalarSupp; projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL); } - setInputDataBlock(pOperator, pSup->pCtx, pBlock, pInfo->order, MAIN_SCAN, true); - doHashIntervalAgg(pOperator, pBlock, pBlock->info.groupId, pUpdatedMap); + setInputDataBlock(pOperator, pSup->pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true); + doStreamIntervalAggImpl(pOperator, pBlock, pBlock->info.groupId, pUpdatedMap); if (IS_FINAL_OP(pInfo)) { int32_t chIndex = getChildIndex(pBlock); int32_t size = taosArrayGetSize(pInfo->pChildren); @@ -3272,15 +3302,15 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { if (!pChildOp) { T_LONG_JMP(pOperator->pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); } - SStreamFinalIntervalOperatorInfo* pTmpInfo = pChildOp->info; + SStreamIntervalOperatorInfo* pTmpInfo = pChildOp->info; pTmpInfo->twAggSup.calTrigger = STREAM_TRIGGER_AT_ONCE; taosArrayPush(pInfo->pChildren, &pChildOp); qDebug("===stream===add child, id:%d", chIndex); } - SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, chIndex); - SStreamFinalIntervalOperatorInfo* pChInfo = pChildOp->info; - setInputDataBlock(pChildOp, pChildOp->exprSupp.pCtx, pBlock, pChInfo->order, MAIN_SCAN, true); - doHashIntervalAgg(pChildOp, pBlock, pBlock->info.groupId, NULL); + SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, chIndex); + SStreamIntervalOperatorInfo* pChInfo = pChildOp->info; + setInputDataBlock(pChildOp, pChildOp->exprSupp.pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true); + doStreamIntervalAggImpl(pChildOp, pBlock, pBlock->info.groupId, NULL); } maxTs = TMAX(maxTs, pBlock->info.window.ekey); maxTs = TMAX(maxTs, pBlock->info.watermark); @@ -3290,12 +3320,11 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, maxTs); pInfo->twAggSup.minTs = TMIN(pInfo->twAggSup.minTs, minTs); if (IS_FINAL_OP(pInfo)) { - closeIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, &pInfo->interval, pInfo->pPullDataMap, - pUpdatedMap, pInfo->pRecycledPages, pInfo->aggSup.pResultBuf); - closeChildIntervalWindow(pInfo->pChildren, pInfo->twAggSup.maxTs); - } else { - pInfo->binfo.pRes->info.watermark = pInfo->twAggSup.maxTs; + closeStreamIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, &pInfo->interval, + pInfo->pPullDataMap, pUpdatedMap, pOperator); + closeChildIntervalWindow(pOperator, pInfo->pChildren, pInfo->twAggSup.maxTs); } + pInfo->binfo.pRes->info.watermark = pInfo->twAggSup.maxTs; void* pIte = NULL; while ((pIte = taosHashIterate(pUpdatedMap, pIte)) != NULL) { @@ -3304,7 +3333,6 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { taosHashCleanup(pUpdatedMap); taosArraySort(pUpdated, resultrowComparAsc); - finalizeUpdatedResult(pOperator->exprSupp.numOfExprs, pInfo->aggSup.pResultBuf, pUpdated, pSup->rowEntryInfoOffset); initMultiResInfoFromArrayList(&pInfo->groupResInfo, pUpdated); blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity); @@ -3316,8 +3344,14 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { return pInfo->pPullDataRes; } - // we should send result first. - doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); + doBuildDeleteResult(pInfo->pDelWins, &pInfo->delIndex, pInfo->pDelRes); + if (pInfo->pDelRes->info.rows != 0) { + // process the rest of the data + printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi"); + return pInfo->pDelRes; + } + + doBuildResult(pOperator, pInfo->pState, pInfo->binfo.pRes, &pInfo->groupResInfo); if (pInfo->binfo.pRes->info.rows != 0) { printDataBlock(pInfo->binfo.pRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi"); return pInfo->binfo.pRes; @@ -3330,27 +3364,19 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { // process the rest of the data return pInfo->pUpdateRes; } - - doBuildDeleteResult(pInfo->pDelWins, &pInfo->delIndex, pInfo->pDelRes); - if (pInfo->pDelRes->info.rows != 0) { - // process the rest of the data - printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi"); - return pInfo->pDelRes; - } return NULL; } SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, int32_t numOfChild) { - SIntervalPhysiNode* pIntervalPhyNode = (SIntervalPhysiNode*)pPhyNode; - SStreamFinalIntervalOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamFinalIntervalOperatorInfo)); - SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + SIntervalPhysiNode* pIntervalPhyNode = (SIntervalPhysiNode*)pPhyNode; + SStreamIntervalOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamIntervalOperatorInfo)); + SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { goto _error; } pOperator->pTaskInfo = pTaskInfo; - pInfo->order = TSDB_ORDER_ASC; pInfo->interval = (SInterval){.interval = pIntervalPhyNode->interval, .sliding = pIntervalPhyNode->sliding, .intervalUnit = pIntervalPhyNode->intervalUnit, @@ -3362,6 +3388,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, .calTrigger = pIntervalPhyNode->window.triggerType, .maxTs = INT64_MIN, .minTs = INT64_MAX, + .deleteMark = INT64_MAX, }; ASSERT(pInfo->twAggSup.calTrigger != STREAM_TRIGGER_MAX_DELAY); pInfo->primaryTsIndex = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId; @@ -3391,6 +3418,10 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, ASSERT(numOfCols > 0); initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window); + pInfo->pState = taosMemoryCalloc(1, sizeof(SStreamState)); + *(pInfo->pState) = *(pTaskInfo->streamInfo.pState); + streamStateSetNumber(pInfo->pState, -1); + initResultRowInfo(&pInfo->binfo.resultRowInfo); pInfo->pChildren = NULL; if (numOfChild > 0) { @@ -3398,9 +3429,10 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, for (int32_t i = 0; i < numOfChild; i++) { SOperatorInfo* pChildOp = createStreamFinalIntervalOperatorInfo(NULL, pPhyNode, pTaskInfo, 0); if (pChildOp) { - SStreamFinalIntervalOperatorInfo* pChInfo = pChildOp->info; + SStreamIntervalOperatorInfo* pChInfo = pChildOp->info; pChInfo->twAggSup.calTrigger = STREAM_TRIGGER_AT_ONCE; taosArrayPush(pInfo->pChildren, &pChildOp); + streamStateSetNumber(pChInfo->pState, i); continue; } goto _error; @@ -3434,7 +3466,8 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, pInfo->pDelRes = createSpecialDataBlock(STREAM_DELETE_RESULT); pInfo->delIndex = 0; pInfo->pDelWins = taosArrayInit(4, sizeof(SWinKey)); - pInfo->pRecycledPages = taosArrayInit(4, sizeof(int32_t)); + pInfo->delKey.ts = INT64_MAX; + pInfo->delKey.groupId = 0; pOperator->operatorType = pPhyNode->type; pOperator->blocking = true; @@ -5576,160 +5609,6 @@ _error: return NULL; } -static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResultRowInfo, SSDataBlock* pBlock, - int32_t scanFlag, SHashObj* pUpdatedMap) { - SStreamIntervalOperatorInfo* pInfo = (SStreamIntervalOperatorInfo*)pOperatorInfo->info; - - SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo; - SExprSupp* pSup = &pOperatorInfo->exprSupp; - - int32_t startPos = 0; - int32_t numOfOutput = pSup->numOfExprs; - SColumnInfoData* pColDataInfo = taosArrayGet(pBlock->pDataBlock, pInfo->primaryTsIndex); - TSKEY* tsCols = (TSKEY*)pColDataInfo->pData; - uint64_t tableGroupId = pBlock->info.groupId; - bool ascScan = true; - TSKEY ts = getStartTsKey(&pBlock->info.window, tsCols); - SResultRow* pResult = NULL; - - STimeWindow win = getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, TSDB_ORDER_ASC); - int32_t ret = TSDB_CODE_SUCCESS; - if ((!pInfo->ignoreExpiredData || !isCloseWindow(&win, &pInfo->twAggSup)) && - inSlidingWindow(&pInfo->interval, &win, &pBlock->info)) { - ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pSup->pCtx, - numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); - if (ret != TSDB_CODE_SUCCESS || pResult == NULL) { - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); - } - if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) { - saveWinResultRow(pResult, tableGroupId, pUpdatedMap); - setResultBufPageDirty(pInfo->aggSup.pResultBuf, &pResultRowInfo->cur); - } - } - - TSKEY ekey = ascScan ? win.ekey : win.skey; - int32_t forwardRows = - getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, TSDB_ORDER_ASC); - ASSERT(forwardRows > 0); - - if ((!pInfo->ignoreExpiredData || !isCloseWindow(&win, &pInfo->twAggSup)) && - inSlidingWindow(&pInfo->interval, &win, &pBlock->info)) { - updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &win, true); - doApplyFunctions(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, pBlock->info.rows, - numOfOutput); - } - - STimeWindow nextWin = win; - while (1) { - int32_t prevEndPos = forwardRows - 1 + startPos; - startPos = getNextQualifiedWindow(&pInfo->interval, &nextWin, &pBlock->info, tsCols, prevEndPos, TSDB_ORDER_ASC); - if (startPos < 0) { - break; - } - if (pInfo->ignoreExpiredData && isCloseWindow(&nextWin, &pInfo->twAggSup)) { - ekey = ascScan ? nextWin.ekey : nextWin.skey; - forwardRows = - getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, TSDB_ORDER_ASC); - continue; - } - - // null data, failed to allocate more memory buffer - int32_t code = setTimeWindowOutputBuf(pResultRowInfo, &nextWin, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, - pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); - if (code != TSDB_CODE_SUCCESS || pResult == NULL) { - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); - } - - if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) { - saveWinResultRow(pResult, tableGroupId, pUpdatedMap); - setResultBufPageDirty(pInfo->aggSup.pResultBuf, &pResultRowInfo->cur); - } - - ekey = ascScan ? nextWin.ekey : nextWin.skey; - forwardRows = - getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, TSDB_ORDER_ASC); - updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &nextWin, true); - doApplyFunctions(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, pBlock->info.rows, - numOfOutput); - } -} - -static void doStreamIntervalAggImpl2(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBlock, uint64_t tableGroupId, - SHashObj* pUpdatedMap) { - SStreamIntervalOperatorInfo* pInfo = (SStreamIntervalOperatorInfo*)pOperatorInfo->info; - - SResultRowInfo* pResultRowInfo = &(pInfo->binfo.resultRowInfo); - SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo; - SExprSupp* pSup = &pOperatorInfo->exprSupp; - int32_t numOfOutput = pSup->numOfExprs; - int32_t step = 1; - TSKEY* tsCols = NULL; - SResultRow* pResult = NULL; - int32_t forwardRows = 0; - - ASSERT(pSDataBlock->pDataBlock != NULL); - SColumnInfoData* pColDataInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex); - tsCols = (int64_t*)pColDataInfo->pData; - - int32_t startPos = 0; - TSKEY ts = getStartTsKey(&pSDataBlock->info.window, tsCols); - STimeWindow nextWin = - getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, TSDB_ORDER_ASC); - while (1) { - bool isClosed = isCloseWindow(&nextWin, &pInfo->twAggSup); - if ((pInfo->ignoreExpiredData && isClosed) || !inSlidingWindow(&pInfo->interval, &nextWin, &pSDataBlock->info)) { - startPos = getNexWindowPos(&pInfo->interval, &pSDataBlock->info, tsCols, startPos, nextWin.ekey, &nextWin); - if (startPos < 0) { - break; - } - continue; - } - - int32_t code = setOutputBuf(&nextWin, &pResult, tableGroupId, pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, - &pInfo->aggSup, pTaskInfo); - if (code != TSDB_CODE_SUCCESS || pResult == NULL) { - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); - } - - forwardRows = getNumOfRowsInTimeWindow(&pSDataBlock->info, tsCols, startPos, nextWin.ekey, binarySearchForKey, NULL, - TSDB_ORDER_ASC); - if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE && pUpdatedMap) { - saveWinResultInfo(pResult->win.skey, tableGroupId, pUpdatedMap); - } - updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &nextWin, true); - doApplyFunctions(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, - pSDataBlock->info.rows, numOfOutput); - SWinKey key = { - .ts = nextWin.skey, - .groupId = tableGroupId, - }; - saveOutputBuf(pTaskInfo, &key, pResult, pInfo->aggSup.resultRowSize); - releaseOutputBuf(pTaskInfo, &key, pResult); - int32_t prevEndPos = (forwardRows - 1) * step + startPos; - ASSERT(pSDataBlock->info.window.skey > 0 && pSDataBlock->info.window.ekey > 0); - startPos = - getNextQualifiedWindow(&pInfo->interval, &nextWin, &pSDataBlock->info, tsCols, prevEndPos, TSDB_ORDER_ASC); - if (startPos < 0) { - break; - } - } -} - -void doBuildResult(SOperatorInfo* pOperator, SSDataBlock* pBlock, SGroupResInfo* pGroupResInfo) { - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - // set output datablock version - pBlock->info.version = pTaskInfo->version; - - blockDataCleanup(pBlock); - if (!hasRemainResults(pGroupResInfo)) { - return; - } - - // clear the existed group id - pBlock->info.groupId = 0; - buildDataBlockFromGroupRes(pTaskInfo, pBlock, &pOperator->exprSupp, pGroupResInfo); -} - static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { SStreamIntervalOperatorInfo* pInfo = pOperator->info; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; @@ -5744,19 +5623,19 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { if (pOperator->status == OP_RES_TO_RETURN) { doBuildDeleteResult(pInfo->pDelWins, &pInfo->delIndex, pInfo->pDelRes); if (pInfo->pDelRes->info.rows > 0) { - printDataBlock(pInfo->pDelRes, "single interval"); + printDataBlock(pInfo->pDelRes, "single interval delete"); return pInfo->pDelRes; } - doBuildResult(pOperator, pInfo->binfo.pRes, &pInfo->groupResInfo); - // doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); - if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainResults(&pInfo->groupResInfo)) { - pOperator->status = OP_EXEC_DONE; - qDebug("===stream===single interval is done"); - freeAllPages(pInfo->pRecycledPages, pInfo->aggSup.pResultBuf); + doBuildResult(pOperator, pInfo->pState, pInfo->binfo.pRes, &pInfo->groupResInfo); + if (pInfo->binfo.pRes->info.rows > 0) { + printDataBlock(pInfo->binfo.pRes, "single interval"); + return pInfo->binfo.pRes; } - printDataBlock(pInfo->binfo.pRes, "single interval"); - return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes; + deleteIntervalDiscBuf(pInfo->pState, NULL, pInfo->twAggSup.maxTs - pInfo->twAggSup.deleteMark, &pInfo->interval, + &pInfo->delKey); + doSetOperatorCompleted(pOperator); + return NULL; } SOperatorInfo* downstream = pOperator->pDownstream[0]; @@ -5777,8 +5656,6 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { qDebug("%s clear existed time window results for updates checked", GET_TASKID(pTaskInfo)); continue; } else if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT) { - // doDeleteSpecifyIntervalWindow(&pInfo->aggSup, &pInfo->twAggSup, pBlock, pInfo->pDelWins, &pInfo->interval, - // pUpdatedMap); doDeleteWindows(pOperator, &pInfo->interval, pOperator->exprSupp.numOfExprs, pBlock, pInfo->pDelWins, pUpdatedMap); continue; @@ -5807,9 +5684,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { maxTs = TMAX(maxTs, pBlock->info.window.ekey); minTs = TMIN(minTs, pBlock->info.window.skey); - // doStreamIntervalAggImpl(pOperator, &pInfo->binfo.resultRowInfo, pBlock, MAIN_SCAN, pUpdatedMap); - // new disc buf - doStreamIntervalAggImpl2(pOperator, pBlock, pBlock->info.groupId, pUpdatedMap); + doStreamIntervalAggImpl(pOperator, pBlock, pBlock->info.groupId, pUpdatedMap); } pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, maxTs); pInfo->twAggSup.minTs = TMIN(pInfo->twAggSup.minTs, minTs); @@ -5823,38 +5698,24 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { } taosArraySort(pUpdated, resultrowComparAsc); - // new disc buf - // finalizeUpdatedResult(pOperator->exprSupp.numOfExprs, pInfo->aggSup.pResultBuf, pUpdated, - // pSup->rowEntryInfoOffset); initMultiResInfoFromArrayList(&pInfo->groupResInfo, pUpdated); blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity); removeDeleteResults(pUpdatedMap, pInfo->pDelWins); taosHashCleanup(pUpdatedMap); + doBuildDeleteResult(pInfo->pDelWins, &pInfo->delIndex, pInfo->pDelRes); if (pInfo->pDelRes->info.rows > 0) { - printDataBlock(pInfo->pDelRes, "single interval"); + printDataBlock(pInfo->pDelRes, "single interval delete"); return pInfo->pDelRes; } - // doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); - // new disc buf - doBuildResult(pOperator, pInfo->binfo.pRes, &pInfo->groupResInfo); - printDataBlock(pInfo->binfo.pRes, "single interval"); - return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes; -} + doBuildResult(pOperator, pInfo->pState, pInfo->binfo.pRes, &pInfo->groupResInfo); + if (pInfo->binfo.pRes->info.rows > 0) { + printDataBlock(pInfo->binfo.pRes, "single interval"); + return pInfo->binfo.pRes; + } -void destroyStreamIntervalOperatorInfo(void* param) { - SStreamIntervalOperatorInfo* pInfo = (SStreamIntervalOperatorInfo*)param; - cleanupBasicInfo(&pInfo->binfo); - cleanupAggSup(&pInfo->aggSup); - pInfo->pRecycledPages = taosArrayDestroy(pInfo->pRecycledPages); - - pInfo->pDelWins = taosArrayDestroy(pInfo->pDelWins); - pInfo->pDelRes = blockDataDestroy(pInfo->pDelRes); - - cleanupGroupResInfo(&pInfo->groupResInfo); - colDataDestroy(&pInfo->twAggSup.timeWindowData); - taosMemoryFreeClear(param); + return NULL; } SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, @@ -5915,20 +5776,35 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window); pInfo->invertible = allInvertible(pSup->pCtx, numOfCols); - pInfo->invertible = false; // Todo(liuyao): Dependent TSDB API - pInfo->pRecycledPages = taosArrayInit(4, sizeof(int32_t)); + pInfo->invertible = false; pInfo->pDelWins = taosArrayInit(4, sizeof(SWinKey)); pInfo->delIndex = 0; pInfo->pDelRes = createSpecialDataBlock(STREAM_DELETE_RESULT); initResultRowInfo(&pInfo->binfo.resultRowInfo); + pInfo->pState = taosMemoryCalloc(1, sizeof(SStreamState)); + *(pInfo->pState) = *(pTaskInfo->streamInfo.pState); + streamStateSetNumber(pInfo->pState, -1); + + pInfo->pUpdateRes = NULL; + pInfo->returnUpdate = false; + pInfo->pPhyNode = NULL; // create new child + pInfo->pPullDataMap = NULL; + pInfo->pPullWins = NULL; // SPullWindowInfo + pInfo->pullIndex = 0; + pInfo->pPullDataRes = NULL; + pInfo->isFinal = false; + pInfo->pChildren = NULL; + pInfo->delKey.ts = INT64_MAX; + pInfo->delKey.groupId = 0; + pOperator->name = "StreamIntervalOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL; pOperator->blocking = true; pOperator->status = OP_NOT_OPENED; pOperator->info = pInfo; pOperator->fpSet = - createOperatorFpSet(operatorDummyOpenFn, doStreamIntervalAgg, NULL, NULL, destroyStreamIntervalOperatorInfo, + createOperatorFpSet(operatorDummyOpenFn, doStreamIntervalAgg, NULL, NULL, destroyStreamFinalIntervalOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL); initIntervalDownStream(downstream, pPhyNode->type, &pInfo->aggSup, &pInfo->interval, &pInfo->twAggSup); @@ -5940,7 +5816,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys return pOperator; _error: - destroyStreamIntervalOperatorInfo(pInfo); + destroyStreamFinalIntervalOperatorInfo(pInfo); taosMemoryFreeClear(pOperator); pTaskInfo->code = code; return NULL; diff --git a/source/libs/function/inc/functionMgtInt.h b/source/libs/function/inc/functionMgtInt.h index 37208c4723..9bff812c3a 100644 --- a/source/libs/function/inc/functionMgtInt.h +++ b/source/libs/function/inc/functionMgtInt.h @@ -50,6 +50,7 @@ extern "C" { #define FUNC_MGT_KEEP_ORDER_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(21) #define FUNC_MGT_CUMULATIVE_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(22) #define FUNC_MGT_FORBID_STABLE_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(23) +#define FUNC_MGT_INTERP_PC_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(24) #define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0) diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 0677bd7d63..e9415dc879 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -2020,6 +2020,11 @@ static int32_t translateUserFunc(SFunctionNode* pFunc, char* pErrBuf, int32_t le return TSDB_CODE_SUCCESS; } +static int32_t translateTagsPseudoColumn(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + // The _tags pseudo-column will be expanded to the actual tags on the client side + return TSDB_CODE_SUCCESS; +} + // clang-format off const SBuiltinFuncDefinition funcMgtBuiltins[] = { { @@ -3146,6 +3151,26 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .classification = FUNC_MGT_SYSTEM_INFO_FUNC | FUNC_MGT_SCALAR_FUNC, .translateFunc = translateUserFunc, }, + { + .name = "_irowts", + .type = FUNCTION_TYPE_IROWTS, + .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_INTERP_PC_FUNC, + .translateFunc = translateTimePseudoColumn, + .getEnvFunc = getTimePseudoFuncEnv, + .initFunc = NULL, + .sprocessFunc = NULL, + .finalizeFunc = NULL + }, + { + .name = "_tags", + .type = FUNCTION_TYPE_TAGS, + .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_MULTI_RES_FUNC, + .translateFunc = translateTagsPseudoColumn, + .getEnvFunc = NULL, + .initFunc = NULL, + .sprocessFunc = NULL, + .finalizeFunc = NULL + }, }; // clang-format on diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index d092c259da..42512d3a11 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -2977,10 +2977,9 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { return TSDB_CODE_SUCCESS; } -static void firstLastTransferInfo(SqlFunctionCtx* pCtx, SFirstLastRes* pInput, SFirstLastRes* pOutput, bool isFirst) { +static void firstLastTransferInfo(SqlFunctionCtx* pCtx, SFirstLastRes* pInput, SFirstLastRes* pOutput, bool isFirst, int32_t rowIndex) { SInputColumnInfoData* pColInfo = &pCtx->input; - int32_t start = pColInfo->startRowIndex; if (pOutput->hasResult) { if (isFirst) { if (pInput->ts > pOutput->ts) { @@ -2998,7 +2997,7 @@ static void firstLastTransferInfo(SqlFunctionCtx* pCtx, SFirstLastRes* pInput, S pOutput->bytes = pInput->bytes; memcpy(pOutput->buf, pInput->buf, pOutput->bytes); - firstlastSaveTupleData(pCtx->pSrcBlock, start, pCtx, pOutput); + firstlastSaveTupleData(pCtx->pSrcBlock, rowIndex, pCtx, pOutput); pOutput->hasResult = true; } @@ -3016,7 +3015,7 @@ static int32_t firstLastFunctionMergeImpl(SqlFunctionCtx* pCtx, bool isFirstQuer for (int32_t i = start; i < start + pInput->numOfRows; ++i) { char* data = colDataGetData(pCol, i); SFirstLastRes* pInputInfo = (SFirstLastRes*)varDataVal(data); - firstLastTransferInfo(pCtx, pInputInfo, pInfo, isFirstQuery); + firstLastTransferInfo(pCtx, pInputInfo, pInfo, isFirstQuery, i); if (!numOfElems) { numOfElems = pInputInfo->hasResult ? 1 : 0; } @@ -6158,7 +6157,10 @@ int32_t groupKeyFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SGroupKeyInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); if (pInfo->hasResult) { - colDataAppend(pCol, pBlock->info.rows, pInfo->data, pInfo->isNull ? true : false); + int32_t currentRow = pBlock->info.rows; + for (; currentRow < pBlock->info.rows + pResInfo->numOfRes; ++currentRow) { + colDataAppend(pCol, currentRow, pInfo->data, pInfo->isNull ? true : false); + } } else { pResInfo->numOfRes = 0; } diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index bc10ce71ae..ca8ddbc60a 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -224,6 +224,8 @@ bool fmIsInterpFunc(int32_t funcId) { return FUNCTION_TYPE_INTERP == funcMgtBuiltins[funcId].type; } +bool fmIsInterpPseudoColumnFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_INTERP_PC_FUNC); } + bool fmIsLastRowFunc(int32_t funcId) { if (funcId < 0 || funcId >= funcMgtBuiltinsNum) { return false; diff --git a/source/libs/function/src/tudf.c b/source/libs/function/src/tudf.c index 62427e0488..060a92f864 100644 --- a/source/libs/function/src/tudf.c +++ b/source/libs/function/src/tudf.c @@ -1656,6 +1656,8 @@ int32_t doSetupUdf(char udfName[], UdfcFuncHandle *funcHandle) { int32_t errCode = udfcRunUdfUvTask(task, UV_TASK_CONNECT); if (errCode != 0) { fnError("failed to connect to pipe. udfName: %s, pipe: %s", udfName, (&gUdfdProxy)->udfdPipeName); + taosMemoryFree(task->session); + taosMemoryFree(task); return TSDB_CODE_UDF_PIPE_CONNECT_ERR; } diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index 636f006d6e..8ff0dc15a5 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -960,7 +960,7 @@ int32_t udfdInitResidentFuncs() { char* token; while ((token = strtok_r(pSave, ",", &pSave)) != NULL) { char func[TSDB_FUNC_NAME_LEN] = {0}; - strncpy(func, token, strlen(token)); + strncpy(func, token, sizeof(func)); taosArrayPush(global.residentFuncs, func); } diff --git a/source/libs/index/src/index.c b/source/libs/index/src/index.c index f507e1b3be..cb671cfff9 100644 --- a/source/libs/index/src/index.c +++ b/source/libs/index/src/index.c @@ -54,11 +54,17 @@ void* indexQhandle = NULL; int32_t indexRefMgt; +int32_t indexThreads = 5; + static void indexDestroy(void* sIdx); -void indexInit() { +void indexInit(int32_t threadNum) { + indexThreads = threadNum; + if (indexThreads <= 1) indexThreads = INDEX_NUM_OF_THREADS; +} +void indexEnvInit() { // refactor later - indexQhandle = taosInitScheduler(INDEX_QUEUE_SIZE, INDEX_NUM_OF_THREADS, "index", NULL); + indexQhandle = taosInitScheduler(INDEX_QUEUE_SIZE, indexThreads, "index", NULL); indexRefMgt = taosOpenRef(1000, indexDestroy); } void indexCleanup() { @@ -99,7 +105,7 @@ static void indexWait(void* idx) { int indexOpen(SIndexOpts* opts, const char* path, SIndex** index) { int ret = TSDB_CODE_SUCCESS; - taosThreadOnce(&isInit, indexInit); + taosThreadOnce(&isInit, indexEnvInit); SIndex* idx = taosMemoryCalloc(1, sizeof(SIndex)); if (idx == NULL) { return TSDB_CODE_OUT_OF_MEMORY; diff --git a/source/libs/index/src/indexCache.c b/source/libs/index/src/indexCache.c index 7e867db755..72f693f7e5 100644 --- a/source/libs/index/src/indexCache.c +++ b/source/libs/index/src/indexCache.c @@ -22,7 +22,7 @@ #define MAX_INDEX_KEY_LEN 256 // test only, change later #define MEM_TERM_LIMIT 10 * 10000 -#define MEM_THRESHOLD 512 * 1024 +#define MEM_THRESHOLD 8 * 512 * 1024 // 8M #define MEM_SIGNAL_QUIT MEM_THRESHOLD * 20 #define MEM_ESTIMATE_RADIO 1.5 @@ -302,6 +302,7 @@ static int32_t cacheSearchCompareFunc_JSON(void* cache, SIndexTerm* term, SIdxTR char* p = taosMemoryCalloc(1, strlen(c->colVal) + 1); memcpy(p, c->colVal, strlen(c->colVal)); cond = cmpFn(p + skip, term->colVal, dType); + taosMemoryFree(p); } } if (cond == MATCH) { diff --git a/source/libs/index/src/indexFstFile.c b/source/libs/index/src/indexFstFile.c index 2a33ddd477..7021fdfae3 100644 --- a/source/libs/index/src/indexFstFile.c +++ b/source/libs/index/src/indexFstFile.c @@ -69,6 +69,8 @@ static int idxFileCtxDoReadFrom(IFileCtx* ctx, uint8_t* buf, int len, int32_t of int32_t blkOffset = offset % kBlockSize; int32_t blkLeft = kBlockSize - blkOffset; + if (offset >= ctx->file.size) return 0; + do { char key[128] = {0}; idxGenLRUKey(key, ctx->file.buf, blkId); @@ -80,24 +82,34 @@ static int idxFileCtxDoReadFrom(IFileCtx* ctx, uint8_t* buf, int len, int32_t of memcpy(buf + total, blk->buf + blkOffset, nread); taosLRUCacheRelease(ctx->lru, h, false); } else { - int32_t cacheMemSize = sizeof(SDataBlock) + kBlockSize; + int32_t left = ctx->file.size - offset; + if (left < kBlockSize) { + nread = TMIN(left, len); + int32_t bytes = taosPReadFile(ctx->file.pFile, buf + total, nread, offset); + assert(bytes == nread); - SDataBlock* blk = taosMemoryCalloc(1, cacheMemSize); - blk->blockId = blkId; - blk->nread = taosPReadFile(ctx->file.pFile, blk->buf, kBlockSize, blkId * kBlockSize); - assert(blk->nread <= kBlockSize); + total += bytes; + return total; + } else { + int32_t cacheMemSize = sizeof(SDataBlock) + kBlockSize; - if (blk->nread < kBlockSize && blk->nread < len) { - break; - } + SDataBlock* blk = taosMemoryCalloc(1, cacheMemSize); + blk->blockId = blkId; + blk->nread = taosPReadFile(ctx->file.pFile, blk->buf, kBlockSize, blkId * kBlockSize); + assert(blk->nread <= kBlockSize); - nread = TMIN(blkLeft, len); - memcpy(buf + total, blk->buf + blkOffset, nread); + if (blk->nread < kBlockSize && blk->nread < len) { + break; + } - LRUStatus s = taosLRUCacheInsert(ctx->lru, key, strlen(key), blk, cacheMemSize, deleteDataBlockFromLRU, NULL, - TAOS_LRU_PRIORITY_LOW); - if (s != TAOS_LRU_STATUS_OK) { - return -1; + nread = TMIN(blkLeft, len); + memcpy(buf + total, blk->buf + blkOffset, nread); + + LRUStatus s = taosLRUCacheInsert(ctx->lru, key, strlen(key), blk, cacheMemSize, deleteDataBlockFromLRU, NULL, + TAOS_LRU_PRIORITY_LOW); + if (s != TAOS_LRU_STATUS_OK) { + return -1; + } } } total += nread; @@ -146,9 +158,7 @@ IFileCtx* idxFileCtxCreate(WriterType type, const char* path, bool readOnly, int } else { ctx->file.pFile = taosOpenFile(path, TD_FILE_READ); - int64_t size = 0; taosFStatFile(ctx->file.pFile, &ctx->file.size, NULL); - ctx->file.size = (int)size; #ifdef USE_MMAP ctx->file.ptr = (char*)tfMmapReadOnly(ctx->file.pFile, ctx->file.size); #endif diff --git a/source/libs/index/src/indexTfile.c b/source/libs/index/src/indexTfile.c index 1fc631e9f3..f3009c051b 100644 --- a/source/libs/index/src/indexTfile.c +++ b/source/libs/index/src/indexTfile.c @@ -555,6 +555,7 @@ int tfileWriterPut(TFileWriter* tw, void* data, bool order) { taosArraySort(v->tableId, idxUidCompare); taosArrayRemoveDuplicate(v->tableId, idxUidCompare, NULL); int32_t tbsz = taosArrayGetSize(v->tableId); + if (tbsz == 0) continue; fstOffset += TF_TABLE_TATOAL_SIZE(tbsz); } tfileWriteFstOffset(tw, fstOffset); @@ -566,6 +567,7 @@ int tfileWriterPut(TFileWriter* tw, void* data, bool order) { TFileValue* v = taosArrayGetP((SArray*)data, i); int32_t tbsz = taosArrayGetSize(v->tableId); + if (tbsz == 0) continue; // check buf has enough space or not int32_t ttsz = TF_TABLE_TATOAL_SIZE(tbsz); @@ -592,6 +594,10 @@ int tfileWriterPut(TFileWriter* tw, void* data, bool order) { for (size_t i = 0; i < sz; i++) { // TODO, fst batch write later TFileValue* v = taosArrayGetP((SArray*)data, i); + + int32_t tbsz = taosArrayGetSize(v->tableId); + if (tbsz == 0) continue; + if (tfileWriteData(tw, v) != 0) { indexError("failed to write data: %s, offset: %d len: %d", v->colVal, v->offset, (int)taosArrayGetSize(v->tableId)); diff --git a/source/libs/index/test/jsonUT.cc b/source/libs/index/test/jsonUT.cc index 1911514d97..8ae3fd4135 100644 --- a/source/libs/index/test/jsonUT.cc +++ b/source/libs/index/test/jsonUT.cc @@ -172,9 +172,9 @@ TEST_F(JsonEnv, testWriteMillonData) { { std::string colName("voltagefdadfa"); std::string colVal("abxxxxxxxxxxxx"); - for (int i = 0; i < 10; i++) { + for (int i = 0; i < 10000; i++) { colVal[i % colVal.size()] = '0' + i % 128; - for (size_t i = 0; i < 100; i++) { + for (size_t i = 0; i < 10; i++) { SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), colVal.size()); diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index c145952778..7cad5df3a1 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -381,6 +381,8 @@ static int32_t logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) { COPY_SCALAR_FIELD(igExpired); CLONE_NODE_LIST_FIELD(pGroupTags); COPY_SCALAR_FIELD(groupSort); + CLONE_NODE_LIST_FIELD(pTags); + CLONE_NODE_FIELD(pSubtable); return TSDB_CODE_SUCCESS; } @@ -488,6 +490,8 @@ static int32_t logicSortCopy(const SSortLogicNode* pSrc, SSortLogicNode* pDst) { static int32_t logicPartitionCopy(const SPartitionLogicNode* pSrc, SPartitionLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); CLONE_NODE_LIST_FIELD(pPartitionKeys); + CLONE_NODE_LIST_FIELD(pTags); + CLONE_NODE_FIELD(pSubtable); return TSDB_CODE_SUCCESS; } diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index af6c1757a9..e401a3da7f 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -254,6 +254,7 @@ const char* nodesNodeName(ENodeType type) { case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: return "PhysiStreamSemiInterval"; case QUERY_NODE_PHYSICAL_PLAN_FILL: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL: return "PhysiFill"; case QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION: return "PhysiSessionWindow"; @@ -1538,6 +1539,8 @@ static const char* jkTableScanPhysiPlanWatermark = "Watermark"; static const char* jkTableScanPhysiPlanIgnoreExpired = "IgnoreExpired"; static const char* jkTableScanPhysiPlanGroupTags = "GroupTags"; static const char* jkTableScanPhysiPlanGroupSort = "GroupSort"; +static const char* jkTableScanPhysiPlanTags = "Tags"; +static const char* jkTableScanPhysiPlanSubtable = "Subtable"; static const char* jkTableScanPhysiPlanAssignBlockUid = "AssignBlockUid"; static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) { @@ -1595,6 +1598,12 @@ static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddBoolToObject(pJson, jkTableScanPhysiPlanGroupSort, pNode->groupSort); } + if (TSDB_CODE_SUCCESS == code) { + code = nodeListToJson(pJson, jkTableScanPhysiPlanTags, pNode->pTags); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkTableScanPhysiPlanSubtable, nodeToJson, pNode->pSubtable); + } if (TSDB_CODE_SUCCESS == code) { code = tjsonAddBoolToObject(pJson, jkTableScanPhysiPlanAssignBlockUid, pNode->assignBlockUid); } @@ -1657,6 +1666,12 @@ static int32_t jsonToPhysiTableScanNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = tjsonGetBoolValue(pJson, jkTableScanPhysiPlanGroupSort, &pNode->groupSort); } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeList(pJson, jkTableScanPhysiPlanTags, &pNode->pTags); + } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkTableScanPhysiPlanSubtable, &pNode->pSubtable); + } if (TSDB_CODE_SUCCESS == code) { code = tjsonGetBoolValue(pJson, jkTableScanPhysiPlanAssignBlockUid, &pNode->assignBlockUid); } @@ -2270,6 +2285,37 @@ static int32_t jsonToPhysiPartitionNode(const SJson* pJson, void* pObj) { return code; } +static const char* jkStreamPartitionPhysiPlanTags = "Tags"; +static const char* jkStreamPartitionPhysiPlanSubtable = "Subtable"; + +static int32_t physiStreamPartitionNodeToJson(const void* pObj, SJson* pJson) { + const SStreamPartitionPhysiNode* pNode = (const SStreamPartitionPhysiNode*)pObj; + + int32_t code = physiPartitionNodeToJson(pObj, pJson); + if (TSDB_CODE_SUCCESS == code) { + code = nodeListToJson(pJson, jkStreamPartitionPhysiPlanTags, pNode->pTags); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkStreamPartitionPhysiPlanSubtable, nodeToJson, pNode->pSubtable); + } + + return code; +} + +static int32_t jsonToPhysiStreamPartitionNode(const SJson* pJson, void* pObj) { + SStreamPartitionPhysiNode* pNode = (SStreamPartitionPhysiNode*)pObj; + + int32_t code = jsonToPhysiPartitionNode(pJson, pObj); + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeList(pJson, jkStreamPartitionPhysiPlanTags, &pNode->pTags); + } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkStreamPartitionPhysiPlanSubtable, &pNode->pSubtable); + } + + return code; +} + static const char* jkIndefRowsFuncPhysiPlanExprs = "Exprs"; static const char* jkIndefRowsFuncPhysiPlanFuncs = "Funcs"; @@ -4109,6 +4155,8 @@ static const char* jkSelectStmtProjections = "Projections"; static const char* jkSelectStmtFrom = "From"; static const char* jkSelectStmtWhere = "Where"; static const char* jkSelectStmtPartitionBy = "PartitionBy"; +static const char* jkSelectStmtTags = "Tags"; +static const char* jkSelectStmtSubtable = "Subtable"; static const char* jkSelectStmtWindow = "Window"; static const char* jkSelectStmtGroupBy = "GroupBy"; static const char* jkSelectStmtHaving = "Having"; @@ -4134,6 +4182,12 @@ static int32_t selectStmtToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = nodeListToJson(pJson, jkSelectStmtPartitionBy, pNode->pPartitionByList); } + if (TSDB_CODE_SUCCESS == code) { + code = nodeListToJson(pJson, jkSelectStmtTags, pNode->pTags); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkSelectStmtSubtable, nodeToJson, pNode->pSubtable); + } if (TSDB_CODE_SUCCESS == code) { code = tjsonAddObject(pJson, jkSelectStmtWindow, nodeToJson, pNode->pWindow); } @@ -4178,6 +4232,12 @@ static int32_t jsonToSelectStmt(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = jsonToNodeList(pJson, jkSelectStmtPartitionBy, &pNode->pPartitionByList); } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeList(pJson, jkSelectStmtTags, &pNode->pTags); + } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkSelectStmtSubtable, &pNode->pSubtable); + } if (TSDB_CODE_SUCCESS == code) { code = jsonToNodeObject(pJson, jkSelectStmtWindow, &pNode->pWindow); } @@ -4576,6 +4636,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: return physiIntervalNodeToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_FILL: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL: return physiFillNodeToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION: @@ -4586,8 +4647,9 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { case QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE: return physiStateWindowNodeToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_PARTITION: - case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION: return physiPartitionNodeToJson(pObj, pJson); + case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION: + return physiStreamPartitionNodeToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC: return physiIndefRowsFuncNodeToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC: @@ -4728,6 +4790,7 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: return jsonToPhysiIntervalNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_FILL: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL: return jsonToPhysiFillNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION: @@ -4738,8 +4801,9 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { case QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE: return jsonToPhysiStateWindowNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_PARTITION: - case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION: return jsonToPhysiPartitionNode(pJson, pObj); + case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION: + return jsonToPhysiStreamPartitionNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC: return jsonToPhysiIndefRowsFuncNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC: diff --git a/source/libs/nodes/src/nodesMsgFuncs.c b/source/libs/nodes/src/nodesMsgFuncs.c index 0c6b11a765..cdc4e66e42 100644 --- a/source/libs/nodes/src/nodesMsgFuncs.c +++ b/source/libs/nodes/src/nodesMsgFuncs.c @@ -90,12 +90,12 @@ static void endTlvEncode(STlvEncoder* pEncoder, char** pMsg, int32_t* pLen) { static int32_t tlvEncodeImpl(STlvEncoder* pEncoder, int16_t type, const void* pValue, int32_t len) { int32_t tlvLen = sizeof(STlv) + len; if (pEncoder->offset + tlvLen > pEncoder->allocSize) { - void* pNewBuf = taosMemoryRealloc(pEncoder->pBuf, pEncoder->allocSize * 2); + pEncoder->allocSize = TMAX(pEncoder->allocSize * 2, pEncoder->allocSize + pEncoder->offset + tlvLen); + void* pNewBuf = taosMemoryRealloc(pEncoder->pBuf, pEncoder->allocSize); if (NULL == pNewBuf) { return TSDB_CODE_OUT_OF_MEMORY; } pEncoder->pBuf = pNewBuf; - pEncoder->allocSize = pEncoder->allocSize * 2; } STlv* pTlv = (STlv*)(pEncoder->pBuf + pEncoder->offset); pTlv->type = htons(type); @@ -1993,7 +1993,9 @@ enum { PHY_TABLE_SCAN_CODE_SCAN = 1, PHY_TABLE_SCAN_CODE_INLINE_ATTRS, PHY_TABLE_SCAN_CODE_DYN_SCAN_FUNCS, - PHY_TABLE_SCAN_CODE_GROUP_TAGS + PHY_TABLE_SCAN_CODE_GROUP_TAGS, + PHY_TABLE_SCAN_CODE_TAGS, + PHY_TABLE_SCAN_CODE_SUBTABLE }; static int32_t physiTableScanNodeInlineToMsg(const void* pObj, STlvEncoder* pEncoder) { @@ -2062,6 +2064,12 @@ static int32_t physiTableScanNodeToMsg(const void* pObj, STlvEncoder* pEncoder) if (TSDB_CODE_SUCCESS == code) { code = tlvEncodeObj(pEncoder, PHY_TABLE_SCAN_CODE_GROUP_TAGS, nodeListToMsg, pNode->pGroupTags); } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeObj(pEncoder, PHY_TABLE_SCAN_CODE_TAGS, nodeListToMsg, pNode->pTags); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeObj(pEncoder, PHY_TABLE_SCAN_CODE_SUBTABLE, nodeToMsg, pNode->pSubtable); + } return code; } @@ -2138,6 +2146,12 @@ static int32_t msgToPhysiTableScanNode(STlvDecoder* pDecoder, void* pObj) { case PHY_TABLE_SCAN_CODE_GROUP_TAGS: code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pGroupTags); break; + case PHY_TABLE_SCAN_CODE_TAGS: + code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pTags); + break; + case PHY_TABLE_SCAN_CODE_SUBTABLE: + code = msgToNodeFromTlv(pTlv, (void**)&pNode->pSubtable); + break; default: break; } @@ -2914,6 +2928,46 @@ static int32_t msgToPhysiPartitionNode(STlvDecoder* pDecoder, void* pObj) { return code; } +enum { PHY_STREAM_PARTITION_CODE_BASE_NODE = 1, PHY_STREAM_PARTITION_CODE_TAGS, PHY_STREAM_PARTITION_CODE_SUBTABLE }; + +static int32_t physiStreamPartitionNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { + const SStreamPartitionPhysiNode* pNode = (const SStreamPartitionPhysiNode*)pObj; + + int32_t code = tlvEncodeObj(pEncoder, PHY_STREAM_PARTITION_CODE_BASE_NODE, physiPartitionNodeToMsg, &pNode->part); + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeObj(pEncoder, PHY_STREAM_PARTITION_CODE_TAGS, nodeListToMsg, pNode->pTags); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeObj(pEncoder, PHY_STREAM_PARTITION_CODE_SUBTABLE, nodeToMsg, pNode->pSubtable); + } + + return code; +} + +static int32_t msgToPhysiStreamPartitionNode(STlvDecoder* pDecoder, void* pObj) { + SStreamPartitionPhysiNode* pNode = (SStreamPartitionPhysiNode*)pObj; + + int32_t code = TSDB_CODE_SUCCESS; + STlv* pTlv = NULL; + tlvForEach(pDecoder, pTlv, code) { + switch (pTlv->type) { + case PHY_STREAM_PARTITION_CODE_BASE_NODE: + code = tlvDecodeObjFromTlv(pTlv, msgToPhysiPartitionNode, &pNode->part); + break; + case PHY_STREAM_PARTITION_CODE_TAGS: + code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pTags); + break; + case PHY_STREAM_PARTITION_CODE_SUBTABLE: + code = msgToNodeFromTlv(pTlv, (void**)&pNode->pSubtable); + break; + default: + break; + } + } + + return code; +} + enum { PHY_INDEF_ROWS_FUNC_CODE_BASE_NODE = 1, PHY_INDEF_ROWS_FUNC_CODE_EXPRS, PHY_INDEF_ROWS_FUNC_CODE_FUNCS }; static int32_t physiIndefRowsFuncNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { @@ -3579,6 +3633,7 @@ static int32_t specificNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { code = physiIntervalNodeToMsg(pObj, pEncoder); break; case QUERY_NODE_PHYSICAL_PLAN_FILL: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL: code = physiFillNodeToMsg(pObj, pEncoder); break; case QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION: @@ -3592,9 +3647,11 @@ static int32_t specificNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { code = physiStateWindowNodeToMsg(pObj, pEncoder); break; case QUERY_NODE_PHYSICAL_PLAN_PARTITION: - case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION: code = physiPartitionNodeToMsg(pObj, pEncoder); break; + case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION: + code = physiStreamPartitionNodeToMsg(pObj, pEncoder); + break; case QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC: code = physiIndefRowsFuncNodeToMsg(pObj, pEncoder); break; @@ -3714,6 +3771,7 @@ static int32_t msgToSpecificNode(STlvDecoder* pDecoder, void* pObj) { code = msgToPhysiIntervalNode(pDecoder, pObj); break; case QUERY_NODE_PHYSICAL_PLAN_FILL: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL: code = msgToPhysiFillNode(pDecoder, pObj); break; case QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION: @@ -3727,9 +3785,11 @@ static int32_t msgToSpecificNode(STlvDecoder* pDecoder, void* pObj) { code = msgToPhysiStateWindowNode(pDecoder, pObj); break; case QUERY_NODE_PHYSICAL_PLAN_PARTITION: - case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION: code = msgToPhysiPartitionNode(pDecoder, pObj); break; + case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION: + code = msgToPhysiStreamPartitionNode(pDecoder, pObj); + break; case QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC: code = msgToPhysiIndefRowsFuncNode(pDecoder, pObj); break; diff --git a/source/libs/nodes/src/nodesTraverseFuncs.c b/source/libs/nodes/src/nodesTraverseFuncs.c index 8ea80344fc..9f851f6a3f 100644 --- a/source/libs/nodes/src/nodesTraverseFuncs.c +++ b/source/libs/nodes/src/nodesTraverseFuncs.c @@ -378,6 +378,8 @@ void nodesWalkSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeWalker wa nodesWalkExpr(pSelect->pWhere, walker, pContext); case SQL_CLAUSE_WHERE: nodesWalkExprs(pSelect->pPartitionByList, walker, pContext); + nodesWalkExprs(pSelect->pTags, walker, pContext); + nodesWalkExpr(pSelect->pSubtable, walker, pContext); case SQL_CLAUSE_PARTITION_BY: nodesWalkExpr(pSelect->pWindow, walker, pContext); case SQL_CLAUSE_WINDOW: @@ -412,6 +414,8 @@ void nodesRewriteSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeRewrit nodesRewriteExpr(&(pSelect->pWhere), rewriter, pContext); case SQL_CLAUSE_WHERE: nodesRewriteExprs(pSelect->pPartitionByList, rewriter, pContext); + nodesRewriteExprs(pSelect->pTags, rewriter, pContext); + nodesRewriteExpr(&(pSelect->pSubtable), rewriter, pContext); case SQL_CLAUSE_PARTITION_BY: nodesRewriteExpr(&(pSelect->pWindow), rewriter, pContext); case SQL_CLAUSE_WINDOW: diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 7a04d319ec..6e964fb53a 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -419,6 +419,7 @@ SNode* nodesMakeNode(ENodeType type) { case QUERY_NODE_SHOW_TRANSACTIONS_STMT: case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: case QUERY_NODE_SHOW_TAGS_STMT: + case QUERY_NODE_SHOW_TABLE_TAGS_STMT: return makeNode(type, sizeof(SShowStmt)); case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT: return makeNode(type, sizeof(SShowDnodeVariablesStmt)); @@ -511,6 +512,7 @@ SNode* nodesMakeNode(ENodeType type) { case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: return makeNode(type, sizeof(SStreamSemiIntervalPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_FILL: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL: return makeNode(type, sizeof(SFillPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION: return makeNode(type, sizeof(SSessionWinodwPhysiNode)); @@ -772,6 +774,8 @@ void nodesDestroyNode(SNode* pNode) { nodesDestroyNode(pStmt->pFromTable); nodesDestroyNode(pStmt->pWhere); nodesDestroyList(pStmt->pPartitionByList); + nodesDestroyList(pStmt->pTags); + nodesDestroyNode(pStmt->pSubtable); nodesDestroyNode(pStmt->pWindow); nodesDestroyList(pStmt->pGroupByList); nodesDestroyNode(pStmt->pHaving); @@ -918,7 +922,8 @@ void nodesDestroyNode(SNode* pNode) { case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT: case QUERY_NODE_SHOW_TRANSACTIONS_STMT: case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: - case QUERY_NODE_SHOW_TAGS_STMT: { + case QUERY_NODE_SHOW_TAGS_STMT: + case QUERY_NODE_SHOW_TABLE_TAGS_STMT: { SShowStmt* pStmt = (SShowStmt*)pNode; nodesDestroyNode(pStmt->pDbName); nodesDestroyNode(pStmt->pTbName); @@ -1154,7 +1159,8 @@ void nodesDestroyNode(SNode* pNode) { case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: destroyWinodwPhysiNode((SWinodwPhysiNode*)pNode); break; - case QUERY_NODE_PHYSICAL_PLAN_FILL: { + case QUERY_NODE_PHYSICAL_PLAN_FILL: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL: { SFillPhysiNode* pPhyNode = (SFillPhysiNode*)pNode; destroyPhysiNode((SPhysiNode*)pPhyNode); nodesDestroyList(pPhyNode->pFillExprs); diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index dea741cc9b..1a955b3f6b 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -147,7 +147,7 @@ SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, STok SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pDbName); SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode* pOptions); SNode* createFlushDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName); -SNode* createTrimDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName); +SNode* createTrimDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, int32_t maxSpeed); SNode* createDefaultTableOptions(SAstCreateContext* pCxt); SNode* createAlterTableOptions(SAstCreateContext* pCxt); SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, void* pVal); @@ -212,7 +212,7 @@ SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool SNode* createDropFunctionStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pFuncName); SNode* createStreamOptions(SAstCreateContext* pCxt); SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pStreamName, SNode* pRealTable, - SNode* pOptions, SNode* pQuery); + SNode* pOptions, SNodeList* pTags, SNode* pSubtable, SNode* pQuery); SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pStreamName); SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId); SNode* createKillQueryStmt(SAstCreateContext* pCxt, const SToken* pQueryId); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 3e05583d92..83fa92041e 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -159,7 +159,7 @@ cmd ::= DROP DATABASE exists_opt(A) db_name(B). cmd ::= USE db_name(A). { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &A); } cmd ::= ALTER DATABASE db_name(A) alter_db_options(B). { pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &A, B); } cmd ::= FLUSH DATABASE db_name(A). { pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &A); } -cmd ::= TRIM DATABASE db_name(A). { pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &A); } +cmd ::= TRIM DATABASE db_name(A) speed_opt(B). { pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &A, B); } %type not_exists_opt { bool } %destructor not_exists_opt { } @@ -246,6 +246,11 @@ retention_list(A) ::= retention_list(B) NK_COMMA retention(C). retention(A) ::= NK_VARIABLE(B) NK_COLON NK_VARIABLE(C). { A = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &B), createDurationValueNode(pCxt, &C)); } +%type speed_opt { int32_t } +%destructor speed_opt { } +speed_opt(A) ::= . { A = 0; } +speed_opt(A) ::= MAX_SPEED NK_INTEGER(B). { A = taosStr2Int32(B.z, NULL, 10); } + /************************************************ create/drop table/stable ********************************************/ cmd ::= CREATE TABLE not_exists_opt(A) full_table_name(B) NK_LP column_def_list(C) NK_RP tags_def_opt(D) table_options(E). { pCxt->pRootNode = createCreateTableStmt(pCxt, A, B, C, D, E); } @@ -415,6 +420,7 @@ cmd ::= SHOW TABLE DISTRIBUTED full_table_name(A). cmd ::= SHOW CONSUMERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } cmd ::= SHOW SUBSCRIPTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } cmd ::= SHOW TAGS FROM table_name_cond(A) from_db_opt(B). { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, B, A, OP_TYPE_EQUAL); } +cmd ::= SHOW TABLE TAGS FROM table_name_cond(A) from_db_opt(B). { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLE_TAGS_STMT, B, A, OP_TYPE_EQUAL); } cmd ::= SHOW VNODES NK_INTEGER(A). { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &A), NULL); } cmd ::= SHOW VNODES NK_STRING(A). { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, createValueNode(pCxt, TSDB_DATA_TYPE_VARCHAR, &A)); } @@ -501,8 +507,8 @@ bufsize_opt(A) ::= . bufsize_opt(A) ::= BUFSIZE NK_INTEGER(B). { A = taosStr2Int32(B.z, NULL, 10); } /************************************************ create/drop stream **************************************************/ -cmd ::= CREATE STREAM not_exists_opt(E) stream_name(A) - stream_options(B) INTO full_table_name(C) AS query_or_subquery(D). { pCxt->pRootNode = createCreateStreamStmt(pCxt, E, &A, C, B, D); } +cmd ::= CREATE STREAM not_exists_opt(E) stream_name(A) stream_options(B) INTO + full_table_name(C) tags_def_opt(F) subtable_opt(G) AS query_or_subquery(D). { pCxt->pRootNode = createCreateStreamStmt(pCxt, E, &A, C, B, F, G, D); } cmd ::= DROP STREAM exists_opt(A) stream_name(B). { pCxt->pRootNode = createDropStreamStmt(pCxt, A, &B); } stream_options(A) ::= . { A = createStreamOptions(pCxt); } @@ -512,6 +518,9 @@ stream_options(A) ::= stream_options(B) TRIGGER MAX_DELAY duration_literal(C). stream_options(A) ::= stream_options(B) WATERMARK duration_literal(C). { ((SStreamOptions*)B)->pWatermark = releaseRawExprNode(pCxt, C); A = B; } stream_options(A) ::= stream_options(B) IGNORE EXPIRED NK_INTEGER(C). { ((SStreamOptions*)B)->ignoreExpired = taosStr2Int8(C.z, NULL, 10); A = B; } +subtable_opt(A) ::= . { A = NULL; } +subtable_opt(A) ::= SUBTABLE NK_LP expression(B) NK_RP. { A = releaseRawExprNode(pCxt, B); } + /************************************************ kill connection/query ***********************************************/ cmd ::= KILL CONNECTION NK_INTEGER(A). { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &A); } cmd ::= KILL QUERY NK_STRING(A). { pCxt->pRootNode = createKillQueryStmt(pCxt, &A); } @@ -699,6 +708,8 @@ pseudo_column(A) ::= QDURATION(B). pseudo_column(A) ::= WSTART(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } pseudo_column(A) ::= WEND(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } pseudo_column(A) ::= WDURATION(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } +pseudo_column(A) ::= IROWTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } +pseudo_column(A) ::= QTAGS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } function_expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); } function_expression(A) ::= star_func(B) NK_LP star_func_para_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); } @@ -909,7 +920,16 @@ where_clause_opt(A) ::= WHERE search_condition(B). %type partition_by_clause_opt { SNodeList* } %destructor partition_by_clause_opt { nodesDestroyList($$); } partition_by_clause_opt(A) ::= . { A = NULL; } -partition_by_clause_opt(A) ::= PARTITION BY expression_list(B). { A = B; } +partition_by_clause_opt(A) ::= PARTITION BY partition_list(B). { A = B; } + +%type partition_list { SNodeList* } +%destructor partition_list { nodesDestroyList($$); } +partition_list(A) ::= partition_item(B). { A = createNodeList(pCxt, B); } +partition_list(A) ::= partition_list(B) NK_COMMA partition_item(C). { A = addNodeToList(pCxt, B, C); } + +partition_item(A) ::= expr_or_subquery(B). { A = releaseRawExprNode(pCxt, B); } +partition_item(A) ::= expr_or_subquery(B) column_alias(C). { A = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, B), &C); } +partition_item(A) ::= expr_or_subquery(B) AS column_alias(C). { A = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, B), &C); } twindow_clause_opt(A) ::= . { A = NULL; } twindow_clause_opt(A) ::= diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 65afc84c9d..8998ffdbf3 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -1055,7 +1055,7 @@ SNode* createFlushDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName) { return (SNode*)pStmt; } -SNode* createTrimDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName) { +SNode* createTrimDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, int32_t maxSpeed) { CHECK_PARSER_STATUS(pCxt); if (!checkDbName(pCxt, pDbName, false)) { return NULL; @@ -1063,6 +1063,7 @@ SNode* createTrimDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName) { STrimDatabaseStmt* pStmt = (STrimDatabaseStmt*)nodesMakeNode(QUERY_NODE_TRIM_DATABASE_STMT); CHECK_OUT_OF_MEM(pStmt); COPY_STRING_FORM_ID_TOKEN(pStmt->dbName, pDbName); + pStmt->maxSpeed = maxSpeed; return (SNode*)pStmt; } @@ -1309,7 +1310,7 @@ SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName) { static bool needDbShowStmt(ENodeType type) { return QUERY_NODE_SHOW_TABLES_STMT == type || QUERY_NODE_SHOW_STABLES_STMT == type || QUERY_NODE_SHOW_VGROUPS_STMT == type || QUERY_NODE_SHOW_INDEXES_STMT == type || - QUERY_NODE_SHOW_TAGS_STMT == type; + QUERY_NODE_SHOW_TAGS_STMT == type || QUERY_NODE_SHOW_TABLE_TAGS_STMT == type; } SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type) { @@ -1700,7 +1701,7 @@ SNode* createStreamOptions(SAstCreateContext* pCxt) { } SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pStreamName, SNode* pRealTable, - SNode* pOptions, SNode* pQuery) { + SNode* pOptions, SNodeList* pTags, SNode* pSubtable, SNode* pQuery) { CHECK_PARSER_STATUS(pCxt); SCreateStreamStmt* pStmt = (SCreateStreamStmt*)nodesMakeNode(QUERY_NODE_CREATE_STREAM_STMT); CHECK_OUT_OF_MEM(pStmt); @@ -1713,6 +1714,8 @@ SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const pStmt->ignoreExists = ignoreExists; pStmt->pOptions = (SStreamOptions*)pOptions; pStmt->pQuery = pQuery; + pStmt->pTags = pTags; + pStmt->pSubtable = pSubtable; return (SNode*)pStmt; } diff --git a/source/libs/parser/src/parAstParser.c b/source/libs/parser/src/parAstParser.c index ec5f6c4e57..ce90bd3da0 100644 --- a/source/libs/parser/src/parAstParser.c +++ b/source/libs/parser/src/parAstParser.c @@ -407,9 +407,18 @@ static int32_t collectMetaKeyFromShowTags(SCollectMetaKeyCxt* pCxt, SShowStmt* p if (TSDB_CODE_SUCCESS == code) { code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache); } + if (TSDB_CODE_SUCCESS == code && NULL != pStmt->pTbName) { + code = reserveTableVgroupInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, + ((SValueNode*)pStmt->pTbName)->literal, pCxt->pMetaCache); + } return code; } +static int32_t collectMetaKeyFromShowStableTags(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { + return collectMetaKeyFromRealTableImpl(pCxt, ((SValueNode*)pStmt->pDbName)->literal, + ((SValueNode*)pStmt->pTbName)->literal, AUTH_TYPE_READ); +} + static int32_t collectMetaKeyFromShowUsers(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USERS, pCxt->pMetaCache); @@ -591,6 +600,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) { return collectMetaKeyFromShowTables(pCxt, (SShowStmt*)pStmt); case QUERY_NODE_SHOW_TAGS_STMT: return collectMetaKeyFromShowTags(pCxt, (SShowStmt*)pStmt); + case QUERY_NODE_SHOW_TABLE_TAGS_STMT: + return collectMetaKeyFromShowStableTags(pCxt, (SShowStmt*)pStmt); case QUERY_NODE_SHOW_USERS_STMT: return collectMetaKeyFromShowUsers(pCxt, (SShowStmt*)pStmt); case QUERY_NODE_SHOW_LICENCES_STMT: diff --git a/source/libs/parser/src/parCalcConst.c b/source/libs/parser/src/parCalcConst.c index a7c08d8f65..efc9d77e67 100644 --- a/source/libs/parser/src/parCalcConst.c +++ b/source/libs/parser/src/parCalcConst.c @@ -275,6 +275,12 @@ static int32_t calcConstSelectFrom(SCalcConstContext* pCxt, SSelectStmt* pSelect if (TSDB_CODE_SUCCESS == code) { code = calcConstList(pSelect->pPartitionByList); } + if (TSDB_CODE_SUCCESS == code) { + code = calcConstList(pSelect->pTags); + } + if (TSDB_CODE_SUCCESS == code) { + code = calcConstNode(&pSelect->pSubtable); + } if (TSDB_CODE_SUCCESS == code) { code = calcConstNode(&pSelect->pWindow); } diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index c51553f7a1..345b9cc5b9 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -129,6 +129,7 @@ static SKeyword keywordTable[] = { {"MATCH", TK_MATCH}, {"MAXROWS", TK_MAXROWS}, {"MAX_DELAY", TK_MAX_DELAY}, + {"MAX_SPEED", TK_MAX_SPEED}, {"MERGE", TK_MERGE}, {"META", TK_META}, {"MINROWS", TK_MINROWS}, @@ -200,6 +201,7 @@ static SKeyword keywordTable[] = { {"STREAMS", TK_STREAMS}, {"STRICT", TK_STRICT}, {"SUBSCRIPTIONS", TK_SUBSCRIPTIONS}, + {"SUBTABLE", TK_SUBTABLE}, {"SYSINFO", TK_SYSINFO}, {"TABLE", TK_TABLE}, {"TABLES", TK_TABLES}, @@ -250,10 +252,12 @@ static SKeyword keywordTable[] = { {"WITH", TK_WITH}, {"WRITE", TK_WRITE}, {"_C0", TK_ROWTS}, + {"_IROWTS", TK_IROWTS}, {"_QDURATION", TK_QDURATION}, {"_QEND", TK_QEND}, {"_QSTART", TK_QSTART}, {"_ROWTS", TK_ROWTS}, + {"_TAGS", TK_QTAGS}, {"_WDURATION", TK_WDURATION}, {"_WEND", TK_WEND}, {"_WSTART", TK_WSTART}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 82167e8911..9d805b8e33 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -1215,6 +1215,9 @@ static bool isMultiResFunc(SNode* pNode) { if (QUERY_NODE_FUNCTION != nodeType(pNode) || !fmIsMultiResFunc(((SFunctionNode*)pNode)->funcId)) { return false; } + if (FUNCTION_TYPE_TAGS == ((SFunctionNode*)pNode)->funcType) { + return true; + } SNodeList* pParameterList = ((SFunctionNode*)pNode)->pParameterList; if (LIST_LENGTH(pParameterList) > 1) { return true; @@ -1556,6 +1559,9 @@ static int32_t translateMultiResFunc(STranslateContext* pCxt, SFunctionNode* pFu "%s(*) is only supported in SELECTed list", pFunc->functionName); } } + if (tsKeepColumnName && 1 == LIST_LENGTH(pFunc->pParameterList)) { + strcpy(pFunc->node.userAlias, ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->userAlias); + } return TSDB_CODE_SUCCESS; } @@ -1839,17 +1845,46 @@ static EDealRes translateWhenThen(STranslateContext* pCxt, SWhenThenNode* pWhenT return DEAL_RES_CONTINUE; } +static bool isCondition(const SNode* pNode) { + if (QUERY_NODE_OPERATOR == nodeType(pNode)) { + return nodesIsComparisonOp((const SOperatorNode*)pNode); + } + return (QUERY_NODE_LOGIC_CONDITION == nodeType(pNode)); +} + +static int32_t rewriteIsTrue(SNode* pSrc, SNode** pIsTrue) { + SOperatorNode* pOp = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR); + if (NULL == pOp) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pOp->opType = OP_TYPE_IS_TRUE; + pOp->pLeft = pSrc; + pOp->node.resType.type = TSDB_DATA_TYPE_BOOL; + pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes; + *pIsTrue = (SNode*)pOp; + return TSDB_CODE_SUCCESS; +} + static EDealRes translateCaseWhen(STranslateContext* pCxt, SCaseWhenNode* pCaseWhen) { bool first = true; SNode* pNode = NULL; FOREACH(pNode, pCaseWhen->pWhenThenList) { + SWhenThenNode* pWhenThen = (SWhenThenNode*)pNode; + if (NULL == pCaseWhen->pCase && !isCondition(pWhenThen->pWhen)) { + SNode* pIsTrue = NULL; + pCxt->errCode = rewriteIsTrue(pWhenThen->pWhen, &pIsTrue); + if (TSDB_CODE_SUCCESS != pCxt->errCode) { + return DEAL_RES_ERROR; + } + pWhenThen->pWhen = pIsTrue; + } if (first) { pCaseWhen->node.resType = ((SExprNode*)pNode)->resType; } else if (!dataTypeEqual(&pCaseWhen->node.resType, &((SExprNode*)pNode)->resType)) { - SWhenThenNode* pWhenThen = (SWhenThenNode*)pNode; - SNode* pCastFunc = NULL; - if (TSDB_CODE_SUCCESS != createCastFunc(pCxt, pWhenThen->pThen, pCaseWhen->node.resType, &pCastFunc)) { - return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, "CASE WHEN data type mismatch"); + SNode* pCastFunc = NULL; + pCxt->errCode = createCastFunc(pCxt, pWhenThen->pThen, pCaseWhen->node.resType, &pCastFunc); + if (TSDB_CODE_SUCCESS != pCxt->errCode) { + return DEAL_RES_ERROR; } pWhenThen->pThen = pCastFunc; pWhenThen->node.resType = pCaseWhen->node.resType; @@ -1857,8 +1892,9 @@ static EDealRes translateCaseWhen(STranslateContext* pCxt, SCaseWhenNode* pCaseW } if (NULL != pCaseWhen->pElse && !dataTypeEqual(&pCaseWhen->node.resType, &((SExprNode*)pCaseWhen->pElse)->resType)) { SNode* pCastFunc = NULL; - if (TSDB_CODE_SUCCESS != createCastFunc(pCxt, pCaseWhen->pElse, pCaseWhen->node.resType, &pCastFunc)) { - return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, "CASE WHEN data type mismatch"); + pCxt->errCode = createCastFunc(pCxt, pCaseWhen->pElse, pCaseWhen->node.resType, &pCastFunc); + if (TSDB_CODE_SUCCESS != pCxt->errCode) { + return DEAL_RES_ERROR; } pCaseWhen->pElse = pCastFunc; ((SExprNode*)pCaseWhen->pElse)->resType = pCaseWhen->node.resType; @@ -2138,10 +2174,114 @@ static bool sysTableFromVnode(const char* pTable) { static bool sysTableFromDnode(const char* pTable) { return 0 == strcmp(pTable, TSDB_INS_TABLE_DNODE_VARIABLES); } +static int32_t getTagsTableVgroupListImpl(STranslateContext* pCxt, SName* pTargetName, SName* pName, + SArray** pVgroupList) { + if (0 == pTargetName->type) { + return getDBVgInfoImpl(pCxt, pName, pVgroupList); + } + + if (TSDB_DB_NAME_T == pTargetName->type) { + return getDBVgInfoImpl(pCxt, pTargetName, pVgroupList); + } + + SVgroupInfo vgInfo = {0}; + int32_t code = getTableHashVgroupImpl(pCxt, pTargetName, &vgInfo); + if (TSDB_CODE_SUCCESS == code) { + *pVgroupList = taosArrayInit(1, sizeof(SVgroupInfo)); + if (NULL == *pVgroupList) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + } + if (TSDB_CODE_SUCCESS == code) { + taosArrayPush(*pVgroupList, &vgInfo); + } + return code; +} + +static int32_t getTagsTableTargetNameFromOp(STranslateContext* pCxt, SOperatorNode* pOper, SName* pName) { + if (OP_TYPE_EQUAL != pOper->opType) { + return TSDB_CODE_SUCCESS; + } + + SColumnNode* pCol = NULL; + SValueNode* pVal = NULL; + if (QUERY_NODE_COLUMN == nodeType(pOper->pLeft)) { + pCol = (SColumnNode*)pOper->pLeft; + } else if (QUERY_NODE_VALUE == nodeType(pOper->pLeft)) { + pVal = (SValueNode*)pOper->pLeft; + } + if (QUERY_NODE_COLUMN == nodeType(pOper->pRight)) { + pCol = (SColumnNode*)pOper->pRight; + } else if (QUERY_NODE_VALUE == nodeType(pOper->pRight)) { + pVal = (SValueNode*)pOper->pRight; + } + if (NULL == pCol || NULL == pVal) { + return TSDB_CODE_SUCCESS; + } + + if (0 == strcmp(pCol->colName, "db_name")) { + return tNameSetDbName(pName, pCxt->pParseCxt->acctId, pVal->literal, strlen(pVal->literal)); + } else if (0 == strcmp(pCol->colName, "table_name")) { + return tNameAddTbName(pName, pVal->literal, strlen(pVal->literal)); + } + + return TSDB_CODE_SUCCESS; +} + +static void getTagsTableTargetObjName(STranslateContext* pCxt, SNode* pNode, SName* pName) { + if (QUERY_NODE_OPERATOR == nodeType(pNode)) { + getTagsTableTargetNameFromOp(pCxt, (SOperatorNode*)pNode, pName); + } +} + +static int32_t getTagsTableTargetNameFromCond(STranslateContext* pCxt, SLogicConditionNode* pCond, SName* pName) { + if (LOGIC_COND_TYPE_AND != pCond->condType) { + return TSDB_CODE_SUCCESS; + } + + SNode* pNode = NULL; + FOREACH(pNode, pCond->pParameterList) { getTagsTableTargetObjName(pCxt, pNode, pName); } + if ('\0' == pName->dbname[0]) { + pName->type = 0; + } + return TSDB_CODE_SUCCESS; +} + +static int32_t getTagsTableTargetName(STranslateContext* pCxt, SNode* pWhere, SName* pName) { + if (NULL == pWhere) { + return TSDB_CODE_SUCCESS; + } + + if (QUERY_NODE_OPERATOR == nodeType(pWhere)) { + return getTagsTableTargetNameFromOp(pCxt, (SOperatorNode*)pWhere, pName); + } + + if (QUERY_NODE_LOGIC_CONDITION == nodeType(pWhere)) { + return getTagsTableTargetNameFromCond(pCxt, (SLogicConditionNode*)pWhere, pName); + } + + return TSDB_CODE_SUCCESS; +} + +static int32_t getTagsTableVgroupList(STranslateContext* pCxt, SName* pName, SArray** pVgroupList) { + if (!isSelectStmt(pCxt->pCurrStmt)) { + return TSDB_CODE_SUCCESS; + } + SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt; + SName targetName = {0}; + int32_t code = getTagsTableTargetName(pCxt, pSelect->pWhere, &targetName); + if (TSDB_CODE_SUCCESS == code) { + code = getTagsTableVgroupListImpl(pCxt, &targetName, pName, pVgroupList); + } + return code; +} + static int32_t setVnodeSysTableVgroupList(STranslateContext* pCxt, SName* pName, SRealTableNode* pRealTable) { int32_t code = TSDB_CODE_SUCCESS; SArray* vgroupList = NULL; - if ('\0' != pRealTable->qualDbName[0]) { + if (0 == strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_TAGS)) { + code = getTagsTableVgroupList(pCxt, pName, &vgroupList); + } else if ('\0' != pRealTable->qualDbName[0]) { if (0 != strcmp(pRealTable->qualDbName, TSDB_INFORMATION_SCHEMA_DB)) { code = getDBVgInfo(pCxt, pRealTable->qualDbName, &vgroupList); } @@ -2149,14 +2289,12 @@ static int32_t setVnodeSysTableVgroupList(STranslateContext* pCxt, SName* pName, code = getDBVgInfoImpl(pCxt, pName, &vgroupList); } - if (TSDB_CODE_SUCCESS == code && 0 == strcmp(pRealTable->table.dbName, TSDB_INFORMATION_SCHEMA_DB) && - 0 == strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_TAGS) && isSelectStmt(pCxt->pCurrStmt) && - 0 == taosArrayGetSize(vgroupList)) { + if (TSDB_CODE_SUCCESS == code && 0 == strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_TAGS) && + isSelectStmt(pCxt->pCurrStmt) && 0 == taosArrayGetSize(vgroupList)) { ((SSelectStmt*)pCxt->pCurrStmt)->isEmptyResult = true; } - if (TSDB_CODE_SUCCESS == code && 0 == strcmp(pRealTable->table.dbName, TSDB_INFORMATION_SCHEMA_DB) && - 0 == strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_TABLES)) { + if (TSDB_CODE_SUCCESS == code && 0 == strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_TABLES)) { code = addMnodeToVgroupList(&pCxt->pParseCxt->mgmtEpSet, &vgroupList); } @@ -2388,8 +2526,12 @@ static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) { SColumnNode* pCol = (SColumnNode*)pExpr; len = snprintf(buf, sizeof(buf), "%s(%s.%s)", pSrcFunc->functionName, pCol->tableAlias, pCol->colName); strncpy(pFunc->node.aliasName, buf, TMIN(len, sizeof(pFunc->node.aliasName) - 1)); - len = snprintf(buf, sizeof(buf), "%s(%s)", pSrcFunc->functionName, pCol->colName); - strncpy(pFunc->node.userAlias, buf, TMIN(len, sizeof(pFunc->node.userAlias) - 1)); + if (tsKeepColumnName) { + strcpy(pFunc->node.userAlias, pCol->colName); + } else { + len = snprintf(buf, sizeof(buf), "%s(%s)", pSrcFunc->functionName, pCol->colName); + strncpy(pFunc->node.userAlias, buf, TMIN(len, sizeof(pFunc->node.userAlias) - 1)); + } } else { len = snprintf(buf, sizeof(buf), "%s(%s)", pSrcFunc->functionName, pExpr->aliasName); strncpy(pFunc->node.aliasName, buf, TMIN(len, sizeof(pFunc->node.aliasName) - 1)); @@ -2476,6 +2618,34 @@ static int32_t createMultiResFuncsFromStar(STranslateContext* pCxt, SFunctionNod return code; } +static int32_t createTags(STranslateContext* pCxt, SNodeList** pOutput) { + if (QUERY_NODE_REAL_TABLE != nodeType(((SSelectStmt*)pCxt->pCurrStmt)->pFromTable)) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TAGS_PC, + "The _TAGS pseudo column can only be used for subtable and supertable queries"); + } + + SRealTableNode* pTable = (SRealTableNode*)(((SSelectStmt*)pCxt->pCurrStmt)->pFromTable); + const STableMeta* pMeta = pTable->pMeta; + if (TSDB_SUPER_TABLE != pMeta->tableType && TSDB_CHILD_TABLE != pMeta->tableType) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TAGS_PC, + "The _TAGS pseudo column can only be used for subtable and supertable queries"); + } + + SSchema* pTagsSchema = getTableTagSchema(pMeta); + for (int32_t i = 0; i < pMeta->tableInfo.numOfTags; ++i) { + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); + if (NULL == pCol) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY); + } + setColumnInfoBySchema(pTable, pTagsSchema + i, 1, pCol); + if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(pOutput, (SNode*)pCol)) { + NODES_DESTORY_LIST(*pOutput); + return TSDB_CODE_OUT_OF_MEMORY; + } + } + return TSDB_CODE_SUCCESS; +} + static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) { SNode* pNode = NULL; WHERE_EACH(pNode, pSelect->pProjectionList) { @@ -2489,10 +2659,14 @@ static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) { continue; } } else if (isMultiResFunc(pNode)) { - SNodeList* pFuncs = NULL; - code = createMultiResFuncsFromStar(pCxt, (SFunctionNode*)pNode, &pFuncs); + SNodeList* pNodeList = NULL; + if (FUNCTION_TYPE_TAGS == ((SFunctionNode*)pNode)->funcType) { + code = createTags(pCxt, &pNodeList); + } else { + code = createMultiResFuncsFromStar(pCxt, (SFunctionNode*)pNode, &pNodeList); + } if (TSDB_CODE_SUCCESS == code) { - INSERT_LIST(pSelect->pProjectionList, pFuncs); + INSERT_LIST(pSelect->pProjectionList, pNodeList); ERASE_NODE(pSelect->pProjectionList); continue; } @@ -3076,7 +3250,14 @@ static int32_t translatePartitionBy(STranslateContext* pCxt, SSelectStmt* pSelec return TSDB_CODE_SUCCESS; } pCxt->currClause = SQL_CLAUSE_PARTITION_BY; - return translateExprList(pCxt, pSelect->pPartitionByList); + int32_t code = translateExprList(pCxt, pSelect->pPartitionByList); + if (TSDB_CODE_SUCCESS == code) { + code = translateExprList(pCxt, pSelect->pTags); + } + if (TSDB_CODE_SUCCESS == code) { + code = translateExpr(pCxt, &pSelect->pSubtable); + } + return code; } static int32_t translateWhere(STranslateContext* pCxt, SSelectStmt* pSelect) { @@ -3968,7 +4149,7 @@ static int32_t translateAlterDatabase(STranslateContext* pCxt, SAlterDatabaseStm } static int32_t translateTrimDatabase(STranslateContext* pCxt, STrimDatabaseStmt* pStmt) { - STrimDbReq req = {0}; + STrimDbReq req = {.maxSpeed = pStmt->maxSpeed}; SName name = {0}; tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); tNameGetFullDbName(&name, req.db); @@ -4463,6 +4644,8 @@ static SNode* createTbnameFunction() { return NULL; } strcpy(pFunc->functionName, "tbname"); + strcpy(pFunc->node.aliasName, "tbname"); + strcpy(pFunc->node.userAlias, "tbname"); return (SNode*)pFunc; } @@ -5211,6 +5394,93 @@ static int32_t addWstartTsToCreateStreamQuery(SNode* pStmt) { return code; } +static int32_t addTagsToCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStmt, SSelectStmt* pSelect) { + if (NULL == pStmt->pTags) { + return TSDB_CODE_SUCCESS; + } + + SNode* pTag = NULL; + FOREACH(pTag, pStmt->pTags) { + bool found = false; + SNode* pPart = NULL; + FOREACH(pPart, pSelect->pPartitionByList) { + if (0 == strcmp(((SColumnDefNode*)pTag)->colName, ((SExprNode*)pPart)->userAlias)) { + if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pSelect->pTags, nodesCloneNode(pPart))) { + return TSDB_CODE_OUT_OF_MEMORY; + } + found = true; + break; + } + } + if (!found) { + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_COLUMN, ((SColumnDefNode*)pTag)->colName); + } + } + return TSDB_CODE_SUCCESS; +} + +typedef struct SRewriteSubtableCxt { + STranslateContext* pCxt; + SNodeList* pPartitionList; +} SRewriteSubtableCxt; + +static EDealRes rewriteSubtable(SNode** pNode, void* pContext) { + if (QUERY_NODE_COLUMN == nodeType(*pNode)) { + SRewriteSubtableCxt* pCxt = pContext; + bool found = false; + SNode* pPart = NULL; + FOREACH(pPart, pCxt->pPartitionList) { + if (0 == strcmp(((SColumnNode*)*pNode)->colName, ((SExprNode*)pPart)->userAlias)) { + SNode* pNew = nodesCloneNode(pPart); + if (NULL == pNew) { + pCxt->pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY; + return DEAL_RES_ERROR; + } + nodesDestroyNode(*pNode); + *pNode = pNew; + found = true; + break; + } + if (!found) { + return generateDealNodeErrMsg(pCxt->pCxt, TSDB_CODE_PAR_INVALID_COLUMN, ((SColumnNode*)*pNode)->colName); + } + } + return DEAL_RES_IGNORE_CHILD; + } + return DEAL_RES_CONTINUE; +} + +static int32_t addSubtableNameToCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStmt, + SSelectStmt* pSelect) { + if (NULL == pStmt->pSubtable) { + return TSDB_CODE_SUCCESS; + } + pSelect->pSubtable = nodesCloneNode(pStmt->pSubtable); + if (NULL == pSelect->pSubtable) { + return TSDB_CODE_OUT_OF_MEMORY; + } + SRewriteSubtableCxt cxt = {.pCxt = pCxt, .pPartitionList = pSelect->pPartitionByList}; + nodesRewriteExpr(&pSelect->pSubtable, rewriteSubtable, &cxt); + return pCxt->errCode; +} + +static int32_t addSubtableInfoToCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStmt) { + SSelectStmt* pSelect = (SSelectStmt*)pStmt->pQuery; + if (NULL == pSelect->pPartitionByList) { + if (NULL != pStmt->pTags || NULL != pStmt->pSubtable) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, "Unsupported stream query"); + } + return TSDB_CODE_SUCCESS; + } + + int32_t code = addTagsToCreateStreamQuery(pCxt, pStmt, pSelect); + if (TSDB_CODE_SUCCESS == code) { + code = addSubtableNameToCreateStreamQuery(pCxt, pStmt, pSelect); + } + + return code; +} + static int32_t checkStreamQuery(STranslateContext* pCxt, SSelectStmt* pSelect) { if (TSDB_DATA_TYPE_TIMESTAMP != ((SExprNode*)nodesListGetNode(pSelect->pProjectionList, 0))->resType.type || !pSelect->isTimeLineResult || crossTableWithoutAggOper(pSelect) || NULL != pSelect->pOrderByList || @@ -5220,18 +5490,21 @@ static int32_t checkStreamQuery(STranslateContext* pCxt, SSelectStmt* pSelect) { return TSDB_CODE_SUCCESS; } -static int32_t buildCreateStreamQuery(STranslateContext* pCxt, SNode* pStmt, SCMCreateStreamReq* pReq) { +static int32_t buildCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStmt, SCMCreateStreamReq* pReq) { pCxt->createStream = true; - int32_t code = addWstartTsToCreateStreamQuery(pStmt); + int32_t code = addWstartTsToCreateStreamQuery(pStmt->pQuery); if (TSDB_CODE_SUCCESS == code) { - code = translateQuery(pCxt, pStmt); + code = addSubtableInfoToCreateStreamQuery(pCxt, pStmt); } if (TSDB_CODE_SUCCESS == code) { - code = checkStreamQuery(pCxt, (SSelectStmt*)pStmt); + code = translateQuery(pCxt, pStmt->pQuery); } if (TSDB_CODE_SUCCESS == code) { - getSourceDatabase(pStmt, pCxt->pParseCxt->acctId, pReq->sourceDB); - code = nodesNodeToString(pStmt, false, &pReq->ast, NULL); + code = checkStreamQuery(pCxt, (SSelectStmt*)pStmt->pQuery); + } + if (TSDB_CODE_SUCCESS == code) { + getSourceDatabase(pStmt->pQuery, pCxt->pParseCxt->acctId, pReq->sourceDB); + code = nodesNodeToString(pStmt->pQuery, false, &pReq->ast, NULL); } return code; } @@ -5249,7 +5522,7 @@ static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt* tNameExtractFullName(&name, pReq->targetStbFullName); } - int32_t code = buildCreateStreamQuery(pCxt, pStmt->pQuery, pReq); + int32_t code = buildCreateStreamQuery(pCxt, pStmt, pReq); if (TSDB_CODE_SUCCESS == code) { pReq->sql = strdup(pCxt->pParseCxt->pSql); if (NULL == pReq->sql) { @@ -5262,6 +5535,8 @@ static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt* pReq->maxDelay = (NULL != pStmt->pOptions->pDelay ? ((SValueNode*)pStmt->pOptions->pDelay)->datum.i : 0); pReq->watermark = (NULL != pStmt->pOptions->pWatermark ? ((SValueNode*)pStmt->pOptions->pWatermark)->datum.i : 0); pReq->igExpired = pStmt->pOptions->ignoreExpired; + columnDefNodeToField(pStmt->pTags, &pReq->pTags); + pReq->numOfTags = LIST_LENGTH(pStmt->pTags); } return code; @@ -5799,7 +6074,7 @@ static SNode* createProjectCol(const char* pProjCol) { static SNodeList* createProjectCols(int32_t ncols, const char* const pCols[]) { SNodeList* pProjections = NULL; - if (ncols <= 0) { + if (0 == ncols) { nodesListMakeStrictAppend(&pProjections, createStarCol()); return pProjections; } @@ -5831,10 +6106,12 @@ static int32_t createSimpleSelectStmt(const char* pDb, const char* pTable, int32 strcpy(pRealTable->table.tableAlias, pTable); pSelect->pFromTable = (SNode*)pRealTable; - pSelect->pProjectionList = createProjectCols(numOfProjs, pProjCol); - if (NULL == pSelect->pProjectionList) { - nodesDestroyNode((SNode*)pSelect); - return TSDB_CODE_OUT_OF_MEMORY; + if (numOfProjs >= 0) { + pSelect->pProjectionList = createProjectCols(numOfProjs, pProjCol); + if (NULL == pSelect->pProjectionList) { + nodesDestroyNode((SNode*)pSelect); + return TSDB_CODE_OUT_OF_MEMORY; + } } *pStmt = pSelect; @@ -5937,6 +6214,40 @@ static int32_t rewriteShow(STranslateContext* pCxt, SQuery* pQuery) { pQuery->showRewrite = true; nodesDestroyNode(pQuery->pRoot); pQuery->pRoot = (SNode*)pStmt; + } else { + nodesDestroyNode((SNode*)pStmt); + } + return code; +} + +static SNode* createTagsFunction() { + SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); + if (NULL == pFunc) { + return NULL; + } + strcpy(pFunc->functionName, "_tags"); + return (SNode*)pFunc; +} + +static int32_t rewriteShowStableTags(STranslateContext* pCxt, SQuery* pQuery) { + const char* cols[] = {"tbname", "_tags"}; + SShowStmt* pShow = (SShowStmt*)pQuery->pRoot; + SSelectStmt* pSelect = NULL; + int32_t code = createSimpleSelectStmt(((SValueNode*)pShow->pDbName)->literal, ((SValueNode*)pShow->pTbName)->literal, + -1, NULL, &pSelect); + if (TSDB_CODE_SUCCESS == code) { + code = nodesListMakeStrictAppend(&pSelect->pProjectionList, createTbnameFunction()); + } + if (TSDB_CODE_SUCCESS == code) { + code = nodesListMakeStrictAppend(&pSelect->pProjectionList, createTagsFunction()); + } + if (TSDB_CODE_SUCCESS == code) { + pSelect->isDistinct = true; + pQuery->showRewrite = true; + nodesDestroyNode(pQuery->pRoot); + pQuery->pRoot = (SNode*)pSelect; + } else { + nodesDestroyNode((SNode*)pSelect); } return code; } @@ -7074,6 +7385,9 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) { case QUERY_NODE_SHOW_TAGS_STMT: code = rewriteShow(pCxt, pQuery); break; + case QUERY_NODE_SHOW_TABLE_TAGS_STMT: + code = rewriteShowStableTags(pCxt, pQuery); + break; case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT: code = rewriteShowDnodeVariables(pCxt, pQuery); break; diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index f4ced2799a..9711aed4ba 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -104,26 +104,26 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 441 +#define YYNOCODE 449 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - EFillMode yy18; - EOperatorType yy128; - bool yy173; - SNodeList* yy334; - int8_t yy341; - int64_t yy459; - ENullOrder yy487; - SAlterOption yy515; - EJoinType yy540; - SNode* yy560; - SDataType yy574; - EOrder yy596; - SToken yy659; - int32_t yy676; + EOrder yy14; + bool yy39; + SToken yy181; + EJoinType yy202; + int32_t yy276; + SNodeList* yy282; + int8_t yy293; + ENullOrder yy305; + SDataType yy380; + EFillMode yy381; + SAlterOption yy645; + EOperatorType yy682; + SNode* yy778; + int64_t yy831; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -139,17 +139,17 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 679 -#define YYNRULE 509 -#define YYNTOKEN 313 -#define YY_MAX_SHIFT 678 -#define YY_MIN_SHIFTREDUCE 1000 -#define YY_MAX_SHIFTREDUCE 1508 -#define YY_ERROR_ACTION 1509 -#define YY_ACCEPT_ACTION 1510 -#define YY_NO_ACTION 1511 -#define YY_MIN_REDUCE 1512 -#define YY_MAX_REDUCE 2020 +#define YYNSTATE 693 +#define YYNRULE 521 +#define YYNTOKEN 317 +#define YY_MAX_SHIFT 692 +#define YY_MIN_SHIFTREDUCE 1022 +#define YY_MAX_SHIFTREDUCE 1542 +#define YY_ERROR_ACTION 1543 +#define YY_ACCEPT_ACTION 1544 +#define YY_NO_ACTION 1545 +#define YY_MIN_REDUCE 1546 +#define YY_MAX_REDUCE 2066 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -216,720 +216,791 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2662) +#define YY_ACTTAB_COUNT (2993) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 530, 556, 1760, 530, 435, 1829, 436, 1547, 32, 258, - /* 10 */ 1843, 117, 42, 40, 117, 1996, 1825, 1033, 473, 1646, - /* 20 */ 339, 478, 1296, 41, 39, 38, 37, 36, 1657, 1323, - /* 30 */ 1991, 1657, 1323, 1374, 1577, 1294, 571, 571, 1861, 1648, - /* 40 */ 1821, 1827, 327, 555, 166, 1510, 572, 325, 1992, 557, - /* 50 */ 1825, 1811, 1642, 584, 578, 150, 1369, 1037, 1038, 571, - /* 60 */ 443, 16, 436, 1547, 1659, 1861, 60, 1843, 1302, 42, - /* 70 */ 40, 1444, 440, 550, 1821, 1827, 1875, 339, 1319, 1296, - /* 80 */ 95, 1841, 1842, 1844, 588, 1846, 1847, 583, 578, 578, - /* 90 */ 1374, 530, 1294, 1, 163, 1861, 1928, 384, 485, 484, - /* 100 */ 332, 1924, 50, 572, 354, 124, 1498, 56, 1811, 44, - /* 110 */ 584, 549, 152, 1369, 1524, 675, 480, 483, 16, 1657, - /* 120 */ 513, 1955, 479, 344, 1829, 1302, 1702, 1704, 452, 1376, - /* 130 */ 1377, 212, 44, 1875, 301, 1825, 1996, 95, 1841, 1842, - /* 140 */ 1844, 588, 1846, 1847, 583, 1830, 578, 1703, 1704, 1991, - /* 150 */ 1, 163, 45, 1928, 1843, 56, 1825, 332, 1924, 1821, - /* 160 */ 1827, 333, 1997, 166, 532, 1991, 1900, 1992, 557, 1709, - /* 170 */ 168, 257, 675, 578, 257, 1297, 326, 1295, 1954, 1995, - /* 180 */ 1821, 1827, 1861, 1992, 1994, 1707, 1376, 1377, 77, 303, - /* 190 */ 585, 1322, 520, 568, 578, 1811, 154, 584, 1300, 1301, - /* 200 */ 1616, 1351, 1352, 1354, 1355, 1356, 1357, 1358, 1359, 580, - /* 210 */ 576, 1367, 1368, 1370, 1371, 1372, 1373, 1375, 1378, 3, - /* 220 */ 1875, 130, 162, 621, 95, 1841, 1842, 1844, 588, 1846, - /* 230 */ 1847, 583, 1297, 578, 1295, 1696, 127, 169, 137, 1899, - /* 240 */ 1928, 1465, 35, 34, 332, 1924, 41, 39, 38, 37, - /* 250 */ 36, 169, 1050, 169, 1049, 1300, 1301, 128, 1351, 1352, - /* 260 */ 1354, 1355, 1356, 1357, 1358, 1359, 580, 576, 1367, 1368, - /* 270 */ 1370, 1371, 1372, 1373, 1375, 1378, 3, 42, 40, 165, - /* 280 */ 1936, 1937, 1051, 1941, 11, 339, 1321, 1296, 1322, 543, - /* 290 */ 1463, 1464, 1466, 1467, 434, 1843, 169, 438, 1374, 169, - /* 300 */ 1294, 56, 1151, 610, 609, 608, 1155, 607, 1157, 1158, - /* 310 */ 606, 1160, 603, 568, 1166, 600, 1168, 1169, 597, 594, - /* 320 */ 421, 1369, 11, 1861, 9, 219, 16, 1635, 1475, 225, - /* 330 */ 226, 585, 530, 1302, 42, 40, 1811, 613, 584, 546, - /* 340 */ 1709, 130, 339, 171, 1296, 35, 34, 343, 1535, 41, - /* 350 */ 39, 38, 37, 36, 1324, 1374, 1707, 1294, 1, 56, - /* 360 */ 1657, 1875, 56, 1113, 79, 95, 1841, 1842, 1844, 588, - /* 370 */ 1846, 1847, 583, 373, 578, 179, 178, 119, 1369, 1903, - /* 380 */ 675, 1928, 377, 16, 376, 332, 1924, 452, 303, 1811, - /* 390 */ 1302, 520, 375, 371, 1376, 1377, 1115, 1193, 1194, 255, - /* 400 */ 1936, 567, 1513, 566, 35, 34, 1991, 530, 41, 39, - /* 410 */ 38, 37, 36, 442, 617, 1, 438, 1700, 382, 555, - /* 420 */ 166, 552, 547, 107, 1992, 557, 106, 105, 104, 103, - /* 430 */ 102, 101, 100, 99, 98, 1657, 517, 675, 1633, 24, - /* 440 */ 1297, 1448, 1295, 324, 85, 169, 1757, 1321, 1534, 1302, - /* 450 */ 107, 1376, 1377, 106, 105, 104, 103, 102, 101, 100, - /* 460 */ 99, 98, 1321, 1300, 1301, 1650, 1351, 1352, 1354, 1355, - /* 470 */ 1356, 1357, 1358, 1359, 580, 576, 1367, 1368, 1370, 1371, - /* 480 */ 1372, 1373, 1375, 1378, 3, 1512, 11, 35, 34, 1811, - /* 490 */ 530, 41, 39, 38, 37, 36, 234, 1297, 621, 1295, - /* 500 */ 1995, 383, 126, 169, 1505, 1899, 169, 315, 633, 116, - /* 510 */ 115, 114, 113, 112, 111, 110, 109, 108, 1657, 1943, - /* 520 */ 1300, 1301, 551, 1351, 1352, 1354, 1355, 1356, 1357, 1358, - /* 530 */ 1359, 580, 576, 1367, 1368, 1370, 1371, 1372, 1373, 1375, - /* 540 */ 1378, 3, 42, 40, 1709, 224, 1296, 342, 1940, 1644, - /* 550 */ 339, 310, 1296, 482, 481, 150, 563, 75, 75, 1294, - /* 560 */ 1707, 568, 198, 1374, 1659, 1294, 316, 530, 314, 313, - /* 570 */ 123, 475, 1050, 1455, 1049, 477, 156, 1533, 391, 1652, - /* 580 */ 1653, 469, 465, 461, 457, 197, 1369, 471, 556, 130, - /* 590 */ 92, 1843, 1302, 619, 1320, 1657, 1504, 476, 1302, 42, - /* 600 */ 40, 1379, 1051, 125, 1943, 1276, 1277, 339, 1640, 1296, - /* 610 */ 568, 1649, 141, 140, 616, 615, 614, 1991, 1811, 1861, - /* 620 */ 1374, 76, 1294, 8, 195, 128, 530, 585, 215, 1353, - /* 630 */ 555, 166, 1811, 1939, 584, 1992, 557, 406, 130, 675, - /* 640 */ 175, 530, 1532, 1369, 1384, 675, 570, 164, 1936, 1937, - /* 650 */ 1321, 1941, 407, 579, 1657, 1302, 1709, 1875, 499, 1376, - /* 660 */ 1377, 95, 1841, 1842, 1844, 588, 1846, 1847, 583, 1657, - /* 670 */ 578, 497, 1708, 495, 128, 2011, 72, 1928, 530, 71, - /* 680 */ 8, 332, 1924, 1811, 1843, 485, 484, 194, 188, 450, - /* 690 */ 193, 1962, 124, 534, 448, 1900, 167, 1936, 1937, 1297, - /* 700 */ 1941, 1295, 675, 480, 483, 1297, 1657, 1295, 1750, 479, - /* 710 */ 186, 1531, 1861, 38, 37, 36, 1376, 1377, 1634, 174, - /* 720 */ 585, 150, 1300, 1301, 1530, 1811, 508, 584, 1300, 1301, - /* 730 */ 1660, 1351, 1352, 1354, 1355, 1356, 1357, 1358, 1359, 580, - /* 740 */ 576, 1367, 1368, 1370, 1371, 1372, 1373, 1375, 1378, 3, - /* 750 */ 1875, 559, 1811, 1943, 95, 1841, 1842, 1844, 588, 1846, - /* 760 */ 1847, 583, 1297, 578, 1295, 1811, 28, 169, 1901, 1529, - /* 770 */ 1928, 564, 35, 34, 332, 1924, 41, 39, 38, 37, - /* 780 */ 36, 1528, 1938, 1843, 1527, 1300, 1301, 7, 1351, 1352, - /* 790 */ 1354, 1355, 1356, 1357, 1358, 1359, 580, 576, 1367, 1368, - /* 800 */ 1370, 1371, 1372, 1373, 1375, 1378, 3, 42, 40, 1526, - /* 810 */ 1811, 1861, 345, 646, 644, 339, 322, 1296, 618, 585, - /* 820 */ 150, 1700, 1811, 619, 1811, 1811, 584, 30, 1374, 1659, - /* 830 */ 1294, 378, 1353, 35, 34, 1037, 1038, 41, 39, 38, - /* 840 */ 37, 36, 141, 140, 616, 615, 614, 513, 1321, 1875, - /* 850 */ 1811, 1369, 1523, 292, 1841, 1842, 1844, 588, 1846, 1847, - /* 860 */ 583, 218, 578, 1302, 42, 40, 1750, 612, 1756, 517, - /* 870 */ 298, 530, 339, 1755, 1296, 298, 1991, 177, 678, 1758, - /* 880 */ 1522, 634, 451, 1629, 1525, 1374, 1405, 1294, 8, 1997, - /* 890 */ 166, 252, 265, 1811, 1992, 557, 1617, 35, 34, 1657, - /* 900 */ 78, 41, 39, 38, 37, 36, 160, 530, 1369, 477, - /* 910 */ 675, 668, 664, 660, 656, 263, 516, 1521, 1654, 1077, - /* 920 */ 1302, 1811, 35, 34, 1376, 1377, 41, 39, 38, 37, - /* 930 */ 36, 476, 513, 35, 34, 1657, 91, 41, 39, 38, - /* 940 */ 37, 36, 13, 12, 270, 1, 88, 1687, 530, 530, - /* 950 */ 306, 93, 1078, 29, 232, 530, 1305, 530, 1811, 502, - /* 960 */ 509, 1991, 530, 1410, 46, 4, 514, 675, 229, 1441, - /* 970 */ 1297, 139, 1295, 526, 1997, 166, 1657, 1657, 1520, 1992, - /* 980 */ 557, 1376, 1377, 1657, 1437, 1657, 544, 527, 1948, 1437, - /* 990 */ 1657, 1403, 1519, 1300, 1301, 1564, 1351, 1352, 1354, 1355, - /* 1000 */ 1356, 1357, 1358, 1359, 580, 576, 1367, 1368, 1370, 1371, - /* 1010 */ 1372, 1373, 1375, 1378, 3, 530, 300, 486, 1319, 1811, - /* 1020 */ 221, 385, 49, 48, 512, 414, 528, 1297, 426, 1295, - /* 1030 */ 1353, 1518, 1798, 1811, 386, 1417, 352, 1517, 1270, 1516, - /* 1040 */ 214, 203, 1515, 1657, 201, 399, 1404, 427, 1862, 401, - /* 1050 */ 1300, 1301, 513, 1351, 1352, 1354, 1355, 1356, 1357, 1358, - /* 1060 */ 1359, 580, 576, 1367, 1368, 1370, 1371, 1372, 1373, 1375, - /* 1070 */ 1378, 3, 1811, 530, 205, 1559, 149, 204, 1811, 361, - /* 1080 */ 1811, 1991, 530, 1811, 529, 207, 151, 560, 206, 1557, - /* 1090 */ 392, 276, 1632, 259, 1997, 166, 575, 488, 1308, 1992, - /* 1100 */ 557, 1657, 388, 1574, 209, 274, 64, 208, 43, 63, - /* 1110 */ 1657, 491, 223, 31, 336, 1398, 1399, 1400, 1401, 1402, - /* 1120 */ 1406, 1407, 1408, 1409, 470, 182, 431, 429, 13, 12, - /* 1130 */ 425, 1507, 1508, 420, 419, 418, 417, 416, 413, 412, - /* 1140 */ 411, 410, 409, 405, 404, 403, 402, 396, 395, 394, - /* 1150 */ 393, 246, 390, 389, 312, 134, 1996, 350, 138, 1247, - /* 1160 */ 139, 56, 1548, 227, 58, 1996, 652, 651, 650, 649, - /* 1170 */ 349, 238, 648, 647, 131, 642, 641, 640, 639, 638, - /* 1180 */ 637, 636, 635, 143, 631, 630, 629, 348, 347, 626, - /* 1190 */ 625, 624, 623, 622, 1991, 1304, 530, 619, 58, 94, - /* 1200 */ 1697, 1958, 1843, 1440, 43, 1832, 523, 346, 1995, 231, - /* 1210 */ 627, 1144, 1992, 1993, 254, 1462, 141, 140, 616, 615, - /* 1220 */ 614, 1553, 241, 569, 1657, 251, 628, 2, 5, 43, - /* 1230 */ 1861, 592, 1097, 1395, 355, 69, 68, 381, 585, 138, - /* 1240 */ 173, 360, 490, 1811, 311, 584, 139, 1498, 1095, 1411, - /* 1250 */ 120, 351, 1834, 138, 1263, 1360, 299, 500, 176, 369, - /* 1260 */ 387, 367, 363, 359, 356, 353, 266, 513, 1875, 670, - /* 1270 */ 1319, 211, 96, 586, 338, 1844, 588, 1846, 1847, 583, - /* 1280 */ 269, 578, 1172, 501, 1843, 493, 408, 1752, 1928, 487, - /* 1290 */ 1176, 415, 305, 1924, 210, 423, 1991, 1183, 422, 513, - /* 1300 */ 561, 1181, 424, 1991, 142, 169, 428, 430, 432, 1997, - /* 1310 */ 166, 1325, 1861, 1327, 1992, 557, 555, 166, 433, 441, - /* 1320 */ 585, 1992, 557, 444, 185, 1811, 445, 584, 1991, 1326, - /* 1330 */ 62, 187, 446, 61, 1328, 449, 190, 1307, 192, 447, - /* 1340 */ 73, 1997, 166, 74, 1843, 453, 1992, 557, 196, 472, - /* 1350 */ 1875, 1791, 267, 474, 95, 1841, 1842, 1844, 588, 1846, - /* 1360 */ 1847, 583, 1647, 578, 118, 302, 1843, 200, 2011, 1643, - /* 1370 */ 1928, 202, 1861, 144, 332, 1924, 507, 145, 1645, 213, - /* 1380 */ 585, 1641, 146, 147, 1985, 1811, 503, 584, 504, 216, - /* 1390 */ 510, 515, 542, 321, 1861, 524, 220, 135, 518, 1790, - /* 1400 */ 1762, 525, 585, 521, 82, 323, 84, 1811, 1658, 584, - /* 1410 */ 1875, 268, 136, 1324, 95, 1841, 1842, 1844, 588, 1846, - /* 1420 */ 1847, 583, 1843, 578, 545, 236, 240, 1969, 2011, 538, - /* 1430 */ 1928, 540, 1875, 541, 332, 1924, 285, 586, 338, 1844, - /* 1440 */ 588, 1846, 1847, 583, 1947, 578, 1959, 335, 334, 1968, - /* 1450 */ 1861, 328, 548, 6, 554, 536, 537, 1310, 585, 250, - /* 1460 */ 329, 539, 565, 1811, 2014, 584, 562, 1991, 1374, 1437, - /* 1470 */ 1303, 129, 1323, 55, 247, 1950, 245, 157, 248, 86, - /* 1480 */ 555, 166, 249, 1843, 1944, 1992, 557, 1909, 1875, 1990, - /* 1490 */ 590, 1369, 95, 1841, 1842, 1844, 588, 1846, 1847, 583, - /* 1500 */ 1701, 578, 1630, 1302, 271, 1843, 533, 262, 1928, 671, - /* 1510 */ 253, 1861, 332, 1924, 672, 47, 674, 297, 273, 585, - /* 1520 */ 283, 294, 293, 275, 1811, 1805, 584, 66, 1803, 1802, - /* 1530 */ 67, 1799, 357, 1861, 1804, 358, 1288, 1289, 172, 362, - /* 1540 */ 1797, 585, 364, 365, 366, 1796, 1811, 368, 584, 1875, - /* 1550 */ 574, 1795, 370, 96, 1841, 1842, 1844, 588, 1846, 1847, - /* 1560 */ 583, 1794, 578, 372, 1793, 374, 1266, 1265, 1773, 1928, - /* 1570 */ 1772, 1875, 379, 1927, 1924, 96, 1841, 1842, 1844, 588, - /* 1580 */ 1846, 1847, 583, 380, 578, 1771, 1770, 1745, 1235, 1843, - /* 1590 */ 1744, 1928, 1743, 1742, 132, 573, 1924, 1741, 1740, 70, - /* 1600 */ 1739, 1738, 1737, 1736, 1735, 397, 398, 1734, 400, 1733, - /* 1610 */ 1311, 1732, 1306, 1731, 1730, 1729, 1728, 1861, 1727, 1726, - /* 1620 */ 1725, 1724, 1723, 1722, 1721, 582, 1720, 1719, 1718, 1717, - /* 1630 */ 1811, 133, 584, 1314, 1316, 1716, 1715, 1714, 1713, 1237, - /* 1640 */ 1712, 1711, 1710, 1579, 1843, 576, 1367, 1368, 1370, 1371, - /* 1650 */ 1372, 1373, 1578, 1576, 1544, 1875, 437, 1543, 1040, 291, - /* 1660 */ 1841, 1842, 1844, 588, 1846, 1847, 583, 581, 578, 531, - /* 1670 */ 1893, 121, 1861, 183, 184, 1039, 161, 1786, 122, 1780, - /* 1680 */ 585, 180, 1769, 1768, 191, 1811, 181, 584, 189, 1754, - /* 1690 */ 1636, 439, 1575, 1573, 454, 455, 1571, 1843, 458, 1569, - /* 1700 */ 462, 456, 459, 460, 1567, 463, 464, 466, 468, 1070, - /* 1710 */ 1875, 1556, 1555, 467, 153, 1841, 1842, 1844, 588, 1846, - /* 1720 */ 1847, 583, 1540, 578, 1638, 1861, 1187, 1186, 1637, 1112, - /* 1730 */ 1111, 643, 1108, 585, 1565, 1107, 1106, 1560, 1811, 317, - /* 1740 */ 584, 645, 318, 1558, 492, 319, 1539, 1538, 494, 1843, - /* 1750 */ 489, 199, 57, 496, 1537, 498, 97, 1785, 1779, 148, - /* 1760 */ 1272, 1843, 505, 1875, 217, 558, 2012, 96, 1841, 1842, - /* 1770 */ 1844, 588, 1846, 1847, 583, 1843, 578, 1861, 1767, 1765, - /* 1780 */ 1996, 1766, 1764, 1928, 1763, 582, 1280, 1761, 1925, 1861, - /* 1790 */ 1811, 1753, 584, 519, 535, 81, 17, 585, 233, 1386, - /* 1800 */ 10, 222, 1811, 1861, 584, 18, 43, 19, 1385, 228, - /* 1810 */ 244, 585, 80, 88, 230, 1875, 1811, 54, 584, 291, - /* 1820 */ 1841, 1842, 1844, 588, 1846, 1847, 583, 1875, 578, 1843, - /* 1830 */ 1894, 292, 1841, 1842, 1844, 588, 1846, 1847, 583, 511, - /* 1840 */ 578, 1875, 51, 1843, 522, 287, 1841, 1842, 1844, 588, - /* 1850 */ 1846, 1847, 583, 83, 578, 1477, 243, 1861, 25, 235, - /* 1860 */ 1832, 27, 237, 1459, 506, 585, 239, 59, 320, 1461, - /* 1870 */ 1811, 1861, 584, 155, 21, 1492, 337, 1454, 242, 585, - /* 1880 */ 1497, 26, 87, 1491, 1811, 330, 584, 1496, 553, 1498, - /* 1890 */ 1495, 331, 1434, 1843, 1433, 1875, 53, 256, 12, 153, - /* 1900 */ 1841, 1842, 1844, 588, 1846, 1847, 583, 1831, 578, 1875, - /* 1910 */ 1312, 20, 1843, 292, 1841, 1842, 1844, 588, 1846, 1847, - /* 1920 */ 583, 1861, 578, 158, 1396, 1878, 340, 15, 1364, 585, - /* 1930 */ 577, 159, 1362, 1361, 1811, 33, 584, 14, 22, 170, - /* 1940 */ 1861, 1336, 1344, 52, 587, 589, 591, 23, 585, 341, - /* 1950 */ 593, 2013, 1173, 1811, 1170, 584, 595, 1167, 596, 1875, - /* 1960 */ 598, 599, 1843, 292, 1841, 1842, 1844, 588, 1846, 1847, - /* 1970 */ 583, 601, 578, 1161, 602, 604, 1843, 1159, 1875, 605, - /* 1980 */ 1150, 1182, 277, 1841, 1842, 1844, 588, 1846, 1847, 583, - /* 1990 */ 1861, 578, 1165, 1164, 611, 1163, 89, 1162, 585, 90, - /* 2000 */ 65, 1178, 260, 1811, 1861, 584, 1068, 1103, 620, 1102, - /* 2010 */ 1101, 1100, 585, 1099, 632, 1098, 1096, 1811, 1094, 584, - /* 2020 */ 1093, 1092, 1119, 1090, 1089, 261, 1088, 1087, 1875, 1086, - /* 2030 */ 1085, 1843, 278, 1841, 1842, 1844, 588, 1846, 1847, 583, - /* 2040 */ 1084, 578, 1875, 1083, 1114, 1116, 279, 1841, 1842, 1844, - /* 2050 */ 588, 1846, 1847, 583, 1080, 578, 1079, 1843, 1076, 1861, - /* 2060 */ 1075, 1074, 1073, 1572, 653, 655, 1570, 585, 657, 654, - /* 2070 */ 659, 658, 1811, 1568, 584, 661, 663, 662, 1566, 665, - /* 2080 */ 667, 666, 1554, 1843, 669, 1861, 1030, 1536, 677, 264, - /* 2090 */ 673, 1511, 1298, 585, 272, 676, 1511, 1875, 1811, 1511, - /* 2100 */ 584, 286, 1841, 1842, 1844, 588, 1846, 1847, 583, 1843, - /* 2110 */ 578, 1861, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 585, - /* 2120 */ 1511, 1511, 1511, 1875, 1811, 1511, 584, 288, 1841, 1842, - /* 2130 */ 1844, 588, 1846, 1847, 583, 1843, 578, 1861, 1511, 1511, - /* 2140 */ 1511, 1511, 1511, 1511, 1511, 585, 1511, 1511, 1511, 1875, - /* 2150 */ 1811, 1511, 584, 280, 1841, 1842, 1844, 588, 1846, 1847, - /* 2160 */ 583, 1511, 578, 1861, 1511, 1511, 1511, 1511, 1511, 1511, - /* 2170 */ 1511, 585, 1511, 1511, 1511, 1875, 1811, 1511, 584, 289, - /* 2180 */ 1841, 1842, 1844, 588, 1846, 1847, 583, 1843, 578, 1511, - /* 2190 */ 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, - /* 2200 */ 1511, 1875, 1511, 1843, 1511, 281, 1841, 1842, 1844, 588, - /* 2210 */ 1846, 1847, 583, 1511, 578, 1861, 1511, 1511, 1511, 1511, - /* 2220 */ 1511, 1511, 1511, 585, 1511, 1511, 1511, 1511, 1811, 1511, - /* 2230 */ 584, 1861, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 585, - /* 2240 */ 1511, 1511, 1511, 1511, 1811, 1511, 584, 1511, 1511, 1511, - /* 2250 */ 1511, 1511, 1511, 1875, 1511, 1511, 1511, 290, 1841, 1842, - /* 2260 */ 1844, 588, 1846, 1847, 583, 1843, 578, 1511, 1511, 1875, - /* 2270 */ 1511, 1511, 1511, 282, 1841, 1842, 1844, 588, 1846, 1847, - /* 2280 */ 583, 1843, 578, 1511, 1511, 1511, 1511, 1511, 1511, 1511, - /* 2290 */ 1511, 1511, 1511, 1861, 1511, 1511, 1511, 1511, 1511, 1511, - /* 2300 */ 1511, 585, 1511, 1511, 1511, 1511, 1811, 1511, 584, 1861, - /* 2310 */ 1511, 1511, 1511, 1511, 1511, 1511, 1511, 585, 1511, 1511, - /* 2320 */ 1511, 1511, 1811, 1511, 584, 1511, 1511, 1511, 1511, 1511, - /* 2330 */ 1511, 1875, 1511, 1511, 1843, 295, 1841, 1842, 1844, 588, - /* 2340 */ 1846, 1847, 583, 1511, 578, 1511, 1511, 1875, 1843, 1511, - /* 2350 */ 1511, 296, 1841, 1842, 1844, 588, 1846, 1847, 583, 1511, - /* 2360 */ 578, 1511, 1861, 1511, 1511, 1511, 1511, 1511, 1511, 1511, - /* 2370 */ 585, 1511, 1511, 1511, 1511, 1811, 1861, 584, 1511, 1511, - /* 2380 */ 1511, 1511, 1511, 1511, 585, 1511, 1511, 1511, 1511, 1811, - /* 2390 */ 1511, 584, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, - /* 2400 */ 1875, 1511, 1843, 1511, 1855, 1841, 1842, 1844, 588, 1846, - /* 2410 */ 1847, 583, 1511, 578, 1875, 1511, 1511, 1511, 1854, 1841, - /* 2420 */ 1842, 1844, 588, 1846, 1847, 583, 1843, 578, 1511, 1511, - /* 2430 */ 1861, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 585, 1511, - /* 2440 */ 1511, 1511, 1511, 1811, 1511, 584, 1511, 1511, 1511, 1511, - /* 2450 */ 1511, 1511, 1843, 1511, 1861, 1511, 1511, 1511, 1511, 1511, - /* 2460 */ 1511, 1511, 585, 1511, 1511, 1511, 1511, 1811, 1875, 584, - /* 2470 */ 1511, 1511, 1853, 1841, 1842, 1844, 588, 1846, 1847, 583, - /* 2480 */ 1861, 578, 1511, 1511, 1511, 1511, 1511, 1511, 585, 1511, - /* 2490 */ 1511, 1511, 1875, 1811, 1511, 584, 307, 1841, 1842, 1844, - /* 2500 */ 588, 1846, 1847, 583, 1843, 578, 1511, 1511, 1511, 1511, - /* 2510 */ 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1875, 1511, - /* 2520 */ 1843, 1511, 308, 1841, 1842, 1844, 588, 1846, 1847, 583, - /* 2530 */ 1511, 578, 1861, 1511, 1511, 1511, 1511, 1511, 1511, 1511, - /* 2540 */ 585, 1511, 1511, 1511, 1511, 1811, 1511, 584, 1861, 1511, - /* 2550 */ 1511, 1511, 1511, 1511, 1511, 1511, 585, 1511, 1511, 1511, - /* 2560 */ 1511, 1811, 1511, 584, 1511, 1511, 1511, 1511, 1511, 1511, - /* 2570 */ 1875, 1511, 1511, 1511, 304, 1841, 1842, 1844, 588, 1846, - /* 2580 */ 1847, 583, 1843, 578, 1511, 1511, 1875, 1511, 1511, 1511, - /* 2590 */ 309, 1841, 1842, 1844, 588, 1846, 1847, 583, 1511, 578, - /* 2600 */ 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, - /* 2610 */ 1861, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 585, 1511, - /* 2620 */ 1511, 1511, 1511, 1811, 1511, 584, 1511, 1511, 1511, 1511, - /* 2630 */ 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, - /* 2640 */ 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1875, 1511, - /* 2650 */ 1511, 1511, 284, 1841, 1842, 1844, 588, 1846, 1847, 583, - /* 2660 */ 1511, 578, + /* 0 */ 1868, 1797, 447, 1868, 448, 1581, 455, 1882, 448, 1581, + /* 10 */ 1684, 1864, 44, 42, 1864, 354, 544, 394, 1738, 1740, + /* 20 */ 349, 1864, 1323, 43, 41, 40, 39, 38, 52, 2042, + /* 30 */ 34, 267, 585, 1403, 1348, 1321, 1900, 1860, 1866, 337, + /* 40 */ 1860, 1866, 343, 1349, 586, 1693, 1350, 1860, 1866, 1850, + /* 50 */ 592, 598, 30, 592, 1671, 310, 1398, 1055, 37, 36, + /* 60 */ 592, 17, 43, 41, 40, 39, 38, 1882, 1329, 44, + /* 70 */ 42, 1473, 1880, 40, 39, 38, 1916, 349, 570, 1323, + /* 80 */ 97, 1881, 1883, 602, 1885, 1886, 597, 1072, 592, 1071, + /* 90 */ 1403, 62, 1321, 168, 1, 1969, 1900, 1059, 1060, 342, + /* 100 */ 1965, 77, 483, 464, 599, 582, 46, 2037, 58, 1850, + /* 110 */ 585, 598, 173, 1398, 464, 125, 689, 1073, 17, 531, + /* 120 */ 1995, 1532, 569, 171, 1688, 1329, 334, 2038, 571, 1794, + /* 130 */ 1405, 1406, 600, 585, 132, 181, 1916, 1547, 154, 227, + /* 140 */ 98, 348, 1883, 602, 1885, 1886, 597, 1696, 592, 1900, + /* 150 */ 1072, 1, 1071, 1217, 1218, 1969, 58, 564, 109, 314, + /* 160 */ 1965, 108, 107, 106, 105, 104, 103, 102, 101, 100, + /* 170 */ 2037, 130, 74, 689, 58, 73, 1324, 58, 1322, 81, + /* 180 */ 1073, 58, 1669, 1569, 46, 569, 171, 1405, 1406, 266, + /* 190 */ 2038, 571, 584, 169, 1977, 1978, 563, 1982, 1739, 1740, + /* 200 */ 1327, 1328, 635, 1378, 1379, 1381, 1382, 1383, 1384, 1385, + /* 210 */ 1386, 1387, 1388, 594, 590, 1396, 1397, 1399, 1400, 1401, + /* 220 */ 1402, 1404, 1407, 3, 205, 1850, 233, 234, 1349, 633, + /* 230 */ 582, 159, 325, 1324, 1477, 1322, 1650, 387, 161, 386, + /* 240 */ 1348, 174, 635, 481, 477, 473, 469, 204, 145, 144, + /* 250 */ 630, 629, 628, 174, 156, 174, 1558, 1327, 1328, 132, + /* 260 */ 1378, 1379, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, + /* 270 */ 594, 590, 1396, 1397, 1399, 1400, 1401, 1402, 1404, 1407, + /* 280 */ 3, 44, 42, 219, 78, 312, 167, 202, 534, 349, + /* 290 */ 335, 1323, 326, 1568, 324, 323, 130, 487, 154, 1732, + /* 300 */ 582, 489, 1403, 174, 1321, 1567, 109, 1695, 1348, 108, + /* 310 */ 107, 106, 105, 104, 103, 102, 101, 100, 170, 1977, + /* 320 */ 1978, 174, 1982, 488, 174, 1398, 565, 1745, 174, 132, + /* 330 */ 17, 1869, 560, 1882, 336, 1850, 232, 1329, 44, 42, + /* 340 */ 79, 312, 1864, 1743, 534, 1787, 349, 1850, 1323, 582, + /* 350 */ 201, 195, 47, 200, 452, 544, 179, 460, 94, 1403, + /* 360 */ 1346, 1321, 1900, 1, 544, 1413, 130, 119, 1860, 1866, + /* 370 */ 586, 1348, 127, 193, 485, 1850, 119, 598, 132, 1745, + /* 380 */ 1685, 592, 1398, 490, 1693, 689, 353, 17, 172, 1977, + /* 390 */ 1978, 395, 1982, 1693, 1329, 1743, 1301, 1302, 1880, 1405, + /* 400 */ 1406, 1499, 1916, 1546, 396, 352, 97, 1881, 1883, 602, + /* 410 */ 1885, 1886, 597, 154, 592, 121, 1135, 566, 561, 168, + /* 420 */ 1, 1969, 1695, 1434, 1380, 342, 1965, 118, 117, 116, + /* 430 */ 115, 114, 113, 112, 111, 110, 2042, 264, 1977, 581, + /* 440 */ 432, 580, 689, 77, 2037, 1324, 1996, 1322, 511, 1137, + /* 450 */ 355, 557, 1497, 1498, 1500, 1501, 1405, 1406, 154, 569, + /* 460 */ 171, 509, 1350, 507, 2038, 571, 1689, 1695, 1347, 1327, + /* 470 */ 1328, 1670, 1378, 1379, 1381, 1382, 1383, 1384, 1385, 1386, + /* 480 */ 1387, 1388, 594, 590, 1396, 1397, 1399, 1400, 1401, 1402, + /* 490 */ 1404, 1407, 3, 31, 11, 446, 185, 184, 450, 174, + /* 500 */ 494, 493, 1324, 1439, 1322, 1329, 1175, 624, 623, 622, + /* 510 */ 1179, 621, 1181, 1182, 620, 1184, 617, 1566, 1190, 614, + /* 520 */ 1192, 1193, 611, 608, 1984, 2042, 1327, 1328, 1532, 1378, + /* 530 */ 1379, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 594, + /* 540 */ 590, 1396, 1397, 1399, 1400, 1401, 1402, 1404, 1407, 3, + /* 550 */ 44, 42, 1981, 544, 2037, 1380, 660, 658, 349, 1850, + /* 560 */ 1323, 11, 1332, 9, 544, 176, 544, 627, 1565, 454, + /* 570 */ 2041, 1403, 450, 1321, 2038, 2040, 392, 633, 393, 1564, + /* 580 */ 37, 36, 1693, 1882, 43, 41, 40, 39, 38, 544, + /* 590 */ 13, 12, 1351, 1693, 1398, 1693, 145, 144, 630, 629, + /* 600 */ 628, 403, 1882, 1668, 544, 266, 1329, 44, 42, 1408, + /* 610 */ 1850, 544, 1900, 1563, 544, 349, 417, 1323, 1693, 1984, + /* 620 */ 599, 1850, 1745, 418, 1562, 1850, 462, 598, 1403, 1745, + /* 630 */ 1321, 1900, 8, 1693, 11, 546, 319, 1941, 1744, 599, + /* 640 */ 1693, 544, 226, 1693, 1850, 1743, 598, 1980, 600, 1561, + /* 650 */ 87, 1398, 1916, 463, 689, 1850, 294, 348, 1883, 602, + /* 660 */ 1885, 1886, 597, 1329, 592, 647, 1850, 1880, 1405, 1406, + /* 670 */ 1693, 1916, 1686, 1560, 570, 97, 1881, 1883, 602, 1885, + /* 680 */ 1886, 597, 80, 592, 1446, 1793, 2037, 307, 2057, 8, + /* 690 */ 1969, 1850, 37, 36, 342, 1965, 43, 41, 40, 39, + /* 700 */ 38, 569, 171, 2037, 2003, 1335, 2038, 571, 544, 633, + /* 710 */ 548, 689, 1941, 383, 1324, 1850, 1322, 1544, 569, 171, + /* 720 */ 356, 1059, 1060, 2038, 571, 1405, 1406, 26, 145, 144, + /* 730 */ 630, 629, 628, 385, 381, 243, 1557, 1693, 1327, 1328, + /* 740 */ 1682, 1378, 1379, 1381, 1382, 1383, 1384, 1385, 1386, 1387, + /* 750 */ 1388, 594, 590, 1396, 1397, 1399, 1400, 1401, 1402, 1404, + /* 760 */ 1407, 3, 37, 36, 544, 1678, 43, 41, 40, 39, + /* 770 */ 38, 1324, 220, 1322, 1787, 1723, 1690, 364, 1850, 174, + /* 780 */ 2041, 1351, 37, 36, 1556, 180, 43, 41, 40, 39, + /* 790 */ 38, 1611, 1555, 1693, 527, 1327, 1328, 7, 1378, 1379, + /* 800 */ 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 594, 590, + /* 810 */ 1396, 1397, 1399, 1400, 1401, 1402, 1404, 1407, 3, 44, + /* 820 */ 42, 544, 1323, 2037, 1554, 1553, 1850, 349, 574, 1323, + /* 830 */ 1552, 531, 1680, 137, 1850, 1321, 544, 1099, 2043, 171, + /* 840 */ 1403, 1795, 1321, 2038, 571, 1676, 1551, 32, 523, 1509, + /* 850 */ 1693, 1470, 1882, 37, 36, 497, 496, 43, 41, 40, + /* 860 */ 39, 38, 126, 1398, 1550, 1693, 1850, 1850, 1329, 2042, + /* 870 */ 1100, 1882, 1850, 492, 495, 1329, 44, 42, 544, 491, + /* 880 */ 544, 1900, 1984, 544, 349, 1792, 1323, 307, 1850, 599, + /* 890 */ 528, 1787, 237, 544, 1850, 540, 598, 1403, 2037, 1321, + /* 900 */ 1900, 8, 183, 1989, 1466, 542, 1850, 1693, 599, 1693, + /* 910 */ 1979, 1348, 1693, 1850, 2041, 598, 689, 1880, 2038, 2039, + /* 920 */ 1398, 1916, 1693, 689, 242, 157, 1881, 1883, 602, 1885, + /* 930 */ 1886, 597, 1329, 592, 489, 223, 1880, 1405, 1406, 1549, + /* 940 */ 1916, 544, 1539, 544, 97, 1881, 1883, 602, 1885, 1886, + /* 950 */ 597, 128, 592, 543, 1940, 268, 488, 2057, 1, 1969, + /* 960 */ 648, 593, 1663, 342, 1965, 631, 549, 2006, 1736, 522, + /* 970 */ 1693, 632, 1693, 2031, 1736, 1598, 1324, 626, 1322, 279, + /* 980 */ 689, 1850, 1723, 1324, 143, 1322, 48, 4, 210, 402, + /* 990 */ 212, 208, 45, 211, 1405, 1406, 214, 498, 1466, 213, + /* 1000 */ 1327, 1328, 1837, 216, 50, 526, 215, 1327, 1328, 1593, + /* 1010 */ 1378, 1379, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, + /* 1020 */ 594, 590, 1396, 1397, 1399, 1400, 1401, 1402, 1404, 1407, + /* 1030 */ 3, 500, 1541, 1542, 577, 573, 51, 1538, 72, 1331, + /* 1040 */ 1324, 231, 1322, 1559, 1272, 575, 37, 36, 589, 371, + /* 1050 */ 43, 41, 40, 39, 38, 37, 36, 138, 2009, 43, + /* 1060 */ 41, 40, 39, 38, 1327, 1328, 1608, 1378, 1379, 1381, + /* 1070 */ 1382, 1383, 1384, 1385, 1386, 1387, 1388, 594, 590, 1396, + /* 1080 */ 1397, 1399, 1400, 1401, 1402, 1404, 1407, 3, 309, 1469, + /* 1090 */ 1346, 13, 12, 235, 93, 1380, 1591, 425, 261, 558, + /* 1100 */ 437, 641, 642, 1651, 90, 482, 37, 36, 142, 537, + /* 1110 */ 43, 41, 40, 39, 38, 143, 60, 410, 503, 438, + /* 1120 */ 247, 412, 60, 1119, 1117, 1587, 255, 45, 1901, 666, + /* 1130 */ 665, 664, 663, 359, 45, 662, 661, 133, 656, 655, + /* 1140 */ 654, 653, 652, 651, 650, 649, 147, 645, 644, 643, + /* 1150 */ 358, 357, 640, 639, 638, 637, 636, 155, 360, 1582, + /* 1160 */ 239, 1999, 285, 322, 1733, 583, 263, 1168, 1496, 260, + /* 1170 */ 2, 5, 250, 684, 1440, 398, 283, 66, 388, 1389, + /* 1180 */ 65, 365, 1334, 1871, 606, 142, 278, 1424, 275, 143, + /* 1190 */ 370, 122, 320, 1489, 142, 527, 189, 443, 441, 1288, + /* 1200 */ 182, 153, 397, 436, 401, 1882, 431, 430, 429, 428, + /* 1210 */ 427, 424, 423, 422, 421, 420, 416, 415, 414, 413, + /* 1220 */ 407, 406, 405, 404, 2037, 400, 399, 321, 1346, 419, + /* 1230 */ 426, 1873, 1789, 58, 1900, 433, 1196, 1200, 434, 2043, + /* 1240 */ 171, 1207, 599, 1205, 2038, 571, 146, 1850, 435, 598, + /* 1250 */ 440, 37, 36, 578, 439, 43, 41, 40, 39, 38, + /* 1260 */ 186, 1352, 442, 444, 445, 453, 1354, 457, 192, 456, + /* 1270 */ 1880, 96, 194, 1353, 1916, 458, 1355, 197, 97, 1881, + /* 1280 */ 1883, 602, 1885, 1886, 597, 459, 592, 497, 496, 129, + /* 1290 */ 461, 141, 1940, 1969, 126, 199, 75, 342, 1965, 76, + /* 1300 */ 465, 530, 203, 362, 315, 492, 495, 71, 70, 391, + /* 1310 */ 361, 491, 178, 120, 484, 486, 1882, 1683, 527, 311, + /* 1320 */ 527, 1828, 207, 1679, 514, 209, 148, 527, 149, 308, + /* 1330 */ 1681, 1677, 379, 276, 377, 373, 369, 366, 363, 150, + /* 1340 */ 516, 221, 151, 518, 517, 1900, 1432, 2037, 224, 2037, + /* 1350 */ 521, 524, 529, 599, 331, 556, 2037, 228, 1850, 538, + /* 1360 */ 598, 515, 2043, 171, 2043, 171, 139, 2038, 571, 2038, + /* 1370 */ 571, 2043, 171, 140, 532, 1827, 2038, 571, 527, 1799, + /* 1380 */ 174, 1880, 535, 333, 84, 1916, 539, 277, 86, 97, + /* 1390 */ 1881, 1883, 602, 1885, 1886, 597, 1694, 592, 1351, 2000, + /* 1400 */ 2010, 1433, 2057, 552, 1969, 559, 245, 2037, 342, 1965, + /* 1410 */ 692, 554, 2015, 555, 338, 249, 6, 2014, 1988, 562, + /* 1420 */ 254, 1882, 2043, 171, 274, 568, 553, 2038, 571, 551, + /* 1430 */ 550, 1991, 162, 256, 339, 259, 579, 257, 165, 576, + /* 1440 */ 1466, 258, 131, 682, 678, 674, 670, 272, 1350, 57, + /* 1450 */ 1900, 1985, 88, 604, 2060, 1950, 1737, 1664, 599, 280, + /* 1460 */ 271, 2036, 685, 1850, 1882, 598, 49, 262, 686, 688, + /* 1470 */ 306, 33, 346, 1427, 1428, 1429, 1430, 1431, 1435, 1436, + /* 1480 */ 1437, 1438, 284, 292, 95, 282, 1880, 240, 1844, 1843, + /* 1490 */ 1916, 68, 303, 1900, 97, 1881, 1883, 602, 1885, 1886, + /* 1500 */ 597, 599, 592, 302, 1842, 1841, 1850, 1944, 598, 1969, + /* 1510 */ 69, 345, 344, 342, 1965, 1838, 367, 1882, 368, 1315, + /* 1520 */ 541, 1337, 1316, 372, 1836, 177, 374, 375, 376, 1880, + /* 1530 */ 1835, 378, 1403, 1916, 1330, 1834, 380, 97, 1881, 1883, + /* 1540 */ 602, 1885, 1886, 597, 384, 592, 1900, 1833, 382, 1832, + /* 1550 */ 1942, 1291, 1969, 229, 599, 1398, 342, 1965, 1290, 1850, + /* 1560 */ 1810, 598, 1809, 1808, 389, 390, 1807, 1329, 1782, 1260, + /* 1570 */ 1882, 1295, 1781, 222, 1779, 134, 1778, 1777, 1780, 135, + /* 1580 */ 1776, 1775, 1880, 1774, 1773, 1772, 1916, 1771, 408, 409, + /* 1590 */ 97, 1881, 1883, 602, 1885, 1886, 597, 1770, 592, 1900, + /* 1600 */ 411, 1769, 1768, 547, 1262, 1969, 1767, 599, 1766, 342, + /* 1610 */ 1965, 1765, 1850, 1882, 598, 588, 1764, 1763, 1762, 1761, + /* 1620 */ 1760, 1759, 1758, 1757, 1756, 1755, 1754, 1753, 136, 1752, + /* 1630 */ 1751, 1750, 1749, 1748, 1747, 1880, 1746, 1613, 1143, 1916, + /* 1640 */ 1612, 1610, 1900, 98, 1881, 1883, 602, 1885, 1886, 597, + /* 1650 */ 599, 592, 187, 1578, 188, 1850, 190, 598, 1969, 1062, + /* 1660 */ 1061, 449, 1968, 1965, 198, 1805, 1882, 123, 1577, 1823, + /* 1670 */ 1817, 1806, 1791, 1672, 124, 1338, 1609, 1333, 1880, 1607, + /* 1680 */ 1605, 166, 1916, 191, 466, 451, 98, 1881, 1883, 602, + /* 1690 */ 1885, 1886, 597, 196, 592, 1900, 468, 467, 470, 1341, + /* 1700 */ 1343, 1969, 471, 596, 1092, 587, 1965, 1603, 1850, 474, + /* 1710 */ 598, 1601, 1590, 590, 1396, 1397, 1399, 1400, 1401, 1402, + /* 1720 */ 472, 476, 1882, 478, 475, 479, 480, 1589, 1574, 1674, + /* 1730 */ 1211, 1880, 1210, 1673, 1134, 1916, 1133, 657, 1130, 300, + /* 1740 */ 1881, 1883, 602, 1885, 1886, 597, 595, 592, 545, 1934, + /* 1750 */ 1129, 1900, 659, 206, 59, 1599, 1128, 327, 1594, 599, + /* 1760 */ 328, 1592, 501, 329, 1850, 504, 598, 1573, 1572, 1571, + /* 1770 */ 510, 99, 506, 1822, 508, 53, 1816, 1297, 1307, 25, + /* 1780 */ 1804, 519, 1802, 1803, 1882, 18, 152, 1880, 1801, 502, + /* 1790 */ 2042, 1916, 1800, 230, 1798, 158, 1881, 1883, 602, 1885, + /* 1800 */ 1886, 597, 236, 592, 512, 1305, 1790, 520, 225, 90, + /* 1810 */ 82, 83, 241, 1900, 85, 1415, 10, 19, 218, 330, + /* 1820 */ 536, 599, 20, 525, 1414, 238, 1850, 1511, 598, 56, + /* 1830 */ 253, 61, 505, 15, 27, 1871, 499, 244, 252, 246, + /* 1840 */ 1493, 217, 1882, 248, 29, 1495, 160, 572, 2058, 1880, + /* 1850 */ 533, 251, 22, 1916, 28, 21, 89, 98, 1881, 1883, + /* 1860 */ 602, 1885, 1886, 597, 1882, 592, 1488, 1526, 1525, 340, + /* 1870 */ 1531, 1900, 1969, 1532, 1530, 1529, 332, 1966, 64, 599, + /* 1880 */ 341, 63, 265, 1870, 1850, 1463, 598, 55, 1462, 163, + /* 1890 */ 12, 1339, 1425, 1900, 1919, 164, 175, 1393, 591, 35, + /* 1900 */ 54, 596, 1391, 1390, 14, 16, 1850, 1880, 598, 23, + /* 1910 */ 24, 1916, 1363, 1371, 1197, 301, 1881, 1883, 602, 1885, + /* 1920 */ 1886, 597, 605, 592, 1882, 601, 603, 351, 609, 1880, + /* 1930 */ 1194, 612, 607, 1916, 615, 610, 613, 300, 1881, 1883, + /* 1940 */ 602, 1885, 1886, 597, 618, 592, 1191, 1935, 1185, 616, + /* 1950 */ 1174, 1183, 619, 1900, 625, 91, 92, 1206, 67, 269, + /* 1960 */ 1202, 599, 1090, 634, 1189, 1188, 1850, 1882, 598, 1125, + /* 1970 */ 1187, 1124, 1186, 1141, 1123, 1122, 1121, 1120, 1118, 1116, + /* 1980 */ 1115, 1114, 1110, 1108, 1882, 646, 1112, 1111, 1109, 1880, + /* 1990 */ 270, 1107, 1106, 1916, 1105, 1138, 1900, 157, 1881, 1883, + /* 2000 */ 602, 1885, 1886, 597, 599, 592, 1136, 1102, 1101, 1850, + /* 2010 */ 1098, 598, 1097, 1900, 1096, 1095, 1606, 667, 669, 1604, + /* 2020 */ 671, 599, 673, 668, 1602, 672, 1850, 677, 598, 675, + /* 2030 */ 1600, 676, 1880, 679, 680, 681, 1916, 1588, 1882, 2007, + /* 2040 */ 296, 1881, 1883, 602, 1885, 1886, 597, 683, 592, 1880, + /* 2050 */ 1052, 1570, 687, 1916, 273, 1325, 1882, 158, 1881, 1883, + /* 2060 */ 602, 1885, 1886, 597, 281, 592, 690, 1900, 691, 1545, + /* 2070 */ 1545, 1545, 347, 1545, 1545, 599, 1545, 1545, 1545, 1545, + /* 2080 */ 1850, 1545, 598, 1545, 567, 1900, 1545, 1545, 1545, 1545, + /* 2090 */ 350, 1545, 1545, 599, 1545, 1545, 1545, 1545, 1850, 1545, + /* 2100 */ 598, 1545, 1545, 1880, 1545, 1545, 1545, 1916, 1545, 1545, + /* 2110 */ 2059, 301, 1881, 1883, 602, 1885, 1886, 597, 1882, 592, + /* 2120 */ 1545, 1880, 1545, 1545, 1545, 1916, 1545, 1545, 1545, 301, + /* 2130 */ 1881, 1883, 602, 1885, 1886, 597, 1545, 592, 1545, 1545, + /* 2140 */ 1545, 1545, 1882, 1545, 1545, 1545, 1545, 1900, 1545, 1545, + /* 2150 */ 1545, 1545, 1545, 1545, 1545, 599, 1545, 1545, 1545, 1545, + /* 2160 */ 1850, 1545, 598, 1545, 1545, 1545, 1545, 1545, 1545, 1545, + /* 2170 */ 1545, 1900, 1545, 1545, 1545, 1545, 1545, 1545, 1545, 599, + /* 2180 */ 1545, 1545, 1545, 513, 1850, 1882, 598, 1916, 1545, 1545, + /* 2190 */ 1545, 294, 1881, 1883, 602, 1885, 1886, 597, 1545, 592, + /* 2200 */ 1545, 1545, 1545, 1545, 1545, 1882, 1545, 1880, 1545, 1545, + /* 2210 */ 1545, 1916, 1545, 1545, 1900, 286, 1881, 1883, 602, 1885, + /* 2220 */ 1886, 597, 599, 592, 1545, 1545, 1545, 1850, 1545, 598, + /* 2230 */ 1545, 1545, 1545, 1545, 1900, 1545, 1545, 1545, 1545, 1545, + /* 2240 */ 1545, 1545, 599, 1545, 1545, 1545, 1545, 1850, 1545, 598, + /* 2250 */ 1880, 1545, 1545, 1545, 1916, 1545, 1545, 1545, 287, 1881, + /* 2260 */ 1883, 602, 1885, 1886, 597, 1545, 592, 1545, 1882, 1545, + /* 2270 */ 1880, 1545, 1545, 1545, 1916, 1545, 1545, 1545, 288, 1881, + /* 2280 */ 1883, 602, 1885, 1886, 597, 1545, 592, 1882, 1545, 1545, + /* 2290 */ 1545, 1545, 1545, 1545, 1545, 1545, 1545, 1900, 1545, 1545, + /* 2300 */ 1545, 1545, 1545, 1545, 1545, 599, 1545, 1545, 1545, 1545, + /* 2310 */ 1850, 1545, 598, 1545, 1545, 1545, 1900, 1545, 1545, 1545, + /* 2320 */ 1545, 1545, 1545, 1545, 599, 1545, 1545, 1545, 1545, 1850, + /* 2330 */ 1882, 598, 1545, 1880, 1545, 1545, 1545, 1916, 1545, 1545, + /* 2340 */ 1545, 295, 1881, 1883, 602, 1885, 1886, 597, 1545, 592, + /* 2350 */ 1545, 1545, 1880, 1545, 1545, 1545, 1916, 1545, 1545, 1900, + /* 2360 */ 297, 1881, 1883, 602, 1885, 1886, 597, 599, 592, 1545, + /* 2370 */ 1545, 1545, 1850, 1545, 598, 1545, 1545, 1545, 1545, 1545, + /* 2380 */ 1545, 1882, 1545, 1545, 1545, 1545, 1545, 1545, 1545, 1545, + /* 2390 */ 1545, 1545, 1545, 1545, 1545, 1880, 1545, 1545, 1545, 1916, + /* 2400 */ 1545, 1882, 1545, 289, 1881, 1883, 602, 1885, 1886, 597, + /* 2410 */ 1900, 592, 1545, 1545, 1545, 1545, 1545, 1545, 599, 1545, + /* 2420 */ 1545, 1545, 1545, 1850, 1545, 598, 1545, 1545, 1545, 1545, + /* 2430 */ 1900, 1545, 1545, 1545, 1545, 1545, 1545, 1545, 599, 1545, + /* 2440 */ 1545, 1545, 1545, 1850, 1545, 598, 1880, 1545, 1545, 1545, + /* 2450 */ 1916, 1545, 1882, 1545, 298, 1881, 1883, 602, 1885, 1886, + /* 2460 */ 597, 1545, 592, 1545, 1545, 1545, 1880, 1545, 1545, 1545, + /* 2470 */ 1916, 1545, 1545, 1545, 290, 1881, 1883, 602, 1885, 1886, + /* 2480 */ 597, 1900, 592, 1545, 1545, 1545, 1545, 1545, 1545, 599, + /* 2490 */ 1545, 1545, 1545, 1545, 1850, 1545, 598, 1545, 1545, 1545, + /* 2500 */ 1545, 1545, 1545, 1545, 1545, 1882, 1545, 1545, 1545, 1545, + /* 2510 */ 1545, 1545, 1545, 1545, 1545, 1545, 1545, 1880, 1545, 1545, + /* 2520 */ 1545, 1916, 1545, 1545, 1545, 299, 1881, 1883, 602, 1885, + /* 2530 */ 1886, 597, 1545, 592, 1900, 1545, 1545, 1545, 1545, 1545, + /* 2540 */ 1545, 1545, 599, 1545, 1545, 1545, 1545, 1850, 1882, 598, + /* 2550 */ 1545, 1545, 1545, 1545, 1545, 1545, 1545, 1545, 1545, 1545, + /* 2560 */ 1545, 1545, 1545, 1545, 1545, 1545, 1545, 1545, 1882, 1545, + /* 2570 */ 1880, 1545, 1545, 1545, 1916, 1545, 1545, 1900, 291, 1881, + /* 2580 */ 1883, 602, 1885, 1886, 597, 599, 592, 1545, 1545, 1545, + /* 2590 */ 1850, 1545, 598, 1545, 1545, 1545, 1545, 1900, 1545, 1545, + /* 2600 */ 1545, 1545, 1545, 1545, 1545, 599, 1545, 1545, 1545, 1545, + /* 2610 */ 1850, 1545, 598, 1880, 1545, 1545, 1545, 1916, 1545, 1545, + /* 2620 */ 1545, 304, 1881, 1883, 602, 1885, 1886, 597, 1545, 592, + /* 2630 */ 1545, 1882, 1545, 1880, 1545, 1545, 1545, 1916, 1545, 1545, + /* 2640 */ 1545, 305, 1881, 1883, 602, 1885, 1886, 597, 1545, 592, + /* 2650 */ 1882, 1545, 1545, 1545, 1545, 1545, 1545, 1545, 1545, 1545, + /* 2660 */ 1900, 1545, 1545, 1545, 1545, 1545, 1545, 1545, 599, 1545, + /* 2670 */ 1545, 1545, 1545, 1850, 1545, 598, 1545, 1545, 1545, 1900, + /* 2680 */ 1545, 1545, 1545, 1545, 1545, 1545, 1545, 599, 1545, 1545, + /* 2690 */ 1545, 1545, 1850, 1882, 598, 1545, 1880, 1545, 1545, 1545, + /* 2700 */ 1916, 1545, 1545, 1545, 1894, 1881, 1883, 602, 1885, 1886, + /* 2710 */ 597, 1545, 592, 1545, 1545, 1880, 1545, 1545, 1545, 1916, + /* 2720 */ 1545, 1545, 1900, 1893, 1881, 1883, 602, 1885, 1886, 597, + /* 2730 */ 599, 592, 1545, 1545, 1545, 1850, 1545, 598, 1545, 1545, + /* 2740 */ 1545, 1545, 1545, 1545, 1882, 1545, 1545, 1545, 1545, 1545, + /* 2750 */ 1545, 1545, 1545, 1545, 1545, 1545, 1545, 1545, 1880, 1545, + /* 2760 */ 1545, 1545, 1916, 1545, 1882, 1545, 1892, 1881, 1883, 602, + /* 2770 */ 1885, 1886, 597, 1900, 592, 1545, 1545, 1545, 1545, 1545, + /* 2780 */ 1545, 599, 1545, 1545, 1545, 1545, 1850, 1545, 598, 1545, + /* 2790 */ 1545, 1545, 1545, 1900, 1545, 1545, 1545, 1545, 1545, 1545, + /* 2800 */ 1545, 599, 1545, 1545, 1545, 1545, 1850, 1545, 598, 1880, + /* 2810 */ 1545, 1545, 1545, 1916, 1545, 1882, 1545, 316, 1881, 1883, + /* 2820 */ 602, 1885, 1886, 597, 1545, 592, 1545, 1545, 1545, 1880, + /* 2830 */ 1545, 1545, 1545, 1916, 1545, 1545, 1545, 317, 1881, 1883, + /* 2840 */ 602, 1885, 1886, 597, 1900, 592, 1545, 1545, 1545, 1545, + /* 2850 */ 1545, 1545, 599, 1545, 1545, 1545, 1545, 1850, 1545, 598, + /* 2860 */ 1545, 1545, 1545, 1545, 1545, 1545, 1545, 1545, 1882, 1545, + /* 2870 */ 1545, 1545, 1545, 1545, 1545, 1545, 1545, 1545, 1545, 1545, + /* 2880 */ 1880, 1545, 1545, 1545, 1916, 1545, 1545, 1545, 313, 1881, + /* 2890 */ 1883, 602, 1885, 1886, 597, 1545, 592, 1900, 1545, 1545, + /* 2900 */ 1545, 1545, 1545, 1545, 1545, 599, 1545, 1545, 1545, 1545, + /* 2910 */ 1850, 1882, 598, 1545, 1545, 1545, 1545, 1545, 1545, 1545, + /* 2920 */ 1545, 1545, 1545, 1545, 1545, 1545, 1545, 1545, 1545, 1545, + /* 2930 */ 1545, 1545, 1545, 1880, 1545, 1545, 1545, 1916, 1545, 1545, + /* 2940 */ 1900, 318, 1881, 1883, 602, 1885, 1886, 597, 599, 592, + /* 2950 */ 1545, 1545, 1545, 1850, 1545, 598, 1545, 1545, 1545, 1545, + /* 2960 */ 1545, 1545, 1545, 1545, 1545, 1545, 1545, 1545, 1545, 1545, + /* 2970 */ 1545, 1545, 1545, 1545, 1545, 1545, 1880, 1545, 1545, 1545, + /* 2980 */ 1916, 1545, 1545, 1545, 293, 1881, 1883, 602, 1885, 1886, + /* 2990 */ 597, 1545, 592, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 324, 388, 0, 324, 320, 346, 322, 323, 403, 404, - /* 10 */ 316, 335, 12, 13, 335, 3, 357, 4, 342, 345, - /* 20 */ 20, 342, 22, 12, 13, 14, 15, 16, 352, 20, - /* 30 */ 417, 352, 20, 33, 0, 35, 20, 20, 344, 346, - /* 40 */ 381, 382, 383, 430, 431, 313, 352, 336, 435, 436, - /* 50 */ 357, 357, 345, 359, 395, 344, 56, 44, 45, 20, - /* 60 */ 320, 61, 322, 323, 353, 344, 4, 316, 68, 12, - /* 70 */ 13, 14, 14, 352, 381, 382, 382, 20, 20, 22, - /* 80 */ 386, 387, 388, 389, 390, 391, 392, 393, 395, 395, - /* 90 */ 33, 324, 35, 93, 400, 344, 402, 324, 64, 65, - /* 100 */ 406, 407, 335, 352, 372, 71, 94, 93, 357, 93, - /* 110 */ 359, 390, 315, 56, 317, 115, 82, 83, 61, 352, - /* 120 */ 388, 427, 88, 355, 346, 68, 358, 359, 60, 129, - /* 130 */ 130, 125, 93, 382, 361, 357, 388, 386, 387, 388, - /* 140 */ 389, 390, 391, 392, 393, 346, 395, 358, 359, 417, - /* 150 */ 93, 400, 93, 402, 316, 93, 357, 406, 407, 381, - /* 160 */ 382, 383, 430, 431, 399, 417, 401, 435, 436, 344, - /* 170 */ 419, 162, 115, 395, 162, 175, 351, 177, 427, 431, - /* 180 */ 381, 382, 344, 435, 436, 360, 129, 130, 182, 183, - /* 190 */ 352, 20, 186, 324, 395, 357, 329, 359, 198, 199, - /* 200 */ 333, 201, 202, 203, 204, 205, 206, 207, 208, 209, + /* 0 */ 351, 0, 324, 351, 326, 327, 324, 320, 326, 327, + /* 10 */ 351, 362, 12, 13, 362, 360, 328, 328, 363, 364, + /* 20 */ 20, 362, 22, 12, 13, 14, 15, 16, 340, 3, + /* 30 */ 409, 410, 20, 33, 20, 35, 349, 388, 389, 390, + /* 40 */ 388, 389, 390, 20, 357, 357, 20, 388, 389, 362, + /* 50 */ 401, 364, 2, 401, 0, 366, 56, 4, 8, 9, + /* 60 */ 401, 61, 12, 13, 14, 15, 16, 320, 68, 12, + /* 70 */ 13, 14, 385, 14, 15, 16, 389, 20, 394, 22, + /* 80 */ 393, 394, 395, 396, 397, 398, 399, 20, 401, 22, + /* 90 */ 33, 4, 35, 406, 94, 408, 349, 44, 45, 412, + /* 100 */ 413, 332, 35, 60, 357, 328, 94, 423, 94, 362, + /* 110 */ 20, 364, 425, 56, 60, 346, 116, 50, 61, 364, + /* 120 */ 433, 95, 438, 439, 355, 68, 371, 443, 444, 374, + /* 130 */ 130, 131, 385, 20, 357, 56, 389, 0, 349, 56, + /* 140 */ 393, 394, 395, 396, 397, 398, 399, 358, 401, 349, + /* 150 */ 20, 94, 22, 130, 131, 408, 94, 357, 21, 412, + /* 160 */ 413, 24, 25, 26, 27, 28, 29, 30, 31, 32, + /* 170 */ 423, 394, 93, 116, 94, 96, 176, 94, 178, 96, + /* 180 */ 50, 94, 0, 320, 94, 438, 439, 130, 131, 163, + /* 190 */ 443, 444, 415, 416, 417, 418, 396, 420, 363, 364, + /* 200 */ 200, 201, 60, 203, 204, 205, 206, 207, 208, 209, /* 210 */ 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, - /* 220 */ 382, 352, 343, 60, 386, 387, 388, 389, 390, 391, - /* 230 */ 392, 393, 175, 395, 177, 356, 398, 237, 400, 401, - /* 240 */ 402, 198, 8, 9, 406, 407, 12, 13, 14, 15, - /* 250 */ 16, 237, 20, 237, 22, 198, 199, 388, 201, 202, + /* 220 */ 220, 221, 222, 223, 33, 362, 125, 126, 20, 106, + /* 230 */ 328, 333, 37, 176, 14, 178, 338, 175, 47, 177, + /* 240 */ 20, 241, 60, 52, 53, 54, 55, 56, 125, 126, + /* 250 */ 127, 128, 129, 241, 319, 241, 321, 200, 201, 357, /* 260 */ 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, - /* 270 */ 213, 214, 215, 216, 217, 218, 219, 12, 13, 410, - /* 280 */ 411, 412, 50, 414, 221, 20, 20, 22, 20, 246, - /* 290 */ 247, 248, 249, 250, 321, 316, 237, 324, 33, 237, - /* 300 */ 35, 93, 106, 107, 108, 109, 110, 111, 112, 113, - /* 310 */ 114, 115, 116, 324, 118, 119, 120, 121, 122, 123, - /* 320 */ 78, 56, 221, 344, 223, 56, 61, 0, 94, 124, - /* 330 */ 125, 352, 324, 68, 12, 13, 357, 104, 359, 160, - /* 340 */ 344, 352, 20, 335, 22, 8, 9, 351, 316, 12, - /* 350 */ 13, 14, 15, 16, 20, 33, 360, 35, 93, 93, - /* 360 */ 352, 382, 93, 35, 95, 386, 387, 388, 389, 390, - /* 370 */ 391, 392, 393, 170, 395, 133, 134, 388, 56, 400, - /* 380 */ 115, 402, 174, 61, 176, 406, 407, 60, 183, 357, - /* 390 */ 68, 186, 189, 190, 129, 130, 68, 129, 130, 410, - /* 400 */ 411, 412, 0, 414, 8, 9, 417, 324, 12, 13, - /* 410 */ 14, 15, 16, 321, 354, 93, 324, 357, 335, 430, - /* 420 */ 431, 242, 243, 21, 435, 436, 24, 25, 26, 27, - /* 430 */ 28, 29, 30, 31, 32, 352, 359, 115, 0, 43, - /* 440 */ 175, 14, 177, 366, 326, 237, 369, 20, 316, 68, - /* 450 */ 21, 129, 130, 24, 25, 26, 27, 28, 29, 30, - /* 460 */ 31, 32, 20, 198, 199, 347, 201, 202, 203, 204, - /* 470 */ 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, - /* 480 */ 215, 216, 217, 218, 219, 0, 221, 8, 9, 357, - /* 490 */ 324, 12, 13, 14, 15, 16, 162, 175, 60, 177, - /* 500 */ 3, 335, 398, 237, 167, 401, 237, 37, 68, 24, - /* 510 */ 25, 26, 27, 28, 29, 30, 31, 32, 352, 384, - /* 520 */ 198, 199, 20, 201, 202, 203, 204, 205, 206, 207, - /* 530 */ 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, - /* 540 */ 218, 219, 12, 13, 344, 124, 22, 336, 413, 345, - /* 550 */ 20, 351, 22, 330, 331, 344, 43, 328, 328, 35, - /* 560 */ 360, 324, 33, 33, 353, 35, 96, 324, 98, 99, - /* 570 */ 341, 101, 20, 94, 22, 105, 47, 316, 335, 350, - /* 580 */ 350, 52, 53, 54, 55, 56, 56, 35, 388, 352, - /* 590 */ 326, 316, 68, 105, 20, 352, 259, 127, 68, 12, - /* 600 */ 13, 14, 50, 339, 384, 184, 185, 20, 345, 22, - /* 610 */ 324, 347, 124, 125, 126, 127, 128, 417, 357, 344, - /* 620 */ 33, 92, 35, 93, 95, 388, 324, 352, 345, 202, - /* 630 */ 430, 431, 357, 413, 359, 435, 436, 335, 352, 115, - /* 640 */ 56, 324, 316, 56, 14, 115, 409, 410, 411, 412, - /* 650 */ 20, 414, 335, 345, 352, 68, 344, 382, 21, 129, - /* 660 */ 130, 386, 387, 388, 389, 390, 391, 392, 393, 352, - /* 670 */ 395, 34, 360, 36, 388, 400, 92, 402, 324, 95, - /* 680 */ 93, 406, 407, 357, 316, 64, 65, 158, 159, 335, - /* 690 */ 161, 416, 71, 399, 165, 401, 410, 411, 412, 175, - /* 700 */ 414, 177, 115, 82, 83, 175, 352, 177, 352, 88, - /* 710 */ 181, 316, 344, 14, 15, 16, 129, 130, 0, 363, - /* 720 */ 352, 344, 198, 199, 316, 357, 376, 359, 198, 199, - /* 730 */ 353, 201, 202, 203, 204, 205, 206, 207, 208, 209, - /* 740 */ 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, - /* 750 */ 382, 254, 357, 384, 386, 387, 388, 389, 390, 391, - /* 760 */ 392, 393, 175, 395, 177, 357, 2, 237, 400, 316, - /* 770 */ 402, 258, 8, 9, 406, 407, 12, 13, 14, 15, - /* 780 */ 16, 316, 413, 316, 316, 198, 199, 39, 201, 202, - /* 790 */ 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, - /* 800 */ 213, 214, 215, 216, 217, 218, 219, 12, 13, 316, - /* 810 */ 357, 344, 336, 330, 331, 20, 349, 22, 354, 352, - /* 820 */ 344, 357, 357, 105, 357, 357, 359, 2, 33, 353, - /* 830 */ 35, 372, 202, 8, 9, 44, 45, 12, 13, 14, - /* 840 */ 15, 16, 124, 125, 126, 127, 128, 388, 20, 382, - /* 850 */ 357, 56, 316, 386, 387, 388, 389, 390, 391, 392, - /* 860 */ 393, 56, 395, 68, 12, 13, 352, 345, 368, 359, - /* 870 */ 370, 324, 20, 368, 22, 370, 417, 363, 19, 369, - /* 880 */ 316, 332, 335, 334, 317, 33, 157, 35, 93, 430, - /* 890 */ 431, 439, 33, 357, 435, 436, 333, 8, 9, 352, - /* 900 */ 95, 12, 13, 14, 15, 16, 47, 324, 56, 105, - /* 910 */ 115, 52, 53, 54, 55, 56, 372, 316, 335, 35, - /* 920 */ 68, 357, 8, 9, 129, 130, 12, 13, 14, 15, - /* 930 */ 16, 127, 388, 8, 9, 352, 93, 12, 13, 14, - /* 940 */ 15, 16, 1, 2, 337, 93, 103, 340, 324, 324, - /* 950 */ 61, 92, 68, 224, 95, 324, 35, 324, 357, 335, - /* 960 */ 335, 417, 324, 234, 42, 43, 335, 115, 335, 4, - /* 970 */ 175, 43, 177, 335, 430, 431, 352, 352, 316, 435, - /* 980 */ 436, 129, 130, 352, 236, 352, 428, 128, 235, 236, - /* 990 */ 352, 102, 316, 198, 199, 0, 201, 202, 203, 204, - /* 1000 */ 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, - /* 1010 */ 215, 216, 217, 218, 219, 324, 18, 22, 20, 357, - /* 1020 */ 161, 22, 94, 162, 163, 27, 335, 175, 30, 177, - /* 1030 */ 202, 316, 0, 357, 35, 94, 372, 316, 179, 316, - /* 1040 */ 181, 97, 316, 352, 100, 47, 157, 49, 344, 51, - /* 1050 */ 198, 199, 388, 201, 202, 203, 204, 205, 206, 207, - /* 1060 */ 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, - /* 1070 */ 218, 219, 357, 324, 97, 0, 162, 100, 357, 47, - /* 1080 */ 357, 417, 324, 357, 335, 97, 18, 43, 100, 0, - /* 1090 */ 92, 23, 0, 335, 430, 431, 61, 22, 177, 435, - /* 1100 */ 436, 352, 104, 0, 97, 37, 38, 100, 43, 41, - /* 1110 */ 352, 22, 43, 224, 225, 226, 227, 228, 229, 230, - /* 1120 */ 231, 232, 233, 234, 325, 57, 58, 59, 1, 2, - /* 1130 */ 132, 129, 130, 135, 136, 137, 138, 139, 140, 141, - /* 1140 */ 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, - /* 1150 */ 152, 424, 154, 155, 156, 43, 3, 325, 43, 94, - /* 1160 */ 43, 93, 323, 94, 43, 388, 63, 64, 65, 66, - /* 1170 */ 67, 43, 69, 70, 71, 72, 73, 74, 75, 76, - /* 1180 */ 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, - /* 1190 */ 87, 88, 89, 90, 417, 35, 324, 105, 43, 131, - /* 1200 */ 356, 385, 316, 238, 43, 46, 94, 335, 431, 94, - /* 1210 */ 13, 94, 435, 436, 432, 94, 124, 125, 126, 127, - /* 1220 */ 128, 0, 94, 415, 352, 408, 13, 418, 239, 43, - /* 1230 */ 344, 43, 35, 198, 380, 167, 168, 169, 352, 43, - /* 1240 */ 172, 47, 4, 357, 379, 359, 43, 94, 35, 94, - /* 1250 */ 43, 372, 93, 43, 173, 94, 188, 19, 42, 191, - /* 1260 */ 364, 193, 194, 195, 196, 197, 374, 388, 382, 48, - /* 1270 */ 20, 33, 386, 387, 388, 389, 390, 391, 392, 393, - /* 1280 */ 94, 395, 94, 372, 316, 47, 324, 324, 402, 51, - /* 1290 */ 94, 364, 406, 407, 56, 157, 417, 94, 362, 388, - /* 1300 */ 256, 94, 362, 417, 94, 237, 324, 324, 324, 430, - /* 1310 */ 431, 20, 344, 20, 435, 436, 430, 431, 318, 318, - /* 1320 */ 352, 435, 436, 378, 328, 357, 359, 359, 417, 20, - /* 1330 */ 92, 328, 371, 95, 20, 371, 328, 177, 328, 373, - /* 1340 */ 328, 430, 431, 328, 316, 324, 435, 436, 328, 318, - /* 1350 */ 382, 357, 378, 344, 386, 387, 388, 389, 390, 391, - /* 1360 */ 392, 393, 344, 395, 324, 318, 316, 344, 400, 344, - /* 1370 */ 402, 344, 344, 344, 406, 407, 359, 344, 344, 326, - /* 1380 */ 352, 344, 344, 344, 416, 357, 180, 359, 377, 326, - /* 1390 */ 324, 324, 244, 371, 344, 159, 326, 367, 357, 357, - /* 1400 */ 357, 365, 352, 357, 326, 357, 326, 357, 352, 359, - /* 1410 */ 382, 340, 367, 20, 386, 387, 388, 389, 390, 391, - /* 1420 */ 392, 393, 316, 395, 245, 367, 367, 423, 400, 357, - /* 1430 */ 402, 357, 382, 357, 406, 407, 386, 387, 388, 389, - /* 1440 */ 390, 391, 392, 393, 416, 395, 385, 12, 13, 423, - /* 1450 */ 344, 357, 357, 251, 166, 240, 252, 22, 352, 380, - /* 1460 */ 260, 253, 257, 357, 440, 359, 255, 417, 33, 236, - /* 1470 */ 35, 352, 20, 93, 422, 426, 425, 423, 421, 93, - /* 1480 */ 430, 431, 420, 316, 384, 435, 436, 405, 382, 434, - /* 1490 */ 348, 56, 386, 387, 388, 389, 390, 391, 392, 393, - /* 1500 */ 357, 395, 334, 68, 324, 316, 400, 326, 402, 36, - /* 1510 */ 433, 344, 406, 407, 319, 375, 318, 370, 327, 352, - /* 1520 */ 338, 338, 338, 314, 357, 0, 359, 182, 0, 0, - /* 1530 */ 42, 0, 35, 344, 0, 192, 35, 35, 35, 192, - /* 1540 */ 0, 352, 35, 35, 192, 0, 357, 192, 359, 382, - /* 1550 */ 115, 0, 35, 386, 387, 388, 389, 390, 391, 392, - /* 1560 */ 393, 0, 395, 22, 0, 35, 177, 175, 0, 402, - /* 1570 */ 0, 382, 171, 406, 407, 386, 387, 388, 389, 390, - /* 1580 */ 391, 392, 393, 170, 395, 0, 0, 0, 46, 316, - /* 1590 */ 0, 402, 0, 0, 42, 406, 407, 0, 0, 153, - /* 1600 */ 0, 0, 0, 0, 0, 148, 35, 0, 148, 0, - /* 1610 */ 175, 0, 177, 0, 0, 0, 0, 344, 0, 0, - /* 1620 */ 0, 0, 0, 0, 0, 352, 0, 0, 0, 0, - /* 1630 */ 357, 42, 359, 198, 199, 0, 0, 0, 0, 22, - /* 1640 */ 0, 0, 0, 0, 316, 210, 211, 212, 213, 214, - /* 1650 */ 215, 216, 0, 0, 0, 382, 46, 0, 14, 386, - /* 1660 */ 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, - /* 1670 */ 397, 39, 344, 42, 40, 14, 43, 0, 39, 0, - /* 1680 */ 352, 56, 0, 0, 166, 357, 56, 359, 39, 0, - /* 1690 */ 0, 46, 0, 0, 35, 47, 0, 316, 35, 0, - /* 1700 */ 35, 39, 47, 39, 0, 47, 39, 35, 39, 62, - /* 1710 */ 382, 0, 0, 47, 386, 387, 388, 389, 390, 391, - /* 1720 */ 392, 393, 0, 395, 0, 344, 35, 22, 0, 35, - /* 1730 */ 35, 43, 35, 352, 0, 35, 22, 0, 357, 22, - /* 1740 */ 359, 43, 22, 0, 35, 22, 0, 0, 35, 316, - /* 1750 */ 49, 100, 102, 35, 0, 22, 20, 0, 0, 178, - /* 1760 */ 35, 316, 22, 382, 159, 437, 438, 386, 387, 388, - /* 1770 */ 389, 390, 391, 392, 393, 316, 395, 344, 0, 0, - /* 1780 */ 3, 0, 0, 402, 0, 352, 35, 0, 407, 344, - /* 1790 */ 357, 0, 359, 187, 349, 39, 93, 352, 46, 220, - /* 1800 */ 222, 94, 357, 344, 359, 43, 43, 241, 220, 93, - /* 1810 */ 46, 352, 93, 103, 158, 382, 357, 43, 359, 386, - /* 1820 */ 387, 388, 389, 390, 391, 392, 393, 382, 395, 316, - /* 1830 */ 397, 386, 387, 388, 389, 390, 391, 392, 393, 164, - /* 1840 */ 395, 382, 162, 316, 160, 386, 387, 388, 389, 390, - /* 1850 */ 391, 392, 393, 93, 395, 94, 43, 344, 93, 93, - /* 1860 */ 46, 43, 94, 94, 162, 352, 93, 3, 162, 94, - /* 1870 */ 357, 344, 359, 93, 43, 35, 349, 94, 93, 352, - /* 1880 */ 94, 93, 93, 35, 357, 35, 359, 35, 429, 94, - /* 1890 */ 35, 35, 94, 316, 94, 382, 43, 46, 2, 386, - /* 1900 */ 387, 388, 389, 390, 391, 392, 393, 46, 395, 382, - /* 1910 */ 22, 241, 316, 386, 387, 388, 389, 390, 391, 392, - /* 1920 */ 393, 344, 395, 46, 198, 93, 349, 241, 94, 352, - /* 1930 */ 93, 46, 94, 94, 357, 93, 359, 93, 93, 46, - /* 1940 */ 344, 94, 22, 235, 200, 104, 35, 93, 352, 35, - /* 1950 */ 93, 438, 94, 357, 94, 359, 35, 94, 93, 382, - /* 1960 */ 35, 93, 316, 386, 387, 388, 389, 390, 391, 392, - /* 1970 */ 393, 35, 395, 94, 93, 35, 316, 94, 382, 93, - /* 1980 */ 22, 35, 386, 387, 388, 389, 390, 391, 392, 393, - /* 1990 */ 344, 395, 117, 117, 105, 117, 93, 117, 352, 93, - /* 2000 */ 93, 22, 43, 357, 344, 359, 62, 35, 61, 35, - /* 2010 */ 35, 35, 352, 35, 91, 35, 35, 357, 35, 359, - /* 2020 */ 35, 35, 68, 35, 35, 43, 22, 35, 382, 22, - /* 2030 */ 35, 316, 386, 387, 388, 389, 390, 391, 392, 393, - /* 2040 */ 35, 395, 382, 35, 35, 68, 386, 387, 388, 389, - /* 2050 */ 390, 391, 392, 393, 35, 395, 35, 316, 35, 344, - /* 2060 */ 35, 22, 35, 0, 35, 39, 0, 352, 35, 47, - /* 2070 */ 39, 47, 357, 0, 359, 35, 39, 47, 0, 35, - /* 2080 */ 39, 47, 0, 316, 35, 344, 35, 0, 20, 22, - /* 2090 */ 21, 441, 22, 352, 22, 21, 441, 382, 357, 441, - /* 2100 */ 359, 386, 387, 388, 389, 390, 391, 392, 393, 316, - /* 2110 */ 395, 344, 441, 441, 441, 441, 441, 441, 441, 352, - /* 2120 */ 441, 441, 441, 382, 357, 441, 359, 386, 387, 388, - /* 2130 */ 389, 390, 391, 392, 393, 316, 395, 344, 441, 441, - /* 2140 */ 441, 441, 441, 441, 441, 352, 441, 441, 441, 382, - /* 2150 */ 357, 441, 359, 386, 387, 388, 389, 390, 391, 392, - /* 2160 */ 393, 441, 395, 344, 441, 441, 441, 441, 441, 441, - /* 2170 */ 441, 352, 441, 441, 441, 382, 357, 441, 359, 386, - /* 2180 */ 387, 388, 389, 390, 391, 392, 393, 316, 395, 441, - /* 2190 */ 441, 441, 441, 441, 441, 441, 441, 441, 441, 441, - /* 2200 */ 441, 382, 441, 316, 441, 386, 387, 388, 389, 390, - /* 2210 */ 391, 392, 393, 441, 395, 344, 441, 441, 441, 441, - /* 2220 */ 441, 441, 441, 352, 441, 441, 441, 441, 357, 441, - /* 2230 */ 359, 344, 441, 441, 441, 441, 441, 441, 441, 352, - /* 2240 */ 441, 441, 441, 441, 357, 441, 359, 441, 441, 441, - /* 2250 */ 441, 441, 441, 382, 441, 441, 441, 386, 387, 388, - /* 2260 */ 389, 390, 391, 392, 393, 316, 395, 441, 441, 382, - /* 2270 */ 441, 441, 441, 386, 387, 388, 389, 390, 391, 392, - /* 2280 */ 393, 316, 395, 441, 441, 441, 441, 441, 441, 441, - /* 2290 */ 441, 441, 441, 344, 441, 441, 441, 441, 441, 441, - /* 2300 */ 441, 352, 441, 441, 441, 441, 357, 441, 359, 344, - /* 2310 */ 441, 441, 441, 441, 441, 441, 441, 352, 441, 441, - /* 2320 */ 441, 441, 357, 441, 359, 441, 441, 441, 441, 441, - /* 2330 */ 441, 382, 441, 441, 316, 386, 387, 388, 389, 390, - /* 2340 */ 391, 392, 393, 441, 395, 441, 441, 382, 316, 441, - /* 2350 */ 441, 386, 387, 388, 389, 390, 391, 392, 393, 441, - /* 2360 */ 395, 441, 344, 441, 441, 441, 441, 441, 441, 441, - /* 2370 */ 352, 441, 441, 441, 441, 357, 344, 359, 441, 441, - /* 2380 */ 441, 441, 441, 441, 352, 441, 441, 441, 441, 357, - /* 2390 */ 441, 359, 441, 441, 441, 441, 441, 441, 441, 441, - /* 2400 */ 382, 441, 316, 441, 386, 387, 388, 389, 390, 391, - /* 2410 */ 392, 393, 441, 395, 382, 441, 441, 441, 386, 387, - /* 2420 */ 388, 389, 390, 391, 392, 393, 316, 395, 441, 441, - /* 2430 */ 344, 441, 441, 441, 441, 441, 441, 441, 352, 441, - /* 2440 */ 441, 441, 441, 357, 441, 359, 441, 441, 441, 441, - /* 2450 */ 441, 441, 316, 441, 344, 441, 441, 441, 441, 441, - /* 2460 */ 441, 441, 352, 441, 441, 441, 441, 357, 382, 359, - /* 2470 */ 441, 441, 386, 387, 388, 389, 390, 391, 392, 393, - /* 2480 */ 344, 395, 441, 441, 441, 441, 441, 441, 352, 441, - /* 2490 */ 441, 441, 382, 357, 441, 359, 386, 387, 388, 389, - /* 2500 */ 390, 391, 392, 393, 316, 395, 441, 441, 441, 441, - /* 2510 */ 441, 441, 441, 441, 441, 441, 441, 441, 382, 441, - /* 2520 */ 316, 441, 386, 387, 388, 389, 390, 391, 392, 393, - /* 2530 */ 441, 395, 344, 441, 441, 441, 441, 441, 441, 441, - /* 2540 */ 352, 441, 441, 441, 441, 357, 441, 359, 344, 441, - /* 2550 */ 441, 441, 441, 441, 441, 441, 352, 441, 441, 441, - /* 2560 */ 441, 357, 441, 359, 441, 441, 441, 441, 441, 441, - /* 2570 */ 382, 441, 441, 441, 386, 387, 388, 389, 390, 391, - /* 2580 */ 392, 393, 316, 395, 441, 441, 382, 441, 441, 441, - /* 2590 */ 386, 387, 388, 389, 390, 391, 392, 393, 441, 395, - /* 2600 */ 441, 441, 441, 441, 441, 441, 441, 441, 441, 441, - /* 2610 */ 344, 441, 441, 441, 441, 441, 441, 441, 352, 441, - /* 2620 */ 441, 441, 441, 357, 441, 359, 441, 441, 441, 441, - /* 2630 */ 441, 441, 441, 441, 441, 441, 441, 441, 441, 441, - /* 2640 */ 441, 441, 441, 441, 441, 441, 441, 441, 382, 441, - /* 2650 */ 441, 441, 386, 387, 388, 389, 390, 391, 392, 393, - /* 2660 */ 441, 395, + /* 270 */ 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, + /* 280 */ 223, 12, 13, 126, 93, 184, 348, 96, 187, 20, + /* 290 */ 341, 22, 97, 320, 99, 100, 394, 102, 349, 361, + /* 300 */ 328, 106, 33, 241, 35, 320, 21, 358, 20, 24, + /* 310 */ 25, 26, 27, 28, 29, 30, 31, 32, 416, 417, + /* 320 */ 418, 241, 420, 128, 241, 56, 20, 349, 241, 357, + /* 330 */ 61, 351, 161, 320, 356, 362, 125, 68, 12, 13, + /* 340 */ 183, 184, 362, 365, 187, 357, 20, 362, 22, 328, + /* 350 */ 159, 160, 94, 162, 14, 328, 368, 166, 330, 33, + /* 360 */ 20, 35, 349, 94, 328, 14, 394, 340, 388, 389, + /* 370 */ 357, 20, 344, 182, 347, 362, 340, 364, 357, 349, + /* 380 */ 352, 401, 56, 347, 357, 116, 356, 61, 416, 417, + /* 390 */ 418, 22, 420, 357, 68, 365, 185, 186, 385, 130, + /* 400 */ 131, 200, 389, 0, 35, 341, 393, 394, 395, 396, + /* 410 */ 397, 398, 399, 349, 401, 394, 35, 246, 247, 406, + /* 420 */ 94, 408, 358, 158, 204, 412, 413, 24, 25, 26, + /* 430 */ 27, 28, 29, 30, 31, 32, 3, 416, 417, 418, + /* 440 */ 78, 420, 116, 332, 423, 176, 433, 178, 21, 68, + /* 450 */ 341, 250, 251, 252, 253, 254, 130, 131, 349, 438, + /* 460 */ 439, 34, 20, 36, 443, 444, 355, 358, 20, 200, + /* 470 */ 201, 0, 203, 204, 205, 206, 207, 208, 209, 210, + /* 480 */ 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, + /* 490 */ 221, 222, 223, 228, 225, 325, 134, 135, 328, 241, + /* 500 */ 335, 336, 176, 238, 178, 68, 107, 108, 109, 110, + /* 510 */ 111, 112, 113, 114, 115, 116, 117, 320, 119, 120, + /* 520 */ 121, 122, 123, 124, 391, 394, 200, 201, 95, 203, + /* 530 */ 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, + /* 540 */ 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, + /* 550 */ 12, 13, 419, 328, 423, 204, 335, 336, 20, 362, + /* 560 */ 22, 225, 35, 227, 328, 340, 328, 105, 320, 325, + /* 570 */ 439, 33, 328, 35, 443, 444, 340, 106, 340, 320, + /* 580 */ 8, 9, 357, 320, 12, 13, 14, 15, 16, 328, + /* 590 */ 1, 2, 20, 357, 56, 357, 125, 126, 127, 128, + /* 600 */ 129, 340, 320, 0, 328, 163, 68, 12, 13, 14, + /* 610 */ 362, 328, 349, 320, 328, 20, 340, 22, 357, 391, + /* 620 */ 357, 362, 349, 340, 320, 362, 340, 364, 33, 349, + /* 630 */ 35, 349, 94, 357, 225, 405, 356, 407, 365, 357, + /* 640 */ 357, 328, 56, 357, 362, 365, 364, 419, 385, 320, + /* 650 */ 330, 56, 389, 340, 116, 362, 393, 394, 395, 396, + /* 660 */ 397, 398, 399, 68, 401, 68, 362, 385, 130, 131, + /* 670 */ 357, 389, 352, 320, 394, 393, 394, 395, 396, 397, + /* 680 */ 398, 399, 96, 401, 95, 373, 423, 375, 406, 94, + /* 690 */ 408, 362, 8, 9, 412, 413, 12, 13, 14, 15, + /* 700 */ 16, 438, 439, 423, 422, 178, 443, 444, 328, 106, + /* 710 */ 405, 116, 407, 171, 176, 362, 178, 317, 438, 439, + /* 720 */ 340, 44, 45, 443, 444, 130, 131, 43, 125, 126, + /* 730 */ 127, 128, 129, 191, 192, 163, 320, 357, 200, 201, + /* 740 */ 350, 203, 204, 205, 206, 207, 208, 209, 210, 211, + /* 750 */ 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, + /* 760 */ 222, 223, 8, 9, 328, 350, 12, 13, 14, 15, + /* 770 */ 16, 176, 342, 178, 357, 345, 340, 377, 362, 241, + /* 780 */ 3, 20, 8, 9, 320, 368, 12, 13, 14, 15, + /* 790 */ 16, 0, 320, 357, 394, 200, 201, 39, 203, 204, + /* 800 */ 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, + /* 810 */ 215, 216, 217, 218, 219, 220, 221, 222, 223, 12, + /* 820 */ 13, 328, 22, 423, 320, 320, 362, 20, 43, 22, + /* 830 */ 320, 364, 350, 340, 362, 35, 328, 35, 438, 439, + /* 840 */ 33, 374, 35, 443, 444, 350, 320, 2, 340, 95, + /* 850 */ 357, 4, 320, 8, 9, 64, 65, 12, 13, 14, + /* 860 */ 15, 16, 71, 56, 320, 357, 362, 362, 68, 394, + /* 870 */ 68, 320, 362, 82, 83, 68, 12, 13, 328, 88, + /* 880 */ 328, 349, 391, 328, 20, 373, 22, 375, 362, 357, + /* 890 */ 340, 357, 340, 328, 362, 340, 364, 33, 423, 35, + /* 900 */ 349, 94, 368, 239, 240, 340, 362, 357, 357, 357, + /* 910 */ 419, 20, 357, 362, 439, 364, 116, 385, 443, 444, + /* 920 */ 56, 389, 357, 116, 163, 393, 394, 395, 396, 397, + /* 930 */ 398, 399, 68, 401, 106, 350, 385, 130, 131, 320, + /* 940 */ 389, 328, 168, 328, 393, 394, 395, 396, 397, 398, + /* 950 */ 399, 404, 401, 340, 407, 340, 128, 406, 94, 408, + /* 960 */ 337, 350, 339, 412, 413, 359, 434, 435, 362, 381, + /* 970 */ 357, 359, 357, 422, 362, 0, 176, 350, 178, 342, + /* 980 */ 116, 362, 345, 176, 43, 178, 42, 43, 98, 105, + /* 990 */ 98, 101, 43, 101, 130, 131, 98, 22, 240, 101, + /* 1000 */ 200, 201, 0, 98, 163, 164, 101, 200, 201, 0, + /* 1010 */ 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, + /* 1020 */ 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, + /* 1030 */ 223, 22, 130, 131, 43, 258, 95, 263, 154, 35, + /* 1040 */ 176, 43, 178, 321, 95, 260, 8, 9, 61, 47, + /* 1050 */ 12, 13, 14, 15, 16, 8, 9, 43, 392, 12, + /* 1060 */ 13, 14, 15, 16, 200, 201, 0, 203, 204, 205, + /* 1070 */ 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, + /* 1080 */ 216, 217, 218, 219, 220, 221, 222, 223, 18, 242, + /* 1090 */ 20, 1, 2, 95, 94, 204, 0, 27, 447, 436, + /* 1100 */ 30, 13, 13, 338, 104, 329, 8, 9, 43, 95, + /* 1110 */ 12, 13, 14, 15, 16, 43, 43, 47, 22, 49, + /* 1120 */ 43, 51, 43, 35, 35, 0, 430, 43, 349, 63, + /* 1130 */ 64, 65, 66, 67, 43, 69, 70, 71, 72, 73, + /* 1140 */ 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, + /* 1150 */ 84, 85, 86, 87, 88, 89, 90, 18, 329, 327, + /* 1160 */ 95, 392, 23, 93, 361, 421, 440, 95, 95, 414, + /* 1170 */ 424, 243, 95, 48, 95, 105, 37, 38, 377, 95, + /* 1180 */ 41, 387, 178, 46, 43, 43, 95, 200, 379, 43, + /* 1190 */ 47, 43, 386, 95, 43, 394, 57, 58, 59, 174, + /* 1200 */ 42, 163, 369, 133, 369, 320, 136, 137, 138, 139, + /* 1210 */ 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, + /* 1220 */ 150, 151, 152, 153, 423, 155, 156, 157, 20, 328, + /* 1230 */ 369, 94, 328, 94, 349, 367, 95, 95, 158, 438, + /* 1240 */ 439, 95, 357, 95, 443, 444, 95, 362, 367, 364, + /* 1250 */ 334, 8, 9, 262, 92, 12, 13, 14, 15, 16, + /* 1260 */ 328, 20, 328, 328, 322, 322, 20, 364, 332, 383, + /* 1270 */ 385, 132, 332, 20, 389, 376, 20, 332, 393, 394, + /* 1280 */ 395, 396, 397, 398, 399, 378, 401, 64, 65, 404, + /* 1290 */ 376, 406, 407, 408, 71, 332, 332, 412, 413, 332, + /* 1300 */ 328, 377, 332, 377, 61, 82, 83, 168, 169, 170, + /* 1310 */ 377, 88, 173, 328, 322, 349, 320, 349, 394, 322, + /* 1320 */ 394, 362, 349, 349, 189, 349, 349, 394, 349, 190, + /* 1330 */ 349, 349, 193, 383, 195, 196, 197, 198, 199, 349, + /* 1340 */ 384, 330, 349, 382, 181, 349, 103, 423, 330, 423, + /* 1350 */ 364, 328, 328, 357, 376, 248, 423, 330, 362, 160, + /* 1360 */ 364, 377, 438, 439, 438, 439, 372, 443, 444, 443, + /* 1370 */ 444, 438, 439, 372, 362, 362, 443, 444, 394, 362, + /* 1380 */ 241, 385, 362, 362, 330, 389, 370, 345, 330, 393, + /* 1390 */ 394, 395, 396, 397, 398, 399, 357, 401, 20, 392, + /* 1400 */ 392, 158, 406, 362, 408, 249, 372, 423, 412, 413, + /* 1410 */ 19, 362, 429, 362, 362, 372, 255, 429, 422, 362, + /* 1420 */ 431, 320, 438, 439, 33, 167, 257, 443, 444, 256, + /* 1430 */ 244, 432, 429, 428, 264, 387, 261, 427, 47, 259, + /* 1440 */ 240, 426, 357, 52, 53, 54, 55, 56, 20, 94, + /* 1450 */ 349, 391, 94, 353, 448, 411, 362, 339, 357, 328, + /* 1460 */ 330, 442, 36, 362, 320, 364, 380, 441, 323, 322, + /* 1470 */ 375, 228, 229, 230, 231, 232, 233, 234, 235, 236, + /* 1480 */ 237, 238, 318, 343, 93, 331, 385, 96, 0, 0, + /* 1490 */ 389, 183, 343, 349, 393, 394, 395, 396, 397, 398, + /* 1500 */ 399, 357, 401, 343, 0, 0, 362, 406, 364, 408, + /* 1510 */ 42, 12, 13, 412, 413, 0, 35, 320, 194, 35, + /* 1520 */ 129, 22, 35, 194, 0, 35, 35, 35, 194, 385, + /* 1530 */ 0, 194, 33, 389, 35, 0, 35, 393, 394, 395, + /* 1540 */ 396, 397, 398, 399, 35, 401, 349, 0, 22, 0, + /* 1550 */ 406, 178, 408, 162, 357, 56, 412, 413, 176, 362, + /* 1560 */ 0, 364, 0, 0, 172, 171, 0, 68, 0, 46, + /* 1570 */ 320, 180, 0, 182, 0, 42, 0, 0, 0, 42, + /* 1580 */ 0, 0, 385, 0, 0, 0, 389, 0, 149, 35, + /* 1590 */ 393, 394, 395, 396, 397, 398, 399, 0, 401, 349, + /* 1600 */ 149, 0, 0, 406, 22, 408, 0, 357, 0, 412, + /* 1610 */ 413, 0, 362, 320, 364, 116, 0, 0, 0, 0, + /* 1620 */ 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, + /* 1630 */ 0, 0, 0, 0, 0, 385, 0, 0, 35, 389, + /* 1640 */ 0, 0, 349, 393, 394, 395, 396, 397, 398, 399, + /* 1650 */ 357, 401, 56, 0, 56, 362, 42, 364, 408, 14, + /* 1660 */ 14, 46, 412, 413, 167, 0, 320, 39, 0, 0, + /* 1670 */ 0, 0, 0, 0, 39, 176, 0, 178, 385, 0, + /* 1680 */ 0, 43, 389, 40, 35, 46, 393, 394, 395, 396, + /* 1690 */ 397, 398, 399, 39, 401, 349, 39, 47, 35, 200, + /* 1700 */ 201, 408, 47, 357, 62, 412, 413, 0, 362, 35, + /* 1710 */ 364, 0, 0, 214, 215, 216, 217, 218, 219, 220, + /* 1720 */ 39, 39, 320, 35, 47, 47, 39, 0, 0, 0, + /* 1730 */ 35, 385, 22, 0, 35, 389, 35, 43, 35, 393, + /* 1740 */ 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, + /* 1750 */ 35, 349, 43, 101, 103, 0, 22, 22, 0, 357, + /* 1760 */ 22, 0, 49, 22, 362, 35, 364, 0, 0, 0, + /* 1770 */ 22, 20, 35, 0, 35, 163, 0, 35, 95, 94, + /* 1780 */ 0, 22, 0, 0, 320, 94, 179, 385, 0, 4, + /* 1790 */ 3, 389, 0, 95, 0, 393, 394, 395, 396, 397, + /* 1800 */ 398, 399, 94, 401, 19, 35, 0, 163, 160, 104, + /* 1810 */ 94, 39, 46, 349, 94, 224, 226, 43, 33, 163, + /* 1820 */ 161, 357, 43, 165, 224, 159, 362, 95, 364, 43, + /* 1830 */ 46, 3, 47, 245, 94, 46, 51, 94, 43, 95, + /* 1840 */ 95, 56, 320, 94, 43, 95, 94, 445, 446, 385, + /* 1850 */ 188, 94, 43, 389, 94, 245, 94, 393, 394, 395, + /* 1860 */ 396, 397, 398, 399, 320, 401, 95, 35, 35, 35, + /* 1870 */ 95, 349, 408, 95, 35, 35, 354, 413, 93, 357, + /* 1880 */ 35, 96, 46, 46, 362, 95, 364, 43, 95, 46, + /* 1890 */ 2, 22, 200, 349, 94, 46, 46, 95, 94, 94, + /* 1900 */ 239, 357, 95, 95, 94, 245, 362, 385, 364, 94, + /* 1910 */ 94, 389, 95, 22, 95, 393, 394, 395, 396, 397, + /* 1920 */ 398, 399, 35, 401, 320, 202, 105, 35, 35, 385, + /* 1930 */ 95, 35, 94, 389, 35, 94, 94, 393, 394, 395, + /* 1940 */ 396, 397, 398, 399, 35, 401, 95, 403, 95, 94, + /* 1950 */ 22, 95, 94, 349, 106, 94, 94, 35, 94, 43, + /* 1960 */ 22, 357, 62, 61, 118, 118, 362, 320, 364, 35, + /* 1970 */ 118, 35, 118, 68, 35, 35, 35, 35, 35, 35, + /* 1980 */ 35, 35, 22, 22, 320, 91, 35, 35, 35, 385, + /* 1990 */ 43, 35, 35, 389, 35, 68, 349, 393, 394, 395, + /* 2000 */ 396, 397, 398, 399, 357, 401, 35, 35, 35, 362, + /* 2010 */ 35, 364, 35, 349, 22, 35, 0, 35, 39, 0, + /* 2020 */ 35, 357, 39, 47, 0, 47, 362, 39, 364, 35, + /* 2030 */ 0, 47, 385, 35, 47, 39, 389, 0, 320, 435, + /* 2040 */ 393, 394, 395, 396, 397, 398, 399, 35, 401, 385, + /* 2050 */ 35, 0, 21, 389, 22, 22, 320, 393, 394, 395, + /* 2060 */ 396, 397, 398, 399, 22, 401, 21, 349, 20, 449, + /* 2070 */ 449, 449, 354, 449, 449, 357, 449, 449, 449, 449, + /* 2080 */ 362, 449, 364, 449, 437, 349, 449, 449, 449, 449, + /* 2090 */ 354, 449, 449, 357, 449, 449, 449, 449, 362, 449, + /* 2100 */ 364, 449, 449, 385, 449, 449, 449, 389, 449, 449, + /* 2110 */ 446, 393, 394, 395, 396, 397, 398, 399, 320, 401, + /* 2120 */ 449, 385, 449, 449, 449, 389, 449, 449, 449, 393, + /* 2130 */ 394, 395, 396, 397, 398, 399, 449, 401, 449, 449, + /* 2140 */ 449, 449, 320, 449, 449, 449, 449, 349, 449, 449, + /* 2150 */ 449, 449, 449, 449, 449, 357, 449, 449, 449, 449, + /* 2160 */ 362, 449, 364, 449, 449, 449, 449, 449, 449, 449, + /* 2170 */ 449, 349, 449, 449, 449, 449, 449, 449, 449, 357, + /* 2180 */ 449, 449, 449, 385, 362, 320, 364, 389, 449, 449, + /* 2190 */ 449, 393, 394, 395, 396, 397, 398, 399, 449, 401, + /* 2200 */ 449, 449, 449, 449, 449, 320, 449, 385, 449, 449, + /* 2210 */ 449, 389, 449, 449, 349, 393, 394, 395, 396, 397, + /* 2220 */ 398, 399, 357, 401, 449, 449, 449, 362, 449, 364, + /* 2230 */ 449, 449, 449, 449, 349, 449, 449, 449, 449, 449, + /* 2240 */ 449, 449, 357, 449, 449, 449, 449, 362, 449, 364, + /* 2250 */ 385, 449, 449, 449, 389, 449, 449, 449, 393, 394, + /* 2260 */ 395, 396, 397, 398, 399, 449, 401, 449, 320, 449, + /* 2270 */ 385, 449, 449, 449, 389, 449, 449, 449, 393, 394, + /* 2280 */ 395, 396, 397, 398, 399, 449, 401, 320, 449, 449, + /* 2290 */ 449, 449, 449, 449, 449, 449, 449, 349, 449, 449, + /* 2300 */ 449, 449, 449, 449, 449, 357, 449, 449, 449, 449, + /* 2310 */ 362, 449, 364, 449, 449, 449, 349, 449, 449, 449, + /* 2320 */ 449, 449, 449, 449, 357, 449, 449, 449, 449, 362, + /* 2330 */ 320, 364, 449, 385, 449, 449, 449, 389, 449, 449, + /* 2340 */ 449, 393, 394, 395, 396, 397, 398, 399, 449, 401, + /* 2350 */ 449, 449, 385, 449, 449, 449, 389, 449, 449, 349, + /* 2360 */ 393, 394, 395, 396, 397, 398, 399, 357, 401, 449, + /* 2370 */ 449, 449, 362, 449, 364, 449, 449, 449, 449, 449, + /* 2380 */ 449, 320, 449, 449, 449, 449, 449, 449, 449, 449, + /* 2390 */ 449, 449, 449, 449, 449, 385, 449, 449, 449, 389, + /* 2400 */ 449, 320, 449, 393, 394, 395, 396, 397, 398, 399, + /* 2410 */ 349, 401, 449, 449, 449, 449, 449, 449, 357, 449, + /* 2420 */ 449, 449, 449, 362, 449, 364, 449, 449, 449, 449, + /* 2430 */ 349, 449, 449, 449, 449, 449, 449, 449, 357, 449, + /* 2440 */ 449, 449, 449, 362, 449, 364, 385, 449, 449, 449, + /* 2450 */ 389, 449, 320, 449, 393, 394, 395, 396, 397, 398, + /* 2460 */ 399, 449, 401, 449, 449, 449, 385, 449, 449, 449, + /* 2470 */ 389, 449, 449, 449, 393, 394, 395, 396, 397, 398, + /* 2480 */ 399, 349, 401, 449, 449, 449, 449, 449, 449, 357, + /* 2490 */ 449, 449, 449, 449, 362, 449, 364, 449, 449, 449, + /* 2500 */ 449, 449, 449, 449, 449, 320, 449, 449, 449, 449, + /* 2510 */ 449, 449, 449, 449, 449, 449, 449, 385, 449, 449, + /* 2520 */ 449, 389, 449, 449, 449, 393, 394, 395, 396, 397, + /* 2530 */ 398, 399, 449, 401, 349, 449, 449, 449, 449, 449, + /* 2540 */ 449, 449, 357, 449, 449, 449, 449, 362, 320, 364, + /* 2550 */ 449, 449, 449, 449, 449, 449, 449, 449, 449, 449, + /* 2560 */ 449, 449, 449, 449, 449, 449, 449, 449, 320, 449, + /* 2570 */ 385, 449, 449, 449, 389, 449, 449, 349, 393, 394, + /* 2580 */ 395, 396, 397, 398, 399, 357, 401, 449, 449, 449, + /* 2590 */ 362, 449, 364, 449, 449, 449, 449, 349, 449, 449, + /* 2600 */ 449, 449, 449, 449, 449, 357, 449, 449, 449, 449, + /* 2610 */ 362, 449, 364, 385, 449, 449, 449, 389, 449, 449, + /* 2620 */ 449, 393, 394, 395, 396, 397, 398, 399, 449, 401, + /* 2630 */ 449, 320, 449, 385, 449, 449, 449, 389, 449, 449, + /* 2640 */ 449, 393, 394, 395, 396, 397, 398, 399, 449, 401, + /* 2650 */ 320, 449, 449, 449, 449, 449, 449, 449, 449, 449, + /* 2660 */ 349, 449, 449, 449, 449, 449, 449, 449, 357, 449, + /* 2670 */ 449, 449, 449, 362, 449, 364, 449, 449, 449, 349, + /* 2680 */ 449, 449, 449, 449, 449, 449, 449, 357, 449, 449, + /* 2690 */ 449, 449, 362, 320, 364, 449, 385, 449, 449, 449, + /* 2700 */ 389, 449, 449, 449, 393, 394, 395, 396, 397, 398, + /* 2710 */ 399, 449, 401, 449, 449, 385, 449, 449, 449, 389, + /* 2720 */ 449, 449, 349, 393, 394, 395, 396, 397, 398, 399, + /* 2730 */ 357, 401, 449, 449, 449, 362, 449, 364, 449, 449, + /* 2740 */ 449, 449, 449, 449, 320, 449, 449, 449, 449, 449, + /* 2750 */ 449, 449, 449, 449, 449, 449, 449, 449, 385, 449, + /* 2760 */ 449, 449, 389, 449, 320, 449, 393, 394, 395, 396, + /* 2770 */ 397, 398, 399, 349, 401, 449, 449, 449, 449, 449, + /* 2780 */ 449, 357, 449, 449, 449, 449, 362, 449, 364, 449, + /* 2790 */ 449, 449, 449, 349, 449, 449, 449, 449, 449, 449, + /* 2800 */ 449, 357, 449, 449, 449, 449, 362, 449, 364, 385, + /* 2810 */ 449, 449, 449, 389, 449, 320, 449, 393, 394, 395, + /* 2820 */ 396, 397, 398, 399, 449, 401, 449, 449, 449, 385, + /* 2830 */ 449, 449, 449, 389, 449, 449, 449, 393, 394, 395, + /* 2840 */ 396, 397, 398, 399, 349, 401, 449, 449, 449, 449, + /* 2850 */ 449, 449, 357, 449, 449, 449, 449, 362, 449, 364, + /* 2860 */ 449, 449, 449, 449, 449, 449, 449, 449, 320, 449, + /* 2870 */ 449, 449, 449, 449, 449, 449, 449, 449, 449, 449, + /* 2880 */ 385, 449, 449, 449, 389, 449, 449, 449, 393, 394, + /* 2890 */ 395, 396, 397, 398, 399, 449, 401, 349, 449, 449, + /* 2900 */ 449, 449, 449, 449, 449, 357, 449, 449, 449, 449, + /* 2910 */ 362, 320, 364, 449, 449, 449, 449, 449, 449, 449, + /* 2920 */ 449, 449, 449, 449, 449, 449, 449, 449, 449, 449, + /* 2930 */ 449, 449, 449, 385, 449, 449, 449, 389, 449, 449, + /* 2940 */ 349, 393, 394, 395, 396, 397, 398, 399, 357, 401, + /* 2950 */ 449, 449, 449, 362, 449, 364, 449, 449, 449, 449, + /* 2960 */ 449, 449, 449, 449, 449, 449, 449, 449, 449, 449, + /* 2970 */ 449, 449, 449, 449, 449, 449, 385, 449, 449, 449, + /* 2980 */ 389, 449, 449, 449, 393, 394, 395, 396, 397, 398, + /* 2990 */ 399, 449, 401, }; -#define YY_SHIFT_COUNT (678) +#define YY_SHIFT_COUNT (692) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (2087) +#define YY_SHIFT_MAX (2051) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 1068, 0, 57, 265, 57, 322, 322, 322, 530, 322, - /* 10 */ 322, 322, 322, 322, 587, 795, 852, 795, 795, 795, - /* 20 */ 795, 795, 795, 795, 795, 795, 795, 795, 795, 795, - /* 30 */ 795, 795, 795, 795, 795, 795, 795, 795, 795, 795, - /* 40 */ 795, 795, 795, 795, 16, 266, 39, 208, 269, 14, - /* 50 */ 59, 14, 39, 39, 1435, 1435, 14, 1435, 1435, 62, - /* 60 */ 14, 17, 17, 13, 13, 268, 17, 17, 17, 17, - /* 70 */ 17, 17, 17, 17, 17, 17, 68, 17, 17, 17, - /* 80 */ 171, 17, 17, 442, 17, 17, 442, 502, 17, 442, - /* 90 */ 442, 442, 17, 163, 998, 889, 889, 429, 524, 524, - /* 100 */ 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, - /* 110 */ 524, 524, 524, 524, 524, 524, 524, 470, 621, 12, - /* 120 */ 268, 58, 58, 327, 328, 438, 101, 101, 9, 9, - /* 130 */ 9, 328, 574, 574, 171, 2, 2, 63, 442, 442, - /* 140 */ 381, 381, 233, 440, 196, 196, 196, 196, 196, 196, - /* 150 */ 196, 859, 402, 337, 34, 43, 552, 179, 427, 630, - /* 160 */ 232, 791, 804, 334, 753, 748, 497, 753, 922, 965, - /* 170 */ 828, 989, 1194, 1081, 1216, 1250, 1250, 1216, 1138, 1138, - /* 180 */ 1250, 1250, 1250, 1291, 1291, 1293, 68, 171, 68, 1309, - /* 190 */ 1314, 68, 1309, 68, 68, 68, 1250, 68, 1291, 442, - /* 200 */ 442, 442, 442, 442, 442, 442, 442, 442, 442, 442, - /* 210 */ 1250, 1291, 381, 1293, 163, 1206, 171, 163, 1250, 1250, - /* 220 */ 1309, 163, 1148, 381, 381, 381, 381, 1148, 381, 1236, - /* 230 */ 163, 233, 163, 574, 1393, 381, 1179, 1148, 381, 381, - /* 240 */ 1179, 1148, 381, 381, 442, 1202, 1288, 1179, 1208, 1204, - /* 250 */ 1215, 989, 1200, 1205, 1211, 1233, 574, 1452, 1380, 1386, - /* 260 */ 381, 440, 1250, 163, 1473, 1291, 2662, 2662, 2662, 2662, - /* 270 */ 2662, 2662, 2662, 1103, 529, 485, 1238, 234, 396, 479, - /* 280 */ 764, 825, 914, 718, 925, 925, 925, 925, 925, 925, - /* 290 */ 925, 925, 925, 1092, 488, 11, 11, 6, 205, 203, - /* 300 */ 584, 242, 637, 421, 699, 941, 729, 699, 699, 699, - /* 310 */ 928, 1032, 999, 944, 977, 988, 1007, 995, 1075, 1089, - /* 320 */ 805, 861, 1065, 1069, 1112, 1115, 1117, 1121, 1128, 1002, - /* 330 */ 1044, 513, 1127, 1155, 921, 1160, 1035, 1161, 1153, 1159, - /* 340 */ 1186, 1188, 1196, 1203, 1207, 1210, 843, 1197, 1213, 884, - /* 350 */ 1221, 1525, 1534, 1345, 1528, 1529, 1488, 1531, 1497, 1343, - /* 360 */ 1501, 1502, 1503, 1347, 1540, 1507, 1508, 1352, 1545, 1355, - /* 370 */ 1551, 1517, 1561, 1541, 1564, 1530, 1389, 1392, 1568, 1570, - /* 380 */ 1401, 1413, 1585, 1586, 1542, 1587, 1590, 1592, 1552, 1593, - /* 390 */ 1597, 1598, 1446, 1600, 1601, 1602, 1603, 1604, 1457, 1571, - /* 400 */ 1607, 1460, 1609, 1611, 1613, 1614, 1615, 1616, 1618, 1619, - /* 410 */ 1620, 1621, 1622, 1623, 1624, 1626, 1589, 1627, 1628, 1629, - /* 420 */ 1635, 1636, 1637, 1617, 1638, 1640, 1641, 1642, 1643, 1625, - /* 430 */ 1652, 1630, 1653, 1654, 1631, 1632, 1633, 1644, 1610, 1661, - /* 440 */ 1645, 1657, 1634, 1639, 1677, 1679, 1682, 1649, 1518, 1683, - /* 450 */ 1689, 1690, 1647, 1692, 1693, 1659, 1648, 1662, 1696, 1663, - /* 460 */ 1655, 1664, 1699, 1665, 1658, 1667, 1704, 1672, 1666, 1669, - /* 470 */ 1711, 1712, 1722, 1724, 1650, 1651, 1691, 1705, 1728, 1694, - /* 480 */ 1695, 1688, 1698, 1697, 1700, 1714, 1734, 1717, 1737, 1720, - /* 490 */ 1701, 1743, 1723, 1709, 1746, 1713, 1747, 1718, 1754, 1733, - /* 500 */ 1736, 1757, 1680, 1725, 1758, 1581, 1740, 1702, 1605, 1778, - /* 510 */ 1779, 1706, 1675, 1777, 1781, 1782, 1784, 1703, 1707, 1751, - /* 520 */ 1606, 1787, 1716, 1684, 1719, 1791, 1756, 1656, 1760, 1710, - /* 530 */ 1752, 1762, 1579, 1578, 1588, 1763, 1566, 1765, 1761, 1766, - /* 540 */ 1768, 1769, 1773, 1774, 1775, 1780, 1785, 1788, 1783, 1813, - /* 550 */ 1764, 1814, 1789, 1818, 1670, 1786, 1795, 1864, 1831, 1686, - /* 560 */ 1840, 1848, 1850, 1852, 1855, 1856, 1798, 1800, 1851, 1708, - /* 570 */ 1853, 1861, 1877, 1896, 1888, 1726, 1832, 1834, 1837, 1838, - /* 580 */ 1842, 1839, 1885, 1844, 1845, 1893, 1847, 1920, 1744, 1854, - /* 590 */ 1841, 1858, 1911, 1914, 1857, 1860, 1921, 1865, 1863, 1925, - /* 600 */ 1868, 1879, 1936, 1881, 1883, 1940, 1886, 1875, 1876, 1878, - /* 610 */ 1880, 1958, 1889, 1903, 1906, 1946, 1907, 1959, 1959, 1979, - /* 620 */ 1944, 1947, 1972, 1974, 1975, 1976, 1978, 1980, 1981, 1983, - /* 630 */ 1985, 1986, 1954, 1923, 1982, 1988, 1989, 2004, 1992, 2007, - /* 640 */ 1995, 2005, 2008, 1977, 1688, 2009, 1698, 2019, 2021, 2023, - /* 650 */ 2025, 2039, 2027, 2063, 2029, 2022, 2026, 2066, 2033, 2024, - /* 660 */ 2031, 2073, 2040, 2030, 2037, 2078, 2044, 2034, 2041, 2082, - /* 670 */ 2049, 2051, 2087, 2067, 2069, 2070, 2072, 2074, 2068, + /* 0 */ 1139, 0, 57, 269, 57, 326, 326, 326, 538, 326, + /* 10 */ 326, 326, 326, 326, 595, 807, 807, 864, 807, 807, + /* 20 */ 807, 807, 807, 807, 807, 807, 807, 807, 807, 807, + /* 30 */ 807, 807, 807, 807, 807, 807, 807, 807, 807, 807, + /* 40 */ 807, 807, 807, 807, 807, 807, 12, 14, 90, 62, + /* 50 */ 83, 80, 258, 80, 90, 90, 1499, 1499, 80, 1499, + /* 60 */ 1499, 87, 80, 113, 113, 53, 53, 23, 113, 113, + /* 70 */ 113, 113, 113, 113, 113, 113, 113, 113, 43, 113, + /* 80 */ 113, 113, 208, 113, 113, 288, 113, 113, 288, 306, + /* 90 */ 113, 288, 288, 288, 113, 142, 1070, 1243, 1243, 285, + /* 100 */ 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, + /* 110 */ 800, 800, 800, 800, 800, 800, 800, 800, 800, 195, + /* 120 */ 1223, 26, 23, 340, 340, 54, 381, 182, 336, 336, + /* 130 */ 442, 442, 442, 381, 448, 448, 448, 462, 208, 1, + /* 140 */ 1, 409, 288, 288, 437, 437, 462, 597, 399, 399, + /* 150 */ 399, 399, 399, 399, 399, 1391, 137, 572, 774, 791, + /* 160 */ 201, 67, 171, 220, 351, 130, 677, 828, 761, 664, + /* 170 */ 758, 777, 664, 944, 847, 891, 928, 1143, 1025, 1158, + /* 180 */ 1158, 1208, 1208, 1158, 1080, 1080, 1162, 1208, 1208, 1208, + /* 190 */ 1241, 1241, 1246, 43, 208, 43, 1253, 1256, 43, 1253, + /* 200 */ 43, 43, 43, 1208, 43, 1241, 288, 288, 288, 288, + /* 210 */ 288, 288, 288, 288, 288, 288, 288, 1208, 1241, 437, + /* 220 */ 1135, 1246, 142, 1163, 208, 142, 1208, 1208, 1253, 142, + /* 230 */ 1107, 437, 437, 437, 437, 1107, 437, 1199, 142, 462, + /* 240 */ 142, 448, 1378, 1378, 437, 1156, 1107, 437, 437, 1156, + /* 250 */ 1107, 437, 437, 288, 1161, 1258, 1156, 1169, 1173, 1186, + /* 260 */ 928, 1170, 1175, 1180, 1200, 448, 1428, 1355, 1358, 437, + /* 270 */ 597, 1208, 142, 1426, 1241, 2993, 2993, 2993, 2993, 2993, + /* 280 */ 2993, 2993, 1066, 191, 403, 1785, 754, 684, 1098, 50, + /* 290 */ 845, 1038, 471, 1047, 1047, 1047, 1047, 1047, 1047, 1047, + /* 300 */ 1047, 1047, 603, 123, 11, 11, 157, 101, 542, 79, + /* 310 */ 362, 427, 211, 59, 589, 265, 59, 59, 59, 941, + /* 320 */ 1002, 369, 884, 890, 892, 898, 905, 975, 1009, 1096, + /* 330 */ 586, 841, 949, 998, 1014, 1065, 1072, 1073, 1077, 902, + /* 340 */ 785, 991, 1090, 1079, 527, 1004, 987, 1084, 433, 1137, + /* 350 */ 1091, 1141, 1142, 1146, 1148, 1151, 1000, 1088, 1089, 802, + /* 360 */ 1125, 1488, 1489, 1308, 1504, 1505, 1468, 1515, 1481, 1324, + /* 370 */ 1484, 1487, 1490, 1329, 1524, 1491, 1492, 1334, 1530, 1337, + /* 380 */ 1535, 1501, 1547, 1526, 1549, 1509, 1373, 1382, 1560, 1562, + /* 390 */ 1392, 1394, 1563, 1566, 1523, 1568, 1572, 1574, 1533, 1576, + /* 400 */ 1577, 1578, 1537, 1580, 1581, 1583, 1584, 1585, 1587, 1439, + /* 410 */ 1554, 1597, 1451, 1601, 1602, 1606, 1608, 1611, 1616, 1617, + /* 420 */ 1618, 1619, 1620, 1621, 1622, 1623, 1624, 1586, 1625, 1626, + /* 430 */ 1627, 1629, 1630, 1631, 1582, 1632, 1633, 1634, 1636, 1603, + /* 440 */ 1637, 1596, 1640, 1598, 1641, 1653, 1614, 1628, 1638, 1645, + /* 450 */ 1615, 1646, 1639, 1668, 1643, 1635, 1669, 1670, 1671, 1654, + /* 460 */ 1497, 1665, 1672, 1673, 1642, 1676, 1679, 1649, 1650, 1657, + /* 470 */ 1680, 1663, 1655, 1681, 1707, 1674, 1677, 1682, 1711, 1688, + /* 480 */ 1678, 1687, 1712, 1727, 1728, 1729, 1651, 1652, 1695, 1710, + /* 490 */ 1733, 1699, 1701, 1694, 1709, 1703, 1715, 1734, 1755, 1735, + /* 500 */ 1758, 1738, 1713, 1761, 1741, 1730, 1767, 1737, 1768, 1739, + /* 510 */ 1769, 1748, 1751, 1683, 1685, 1773, 1612, 1742, 1776, 1607, + /* 520 */ 1759, 1644, 1648, 1780, 1782, 1656, 1658, 1787, 1783, 1788, + /* 530 */ 1792, 1691, 1698, 1770, 1662, 1794, 1708, 1659, 1716, 1806, + /* 540 */ 1772, 1666, 1720, 1705, 1766, 1774, 1591, 1590, 1600, 1779, + /* 550 */ 1588, 1740, 1732, 1743, 1744, 1745, 1749, 1786, 1750, 1752, + /* 560 */ 1757, 1760, 1771, 1795, 1784, 1789, 1762, 1801, 1610, 1775, + /* 570 */ 1778, 1828, 1809, 1660, 1832, 1833, 1834, 1839, 1840, 1845, + /* 580 */ 1790, 1793, 1836, 1661, 1844, 1837, 1843, 1888, 1869, 1692, + /* 590 */ 1800, 1802, 1804, 1807, 1805, 1808, 1849, 1810, 1815, 1850, + /* 600 */ 1817, 1891, 1723, 1816, 1821, 1819, 1887, 1892, 1838, 1835, + /* 610 */ 1893, 1841, 1851, 1896, 1842, 1853, 1899, 1855, 1856, 1909, + /* 620 */ 1858, 1846, 1847, 1852, 1854, 1928, 1848, 1861, 1862, 1922, + /* 630 */ 1864, 1916, 1916, 1938, 1900, 1902, 1934, 1936, 1939, 1940, + /* 640 */ 1941, 1942, 1943, 1944, 1945, 1946, 1905, 1894, 1947, 1951, + /* 650 */ 1952, 1960, 1953, 1961, 1956, 1957, 1959, 1927, 1694, 1971, + /* 660 */ 1709, 1972, 1973, 1975, 1977, 1992, 1980, 2016, 1982, 1976, + /* 670 */ 1979, 2019, 1985, 1978, 1983, 2024, 1994, 1984, 1988, 2030, + /* 680 */ 1998, 1987, 1996, 2037, 2012, 2015, 2051, 2032, 2031, 2033, + /* 690 */ 2042, 2045, 2048, }; -#define YY_REDUCE_COUNT (272) -#define YY_REDUCE_MIN (-395) -#define YY_REDUCE_MAX (2266) +#define YY_REDUCE_COUNT (281) +#define YY_REDUCE_MIN (-379) +#define YY_REDUCE_MAX (2591) static const short yy_reduce_ofst[] = { - /* 0 */ -268, 886, -249, -162, -306, 275, 968, 1028, 1050, -21, - /* 10 */ 368, 1106, 1167, 1189, 1273, 1328, 1381, 467, 1433, 1445, - /* 20 */ 1459, 1513, 1527, 1577, 1596, 1646, 1660, 1715, 1741, 1767, - /* 30 */ 1793, 1819, 1871, 1887, 1949, 1965, 2018, 2032, 2086, 2110, - /* 40 */ 2136, 2188, 2204, 2266, -11, 200, 237, 459, 544, 664, - /* 50 */ 879, 911, -131, 286, -341, -222, -387, -307, -201, -252, - /* 60 */ 777, -324, -321, -316, -260, -232, -233, 8, 83, 166, - /* 70 */ 243, 302, 317, 354, 547, 583, 229, 624, 625, 631, - /* 80 */ 77, 633, 638, -289, 691, 749, -175, -279, 758, 211, - /* 90 */ -4, 476, 872, 264, -227, -395, -395, -203, 32, 132, - /* 100 */ 261, 326, 395, 408, 453, 465, 468, 493, 536, 564, - /* 110 */ 601, 662, 676, 715, 721, 723, 726, -121, -133, 135, - /* 120 */ -211, -27, 92, 230, 223, 118, -235, 294, 135, 220, - /* 130 */ 369, 483, 356, 514, 510, 500, 505, 104, 377, 312, - /* 140 */ 60, 464, 607, 549, -326, -293, 204, 263, 283, 308, - /* 150 */ 522, 350, 567, 452, 563, 558, 799, 727, 704, 704, - /* 160 */ 832, 839, 844, 816, 808, 808, 782, 808, 817, 809, - /* 170 */ 704, 854, 865, 892, 896, 962, 963, 927, 936, 940, - /* 180 */ 982, 983, 984, 1000, 1001, 945, 996, 967, 1003, 961, - /* 190 */ 966, 1008, 964, 1010, 1012, 1015, 1021, 1020, 1031, 1009, - /* 200 */ 1018, 1023, 1025, 1027, 1029, 1033, 1034, 1037, 1038, 1039, - /* 210 */ 1040, 1047, 994, 974, 1053, 1011, 1017, 1063, 1066, 1067, - /* 220 */ 1022, 1070, 1030, 1041, 1042, 1043, 1046, 1045, 1048, 1036, - /* 230 */ 1078, 1071, 1080, 1056, 1061, 1072, 1004, 1058, 1074, 1076, - /* 240 */ 1026, 1059, 1094, 1095, 704, 1049, 1051, 1054, 1052, 1057, - /* 250 */ 1062, 1079, 1024, 1055, 1077, 808, 1119, 1100, 1082, 1142, - /* 260 */ 1143, 1168, 1180, 1181, 1195, 1198, 1140, 1147, 1182, 1183, - /* 270 */ 1184, 1191, 1209, + /* 0 */ 400, -253, -313, 885, 13, 282, 551, 996, 263, 1101, + /* 10 */ 1144, 1197, 1250, 1293, 1346, 532, 1402, 1464, 1522, 1544, + /* 20 */ 1604, 1647, 1664, 1718, 1736, 1798, 1822, 1865, 1885, 1948, + /* 30 */ 1967, 2010, 2061, 2081, 2132, 2185, 2228, 2248, 2311, 2330, + /* 40 */ 2373, 2424, 2444, 2495, 2548, 2591, 21, 280, -223, 801, + /* 50 */ 924, 926, 933, 984, -98, -28, -351, -348, -316, -341, + /* 60 */ -20, 131, 475, 27, 36, -322, -318, -345, -312, 225, + /* 70 */ 236, 238, 261, 276, 283, 286, 313, 436, -231, 493, + /* 80 */ 508, 550, -245, 552, 555, -51, 565, 613, -22, -200, + /* 90 */ 615, 64, 30, 109, 380, 28, -311, -379, -379, -65, + /* 100 */ -137, -27, -15, 197, 248, 259, 293, 304, 329, 353, + /* 110 */ 416, 464, 472, 504, 505, 510, 526, 544, 619, -62, + /* 120 */ -102, 133, -165, 170, 244, 111, 165, 320, 230, 305, + /* 130 */ 133, 228, 491, 221, -12, 417, 534, 430, 467, 312, + /* 140 */ 512, 547, -211, 273, 606, 612, 637, 623, 390, 415, + /* 150 */ 482, 495, 585, 611, 627, 588, 722, 666, 651, 765, + /* 160 */ 663, 776, 696, 779, 779, 829, 832, 803, 769, 744, + /* 170 */ 744, 726, 744, 755, 746, 779, 794, 806, 809, 833, + /* 180 */ 835, 901, 904, 861, 868, 881, 916, 932, 934, 935, + /* 190 */ 942, 943, 886, 936, 903, 940, 899, 907, 945, 914, + /* 200 */ 963, 964, 967, 972, 970, 992, 966, 968, 973, 974, + /* 210 */ 976, 977, 979, 981, 982, 990, 993, 985, 997, 959, + /* 220 */ 956, 950, 1011, 961, 986, 1018, 1023, 1024, 978, 1027, + /* 230 */ 994, 1012, 1013, 1017, 1020, 1001, 1021, 1016, 1054, 1042, + /* 240 */ 1058, 1039, 1007, 1008, 1041, 983, 1034, 1049, 1051, 988, + /* 250 */ 1043, 1052, 1057, 779, 999, 989, 1003, 1005, 1010, 1015, + /* 260 */ 1048, 1006, 1019, 1026, 744, 1085, 1060, 1044, 1100, 1094, + /* 270 */ 1118, 1131, 1130, 1145, 1147, 1086, 1095, 1140, 1149, 1160, + /* 280 */ 1154, 1164, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 10 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 20 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 30 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 40 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 50 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 60 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 70 */ 1509, 1509, 1509, 1509, 1509, 1509, 1583, 1509, 1509, 1509, - /* 80 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 90 */ 1509, 1509, 1509, 1581, 1746, 1930, 1509, 1509, 1509, 1509, - /* 100 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 110 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1942, - /* 120 */ 1509, 1509, 1509, 1583, 1509, 1581, 1902, 1902, 1942, 1942, - /* 130 */ 1942, 1509, 1509, 1509, 1509, 1787, 1787, 1509, 1509, 1509, - /* 140 */ 1509, 1509, 1686, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 150 */ 1509, 1781, 1509, 2015, 1509, 1509, 1509, 1965, 1509, 1509, - /* 160 */ 1509, 1509, 1639, 1957, 1934, 1948, 1999, 1935, 1932, 1951, - /* 170 */ 1509, 1961, 1509, 1774, 1751, 1509, 1509, 1751, 1748, 1748, - /* 180 */ 1509, 1509, 1509, 1509, 1509, 1509, 1583, 1509, 1583, 1509, - /* 190 */ 1509, 1583, 1509, 1583, 1583, 1583, 1509, 1583, 1509, 1509, - /* 200 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 210 */ 1509, 1509, 1509, 1509, 1581, 1783, 1509, 1581, 1509, 1509, - /* 220 */ 1509, 1581, 1970, 1509, 1509, 1509, 1509, 1970, 1509, 1509, - /* 230 */ 1581, 1509, 1581, 1509, 1509, 1509, 1972, 1970, 1509, 1509, - /* 240 */ 1972, 1970, 1509, 1509, 1509, 1984, 1980, 1972, 1988, 1986, - /* 250 */ 1963, 1961, 2018, 2005, 2001, 1948, 1509, 1509, 1509, 1655, - /* 260 */ 1509, 1509, 1509, 1581, 1541, 1509, 1776, 1787, 1689, 1689, - /* 270 */ 1689, 1584, 1514, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 280 */ 1509, 1509, 1509, 1509, 1860, 1509, 1983, 1982, 1906, 1905, - /* 290 */ 1904, 1895, 1859, 1509, 1651, 1858, 1857, 1509, 1509, 1509, - /* 300 */ 1509, 1509, 1509, 1509, 1851, 1509, 1509, 1852, 1850, 1849, - /* 310 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 320 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 330 */ 2002, 2006, 1931, 1509, 1509, 1509, 1509, 1509, 1842, 1833, - /* 340 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 350 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 360 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 370 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 380 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 390 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 400 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 410 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 420 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 430 */ 1509, 1509, 1509, 1509, 1509, 1509, 1546, 1509, 1509, 1509, - /* 440 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 450 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 460 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 470 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 480 */ 1509, 1622, 1621, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 490 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 500 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 510 */ 1509, 1509, 1509, 1998, 1509, 1509, 1509, 1509, 1509, 1509, - /* 520 */ 1509, 1791, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 530 */ 1509, 1892, 1509, 1509, 1509, 1964, 1509, 1509, 1509, 1509, - /* 540 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 550 */ 1509, 1833, 1509, 1981, 1509, 1509, 1996, 1509, 2000, 1509, - /* 560 */ 1509, 1509, 1509, 1509, 1509, 1509, 1941, 1937, 1509, 1509, - /* 570 */ 1933, 1832, 1509, 1926, 1509, 1509, 1877, 1509, 1509, 1509, - /* 580 */ 1509, 1509, 1509, 1509, 1509, 1509, 1841, 1509, 1845, 1509, - /* 590 */ 1509, 1509, 1509, 1509, 1683, 1509, 1509, 1509, 1509, 1509, - /* 600 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1668, 1666, 1665, - /* 610 */ 1664, 1509, 1661, 1509, 1509, 1509, 1509, 1692, 1691, 1509, - /* 620 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 630 */ 1509, 1509, 1509, 1509, 1603, 1509, 1509, 1509, 1509, 1509, - /* 640 */ 1509, 1509, 1509, 1509, 1594, 1509, 1593, 1509, 1509, 1509, - /* 650 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 660 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, - /* 670 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 0 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 10 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 20 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 30 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 40 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 50 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 60 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 70 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1617, 1543, + /* 80 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 90 */ 1543, 1543, 1543, 1543, 1543, 1615, 1783, 1971, 1543, 1543, + /* 100 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 110 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 120 */ 1543, 1983, 1543, 1543, 1543, 1617, 1543, 1615, 1943, 1943, + /* 130 */ 1983, 1983, 1983, 1543, 1543, 1543, 1543, 1722, 1543, 1824, + /* 140 */ 1824, 1543, 1543, 1543, 1543, 1543, 1722, 1543, 1543, 1543, + /* 150 */ 1543, 1543, 1543, 1543, 1543, 1818, 1543, 2008, 2061, 1543, + /* 160 */ 1543, 1543, 2011, 1543, 1543, 1543, 1543, 1675, 1998, 1975, + /* 170 */ 1989, 2045, 1976, 1973, 1992, 1543, 2002, 1543, 1811, 1788, + /* 180 */ 1788, 1543, 1543, 1788, 1785, 1785, 1666, 1543, 1543, 1543, + /* 190 */ 1543, 1543, 1543, 1617, 1543, 1617, 1543, 1543, 1617, 1543, + /* 200 */ 1617, 1617, 1617, 1543, 1617, 1543, 1543, 1543, 1543, 1543, + /* 210 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 220 */ 1830, 1543, 1615, 1820, 1543, 1615, 1543, 1543, 1543, 1615, + /* 230 */ 2016, 1543, 1543, 1543, 1543, 2016, 1543, 1543, 1615, 1543, + /* 240 */ 1615, 1543, 1543, 1543, 1543, 2018, 2016, 1543, 1543, 2018, + /* 250 */ 2016, 1543, 1543, 1543, 2030, 2026, 2018, 2034, 2032, 2004, + /* 260 */ 2002, 2064, 2051, 2047, 1989, 1543, 1543, 1543, 1691, 1543, + /* 270 */ 1543, 1543, 1615, 1575, 1543, 1813, 1824, 1725, 1725, 1725, + /* 280 */ 1618, 1548, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 290 */ 1543, 1543, 1543, 1899, 1543, 2029, 2028, 1947, 1946, 1945, + /* 300 */ 1936, 1898, 1543, 1687, 1897, 1896, 1543, 1543, 1543, 1543, + /* 310 */ 1543, 1543, 1543, 1890, 1543, 1543, 1891, 1889, 1888, 1543, + /* 320 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 330 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 340 */ 2048, 2052, 1972, 1543, 1543, 1543, 1543, 1543, 1881, 1872, + /* 350 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 360 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 370 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 380 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 390 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 400 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 410 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 420 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 430 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 440 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1580, 1543, + /* 450 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 460 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 470 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 480 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 490 */ 1543, 1543, 1543, 1656, 1655, 1543, 1543, 1543, 1543, 1543, + /* 500 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 510 */ 1543, 1543, 1543, 1880, 1543, 1543, 1543, 1543, 1543, 1543, + /* 520 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 2044, 1543, 1543, + /* 530 */ 1543, 1543, 1543, 1543, 1543, 1828, 1543, 1543, 1543, 1543, + /* 540 */ 1543, 1543, 1543, 1543, 1543, 1933, 1543, 1543, 1543, 2005, + /* 550 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 560 */ 1543, 1543, 1543, 1543, 1543, 1872, 1543, 2027, 1543, 1543, + /* 570 */ 2042, 1543, 2046, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 580 */ 1982, 1978, 1543, 1543, 1974, 1871, 1543, 1967, 1543, 1543, + /* 590 */ 1918, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 600 */ 1880, 1543, 1884, 1543, 1543, 1543, 1543, 1543, 1719, 1543, + /* 610 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 620 */ 1543, 1704, 1702, 1701, 1700, 1543, 1697, 1543, 1543, 1543, + /* 630 */ 1543, 1728, 1727, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 640 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1637, 1543, + /* 650 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1628, 1543, + /* 660 */ 1627, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 670 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 680 */ 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, 1543, + /* 690 */ 1543, 1543, 1543, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1041,6 +1112,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* TABLE_PREFIX => nothing */ 0, /* TABLE_SUFFIX => nothing */ 0, /* NK_COLON => nothing */ + 0, /* MAX_SPEED => nothing */ 0, /* TABLE => nothing */ 0, /* NK_LP => nothing */ 0, /* NK_RP => nothing */ @@ -1137,6 +1209,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* WINDOW_CLOSE => nothing */ 0, /* IGNORE => nothing */ 0, /* EXPIRED => nothing */ + 0, /* SUBTABLE => nothing */ 0, /* KILL => nothing */ 0, /* CONNECTION => nothing */ 0, /* TRANSACTION => nothing */ @@ -1158,6 +1231,8 @@ static const YYCODETYPE yyFallback[] = { 0, /* WSTART => nothing */ 0, /* WEND => nothing */ 0, /* WDURATION => nothing */ + 0, /* IROWTS => nothing */ + 0, /* QTAGS => nothing */ 0, /* CAST => nothing */ 0, /* NOW => nothing */ 0, /* TODAY => nothing */ @@ -1169,7 +1244,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* COUNT => nothing */ 0, /* LAST_ROW => nothing */ 0, /* CASE => nothing */ - 261, /* END => ABORT */ + 265, /* END => ABORT */ 0, /* WHEN => nothing */ 0, /* THEN => nothing */ 0, /* ELSE => nothing */ @@ -1211,57 +1286,57 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ABORT => nothing */ - 261, /* AFTER => ABORT */ - 261, /* ATTACH => ABORT */ - 261, /* BEFORE => ABORT */ - 261, /* BEGIN => ABORT */ - 261, /* BITAND => ABORT */ - 261, /* BITNOT => ABORT */ - 261, /* BITOR => ABORT */ - 261, /* BLOCKS => ABORT */ - 261, /* CHANGE => ABORT */ - 261, /* COMMA => ABORT */ - 261, /* COMPACT => ABORT */ - 261, /* CONCAT => ABORT */ - 261, /* CONFLICT => ABORT */ - 261, /* COPY => ABORT */ - 261, /* DEFERRED => ABORT */ - 261, /* DELIMITERS => ABORT */ - 261, /* DETACH => ABORT */ - 261, /* DIVIDE => ABORT */ - 261, /* DOT => ABORT */ - 261, /* EACH => ABORT */ - 261, /* FAIL => ABORT */ - 261, /* FILE => ABORT */ - 261, /* FOR => ABORT */ - 261, /* GLOB => ABORT */ - 261, /* ID => ABORT */ - 261, /* IMMEDIATE => ABORT */ - 261, /* IMPORT => ABORT */ - 261, /* INITIALLY => ABORT */ - 261, /* INSTEAD => ABORT */ - 261, /* ISNULL => ABORT */ - 261, /* KEY => ABORT */ - 261, /* NK_BITNOT => ABORT */ - 261, /* NK_SEMI => ABORT */ - 261, /* NOTNULL => ABORT */ - 261, /* OF => ABORT */ - 261, /* PLUS => ABORT */ - 261, /* PRIVILEGE => ABORT */ - 261, /* RAISE => ABORT */ - 261, /* REPLACE => ABORT */ - 261, /* RESTRICT => ABORT */ - 261, /* ROW => ABORT */ - 261, /* SEMI => ABORT */ - 261, /* STAR => ABORT */ - 261, /* STATEMENT => ABORT */ - 261, /* STRING => ABORT */ - 261, /* TIMES => ABORT */ - 261, /* UPDATE => ABORT */ - 261, /* VALUES => ABORT */ - 261, /* VARIABLE => ABORT */ - 261, /* VIEW => ABORT */ - 261, /* WAL => ABORT */ + 265, /* AFTER => ABORT */ + 265, /* ATTACH => ABORT */ + 265, /* BEFORE => ABORT */ + 265, /* BEGIN => ABORT */ + 265, /* BITAND => ABORT */ + 265, /* BITNOT => ABORT */ + 265, /* BITOR => ABORT */ + 265, /* BLOCKS => ABORT */ + 265, /* CHANGE => ABORT */ + 265, /* COMMA => ABORT */ + 265, /* COMPACT => ABORT */ + 265, /* CONCAT => ABORT */ + 265, /* CONFLICT => ABORT */ + 265, /* COPY => ABORT */ + 265, /* DEFERRED => ABORT */ + 265, /* DELIMITERS => ABORT */ + 265, /* DETACH => ABORT */ + 265, /* DIVIDE => ABORT */ + 265, /* DOT => ABORT */ + 265, /* EACH => ABORT */ + 265, /* FAIL => ABORT */ + 265, /* FILE => ABORT */ + 265, /* FOR => ABORT */ + 265, /* GLOB => ABORT */ + 265, /* ID => ABORT */ + 265, /* IMMEDIATE => ABORT */ + 265, /* IMPORT => ABORT */ + 265, /* INITIALLY => ABORT */ + 265, /* INSTEAD => ABORT */ + 265, /* ISNULL => ABORT */ + 265, /* KEY => ABORT */ + 265, /* NK_BITNOT => ABORT */ + 265, /* NK_SEMI => ABORT */ + 265, /* NOTNULL => ABORT */ + 265, /* OF => ABORT */ + 265, /* PLUS => ABORT */ + 265, /* PRIVILEGE => ABORT */ + 265, /* RAISE => ABORT */ + 265, /* REPLACE => ABORT */ + 265, /* RESTRICT => ABORT */ + 265, /* ROW => ABORT */ + 265, /* SEMI => ABORT */ + 265, /* STAR => ABORT */ + 265, /* STATEMENT => ABORT */ + 265, /* STRING => ABORT */ + 265, /* TIMES => ABORT */ + 265, /* UPDATE => ABORT */ + 265, /* VALUES => ABORT */ + 265, /* VARIABLE => ABORT */ + 265, /* VIEW => ABORT */ + 265, /* WAL => ABORT */ }; #endif /* YYFALLBACK */ @@ -1441,355 +1516,363 @@ static const char *const yyTokenName[] = { /* 89 */ "TABLE_PREFIX", /* 90 */ "TABLE_SUFFIX", /* 91 */ "NK_COLON", - /* 92 */ "TABLE", - /* 93 */ "NK_LP", - /* 94 */ "NK_RP", - /* 95 */ "STABLE", - /* 96 */ "ADD", - /* 97 */ "COLUMN", - /* 98 */ "MODIFY", - /* 99 */ "RENAME", - /* 100 */ "TAG", - /* 101 */ "SET", - /* 102 */ "NK_EQ", - /* 103 */ "USING", - /* 104 */ "TAGS", - /* 105 */ "COMMENT", - /* 106 */ "BOOL", - /* 107 */ "TINYINT", - /* 108 */ "SMALLINT", - /* 109 */ "INT", - /* 110 */ "INTEGER", - /* 111 */ "BIGINT", - /* 112 */ "FLOAT", - /* 113 */ "DOUBLE", - /* 114 */ "BINARY", - /* 115 */ "TIMESTAMP", - /* 116 */ "NCHAR", - /* 117 */ "UNSIGNED", - /* 118 */ "JSON", - /* 119 */ "VARCHAR", - /* 120 */ "MEDIUMBLOB", - /* 121 */ "BLOB", - /* 122 */ "VARBINARY", - /* 123 */ "DECIMAL", - /* 124 */ "MAX_DELAY", - /* 125 */ "WATERMARK", - /* 126 */ "ROLLUP", - /* 127 */ "TTL", - /* 128 */ "SMA", - /* 129 */ "FIRST", - /* 130 */ "LAST", - /* 131 */ "SHOW", - /* 132 */ "DATABASES", - /* 133 */ "TABLES", - /* 134 */ "STABLES", - /* 135 */ "MNODES", - /* 136 */ "MODULES", - /* 137 */ "QNODES", - /* 138 */ "FUNCTIONS", - /* 139 */ "INDEXES", - /* 140 */ "ACCOUNTS", - /* 141 */ "APPS", - /* 142 */ "CONNECTIONS", - /* 143 */ "LICENCES", - /* 144 */ "GRANTS", - /* 145 */ "QUERIES", - /* 146 */ "SCORES", - /* 147 */ "TOPICS", - /* 148 */ "VARIABLES", - /* 149 */ "BNODES", - /* 150 */ "SNODES", - /* 151 */ "CLUSTER", - /* 152 */ "TRANSACTIONS", - /* 153 */ "DISTRIBUTED", - /* 154 */ "CONSUMERS", - /* 155 */ "SUBSCRIPTIONS", - /* 156 */ "VNODES", - /* 157 */ "LIKE", - /* 158 */ "INDEX", - /* 159 */ "FUNCTION", - /* 160 */ "INTERVAL", - /* 161 */ "TOPIC", - /* 162 */ "AS", - /* 163 */ "WITH", - /* 164 */ "META", - /* 165 */ "CONSUMER", - /* 166 */ "GROUP", - /* 167 */ "DESC", - /* 168 */ "DESCRIBE", - /* 169 */ "RESET", - /* 170 */ "QUERY", - /* 171 */ "CACHE", - /* 172 */ "EXPLAIN", - /* 173 */ "ANALYZE", - /* 174 */ "VERBOSE", - /* 175 */ "NK_BOOL", - /* 176 */ "RATIO", - /* 177 */ "NK_FLOAT", - /* 178 */ "OUTPUTTYPE", - /* 179 */ "AGGREGATE", - /* 180 */ "BUFSIZE", - /* 181 */ "STREAM", - /* 182 */ "INTO", - /* 183 */ "TRIGGER", - /* 184 */ "AT_ONCE", - /* 185 */ "WINDOW_CLOSE", - /* 186 */ "IGNORE", - /* 187 */ "EXPIRED", - /* 188 */ "KILL", - /* 189 */ "CONNECTION", - /* 190 */ "TRANSACTION", - /* 191 */ "BALANCE", - /* 192 */ "VGROUP", - /* 193 */ "MERGE", - /* 194 */ "REDISTRIBUTE", - /* 195 */ "SPLIT", - /* 196 */ "DELETE", - /* 197 */ "INSERT", - /* 198 */ "NULL", - /* 199 */ "NK_QUESTION", - /* 200 */ "NK_ARROW", - /* 201 */ "ROWTS", - /* 202 */ "TBNAME", - /* 203 */ "QSTART", - /* 204 */ "QEND", - /* 205 */ "QDURATION", - /* 206 */ "WSTART", - /* 207 */ "WEND", - /* 208 */ "WDURATION", - /* 209 */ "CAST", - /* 210 */ "NOW", - /* 211 */ "TODAY", - /* 212 */ "TIMEZONE", - /* 213 */ "CLIENT_VERSION", - /* 214 */ "SERVER_VERSION", - /* 215 */ "SERVER_STATUS", - /* 216 */ "CURRENT_USER", - /* 217 */ "COUNT", - /* 218 */ "LAST_ROW", - /* 219 */ "CASE", - /* 220 */ "END", - /* 221 */ "WHEN", - /* 222 */ "THEN", - /* 223 */ "ELSE", - /* 224 */ "BETWEEN", - /* 225 */ "IS", - /* 226 */ "NK_LT", - /* 227 */ "NK_GT", - /* 228 */ "NK_LE", - /* 229 */ "NK_GE", - /* 230 */ "NK_NE", - /* 231 */ "MATCH", - /* 232 */ "NMATCH", - /* 233 */ "CONTAINS", - /* 234 */ "IN", - /* 235 */ "JOIN", - /* 236 */ "INNER", - /* 237 */ "SELECT", - /* 238 */ "DISTINCT", - /* 239 */ "WHERE", - /* 240 */ "PARTITION", - /* 241 */ "BY", - /* 242 */ "SESSION", - /* 243 */ "STATE_WINDOW", - /* 244 */ "SLIDING", - /* 245 */ "FILL", - /* 246 */ "VALUE", - /* 247 */ "NONE", - /* 248 */ "PREV", - /* 249 */ "LINEAR", - /* 250 */ "NEXT", - /* 251 */ "HAVING", - /* 252 */ "RANGE", - /* 253 */ "EVERY", - /* 254 */ "ORDER", - /* 255 */ "SLIMIT", - /* 256 */ "SOFFSET", - /* 257 */ "LIMIT", - /* 258 */ "OFFSET", - /* 259 */ "ASC", - /* 260 */ "NULLS", - /* 261 */ "ABORT", - /* 262 */ "AFTER", - /* 263 */ "ATTACH", - /* 264 */ "BEFORE", - /* 265 */ "BEGIN", - /* 266 */ "BITAND", - /* 267 */ "BITNOT", - /* 268 */ "BITOR", - /* 269 */ "BLOCKS", - /* 270 */ "CHANGE", - /* 271 */ "COMMA", - /* 272 */ "COMPACT", - /* 273 */ "CONCAT", - /* 274 */ "CONFLICT", - /* 275 */ "COPY", - /* 276 */ "DEFERRED", - /* 277 */ "DELIMITERS", - /* 278 */ "DETACH", - /* 279 */ "DIVIDE", - /* 280 */ "DOT", - /* 281 */ "EACH", - /* 282 */ "FAIL", - /* 283 */ "FILE", - /* 284 */ "FOR", - /* 285 */ "GLOB", - /* 286 */ "ID", - /* 287 */ "IMMEDIATE", - /* 288 */ "IMPORT", - /* 289 */ "INITIALLY", - /* 290 */ "INSTEAD", - /* 291 */ "ISNULL", - /* 292 */ "KEY", - /* 293 */ "NK_BITNOT", - /* 294 */ "NK_SEMI", - /* 295 */ "NOTNULL", - /* 296 */ "OF", - /* 297 */ "PLUS", - /* 298 */ "PRIVILEGE", - /* 299 */ "RAISE", - /* 300 */ "REPLACE", - /* 301 */ "RESTRICT", - /* 302 */ "ROW", - /* 303 */ "SEMI", - /* 304 */ "STAR", - /* 305 */ "STATEMENT", - /* 306 */ "STRING", - /* 307 */ "TIMES", - /* 308 */ "UPDATE", - /* 309 */ "VALUES", - /* 310 */ "VARIABLE", - /* 311 */ "VIEW", - /* 312 */ "WAL", - /* 313 */ "cmd", - /* 314 */ "account_options", - /* 315 */ "alter_account_options", - /* 316 */ "literal", - /* 317 */ "alter_account_option", - /* 318 */ "user_name", - /* 319 */ "sysinfo_opt", - /* 320 */ "privileges", - /* 321 */ "priv_level", - /* 322 */ "priv_type_list", - /* 323 */ "priv_type", - /* 324 */ "db_name", - /* 325 */ "dnode_endpoint", - /* 326 */ "not_exists_opt", - /* 327 */ "db_options", - /* 328 */ "exists_opt", - /* 329 */ "alter_db_options", - /* 330 */ "integer_list", - /* 331 */ "variable_list", - /* 332 */ "retention_list", - /* 333 */ "alter_db_option", - /* 334 */ "retention", - /* 335 */ "full_table_name", - /* 336 */ "column_def_list", - /* 337 */ "tags_def_opt", - /* 338 */ "table_options", - /* 339 */ "multi_create_clause", - /* 340 */ "tags_def", - /* 341 */ "multi_drop_clause", - /* 342 */ "alter_table_clause", - /* 343 */ "alter_table_options", - /* 344 */ "column_name", - /* 345 */ "type_name", - /* 346 */ "signed_literal", - /* 347 */ "create_subtable_clause", - /* 348 */ "specific_cols_opt", - /* 349 */ "expression_list", - /* 350 */ "drop_table_clause", - /* 351 */ "col_name_list", - /* 352 */ "table_name", - /* 353 */ "column_def", - /* 354 */ "duration_list", - /* 355 */ "rollup_func_list", - /* 356 */ "alter_table_option", - /* 357 */ "duration_literal", - /* 358 */ "rollup_func_name", - /* 359 */ "function_name", - /* 360 */ "col_name", - /* 361 */ "db_name_cond_opt", - /* 362 */ "like_pattern_opt", - /* 363 */ "table_name_cond", - /* 364 */ "from_db_opt", - /* 365 */ "index_options", - /* 366 */ "func_list", - /* 367 */ "sliding_opt", - /* 368 */ "sma_stream_opt", - /* 369 */ "func", - /* 370 */ "stream_options", - /* 371 */ "topic_name", - /* 372 */ "query_or_subquery", - /* 373 */ "cgroup_name", - /* 374 */ "analyze_opt", - /* 375 */ "explain_options", - /* 376 */ "agg_func_opt", - /* 377 */ "bufsize_opt", - /* 378 */ "stream_name", - /* 379 */ "dnode_list", - /* 380 */ "where_clause_opt", - /* 381 */ "signed", - /* 382 */ "literal_func", - /* 383 */ "literal_list", - /* 384 */ "table_alias", - /* 385 */ "column_alias", - /* 386 */ "expr_or_subquery", - /* 387 */ "expression", - /* 388 */ "subquery", - /* 389 */ "pseudo_column", - /* 390 */ "column_reference", - /* 391 */ "function_expression", - /* 392 */ "case_when_expression", - /* 393 */ "star_func", - /* 394 */ "star_func_para_list", - /* 395 */ "noarg_func", - /* 396 */ "other_para_list", - /* 397 */ "star_func_para", - /* 398 */ "when_then_list", - /* 399 */ "case_when_else_opt", - /* 400 */ "common_expression", - /* 401 */ "when_then_expr", - /* 402 */ "predicate", - /* 403 */ "compare_op", - /* 404 */ "in_op", - /* 405 */ "in_predicate_value", - /* 406 */ "boolean_value_expression", - /* 407 */ "boolean_primary", - /* 408 */ "from_clause_opt", - /* 409 */ "table_reference_list", - /* 410 */ "table_reference", - /* 411 */ "table_primary", - /* 412 */ "joined_table", - /* 413 */ "alias_opt", - /* 414 */ "parenthesized_joined_table", - /* 415 */ "join_type", - /* 416 */ "search_condition", - /* 417 */ "query_specification", - /* 418 */ "set_quantifier_opt", - /* 419 */ "select_list", - /* 420 */ "partition_by_clause_opt", - /* 421 */ "range_opt", - /* 422 */ "every_opt", - /* 423 */ "fill_opt", - /* 424 */ "twindow_clause_opt", - /* 425 */ "group_by_clause_opt", - /* 426 */ "having_clause_opt", - /* 427 */ "select_item", - /* 428 */ "fill_mode", - /* 429 */ "group_by_list", - /* 430 */ "query_expression", - /* 431 */ "query_simple", - /* 432 */ "order_by_clause_opt", - /* 433 */ "slimit_clause_opt", - /* 434 */ "limit_clause_opt", - /* 435 */ "union_query_expression", - /* 436 */ "query_simple_or_subquery", - /* 437 */ "sort_specification_list", - /* 438 */ "sort_specification", - /* 439 */ "ordering_specification_opt", - /* 440 */ "null_ordering_opt", + /* 92 */ "MAX_SPEED", + /* 93 */ "TABLE", + /* 94 */ "NK_LP", + /* 95 */ "NK_RP", + /* 96 */ "STABLE", + /* 97 */ "ADD", + /* 98 */ "COLUMN", + /* 99 */ "MODIFY", + /* 100 */ "RENAME", + /* 101 */ "TAG", + /* 102 */ "SET", + /* 103 */ "NK_EQ", + /* 104 */ "USING", + /* 105 */ "TAGS", + /* 106 */ "COMMENT", + /* 107 */ "BOOL", + /* 108 */ "TINYINT", + /* 109 */ "SMALLINT", + /* 110 */ "INT", + /* 111 */ "INTEGER", + /* 112 */ "BIGINT", + /* 113 */ "FLOAT", + /* 114 */ "DOUBLE", + /* 115 */ "BINARY", + /* 116 */ "TIMESTAMP", + /* 117 */ "NCHAR", + /* 118 */ "UNSIGNED", + /* 119 */ "JSON", + /* 120 */ "VARCHAR", + /* 121 */ "MEDIUMBLOB", + /* 122 */ "BLOB", + /* 123 */ "VARBINARY", + /* 124 */ "DECIMAL", + /* 125 */ "MAX_DELAY", + /* 126 */ "WATERMARK", + /* 127 */ "ROLLUP", + /* 128 */ "TTL", + /* 129 */ "SMA", + /* 130 */ "FIRST", + /* 131 */ "LAST", + /* 132 */ "SHOW", + /* 133 */ "DATABASES", + /* 134 */ "TABLES", + /* 135 */ "STABLES", + /* 136 */ "MNODES", + /* 137 */ "MODULES", + /* 138 */ "QNODES", + /* 139 */ "FUNCTIONS", + /* 140 */ "INDEXES", + /* 141 */ "ACCOUNTS", + /* 142 */ "APPS", + /* 143 */ "CONNECTIONS", + /* 144 */ "LICENCES", + /* 145 */ "GRANTS", + /* 146 */ "QUERIES", + /* 147 */ "SCORES", + /* 148 */ "TOPICS", + /* 149 */ "VARIABLES", + /* 150 */ "BNODES", + /* 151 */ "SNODES", + /* 152 */ "CLUSTER", + /* 153 */ "TRANSACTIONS", + /* 154 */ "DISTRIBUTED", + /* 155 */ "CONSUMERS", + /* 156 */ "SUBSCRIPTIONS", + /* 157 */ "VNODES", + /* 158 */ "LIKE", + /* 159 */ "INDEX", + /* 160 */ "FUNCTION", + /* 161 */ "INTERVAL", + /* 162 */ "TOPIC", + /* 163 */ "AS", + /* 164 */ "WITH", + /* 165 */ "META", + /* 166 */ "CONSUMER", + /* 167 */ "GROUP", + /* 168 */ "DESC", + /* 169 */ "DESCRIBE", + /* 170 */ "RESET", + /* 171 */ "QUERY", + /* 172 */ "CACHE", + /* 173 */ "EXPLAIN", + /* 174 */ "ANALYZE", + /* 175 */ "VERBOSE", + /* 176 */ "NK_BOOL", + /* 177 */ "RATIO", + /* 178 */ "NK_FLOAT", + /* 179 */ "OUTPUTTYPE", + /* 180 */ "AGGREGATE", + /* 181 */ "BUFSIZE", + /* 182 */ "STREAM", + /* 183 */ "INTO", + /* 184 */ "TRIGGER", + /* 185 */ "AT_ONCE", + /* 186 */ "WINDOW_CLOSE", + /* 187 */ "IGNORE", + /* 188 */ "EXPIRED", + /* 189 */ "SUBTABLE", + /* 190 */ "KILL", + /* 191 */ "CONNECTION", + /* 192 */ "TRANSACTION", + /* 193 */ "BALANCE", + /* 194 */ "VGROUP", + /* 195 */ "MERGE", + /* 196 */ "REDISTRIBUTE", + /* 197 */ "SPLIT", + /* 198 */ "DELETE", + /* 199 */ "INSERT", + /* 200 */ "NULL", + /* 201 */ "NK_QUESTION", + /* 202 */ "NK_ARROW", + /* 203 */ "ROWTS", + /* 204 */ "TBNAME", + /* 205 */ "QSTART", + /* 206 */ "QEND", + /* 207 */ "QDURATION", + /* 208 */ "WSTART", + /* 209 */ "WEND", + /* 210 */ "WDURATION", + /* 211 */ "IROWTS", + /* 212 */ "QTAGS", + /* 213 */ "CAST", + /* 214 */ "NOW", + /* 215 */ "TODAY", + /* 216 */ "TIMEZONE", + /* 217 */ "CLIENT_VERSION", + /* 218 */ "SERVER_VERSION", + /* 219 */ "SERVER_STATUS", + /* 220 */ "CURRENT_USER", + /* 221 */ "COUNT", + /* 222 */ "LAST_ROW", + /* 223 */ "CASE", + /* 224 */ "END", + /* 225 */ "WHEN", + /* 226 */ "THEN", + /* 227 */ "ELSE", + /* 228 */ "BETWEEN", + /* 229 */ "IS", + /* 230 */ "NK_LT", + /* 231 */ "NK_GT", + /* 232 */ "NK_LE", + /* 233 */ "NK_GE", + /* 234 */ "NK_NE", + /* 235 */ "MATCH", + /* 236 */ "NMATCH", + /* 237 */ "CONTAINS", + /* 238 */ "IN", + /* 239 */ "JOIN", + /* 240 */ "INNER", + /* 241 */ "SELECT", + /* 242 */ "DISTINCT", + /* 243 */ "WHERE", + /* 244 */ "PARTITION", + /* 245 */ "BY", + /* 246 */ "SESSION", + /* 247 */ "STATE_WINDOW", + /* 248 */ "SLIDING", + /* 249 */ "FILL", + /* 250 */ "VALUE", + /* 251 */ "NONE", + /* 252 */ "PREV", + /* 253 */ "LINEAR", + /* 254 */ "NEXT", + /* 255 */ "HAVING", + /* 256 */ "RANGE", + /* 257 */ "EVERY", + /* 258 */ "ORDER", + /* 259 */ "SLIMIT", + /* 260 */ "SOFFSET", + /* 261 */ "LIMIT", + /* 262 */ "OFFSET", + /* 263 */ "ASC", + /* 264 */ "NULLS", + /* 265 */ "ABORT", + /* 266 */ "AFTER", + /* 267 */ "ATTACH", + /* 268 */ "BEFORE", + /* 269 */ "BEGIN", + /* 270 */ "BITAND", + /* 271 */ "BITNOT", + /* 272 */ "BITOR", + /* 273 */ "BLOCKS", + /* 274 */ "CHANGE", + /* 275 */ "COMMA", + /* 276 */ "COMPACT", + /* 277 */ "CONCAT", + /* 278 */ "CONFLICT", + /* 279 */ "COPY", + /* 280 */ "DEFERRED", + /* 281 */ "DELIMITERS", + /* 282 */ "DETACH", + /* 283 */ "DIVIDE", + /* 284 */ "DOT", + /* 285 */ "EACH", + /* 286 */ "FAIL", + /* 287 */ "FILE", + /* 288 */ "FOR", + /* 289 */ "GLOB", + /* 290 */ "ID", + /* 291 */ "IMMEDIATE", + /* 292 */ "IMPORT", + /* 293 */ "INITIALLY", + /* 294 */ "INSTEAD", + /* 295 */ "ISNULL", + /* 296 */ "KEY", + /* 297 */ "NK_BITNOT", + /* 298 */ "NK_SEMI", + /* 299 */ "NOTNULL", + /* 300 */ "OF", + /* 301 */ "PLUS", + /* 302 */ "PRIVILEGE", + /* 303 */ "RAISE", + /* 304 */ "REPLACE", + /* 305 */ "RESTRICT", + /* 306 */ "ROW", + /* 307 */ "SEMI", + /* 308 */ "STAR", + /* 309 */ "STATEMENT", + /* 310 */ "STRING", + /* 311 */ "TIMES", + /* 312 */ "UPDATE", + /* 313 */ "VALUES", + /* 314 */ "VARIABLE", + /* 315 */ "VIEW", + /* 316 */ "WAL", + /* 317 */ "cmd", + /* 318 */ "account_options", + /* 319 */ "alter_account_options", + /* 320 */ "literal", + /* 321 */ "alter_account_option", + /* 322 */ "user_name", + /* 323 */ "sysinfo_opt", + /* 324 */ "privileges", + /* 325 */ "priv_level", + /* 326 */ "priv_type_list", + /* 327 */ "priv_type", + /* 328 */ "db_name", + /* 329 */ "dnode_endpoint", + /* 330 */ "not_exists_opt", + /* 331 */ "db_options", + /* 332 */ "exists_opt", + /* 333 */ "alter_db_options", + /* 334 */ "speed_opt", + /* 335 */ "integer_list", + /* 336 */ "variable_list", + /* 337 */ "retention_list", + /* 338 */ "alter_db_option", + /* 339 */ "retention", + /* 340 */ "full_table_name", + /* 341 */ "column_def_list", + /* 342 */ "tags_def_opt", + /* 343 */ "table_options", + /* 344 */ "multi_create_clause", + /* 345 */ "tags_def", + /* 346 */ "multi_drop_clause", + /* 347 */ "alter_table_clause", + /* 348 */ "alter_table_options", + /* 349 */ "column_name", + /* 350 */ "type_name", + /* 351 */ "signed_literal", + /* 352 */ "create_subtable_clause", + /* 353 */ "specific_cols_opt", + /* 354 */ "expression_list", + /* 355 */ "drop_table_clause", + /* 356 */ "col_name_list", + /* 357 */ "table_name", + /* 358 */ "column_def", + /* 359 */ "duration_list", + /* 360 */ "rollup_func_list", + /* 361 */ "alter_table_option", + /* 362 */ "duration_literal", + /* 363 */ "rollup_func_name", + /* 364 */ "function_name", + /* 365 */ "col_name", + /* 366 */ "db_name_cond_opt", + /* 367 */ "like_pattern_opt", + /* 368 */ "table_name_cond", + /* 369 */ "from_db_opt", + /* 370 */ "index_options", + /* 371 */ "func_list", + /* 372 */ "sliding_opt", + /* 373 */ "sma_stream_opt", + /* 374 */ "func", + /* 375 */ "stream_options", + /* 376 */ "topic_name", + /* 377 */ "query_or_subquery", + /* 378 */ "cgroup_name", + /* 379 */ "analyze_opt", + /* 380 */ "explain_options", + /* 381 */ "agg_func_opt", + /* 382 */ "bufsize_opt", + /* 383 */ "stream_name", + /* 384 */ "subtable_opt", + /* 385 */ "expression", + /* 386 */ "dnode_list", + /* 387 */ "where_clause_opt", + /* 388 */ "signed", + /* 389 */ "literal_func", + /* 390 */ "literal_list", + /* 391 */ "table_alias", + /* 392 */ "column_alias", + /* 393 */ "expr_or_subquery", + /* 394 */ "subquery", + /* 395 */ "pseudo_column", + /* 396 */ "column_reference", + /* 397 */ "function_expression", + /* 398 */ "case_when_expression", + /* 399 */ "star_func", + /* 400 */ "star_func_para_list", + /* 401 */ "noarg_func", + /* 402 */ "other_para_list", + /* 403 */ "star_func_para", + /* 404 */ "when_then_list", + /* 405 */ "case_when_else_opt", + /* 406 */ "common_expression", + /* 407 */ "when_then_expr", + /* 408 */ "predicate", + /* 409 */ "compare_op", + /* 410 */ "in_op", + /* 411 */ "in_predicate_value", + /* 412 */ "boolean_value_expression", + /* 413 */ "boolean_primary", + /* 414 */ "from_clause_opt", + /* 415 */ "table_reference_list", + /* 416 */ "table_reference", + /* 417 */ "table_primary", + /* 418 */ "joined_table", + /* 419 */ "alias_opt", + /* 420 */ "parenthesized_joined_table", + /* 421 */ "join_type", + /* 422 */ "search_condition", + /* 423 */ "query_specification", + /* 424 */ "set_quantifier_opt", + /* 425 */ "select_list", + /* 426 */ "partition_by_clause_opt", + /* 427 */ "range_opt", + /* 428 */ "every_opt", + /* 429 */ "fill_opt", + /* 430 */ "twindow_clause_opt", + /* 431 */ "group_by_clause_opt", + /* 432 */ "having_clause_opt", + /* 433 */ "select_item", + /* 434 */ "partition_list", + /* 435 */ "partition_item", + /* 436 */ "fill_mode", + /* 437 */ "group_by_list", + /* 438 */ "query_expression", + /* 439 */ "query_simple", + /* 440 */ "order_by_clause_opt", + /* 441 */ "slimit_clause_opt", + /* 442 */ "limit_clause_opt", + /* 443 */ "union_query_expression", + /* 444 */ "query_simple_or_subquery", + /* 445 */ "sort_specification_list", + /* 446 */ "sort_specification", + /* 447 */ "ordering_specification_opt", + /* 448 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1864,7 +1947,7 @@ static const char *const yyRuleName[] = { /* 64 */ "cmd ::= USE db_name", /* 65 */ "cmd ::= ALTER DATABASE db_name alter_db_options", /* 66 */ "cmd ::= FLUSH DATABASE db_name", - /* 67 */ "cmd ::= TRIM DATABASE db_name", + /* 67 */ "cmd ::= TRIM DATABASE db_name speed_opt", /* 68 */ "not_exists_opt ::= IF NOT EXISTS", /* 69 */ "not_exists_opt ::=", /* 70 */ "exists_opt ::= IF EXISTS", @@ -1917,395 +2000,407 @@ static const char *const yyRuleName[] = { /* 117 */ "retention_list ::= retention", /* 118 */ "retention_list ::= retention_list NK_COMMA retention", /* 119 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE", - /* 120 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", - /* 121 */ "cmd ::= CREATE TABLE multi_create_clause", - /* 122 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", - /* 123 */ "cmd ::= DROP TABLE multi_drop_clause", - /* 124 */ "cmd ::= DROP STABLE exists_opt full_table_name", - /* 125 */ "cmd ::= ALTER TABLE alter_table_clause", - /* 126 */ "cmd ::= ALTER STABLE alter_table_clause", - /* 127 */ "alter_table_clause ::= full_table_name alter_table_options", - /* 128 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", - /* 129 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", - /* 130 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", - /* 131 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", - /* 132 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", - /* 133 */ "alter_table_clause ::= full_table_name DROP TAG column_name", - /* 134 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", - /* 135 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", - /* 136 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", - /* 137 */ "multi_create_clause ::= create_subtable_clause", - /* 138 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 139 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options", - /* 140 */ "multi_drop_clause ::= drop_table_clause", - /* 141 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", - /* 142 */ "drop_table_clause ::= exists_opt full_table_name", - /* 143 */ "specific_cols_opt ::=", - /* 144 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP", - /* 145 */ "full_table_name ::= table_name", - /* 146 */ "full_table_name ::= db_name NK_DOT table_name", - /* 147 */ "column_def_list ::= column_def", - /* 148 */ "column_def_list ::= column_def_list NK_COMMA column_def", - /* 149 */ "column_def ::= column_name type_name", - /* 150 */ "column_def ::= column_name type_name COMMENT NK_STRING", - /* 151 */ "type_name ::= BOOL", - /* 152 */ "type_name ::= TINYINT", - /* 153 */ "type_name ::= SMALLINT", - /* 154 */ "type_name ::= INT", - /* 155 */ "type_name ::= INTEGER", - /* 156 */ "type_name ::= BIGINT", - /* 157 */ "type_name ::= FLOAT", - /* 158 */ "type_name ::= DOUBLE", - /* 159 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", - /* 160 */ "type_name ::= TIMESTAMP", - /* 161 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", - /* 162 */ "type_name ::= TINYINT UNSIGNED", - /* 163 */ "type_name ::= SMALLINT UNSIGNED", - /* 164 */ "type_name ::= INT UNSIGNED", - /* 165 */ "type_name ::= BIGINT UNSIGNED", - /* 166 */ "type_name ::= JSON", - /* 167 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", - /* 168 */ "type_name ::= MEDIUMBLOB", - /* 169 */ "type_name ::= BLOB", - /* 170 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", - /* 171 */ "type_name ::= DECIMAL", - /* 172 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", - /* 173 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 174 */ "tags_def_opt ::=", - /* 175 */ "tags_def_opt ::= tags_def", - /* 176 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", - /* 177 */ "table_options ::=", - /* 178 */ "table_options ::= table_options COMMENT NK_STRING", - /* 179 */ "table_options ::= table_options MAX_DELAY duration_list", - /* 180 */ "table_options ::= table_options WATERMARK duration_list", - /* 181 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", - /* 182 */ "table_options ::= table_options TTL NK_INTEGER", - /* 183 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 184 */ "alter_table_options ::= alter_table_option", - /* 185 */ "alter_table_options ::= alter_table_options alter_table_option", - /* 186 */ "alter_table_option ::= COMMENT NK_STRING", - /* 187 */ "alter_table_option ::= TTL NK_INTEGER", - /* 188 */ "duration_list ::= duration_literal", - /* 189 */ "duration_list ::= duration_list NK_COMMA duration_literal", - /* 190 */ "rollup_func_list ::= rollup_func_name", - /* 191 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", - /* 192 */ "rollup_func_name ::= function_name", - /* 193 */ "rollup_func_name ::= FIRST", - /* 194 */ "rollup_func_name ::= LAST", - /* 195 */ "col_name_list ::= col_name", - /* 196 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 197 */ "col_name ::= column_name", - /* 198 */ "cmd ::= SHOW DNODES", - /* 199 */ "cmd ::= SHOW USERS", - /* 200 */ "cmd ::= SHOW DATABASES", - /* 201 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", - /* 202 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", - /* 203 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", - /* 204 */ "cmd ::= SHOW MNODES", - /* 205 */ "cmd ::= SHOW MODULES", - /* 206 */ "cmd ::= SHOW QNODES", - /* 207 */ "cmd ::= SHOW FUNCTIONS", - /* 208 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", - /* 209 */ "cmd ::= SHOW STREAMS", - /* 210 */ "cmd ::= SHOW ACCOUNTS", - /* 211 */ "cmd ::= SHOW APPS", - /* 212 */ "cmd ::= SHOW CONNECTIONS", - /* 213 */ "cmd ::= SHOW LICENCES", - /* 214 */ "cmd ::= SHOW GRANTS", - /* 215 */ "cmd ::= SHOW CREATE DATABASE db_name", - /* 216 */ "cmd ::= SHOW CREATE TABLE full_table_name", - /* 217 */ "cmd ::= SHOW CREATE STABLE full_table_name", - /* 218 */ "cmd ::= SHOW QUERIES", - /* 219 */ "cmd ::= SHOW SCORES", - /* 220 */ "cmd ::= SHOW TOPICS", - /* 221 */ "cmd ::= SHOW VARIABLES", - /* 222 */ "cmd ::= SHOW LOCAL VARIABLES", - /* 223 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES", - /* 224 */ "cmd ::= SHOW BNODES", - /* 225 */ "cmd ::= SHOW SNODES", - /* 226 */ "cmd ::= SHOW CLUSTER", - /* 227 */ "cmd ::= SHOW TRANSACTIONS", - /* 228 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", - /* 229 */ "cmd ::= SHOW CONSUMERS", - /* 230 */ "cmd ::= SHOW SUBSCRIPTIONS", - /* 231 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", - /* 232 */ "cmd ::= SHOW VNODES NK_INTEGER", - /* 233 */ "cmd ::= SHOW VNODES NK_STRING", - /* 234 */ "db_name_cond_opt ::=", - /* 235 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 236 */ "like_pattern_opt ::=", - /* 237 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 238 */ "table_name_cond ::= table_name", - /* 239 */ "from_db_opt ::=", - /* 240 */ "from_db_opt ::= FROM db_name", - /* 241 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options", - /* 242 */ "cmd ::= DROP INDEX exists_opt full_table_name", - /* 243 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", - /* 244 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt", - /* 245 */ "func_list ::= func", - /* 246 */ "func_list ::= func_list NK_COMMA func", - /* 247 */ "func ::= function_name NK_LP expression_list NK_RP", - /* 248 */ "sma_stream_opt ::=", - /* 249 */ "sma_stream_opt ::= stream_options WATERMARK duration_literal", - /* 250 */ "sma_stream_opt ::= stream_options MAX_DELAY duration_literal", - /* 251 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", - /* 252 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", - /* 253 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", - /* 254 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", - /* 255 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", - /* 256 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 257 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", - /* 258 */ "cmd ::= DESC full_table_name", - /* 259 */ "cmd ::= DESCRIBE full_table_name", - /* 260 */ "cmd ::= RESET QUERY CACHE", - /* 261 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", - /* 262 */ "analyze_opt ::=", - /* 263 */ "analyze_opt ::= ANALYZE", - /* 264 */ "explain_options ::=", - /* 265 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 266 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 267 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", - /* 268 */ "cmd ::= DROP FUNCTION exists_opt function_name", - /* 269 */ "agg_func_opt ::=", - /* 270 */ "agg_func_opt ::= AGGREGATE", - /* 271 */ "bufsize_opt ::=", - /* 272 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 273 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name AS query_or_subquery", - /* 274 */ "cmd ::= DROP STREAM exists_opt stream_name", - /* 275 */ "stream_options ::=", - /* 276 */ "stream_options ::= stream_options TRIGGER AT_ONCE", - /* 277 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 278 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", - /* 279 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 280 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", - /* 281 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 282 */ "cmd ::= KILL QUERY NK_STRING", - /* 283 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 284 */ "cmd ::= BALANCE VGROUP", - /* 285 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 286 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 287 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 288 */ "dnode_list ::= DNODE NK_INTEGER", - /* 289 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 290 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 291 */ "cmd ::= query_or_subquery", - /* 292 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", - /* 293 */ "cmd ::= INSERT INTO full_table_name query_or_subquery", - /* 294 */ "literal ::= NK_INTEGER", - /* 295 */ "literal ::= NK_FLOAT", - /* 296 */ "literal ::= NK_STRING", - /* 297 */ "literal ::= NK_BOOL", - /* 298 */ "literal ::= TIMESTAMP NK_STRING", - /* 299 */ "literal ::= duration_literal", - /* 300 */ "literal ::= NULL", - /* 301 */ "literal ::= NK_QUESTION", - /* 302 */ "duration_literal ::= NK_VARIABLE", - /* 303 */ "signed ::= NK_INTEGER", - /* 304 */ "signed ::= NK_PLUS NK_INTEGER", - /* 305 */ "signed ::= NK_MINUS NK_INTEGER", - /* 306 */ "signed ::= NK_FLOAT", - /* 307 */ "signed ::= NK_PLUS NK_FLOAT", - /* 308 */ "signed ::= NK_MINUS NK_FLOAT", - /* 309 */ "signed_literal ::= signed", - /* 310 */ "signed_literal ::= NK_STRING", - /* 311 */ "signed_literal ::= NK_BOOL", - /* 312 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 313 */ "signed_literal ::= duration_literal", - /* 314 */ "signed_literal ::= NULL", - /* 315 */ "signed_literal ::= literal_func", - /* 316 */ "signed_literal ::= NK_QUESTION", - /* 317 */ "literal_list ::= signed_literal", - /* 318 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 319 */ "db_name ::= NK_ID", - /* 320 */ "table_name ::= NK_ID", - /* 321 */ "column_name ::= NK_ID", - /* 322 */ "function_name ::= NK_ID", - /* 323 */ "table_alias ::= NK_ID", - /* 324 */ "column_alias ::= NK_ID", - /* 325 */ "user_name ::= NK_ID", - /* 326 */ "topic_name ::= NK_ID", - /* 327 */ "stream_name ::= NK_ID", - /* 328 */ "cgroup_name ::= NK_ID", - /* 329 */ "expr_or_subquery ::= expression", - /* 330 */ "expr_or_subquery ::= subquery", - /* 331 */ "expression ::= literal", - /* 332 */ "expression ::= pseudo_column", - /* 333 */ "expression ::= column_reference", - /* 334 */ "expression ::= function_expression", - /* 335 */ "expression ::= case_when_expression", - /* 336 */ "expression ::= NK_LP expression NK_RP", - /* 337 */ "expression ::= NK_PLUS expr_or_subquery", - /* 338 */ "expression ::= NK_MINUS expr_or_subquery", - /* 339 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", - /* 340 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", - /* 341 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", - /* 342 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", - /* 343 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", - /* 344 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 345 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", - /* 346 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", - /* 347 */ "expression_list ::= expr_or_subquery", - /* 348 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", - /* 349 */ "column_reference ::= column_name", - /* 350 */ "column_reference ::= table_name NK_DOT column_name", - /* 351 */ "pseudo_column ::= ROWTS", - /* 352 */ "pseudo_column ::= TBNAME", - /* 353 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 354 */ "pseudo_column ::= QSTART", - /* 355 */ "pseudo_column ::= QEND", - /* 356 */ "pseudo_column ::= QDURATION", - /* 357 */ "pseudo_column ::= WSTART", - /* 358 */ "pseudo_column ::= WEND", - /* 359 */ "pseudo_column ::= WDURATION", - /* 360 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 361 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 362 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", - /* 363 */ "function_expression ::= literal_func", - /* 364 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 365 */ "literal_func ::= NOW", - /* 366 */ "noarg_func ::= NOW", - /* 367 */ "noarg_func ::= TODAY", - /* 368 */ "noarg_func ::= TIMEZONE", - /* 369 */ "noarg_func ::= DATABASE", - /* 370 */ "noarg_func ::= CLIENT_VERSION", - /* 371 */ "noarg_func ::= SERVER_VERSION", - /* 372 */ "noarg_func ::= SERVER_STATUS", - /* 373 */ "noarg_func ::= CURRENT_USER", - /* 374 */ "noarg_func ::= USER", - /* 375 */ "star_func ::= COUNT", - /* 376 */ "star_func ::= FIRST", - /* 377 */ "star_func ::= LAST", - /* 378 */ "star_func ::= LAST_ROW", - /* 379 */ "star_func_para_list ::= NK_STAR", - /* 380 */ "star_func_para_list ::= other_para_list", - /* 381 */ "other_para_list ::= star_func_para", - /* 382 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 383 */ "star_func_para ::= expr_or_subquery", - /* 384 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 385 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", - /* 386 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", - /* 387 */ "when_then_list ::= when_then_expr", - /* 388 */ "when_then_list ::= when_then_list when_then_expr", - /* 389 */ "when_then_expr ::= WHEN common_expression THEN common_expression", - /* 390 */ "case_when_else_opt ::=", - /* 391 */ "case_when_else_opt ::= ELSE common_expression", - /* 392 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", - /* 393 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", - /* 394 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", - /* 395 */ "predicate ::= expr_or_subquery IS NULL", - /* 396 */ "predicate ::= expr_or_subquery IS NOT NULL", - /* 397 */ "predicate ::= expr_or_subquery in_op in_predicate_value", - /* 398 */ "compare_op ::= NK_LT", - /* 399 */ "compare_op ::= NK_GT", - /* 400 */ "compare_op ::= NK_LE", - /* 401 */ "compare_op ::= NK_GE", - /* 402 */ "compare_op ::= NK_NE", - /* 403 */ "compare_op ::= NK_EQ", - /* 404 */ "compare_op ::= LIKE", - /* 405 */ "compare_op ::= NOT LIKE", - /* 406 */ "compare_op ::= MATCH", - /* 407 */ "compare_op ::= NMATCH", - /* 408 */ "compare_op ::= CONTAINS", - /* 409 */ "in_op ::= IN", - /* 410 */ "in_op ::= NOT IN", - /* 411 */ "in_predicate_value ::= NK_LP literal_list NK_RP", - /* 412 */ "boolean_value_expression ::= boolean_primary", - /* 413 */ "boolean_value_expression ::= NOT boolean_primary", - /* 414 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 415 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 416 */ "boolean_primary ::= predicate", - /* 417 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 418 */ "common_expression ::= expr_or_subquery", - /* 419 */ "common_expression ::= boolean_value_expression", - /* 420 */ "from_clause_opt ::=", - /* 421 */ "from_clause_opt ::= FROM table_reference_list", - /* 422 */ "table_reference_list ::= table_reference", - /* 423 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 424 */ "table_reference ::= table_primary", - /* 425 */ "table_reference ::= joined_table", - /* 426 */ "table_primary ::= table_name alias_opt", - /* 427 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 428 */ "table_primary ::= subquery alias_opt", - /* 429 */ "table_primary ::= parenthesized_joined_table", - /* 430 */ "alias_opt ::=", - /* 431 */ "alias_opt ::= table_alias", - /* 432 */ "alias_opt ::= AS table_alias", - /* 433 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 434 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 435 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 436 */ "join_type ::=", - /* 437 */ "join_type ::= INNER", - /* 438 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 439 */ "set_quantifier_opt ::=", - /* 440 */ "set_quantifier_opt ::= DISTINCT", - /* 441 */ "set_quantifier_opt ::= ALL", - /* 442 */ "select_list ::= select_item", - /* 443 */ "select_list ::= select_list NK_COMMA select_item", - /* 444 */ "select_item ::= NK_STAR", - /* 445 */ "select_item ::= common_expression", - /* 446 */ "select_item ::= common_expression column_alias", - /* 447 */ "select_item ::= common_expression AS column_alias", - /* 448 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 449 */ "where_clause_opt ::=", - /* 450 */ "where_clause_opt ::= WHERE search_condition", - /* 451 */ "partition_by_clause_opt ::=", - /* 452 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 453 */ "twindow_clause_opt ::=", - /* 454 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 455 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", - /* 456 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 457 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 458 */ "sliding_opt ::=", - /* 459 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 460 */ "fill_opt ::=", - /* 461 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 462 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 463 */ "fill_mode ::= NONE", - /* 464 */ "fill_mode ::= PREV", - /* 465 */ "fill_mode ::= NULL", - /* 466 */ "fill_mode ::= LINEAR", - /* 467 */ "fill_mode ::= NEXT", - /* 468 */ "group_by_clause_opt ::=", - /* 469 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 470 */ "group_by_list ::= expr_or_subquery", - /* 471 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", - /* 472 */ "having_clause_opt ::=", - /* 473 */ "having_clause_opt ::= HAVING search_condition", - /* 474 */ "range_opt ::=", - /* 475 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", - /* 476 */ "every_opt ::=", - /* 477 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 478 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 479 */ "query_simple ::= query_specification", - /* 480 */ "query_simple ::= union_query_expression", - /* 481 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", - /* 482 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", - /* 483 */ "query_simple_or_subquery ::= query_simple", - /* 484 */ "query_simple_or_subquery ::= subquery", - /* 485 */ "query_or_subquery ::= query_expression", - /* 486 */ "query_or_subquery ::= subquery", - /* 487 */ "order_by_clause_opt ::=", - /* 488 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 489 */ "slimit_clause_opt ::=", - /* 490 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 491 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 492 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 493 */ "limit_clause_opt ::=", - /* 494 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 495 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 496 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 497 */ "subquery ::= NK_LP query_expression NK_RP", - /* 498 */ "subquery ::= NK_LP subquery NK_RP", - /* 499 */ "search_condition ::= common_expression", - /* 500 */ "sort_specification_list ::= sort_specification", - /* 501 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 502 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", - /* 503 */ "ordering_specification_opt ::=", - /* 504 */ "ordering_specification_opt ::= ASC", - /* 505 */ "ordering_specification_opt ::= DESC", - /* 506 */ "null_ordering_opt ::=", - /* 507 */ "null_ordering_opt ::= NULLS FIRST", - /* 508 */ "null_ordering_opt ::= NULLS LAST", + /* 120 */ "speed_opt ::=", + /* 121 */ "speed_opt ::= MAX_SPEED NK_INTEGER", + /* 122 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", + /* 123 */ "cmd ::= CREATE TABLE multi_create_clause", + /* 124 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", + /* 125 */ "cmd ::= DROP TABLE multi_drop_clause", + /* 126 */ "cmd ::= DROP STABLE exists_opt full_table_name", + /* 127 */ "cmd ::= ALTER TABLE alter_table_clause", + /* 128 */ "cmd ::= ALTER STABLE alter_table_clause", + /* 129 */ "alter_table_clause ::= full_table_name alter_table_options", + /* 130 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", + /* 131 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", + /* 132 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", + /* 133 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", + /* 134 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", + /* 135 */ "alter_table_clause ::= full_table_name DROP TAG column_name", + /* 136 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", + /* 137 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", + /* 138 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", + /* 139 */ "multi_create_clause ::= create_subtable_clause", + /* 140 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", + /* 141 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options", + /* 142 */ "multi_drop_clause ::= drop_table_clause", + /* 143 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", + /* 144 */ "drop_table_clause ::= exists_opt full_table_name", + /* 145 */ "specific_cols_opt ::=", + /* 146 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP", + /* 147 */ "full_table_name ::= table_name", + /* 148 */ "full_table_name ::= db_name NK_DOT table_name", + /* 149 */ "column_def_list ::= column_def", + /* 150 */ "column_def_list ::= column_def_list NK_COMMA column_def", + /* 151 */ "column_def ::= column_name type_name", + /* 152 */ "column_def ::= column_name type_name COMMENT NK_STRING", + /* 153 */ "type_name ::= BOOL", + /* 154 */ "type_name ::= TINYINT", + /* 155 */ "type_name ::= SMALLINT", + /* 156 */ "type_name ::= INT", + /* 157 */ "type_name ::= INTEGER", + /* 158 */ "type_name ::= BIGINT", + /* 159 */ "type_name ::= FLOAT", + /* 160 */ "type_name ::= DOUBLE", + /* 161 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", + /* 162 */ "type_name ::= TIMESTAMP", + /* 163 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", + /* 164 */ "type_name ::= TINYINT UNSIGNED", + /* 165 */ "type_name ::= SMALLINT UNSIGNED", + /* 166 */ "type_name ::= INT UNSIGNED", + /* 167 */ "type_name ::= BIGINT UNSIGNED", + /* 168 */ "type_name ::= JSON", + /* 169 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", + /* 170 */ "type_name ::= MEDIUMBLOB", + /* 171 */ "type_name ::= BLOB", + /* 172 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", + /* 173 */ "type_name ::= DECIMAL", + /* 174 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", + /* 175 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 176 */ "tags_def_opt ::=", + /* 177 */ "tags_def_opt ::= tags_def", + /* 178 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", + /* 179 */ "table_options ::=", + /* 180 */ "table_options ::= table_options COMMENT NK_STRING", + /* 181 */ "table_options ::= table_options MAX_DELAY duration_list", + /* 182 */ "table_options ::= table_options WATERMARK duration_list", + /* 183 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", + /* 184 */ "table_options ::= table_options TTL NK_INTEGER", + /* 185 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", + /* 186 */ "alter_table_options ::= alter_table_option", + /* 187 */ "alter_table_options ::= alter_table_options alter_table_option", + /* 188 */ "alter_table_option ::= COMMENT NK_STRING", + /* 189 */ "alter_table_option ::= TTL NK_INTEGER", + /* 190 */ "duration_list ::= duration_literal", + /* 191 */ "duration_list ::= duration_list NK_COMMA duration_literal", + /* 192 */ "rollup_func_list ::= rollup_func_name", + /* 193 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", + /* 194 */ "rollup_func_name ::= function_name", + /* 195 */ "rollup_func_name ::= FIRST", + /* 196 */ "rollup_func_name ::= LAST", + /* 197 */ "col_name_list ::= col_name", + /* 198 */ "col_name_list ::= col_name_list NK_COMMA col_name", + /* 199 */ "col_name ::= column_name", + /* 200 */ "cmd ::= SHOW DNODES", + /* 201 */ "cmd ::= SHOW USERS", + /* 202 */ "cmd ::= SHOW DATABASES", + /* 203 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", + /* 204 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", + /* 205 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", + /* 206 */ "cmd ::= SHOW MNODES", + /* 207 */ "cmd ::= SHOW MODULES", + /* 208 */ "cmd ::= SHOW QNODES", + /* 209 */ "cmd ::= SHOW FUNCTIONS", + /* 210 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", + /* 211 */ "cmd ::= SHOW STREAMS", + /* 212 */ "cmd ::= SHOW ACCOUNTS", + /* 213 */ "cmd ::= SHOW APPS", + /* 214 */ "cmd ::= SHOW CONNECTIONS", + /* 215 */ "cmd ::= SHOW LICENCES", + /* 216 */ "cmd ::= SHOW GRANTS", + /* 217 */ "cmd ::= SHOW CREATE DATABASE db_name", + /* 218 */ "cmd ::= SHOW CREATE TABLE full_table_name", + /* 219 */ "cmd ::= SHOW CREATE STABLE full_table_name", + /* 220 */ "cmd ::= SHOW QUERIES", + /* 221 */ "cmd ::= SHOW SCORES", + /* 222 */ "cmd ::= SHOW TOPICS", + /* 223 */ "cmd ::= SHOW VARIABLES", + /* 224 */ "cmd ::= SHOW LOCAL VARIABLES", + /* 225 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES", + /* 226 */ "cmd ::= SHOW BNODES", + /* 227 */ "cmd ::= SHOW SNODES", + /* 228 */ "cmd ::= SHOW CLUSTER", + /* 229 */ "cmd ::= SHOW TRANSACTIONS", + /* 230 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", + /* 231 */ "cmd ::= SHOW CONSUMERS", + /* 232 */ "cmd ::= SHOW SUBSCRIPTIONS", + /* 233 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", + /* 234 */ "cmd ::= SHOW TABLE TAGS FROM table_name_cond from_db_opt", + /* 235 */ "cmd ::= SHOW VNODES NK_INTEGER", + /* 236 */ "cmd ::= SHOW VNODES NK_STRING", + /* 237 */ "db_name_cond_opt ::=", + /* 238 */ "db_name_cond_opt ::= db_name NK_DOT", + /* 239 */ "like_pattern_opt ::=", + /* 240 */ "like_pattern_opt ::= LIKE NK_STRING", + /* 241 */ "table_name_cond ::= table_name", + /* 242 */ "from_db_opt ::=", + /* 243 */ "from_db_opt ::= FROM db_name", + /* 244 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options", + /* 245 */ "cmd ::= DROP INDEX exists_opt full_table_name", + /* 246 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", + /* 247 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt", + /* 248 */ "func_list ::= func", + /* 249 */ "func_list ::= func_list NK_COMMA func", + /* 250 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 251 */ "sma_stream_opt ::=", + /* 252 */ "sma_stream_opt ::= stream_options WATERMARK duration_literal", + /* 253 */ "sma_stream_opt ::= stream_options MAX_DELAY duration_literal", + /* 254 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", + /* 255 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", + /* 256 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", + /* 257 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", + /* 258 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", + /* 259 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 260 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", + /* 261 */ "cmd ::= DESC full_table_name", + /* 262 */ "cmd ::= DESCRIBE full_table_name", + /* 263 */ "cmd ::= RESET QUERY CACHE", + /* 264 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", + /* 265 */ "analyze_opt ::=", + /* 266 */ "analyze_opt ::= ANALYZE", + /* 267 */ "explain_options ::=", + /* 268 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 269 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 270 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", + /* 271 */ "cmd ::= DROP FUNCTION exists_opt function_name", + /* 272 */ "agg_func_opt ::=", + /* 273 */ "agg_func_opt ::= AGGREGATE", + /* 274 */ "bufsize_opt ::=", + /* 275 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 276 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery", + /* 277 */ "cmd ::= DROP STREAM exists_opt stream_name", + /* 278 */ "stream_options ::=", + /* 279 */ "stream_options ::= stream_options TRIGGER AT_ONCE", + /* 280 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", + /* 281 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", + /* 282 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 283 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", + /* 284 */ "subtable_opt ::=", + /* 285 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", + /* 286 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 287 */ "cmd ::= KILL QUERY NK_STRING", + /* 288 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 289 */ "cmd ::= BALANCE VGROUP", + /* 290 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 291 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 292 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 293 */ "dnode_list ::= DNODE NK_INTEGER", + /* 294 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 295 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 296 */ "cmd ::= query_or_subquery", + /* 297 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", + /* 298 */ "cmd ::= INSERT INTO full_table_name query_or_subquery", + /* 299 */ "literal ::= NK_INTEGER", + /* 300 */ "literal ::= NK_FLOAT", + /* 301 */ "literal ::= NK_STRING", + /* 302 */ "literal ::= NK_BOOL", + /* 303 */ "literal ::= TIMESTAMP NK_STRING", + /* 304 */ "literal ::= duration_literal", + /* 305 */ "literal ::= NULL", + /* 306 */ "literal ::= NK_QUESTION", + /* 307 */ "duration_literal ::= NK_VARIABLE", + /* 308 */ "signed ::= NK_INTEGER", + /* 309 */ "signed ::= NK_PLUS NK_INTEGER", + /* 310 */ "signed ::= NK_MINUS NK_INTEGER", + /* 311 */ "signed ::= NK_FLOAT", + /* 312 */ "signed ::= NK_PLUS NK_FLOAT", + /* 313 */ "signed ::= NK_MINUS NK_FLOAT", + /* 314 */ "signed_literal ::= signed", + /* 315 */ "signed_literal ::= NK_STRING", + /* 316 */ "signed_literal ::= NK_BOOL", + /* 317 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 318 */ "signed_literal ::= duration_literal", + /* 319 */ "signed_literal ::= NULL", + /* 320 */ "signed_literal ::= literal_func", + /* 321 */ "signed_literal ::= NK_QUESTION", + /* 322 */ "literal_list ::= signed_literal", + /* 323 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 324 */ "db_name ::= NK_ID", + /* 325 */ "table_name ::= NK_ID", + /* 326 */ "column_name ::= NK_ID", + /* 327 */ "function_name ::= NK_ID", + /* 328 */ "table_alias ::= NK_ID", + /* 329 */ "column_alias ::= NK_ID", + /* 330 */ "user_name ::= NK_ID", + /* 331 */ "topic_name ::= NK_ID", + /* 332 */ "stream_name ::= NK_ID", + /* 333 */ "cgroup_name ::= NK_ID", + /* 334 */ "expr_or_subquery ::= expression", + /* 335 */ "expr_or_subquery ::= subquery", + /* 336 */ "expression ::= literal", + /* 337 */ "expression ::= pseudo_column", + /* 338 */ "expression ::= column_reference", + /* 339 */ "expression ::= function_expression", + /* 340 */ "expression ::= case_when_expression", + /* 341 */ "expression ::= NK_LP expression NK_RP", + /* 342 */ "expression ::= NK_PLUS expr_or_subquery", + /* 343 */ "expression ::= NK_MINUS expr_or_subquery", + /* 344 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", + /* 345 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", + /* 346 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", + /* 347 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", + /* 348 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", + /* 349 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 350 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", + /* 351 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", + /* 352 */ "expression_list ::= expr_or_subquery", + /* 353 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", + /* 354 */ "column_reference ::= column_name", + /* 355 */ "column_reference ::= table_name NK_DOT column_name", + /* 356 */ "pseudo_column ::= ROWTS", + /* 357 */ "pseudo_column ::= TBNAME", + /* 358 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 359 */ "pseudo_column ::= QSTART", + /* 360 */ "pseudo_column ::= QEND", + /* 361 */ "pseudo_column ::= QDURATION", + /* 362 */ "pseudo_column ::= WSTART", + /* 363 */ "pseudo_column ::= WEND", + /* 364 */ "pseudo_column ::= WDURATION", + /* 365 */ "pseudo_column ::= IROWTS", + /* 366 */ "pseudo_column ::= QTAGS", + /* 367 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 368 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 369 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", + /* 370 */ "function_expression ::= literal_func", + /* 371 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 372 */ "literal_func ::= NOW", + /* 373 */ "noarg_func ::= NOW", + /* 374 */ "noarg_func ::= TODAY", + /* 375 */ "noarg_func ::= TIMEZONE", + /* 376 */ "noarg_func ::= DATABASE", + /* 377 */ "noarg_func ::= CLIENT_VERSION", + /* 378 */ "noarg_func ::= SERVER_VERSION", + /* 379 */ "noarg_func ::= SERVER_STATUS", + /* 380 */ "noarg_func ::= CURRENT_USER", + /* 381 */ "noarg_func ::= USER", + /* 382 */ "star_func ::= COUNT", + /* 383 */ "star_func ::= FIRST", + /* 384 */ "star_func ::= LAST", + /* 385 */ "star_func ::= LAST_ROW", + /* 386 */ "star_func_para_list ::= NK_STAR", + /* 387 */ "star_func_para_list ::= other_para_list", + /* 388 */ "other_para_list ::= star_func_para", + /* 389 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 390 */ "star_func_para ::= expr_or_subquery", + /* 391 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 392 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", + /* 393 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", + /* 394 */ "when_then_list ::= when_then_expr", + /* 395 */ "when_then_list ::= when_then_list when_then_expr", + /* 396 */ "when_then_expr ::= WHEN common_expression THEN common_expression", + /* 397 */ "case_when_else_opt ::=", + /* 398 */ "case_when_else_opt ::= ELSE common_expression", + /* 399 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", + /* 400 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", + /* 401 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", + /* 402 */ "predicate ::= expr_or_subquery IS NULL", + /* 403 */ "predicate ::= expr_or_subquery IS NOT NULL", + /* 404 */ "predicate ::= expr_or_subquery in_op in_predicate_value", + /* 405 */ "compare_op ::= NK_LT", + /* 406 */ "compare_op ::= NK_GT", + /* 407 */ "compare_op ::= NK_LE", + /* 408 */ "compare_op ::= NK_GE", + /* 409 */ "compare_op ::= NK_NE", + /* 410 */ "compare_op ::= NK_EQ", + /* 411 */ "compare_op ::= LIKE", + /* 412 */ "compare_op ::= NOT LIKE", + /* 413 */ "compare_op ::= MATCH", + /* 414 */ "compare_op ::= NMATCH", + /* 415 */ "compare_op ::= CONTAINS", + /* 416 */ "in_op ::= IN", + /* 417 */ "in_op ::= NOT IN", + /* 418 */ "in_predicate_value ::= NK_LP literal_list NK_RP", + /* 419 */ "boolean_value_expression ::= boolean_primary", + /* 420 */ "boolean_value_expression ::= NOT boolean_primary", + /* 421 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 422 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 423 */ "boolean_primary ::= predicate", + /* 424 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 425 */ "common_expression ::= expr_or_subquery", + /* 426 */ "common_expression ::= boolean_value_expression", + /* 427 */ "from_clause_opt ::=", + /* 428 */ "from_clause_opt ::= FROM table_reference_list", + /* 429 */ "table_reference_list ::= table_reference", + /* 430 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 431 */ "table_reference ::= table_primary", + /* 432 */ "table_reference ::= joined_table", + /* 433 */ "table_primary ::= table_name alias_opt", + /* 434 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 435 */ "table_primary ::= subquery alias_opt", + /* 436 */ "table_primary ::= parenthesized_joined_table", + /* 437 */ "alias_opt ::=", + /* 438 */ "alias_opt ::= table_alias", + /* 439 */ "alias_opt ::= AS table_alias", + /* 440 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 441 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 442 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 443 */ "join_type ::=", + /* 444 */ "join_type ::= INNER", + /* 445 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 446 */ "set_quantifier_opt ::=", + /* 447 */ "set_quantifier_opt ::= DISTINCT", + /* 448 */ "set_quantifier_opt ::= ALL", + /* 449 */ "select_list ::= select_item", + /* 450 */ "select_list ::= select_list NK_COMMA select_item", + /* 451 */ "select_item ::= NK_STAR", + /* 452 */ "select_item ::= common_expression", + /* 453 */ "select_item ::= common_expression column_alias", + /* 454 */ "select_item ::= common_expression AS column_alias", + /* 455 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 456 */ "where_clause_opt ::=", + /* 457 */ "where_clause_opt ::= WHERE search_condition", + /* 458 */ "partition_by_clause_opt ::=", + /* 459 */ "partition_by_clause_opt ::= PARTITION BY partition_list", + /* 460 */ "partition_list ::= partition_item", + /* 461 */ "partition_list ::= partition_list NK_COMMA partition_item", + /* 462 */ "partition_item ::= expr_or_subquery", + /* 463 */ "partition_item ::= expr_or_subquery column_alias", + /* 464 */ "partition_item ::= expr_or_subquery AS column_alias", + /* 465 */ "twindow_clause_opt ::=", + /* 466 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 467 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", + /* 468 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 469 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 470 */ "sliding_opt ::=", + /* 471 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 472 */ "fill_opt ::=", + /* 473 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 474 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 475 */ "fill_mode ::= NONE", + /* 476 */ "fill_mode ::= PREV", + /* 477 */ "fill_mode ::= NULL", + /* 478 */ "fill_mode ::= LINEAR", + /* 479 */ "fill_mode ::= NEXT", + /* 480 */ "group_by_clause_opt ::=", + /* 481 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 482 */ "group_by_list ::= expr_or_subquery", + /* 483 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", + /* 484 */ "having_clause_opt ::=", + /* 485 */ "having_clause_opt ::= HAVING search_condition", + /* 486 */ "range_opt ::=", + /* 487 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", + /* 488 */ "every_opt ::=", + /* 489 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 490 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 491 */ "query_simple ::= query_specification", + /* 492 */ "query_simple ::= union_query_expression", + /* 493 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", + /* 494 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", + /* 495 */ "query_simple_or_subquery ::= query_simple", + /* 496 */ "query_simple_or_subquery ::= subquery", + /* 497 */ "query_or_subquery ::= query_expression", + /* 498 */ "query_or_subquery ::= subquery", + /* 499 */ "order_by_clause_opt ::=", + /* 500 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 501 */ "slimit_clause_opt ::=", + /* 502 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 503 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 504 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 505 */ "limit_clause_opt ::=", + /* 506 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 507 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 508 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 509 */ "subquery ::= NK_LP query_expression NK_RP", + /* 510 */ "subquery ::= NK_LP subquery NK_RP", + /* 511 */ "search_condition ::= common_expression", + /* 512 */ "sort_specification_list ::= sort_specification", + /* 513 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 514 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", + /* 515 */ "ordering_specification_opt ::=", + /* 516 */ "ordering_specification_opt ::= ASC", + /* 517 */ "ordering_specification_opt ::= DESC", + /* 518 */ "null_ordering_opt ::=", + /* 519 */ "null_ordering_opt ::= NULLS FIRST", + /* 520 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -2432,186 +2527,190 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 313: /* cmd */ - case 316: /* literal */ - case 327: /* db_options */ - case 329: /* alter_db_options */ - case 334: /* retention */ - case 335: /* full_table_name */ - case 338: /* table_options */ - case 342: /* alter_table_clause */ - case 343: /* alter_table_options */ - case 346: /* signed_literal */ - case 347: /* create_subtable_clause */ - case 350: /* drop_table_clause */ - case 353: /* column_def */ - case 357: /* duration_literal */ - case 358: /* rollup_func_name */ - case 360: /* col_name */ - case 361: /* db_name_cond_opt */ - case 362: /* like_pattern_opt */ - case 363: /* table_name_cond */ - case 364: /* from_db_opt */ - case 365: /* index_options */ - case 367: /* sliding_opt */ - case 368: /* sma_stream_opt */ - case 369: /* func */ - case 370: /* stream_options */ - case 372: /* query_or_subquery */ - case 375: /* explain_options */ - case 380: /* where_clause_opt */ - case 381: /* signed */ - case 382: /* literal_func */ - case 386: /* expr_or_subquery */ - case 387: /* expression */ - case 388: /* subquery */ - case 389: /* pseudo_column */ - case 390: /* column_reference */ - case 391: /* function_expression */ - case 392: /* case_when_expression */ - case 397: /* star_func_para */ - case 399: /* case_when_else_opt */ - case 400: /* common_expression */ - case 401: /* when_then_expr */ - case 402: /* predicate */ - case 405: /* in_predicate_value */ - case 406: /* boolean_value_expression */ - case 407: /* boolean_primary */ - case 408: /* from_clause_opt */ - case 409: /* table_reference_list */ - case 410: /* table_reference */ - case 411: /* table_primary */ - case 412: /* joined_table */ - case 414: /* parenthesized_joined_table */ - case 416: /* search_condition */ - case 417: /* query_specification */ - case 421: /* range_opt */ - case 422: /* every_opt */ - case 423: /* fill_opt */ - case 424: /* twindow_clause_opt */ - case 426: /* having_clause_opt */ - case 427: /* select_item */ - case 430: /* query_expression */ - case 431: /* query_simple */ - case 433: /* slimit_clause_opt */ - case 434: /* limit_clause_opt */ - case 435: /* union_query_expression */ - case 436: /* query_simple_or_subquery */ - case 438: /* sort_specification */ + case 317: /* cmd */ + case 320: /* literal */ + case 331: /* db_options */ + case 333: /* alter_db_options */ + case 339: /* retention */ + case 340: /* full_table_name */ + case 343: /* table_options */ + case 347: /* alter_table_clause */ + case 348: /* alter_table_options */ + case 351: /* signed_literal */ + case 352: /* create_subtable_clause */ + case 355: /* drop_table_clause */ + case 358: /* column_def */ + case 362: /* duration_literal */ + case 363: /* rollup_func_name */ + case 365: /* col_name */ + case 366: /* db_name_cond_opt */ + case 367: /* like_pattern_opt */ + case 368: /* table_name_cond */ + case 369: /* from_db_opt */ + case 370: /* index_options */ + case 372: /* sliding_opt */ + case 373: /* sma_stream_opt */ + case 374: /* func */ + case 375: /* stream_options */ + case 377: /* query_or_subquery */ + case 380: /* explain_options */ + case 384: /* subtable_opt */ + case 385: /* expression */ + case 387: /* where_clause_opt */ + case 388: /* signed */ + case 389: /* literal_func */ + case 393: /* expr_or_subquery */ + case 394: /* subquery */ + case 395: /* pseudo_column */ + case 396: /* column_reference */ + case 397: /* function_expression */ + case 398: /* case_when_expression */ + case 403: /* star_func_para */ + case 405: /* case_when_else_opt */ + case 406: /* common_expression */ + case 407: /* when_then_expr */ + case 408: /* predicate */ + case 411: /* in_predicate_value */ + case 412: /* boolean_value_expression */ + case 413: /* boolean_primary */ + case 414: /* from_clause_opt */ + case 415: /* table_reference_list */ + case 416: /* table_reference */ + case 417: /* table_primary */ + case 418: /* joined_table */ + case 420: /* parenthesized_joined_table */ + case 422: /* search_condition */ + case 423: /* query_specification */ + case 427: /* range_opt */ + case 428: /* every_opt */ + case 429: /* fill_opt */ + case 430: /* twindow_clause_opt */ + case 432: /* having_clause_opt */ + case 433: /* select_item */ + case 435: /* partition_item */ + case 438: /* query_expression */ + case 439: /* query_simple */ + case 441: /* slimit_clause_opt */ + case 442: /* limit_clause_opt */ + case 443: /* union_query_expression */ + case 444: /* query_simple_or_subquery */ + case 446: /* sort_specification */ { - nodesDestroyNode((yypminor->yy560)); + nodesDestroyNode((yypminor->yy778)); } break; - case 314: /* account_options */ - case 315: /* alter_account_options */ - case 317: /* alter_account_option */ - case 377: /* bufsize_opt */ + case 318: /* account_options */ + case 319: /* alter_account_options */ + case 321: /* alter_account_option */ + case 334: /* speed_opt */ + case 382: /* bufsize_opt */ { } break; - case 318: /* user_name */ - case 321: /* priv_level */ - case 324: /* db_name */ - case 325: /* dnode_endpoint */ - case 344: /* column_name */ - case 352: /* table_name */ - case 359: /* function_name */ - case 371: /* topic_name */ - case 373: /* cgroup_name */ - case 378: /* stream_name */ - case 384: /* table_alias */ - case 385: /* column_alias */ - case 393: /* star_func */ - case 395: /* noarg_func */ - case 413: /* alias_opt */ + case 322: /* user_name */ + case 325: /* priv_level */ + case 328: /* db_name */ + case 329: /* dnode_endpoint */ + case 349: /* column_name */ + case 357: /* table_name */ + case 364: /* function_name */ + case 376: /* topic_name */ + case 378: /* cgroup_name */ + case 383: /* stream_name */ + case 391: /* table_alias */ + case 392: /* column_alias */ + case 399: /* star_func */ + case 401: /* noarg_func */ + case 419: /* alias_opt */ { } break; - case 319: /* sysinfo_opt */ + case 323: /* sysinfo_opt */ { } break; - case 320: /* privileges */ - case 322: /* priv_type_list */ - case 323: /* priv_type */ + case 324: /* privileges */ + case 326: /* priv_type_list */ + case 327: /* priv_type */ { } break; - case 326: /* not_exists_opt */ - case 328: /* exists_opt */ - case 374: /* analyze_opt */ - case 376: /* agg_func_opt */ - case 418: /* set_quantifier_opt */ + case 330: /* not_exists_opt */ + case 332: /* exists_opt */ + case 379: /* analyze_opt */ + case 381: /* agg_func_opt */ + case 424: /* set_quantifier_opt */ { } break; - case 330: /* integer_list */ - case 331: /* variable_list */ - case 332: /* retention_list */ - case 336: /* column_def_list */ - case 337: /* tags_def_opt */ - case 339: /* multi_create_clause */ - case 340: /* tags_def */ - case 341: /* multi_drop_clause */ - case 348: /* specific_cols_opt */ - case 349: /* expression_list */ - case 351: /* col_name_list */ - case 354: /* duration_list */ - case 355: /* rollup_func_list */ - case 366: /* func_list */ - case 379: /* dnode_list */ - case 383: /* literal_list */ - case 394: /* star_func_para_list */ - case 396: /* other_para_list */ - case 398: /* when_then_list */ - case 419: /* select_list */ - case 420: /* partition_by_clause_opt */ - case 425: /* group_by_clause_opt */ - case 429: /* group_by_list */ - case 432: /* order_by_clause_opt */ - case 437: /* sort_specification_list */ + case 335: /* integer_list */ + case 336: /* variable_list */ + case 337: /* retention_list */ + case 341: /* column_def_list */ + case 342: /* tags_def_opt */ + case 344: /* multi_create_clause */ + case 345: /* tags_def */ + case 346: /* multi_drop_clause */ + case 353: /* specific_cols_opt */ + case 354: /* expression_list */ + case 356: /* col_name_list */ + case 359: /* duration_list */ + case 360: /* rollup_func_list */ + case 371: /* func_list */ + case 386: /* dnode_list */ + case 390: /* literal_list */ + case 400: /* star_func_para_list */ + case 402: /* other_para_list */ + case 404: /* when_then_list */ + case 425: /* select_list */ + case 426: /* partition_by_clause_opt */ + case 431: /* group_by_clause_opt */ + case 434: /* partition_list */ + case 437: /* group_by_list */ + case 440: /* order_by_clause_opt */ + case 445: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy334)); + nodesDestroyList((yypminor->yy282)); } break; - case 333: /* alter_db_option */ - case 356: /* alter_table_option */ + case 338: /* alter_db_option */ + case 361: /* alter_table_option */ { } break; - case 345: /* type_name */ + case 350: /* type_name */ { } break; - case 403: /* compare_op */ - case 404: /* in_op */ + case 409: /* compare_op */ + case 410: /* in_op */ { } break; - case 415: /* join_type */ + case 421: /* join_type */ { } break; - case 428: /* fill_mode */ + case 436: /* fill_mode */ { } break; - case 439: /* ordering_specification_opt */ + case 447: /* ordering_specification_opt */ { } break; - case 440: /* null_ordering_opt */ + case 448: /* null_ordering_opt */ { } @@ -2910,515 +3009,527 @@ 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[] = { - { 313, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - { 313, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - { 314, 0 }, /* (2) account_options ::= */ - { 314, -3 }, /* (3) account_options ::= account_options PPS literal */ - { 314, -3 }, /* (4) account_options ::= account_options TSERIES literal */ - { 314, -3 }, /* (5) account_options ::= account_options STORAGE literal */ - { 314, -3 }, /* (6) account_options ::= account_options STREAMS literal */ - { 314, -3 }, /* (7) account_options ::= account_options QTIME literal */ - { 314, -3 }, /* (8) account_options ::= account_options DBS literal */ - { 314, -3 }, /* (9) account_options ::= account_options USERS literal */ - { 314, -3 }, /* (10) account_options ::= account_options CONNS literal */ - { 314, -3 }, /* (11) account_options ::= account_options STATE literal */ - { 315, -1 }, /* (12) alter_account_options ::= alter_account_option */ - { 315, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - { 317, -2 }, /* (14) alter_account_option ::= PASS literal */ - { 317, -2 }, /* (15) alter_account_option ::= PPS literal */ - { 317, -2 }, /* (16) alter_account_option ::= TSERIES literal */ - { 317, -2 }, /* (17) alter_account_option ::= STORAGE literal */ - { 317, -2 }, /* (18) alter_account_option ::= STREAMS literal */ - { 317, -2 }, /* (19) alter_account_option ::= QTIME literal */ - { 317, -2 }, /* (20) alter_account_option ::= DBS literal */ - { 317, -2 }, /* (21) alter_account_option ::= USERS literal */ - { 317, -2 }, /* (22) alter_account_option ::= CONNS literal */ - { 317, -2 }, /* (23) alter_account_option ::= STATE literal */ - { 313, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ - { 313, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 313, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ - { 313, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ - { 313, -3 }, /* (28) cmd ::= DROP USER user_name */ - { 319, 0 }, /* (29) sysinfo_opt ::= */ - { 319, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ - { 313, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ - { 313, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ - { 320, -1 }, /* (33) privileges ::= ALL */ - { 320, -1 }, /* (34) privileges ::= priv_type_list */ - { 322, -1 }, /* (35) priv_type_list ::= priv_type */ - { 322, -3 }, /* (36) priv_type_list ::= priv_type_list NK_COMMA priv_type */ - { 323, -1 }, /* (37) priv_type ::= READ */ - { 323, -1 }, /* (38) priv_type ::= WRITE */ - { 321, -3 }, /* (39) priv_level ::= NK_STAR NK_DOT NK_STAR */ - { 321, -3 }, /* (40) priv_level ::= db_name NK_DOT NK_STAR */ - { 313, -3 }, /* (41) cmd ::= CREATE DNODE dnode_endpoint */ - { 313, -5 }, /* (42) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ - { 313, -3 }, /* (43) cmd ::= DROP DNODE NK_INTEGER */ - { 313, -3 }, /* (44) cmd ::= DROP DNODE dnode_endpoint */ - { 313, -4 }, /* (45) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - { 313, -5 }, /* (46) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - { 313, -4 }, /* (47) cmd ::= ALTER ALL DNODES NK_STRING */ - { 313, -5 }, /* (48) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - { 325, -1 }, /* (49) dnode_endpoint ::= NK_STRING */ - { 325, -1 }, /* (50) dnode_endpoint ::= NK_ID */ - { 325, -1 }, /* (51) dnode_endpoint ::= NK_IPTOKEN */ - { 313, -3 }, /* (52) cmd ::= ALTER LOCAL NK_STRING */ - { 313, -4 }, /* (53) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - { 313, -5 }, /* (54) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 313, -5 }, /* (55) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - { 313, -5 }, /* (56) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - { 313, -5 }, /* (57) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - { 313, -5 }, /* (58) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - { 313, -5 }, /* (59) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - { 313, -5 }, /* (60) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - { 313, -5 }, /* (61) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - { 313, -5 }, /* (62) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 313, -4 }, /* (63) cmd ::= DROP DATABASE exists_opt db_name */ - { 313, -2 }, /* (64) cmd ::= USE db_name */ - { 313, -4 }, /* (65) cmd ::= ALTER DATABASE db_name alter_db_options */ - { 313, -3 }, /* (66) cmd ::= FLUSH DATABASE db_name */ - { 313, -3 }, /* (67) cmd ::= TRIM DATABASE db_name */ - { 326, -3 }, /* (68) not_exists_opt ::= IF NOT EXISTS */ - { 326, 0 }, /* (69) not_exists_opt ::= */ - { 328, -2 }, /* (70) exists_opt ::= IF EXISTS */ - { 328, 0 }, /* (71) exists_opt ::= */ - { 327, 0 }, /* (72) db_options ::= */ - { 327, -3 }, /* (73) db_options ::= db_options BUFFER NK_INTEGER */ - { 327, -3 }, /* (74) db_options ::= db_options CACHEMODEL NK_STRING */ - { 327, -3 }, /* (75) db_options ::= db_options CACHESIZE NK_INTEGER */ - { 327, -3 }, /* (76) db_options ::= db_options COMP NK_INTEGER */ - { 327, -3 }, /* (77) db_options ::= db_options DURATION NK_INTEGER */ - { 327, -3 }, /* (78) db_options ::= db_options DURATION NK_VARIABLE */ - { 327, -3 }, /* (79) db_options ::= db_options MAXROWS NK_INTEGER */ - { 327, -3 }, /* (80) db_options ::= db_options MINROWS NK_INTEGER */ - { 327, -3 }, /* (81) db_options ::= db_options KEEP integer_list */ - { 327, -3 }, /* (82) db_options ::= db_options KEEP variable_list */ - { 327, -3 }, /* (83) db_options ::= db_options PAGES NK_INTEGER */ - { 327, -3 }, /* (84) db_options ::= db_options PAGESIZE NK_INTEGER */ - { 327, -3 }, /* (85) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ - { 327, -3 }, /* (86) db_options ::= db_options PRECISION NK_STRING */ - { 327, -3 }, /* (87) db_options ::= db_options REPLICA NK_INTEGER */ - { 327, -3 }, /* (88) db_options ::= db_options STRICT NK_STRING */ - { 327, -3 }, /* (89) db_options ::= db_options VGROUPS NK_INTEGER */ - { 327, -3 }, /* (90) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 327, -3 }, /* (91) db_options ::= db_options RETENTIONS retention_list */ - { 327, -3 }, /* (92) db_options ::= db_options SCHEMALESS NK_INTEGER */ - { 327, -3 }, /* (93) db_options ::= db_options WAL_LEVEL NK_INTEGER */ - { 327, -3 }, /* (94) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ - { 327, -3 }, /* (95) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ - { 327, -4 }, /* (96) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ - { 327, -3 }, /* (97) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ - { 327, -4 }, /* (98) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ - { 327, -3 }, /* (99) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ - { 327, -3 }, /* (100) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ - { 327, -3 }, /* (101) db_options ::= db_options STT_TRIGGER NK_INTEGER */ - { 327, -3 }, /* (102) db_options ::= db_options TABLE_PREFIX NK_INTEGER */ - { 327, -3 }, /* (103) db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ - { 329, -1 }, /* (104) alter_db_options ::= alter_db_option */ - { 329, -2 }, /* (105) alter_db_options ::= alter_db_options alter_db_option */ - { 333, -2 }, /* (106) alter_db_option ::= CACHEMODEL NK_STRING */ - { 333, -2 }, /* (107) alter_db_option ::= CACHESIZE NK_INTEGER */ - { 333, -2 }, /* (108) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ - { 333, -2 }, /* (109) alter_db_option ::= KEEP integer_list */ - { 333, -2 }, /* (110) alter_db_option ::= KEEP variable_list */ - { 333, -2 }, /* (111) alter_db_option ::= WAL_LEVEL NK_INTEGER */ - { 333, -2 }, /* (112) alter_db_option ::= STT_TRIGGER NK_INTEGER */ - { 330, -1 }, /* (113) integer_list ::= NK_INTEGER */ - { 330, -3 }, /* (114) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - { 331, -1 }, /* (115) variable_list ::= NK_VARIABLE */ - { 331, -3 }, /* (116) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - { 332, -1 }, /* (117) retention_list ::= retention */ - { 332, -3 }, /* (118) retention_list ::= retention_list NK_COMMA retention */ - { 334, -3 }, /* (119) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - { 313, -9 }, /* (120) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 313, -3 }, /* (121) cmd ::= CREATE TABLE multi_create_clause */ - { 313, -9 }, /* (122) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 313, -3 }, /* (123) cmd ::= DROP TABLE multi_drop_clause */ - { 313, -4 }, /* (124) cmd ::= DROP STABLE exists_opt full_table_name */ - { 313, -3 }, /* (125) cmd ::= ALTER TABLE alter_table_clause */ - { 313, -3 }, /* (126) cmd ::= ALTER STABLE alter_table_clause */ - { 342, -2 }, /* (127) alter_table_clause ::= full_table_name alter_table_options */ - { 342, -5 }, /* (128) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - { 342, -4 }, /* (129) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - { 342, -5 }, /* (130) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - { 342, -5 }, /* (131) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - { 342, -5 }, /* (132) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - { 342, -4 }, /* (133) alter_table_clause ::= full_table_name DROP TAG column_name */ - { 342, -5 }, /* (134) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - { 342, -5 }, /* (135) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - { 342, -6 }, /* (136) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ - { 339, -1 }, /* (137) multi_create_clause ::= create_subtable_clause */ - { 339, -2 }, /* (138) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 347, -10 }, /* (139) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ - { 341, -1 }, /* (140) multi_drop_clause ::= drop_table_clause */ - { 341, -2 }, /* (141) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 350, -2 }, /* (142) drop_table_clause ::= exists_opt full_table_name */ - { 348, 0 }, /* (143) specific_cols_opt ::= */ - { 348, -3 }, /* (144) specific_cols_opt ::= NK_LP col_name_list NK_RP */ - { 335, -1 }, /* (145) full_table_name ::= table_name */ - { 335, -3 }, /* (146) full_table_name ::= db_name NK_DOT table_name */ - { 336, -1 }, /* (147) column_def_list ::= column_def */ - { 336, -3 }, /* (148) column_def_list ::= column_def_list NK_COMMA column_def */ - { 353, -2 }, /* (149) column_def ::= column_name type_name */ - { 353, -4 }, /* (150) column_def ::= column_name type_name COMMENT NK_STRING */ - { 345, -1 }, /* (151) type_name ::= BOOL */ - { 345, -1 }, /* (152) type_name ::= TINYINT */ - { 345, -1 }, /* (153) type_name ::= SMALLINT */ - { 345, -1 }, /* (154) type_name ::= INT */ - { 345, -1 }, /* (155) type_name ::= INTEGER */ - { 345, -1 }, /* (156) type_name ::= BIGINT */ - { 345, -1 }, /* (157) type_name ::= FLOAT */ - { 345, -1 }, /* (158) type_name ::= DOUBLE */ - { 345, -4 }, /* (159) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 345, -1 }, /* (160) type_name ::= TIMESTAMP */ - { 345, -4 }, /* (161) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 345, -2 }, /* (162) type_name ::= TINYINT UNSIGNED */ - { 345, -2 }, /* (163) type_name ::= SMALLINT UNSIGNED */ - { 345, -2 }, /* (164) type_name ::= INT UNSIGNED */ - { 345, -2 }, /* (165) type_name ::= BIGINT UNSIGNED */ - { 345, -1 }, /* (166) type_name ::= JSON */ - { 345, -4 }, /* (167) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 345, -1 }, /* (168) type_name ::= MEDIUMBLOB */ - { 345, -1 }, /* (169) type_name ::= BLOB */ - { 345, -4 }, /* (170) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 345, -1 }, /* (171) type_name ::= DECIMAL */ - { 345, -4 }, /* (172) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 345, -6 }, /* (173) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 337, 0 }, /* (174) tags_def_opt ::= */ - { 337, -1 }, /* (175) tags_def_opt ::= tags_def */ - { 340, -4 }, /* (176) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 338, 0 }, /* (177) table_options ::= */ - { 338, -3 }, /* (178) table_options ::= table_options COMMENT NK_STRING */ - { 338, -3 }, /* (179) table_options ::= table_options MAX_DELAY duration_list */ - { 338, -3 }, /* (180) table_options ::= table_options WATERMARK duration_list */ - { 338, -5 }, /* (181) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ - { 338, -3 }, /* (182) table_options ::= table_options TTL NK_INTEGER */ - { 338, -5 }, /* (183) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 343, -1 }, /* (184) alter_table_options ::= alter_table_option */ - { 343, -2 }, /* (185) alter_table_options ::= alter_table_options alter_table_option */ - { 356, -2 }, /* (186) alter_table_option ::= COMMENT NK_STRING */ - { 356, -2 }, /* (187) alter_table_option ::= TTL NK_INTEGER */ - { 354, -1 }, /* (188) duration_list ::= duration_literal */ - { 354, -3 }, /* (189) duration_list ::= duration_list NK_COMMA duration_literal */ - { 355, -1 }, /* (190) rollup_func_list ::= rollup_func_name */ - { 355, -3 }, /* (191) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ - { 358, -1 }, /* (192) rollup_func_name ::= function_name */ - { 358, -1 }, /* (193) rollup_func_name ::= FIRST */ - { 358, -1 }, /* (194) rollup_func_name ::= LAST */ - { 351, -1 }, /* (195) col_name_list ::= col_name */ - { 351, -3 }, /* (196) col_name_list ::= col_name_list NK_COMMA col_name */ - { 360, -1 }, /* (197) col_name ::= column_name */ - { 313, -2 }, /* (198) cmd ::= SHOW DNODES */ - { 313, -2 }, /* (199) cmd ::= SHOW USERS */ - { 313, -2 }, /* (200) cmd ::= SHOW DATABASES */ - { 313, -4 }, /* (201) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - { 313, -4 }, /* (202) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - { 313, -3 }, /* (203) cmd ::= SHOW db_name_cond_opt VGROUPS */ - { 313, -2 }, /* (204) cmd ::= SHOW MNODES */ - { 313, -2 }, /* (205) cmd ::= SHOW MODULES */ - { 313, -2 }, /* (206) cmd ::= SHOW QNODES */ - { 313, -2 }, /* (207) cmd ::= SHOW FUNCTIONS */ - { 313, -5 }, /* (208) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - { 313, -2 }, /* (209) cmd ::= SHOW STREAMS */ - { 313, -2 }, /* (210) cmd ::= SHOW ACCOUNTS */ - { 313, -2 }, /* (211) cmd ::= SHOW APPS */ - { 313, -2 }, /* (212) cmd ::= SHOW CONNECTIONS */ - { 313, -2 }, /* (213) cmd ::= SHOW LICENCES */ - { 313, -2 }, /* (214) cmd ::= SHOW GRANTS */ - { 313, -4 }, /* (215) cmd ::= SHOW CREATE DATABASE db_name */ - { 313, -4 }, /* (216) cmd ::= SHOW CREATE TABLE full_table_name */ - { 313, -4 }, /* (217) cmd ::= SHOW CREATE STABLE full_table_name */ - { 313, -2 }, /* (218) cmd ::= SHOW QUERIES */ - { 313, -2 }, /* (219) cmd ::= SHOW SCORES */ - { 313, -2 }, /* (220) cmd ::= SHOW TOPICS */ - { 313, -2 }, /* (221) cmd ::= SHOW VARIABLES */ - { 313, -3 }, /* (222) cmd ::= SHOW LOCAL VARIABLES */ - { 313, -4 }, /* (223) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ - { 313, -2 }, /* (224) cmd ::= SHOW BNODES */ - { 313, -2 }, /* (225) cmd ::= SHOW SNODES */ - { 313, -2 }, /* (226) cmd ::= SHOW CLUSTER */ - { 313, -2 }, /* (227) cmd ::= SHOW TRANSACTIONS */ - { 313, -4 }, /* (228) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - { 313, -2 }, /* (229) cmd ::= SHOW CONSUMERS */ - { 313, -2 }, /* (230) cmd ::= SHOW SUBSCRIPTIONS */ - { 313, -5 }, /* (231) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ - { 313, -3 }, /* (232) cmd ::= SHOW VNODES NK_INTEGER */ - { 313, -3 }, /* (233) cmd ::= SHOW VNODES NK_STRING */ - { 361, 0 }, /* (234) db_name_cond_opt ::= */ - { 361, -2 }, /* (235) db_name_cond_opt ::= db_name NK_DOT */ - { 362, 0 }, /* (236) like_pattern_opt ::= */ - { 362, -2 }, /* (237) like_pattern_opt ::= LIKE NK_STRING */ - { 363, -1 }, /* (238) table_name_cond ::= table_name */ - { 364, 0 }, /* (239) from_db_opt ::= */ - { 364, -2 }, /* (240) from_db_opt ::= FROM db_name */ - { 313, -8 }, /* (241) cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ - { 313, -4 }, /* (242) cmd ::= DROP INDEX exists_opt full_table_name */ - { 365, -10 }, /* (243) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - { 365, -12 }, /* (244) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ - { 366, -1 }, /* (245) func_list ::= func */ - { 366, -3 }, /* (246) func_list ::= func_list NK_COMMA func */ - { 369, -4 }, /* (247) func ::= function_name NK_LP expression_list NK_RP */ - { 368, 0 }, /* (248) sma_stream_opt ::= */ - { 368, -3 }, /* (249) sma_stream_opt ::= stream_options WATERMARK duration_literal */ - { 368, -3 }, /* (250) sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ - { 313, -6 }, /* (251) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ - { 313, -7 }, /* (252) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ - { 313, -9 }, /* (253) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ - { 313, -7 }, /* (254) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ - { 313, -9 }, /* (255) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ - { 313, -4 }, /* (256) cmd ::= DROP TOPIC exists_opt topic_name */ - { 313, -7 }, /* (257) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - { 313, -2 }, /* (258) cmd ::= DESC full_table_name */ - { 313, -2 }, /* (259) cmd ::= DESCRIBE full_table_name */ - { 313, -3 }, /* (260) cmd ::= RESET QUERY CACHE */ - { 313, -4 }, /* (261) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - { 374, 0 }, /* (262) analyze_opt ::= */ - { 374, -1 }, /* (263) analyze_opt ::= ANALYZE */ - { 375, 0 }, /* (264) explain_options ::= */ - { 375, -3 }, /* (265) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 375, -3 }, /* (266) explain_options ::= explain_options RATIO NK_FLOAT */ - { 313, -10 }, /* (267) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ - { 313, -4 }, /* (268) cmd ::= DROP FUNCTION exists_opt function_name */ - { 376, 0 }, /* (269) agg_func_opt ::= */ - { 376, -1 }, /* (270) agg_func_opt ::= AGGREGATE */ - { 377, 0 }, /* (271) bufsize_opt ::= */ - { 377, -2 }, /* (272) bufsize_opt ::= BUFSIZE NK_INTEGER */ - { 313, -9 }, /* (273) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name AS query_or_subquery */ - { 313, -4 }, /* (274) cmd ::= DROP STREAM exists_opt stream_name */ - { 370, 0 }, /* (275) stream_options ::= */ - { 370, -3 }, /* (276) stream_options ::= stream_options TRIGGER AT_ONCE */ - { 370, -3 }, /* (277) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - { 370, -4 }, /* (278) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - { 370, -3 }, /* (279) stream_options ::= stream_options WATERMARK duration_literal */ - { 370, -4 }, /* (280) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ - { 313, -3 }, /* (281) cmd ::= KILL CONNECTION NK_INTEGER */ - { 313, -3 }, /* (282) cmd ::= KILL QUERY NK_STRING */ - { 313, -3 }, /* (283) cmd ::= KILL TRANSACTION NK_INTEGER */ - { 313, -2 }, /* (284) cmd ::= BALANCE VGROUP */ - { 313, -4 }, /* (285) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - { 313, -4 }, /* (286) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - { 313, -3 }, /* (287) cmd ::= SPLIT VGROUP NK_INTEGER */ - { 379, -2 }, /* (288) dnode_list ::= DNODE NK_INTEGER */ - { 379, -3 }, /* (289) dnode_list ::= dnode_list DNODE NK_INTEGER */ - { 313, -4 }, /* (290) cmd ::= DELETE FROM full_table_name where_clause_opt */ - { 313, -1 }, /* (291) cmd ::= query_or_subquery */ - { 313, -7 }, /* (292) cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ - { 313, -4 }, /* (293) cmd ::= INSERT INTO full_table_name query_or_subquery */ - { 316, -1 }, /* (294) literal ::= NK_INTEGER */ - { 316, -1 }, /* (295) literal ::= NK_FLOAT */ - { 316, -1 }, /* (296) literal ::= NK_STRING */ - { 316, -1 }, /* (297) literal ::= NK_BOOL */ - { 316, -2 }, /* (298) literal ::= TIMESTAMP NK_STRING */ - { 316, -1 }, /* (299) literal ::= duration_literal */ - { 316, -1 }, /* (300) literal ::= NULL */ - { 316, -1 }, /* (301) literal ::= NK_QUESTION */ - { 357, -1 }, /* (302) duration_literal ::= NK_VARIABLE */ - { 381, -1 }, /* (303) signed ::= NK_INTEGER */ - { 381, -2 }, /* (304) signed ::= NK_PLUS NK_INTEGER */ - { 381, -2 }, /* (305) signed ::= NK_MINUS NK_INTEGER */ - { 381, -1 }, /* (306) signed ::= NK_FLOAT */ - { 381, -2 }, /* (307) signed ::= NK_PLUS NK_FLOAT */ - { 381, -2 }, /* (308) signed ::= NK_MINUS NK_FLOAT */ - { 346, -1 }, /* (309) signed_literal ::= signed */ - { 346, -1 }, /* (310) signed_literal ::= NK_STRING */ - { 346, -1 }, /* (311) signed_literal ::= NK_BOOL */ - { 346, -2 }, /* (312) signed_literal ::= TIMESTAMP NK_STRING */ - { 346, -1 }, /* (313) signed_literal ::= duration_literal */ - { 346, -1 }, /* (314) signed_literal ::= NULL */ - { 346, -1 }, /* (315) signed_literal ::= literal_func */ - { 346, -1 }, /* (316) signed_literal ::= NK_QUESTION */ - { 383, -1 }, /* (317) literal_list ::= signed_literal */ - { 383, -3 }, /* (318) literal_list ::= literal_list NK_COMMA signed_literal */ - { 324, -1 }, /* (319) db_name ::= NK_ID */ - { 352, -1 }, /* (320) table_name ::= NK_ID */ - { 344, -1 }, /* (321) column_name ::= NK_ID */ - { 359, -1 }, /* (322) function_name ::= NK_ID */ - { 384, -1 }, /* (323) table_alias ::= NK_ID */ - { 385, -1 }, /* (324) column_alias ::= NK_ID */ - { 318, -1 }, /* (325) user_name ::= NK_ID */ - { 371, -1 }, /* (326) topic_name ::= NK_ID */ - { 378, -1 }, /* (327) stream_name ::= NK_ID */ - { 373, -1 }, /* (328) cgroup_name ::= NK_ID */ - { 386, -1 }, /* (329) expr_or_subquery ::= expression */ - { 386, -1 }, /* (330) expr_or_subquery ::= subquery */ - { 387, -1 }, /* (331) expression ::= literal */ - { 387, -1 }, /* (332) expression ::= pseudo_column */ - { 387, -1 }, /* (333) expression ::= column_reference */ - { 387, -1 }, /* (334) expression ::= function_expression */ - { 387, -1 }, /* (335) expression ::= case_when_expression */ - { 387, -3 }, /* (336) expression ::= NK_LP expression NK_RP */ - { 387, -2 }, /* (337) expression ::= NK_PLUS expr_or_subquery */ - { 387, -2 }, /* (338) expression ::= NK_MINUS expr_or_subquery */ - { 387, -3 }, /* (339) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ - { 387, -3 }, /* (340) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ - { 387, -3 }, /* (341) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ - { 387, -3 }, /* (342) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ - { 387, -3 }, /* (343) expression ::= expr_or_subquery NK_REM expr_or_subquery */ - { 387, -3 }, /* (344) expression ::= column_reference NK_ARROW NK_STRING */ - { 387, -3 }, /* (345) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ - { 387, -3 }, /* (346) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ - { 349, -1 }, /* (347) expression_list ::= expr_or_subquery */ - { 349, -3 }, /* (348) expression_list ::= expression_list NK_COMMA expr_or_subquery */ - { 390, -1 }, /* (349) column_reference ::= column_name */ - { 390, -3 }, /* (350) column_reference ::= table_name NK_DOT column_name */ - { 389, -1 }, /* (351) pseudo_column ::= ROWTS */ - { 389, -1 }, /* (352) pseudo_column ::= TBNAME */ - { 389, -3 }, /* (353) pseudo_column ::= table_name NK_DOT TBNAME */ - { 389, -1 }, /* (354) pseudo_column ::= QSTART */ - { 389, -1 }, /* (355) pseudo_column ::= QEND */ - { 389, -1 }, /* (356) pseudo_column ::= QDURATION */ - { 389, -1 }, /* (357) pseudo_column ::= WSTART */ - { 389, -1 }, /* (358) pseudo_column ::= WEND */ - { 389, -1 }, /* (359) pseudo_column ::= WDURATION */ - { 391, -4 }, /* (360) function_expression ::= function_name NK_LP expression_list NK_RP */ - { 391, -4 }, /* (361) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - { 391, -6 }, /* (362) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - { 391, -1 }, /* (363) function_expression ::= literal_func */ - { 382, -3 }, /* (364) literal_func ::= noarg_func NK_LP NK_RP */ - { 382, -1 }, /* (365) literal_func ::= NOW */ - { 395, -1 }, /* (366) noarg_func ::= NOW */ - { 395, -1 }, /* (367) noarg_func ::= TODAY */ - { 395, -1 }, /* (368) noarg_func ::= TIMEZONE */ - { 395, -1 }, /* (369) noarg_func ::= DATABASE */ - { 395, -1 }, /* (370) noarg_func ::= CLIENT_VERSION */ - { 395, -1 }, /* (371) noarg_func ::= SERVER_VERSION */ - { 395, -1 }, /* (372) noarg_func ::= SERVER_STATUS */ - { 395, -1 }, /* (373) noarg_func ::= CURRENT_USER */ - { 395, -1 }, /* (374) noarg_func ::= USER */ - { 393, -1 }, /* (375) star_func ::= COUNT */ - { 393, -1 }, /* (376) star_func ::= FIRST */ - { 393, -1 }, /* (377) star_func ::= LAST */ - { 393, -1 }, /* (378) star_func ::= LAST_ROW */ - { 394, -1 }, /* (379) star_func_para_list ::= NK_STAR */ - { 394, -1 }, /* (380) star_func_para_list ::= other_para_list */ - { 396, -1 }, /* (381) other_para_list ::= star_func_para */ - { 396, -3 }, /* (382) other_para_list ::= other_para_list NK_COMMA star_func_para */ - { 397, -1 }, /* (383) star_func_para ::= expr_or_subquery */ - { 397, -3 }, /* (384) star_func_para ::= table_name NK_DOT NK_STAR */ - { 392, -4 }, /* (385) case_when_expression ::= CASE when_then_list case_when_else_opt END */ - { 392, -5 }, /* (386) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ - { 398, -1 }, /* (387) when_then_list ::= when_then_expr */ - { 398, -2 }, /* (388) when_then_list ::= when_then_list when_then_expr */ - { 401, -4 }, /* (389) when_then_expr ::= WHEN common_expression THEN common_expression */ - { 399, 0 }, /* (390) case_when_else_opt ::= */ - { 399, -2 }, /* (391) case_when_else_opt ::= ELSE common_expression */ - { 402, -3 }, /* (392) predicate ::= expr_or_subquery compare_op expr_or_subquery */ - { 402, -5 }, /* (393) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ - { 402, -6 }, /* (394) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ - { 402, -3 }, /* (395) predicate ::= expr_or_subquery IS NULL */ - { 402, -4 }, /* (396) predicate ::= expr_or_subquery IS NOT NULL */ - { 402, -3 }, /* (397) predicate ::= expr_or_subquery in_op in_predicate_value */ - { 403, -1 }, /* (398) compare_op ::= NK_LT */ - { 403, -1 }, /* (399) compare_op ::= NK_GT */ - { 403, -1 }, /* (400) compare_op ::= NK_LE */ - { 403, -1 }, /* (401) compare_op ::= NK_GE */ - { 403, -1 }, /* (402) compare_op ::= NK_NE */ - { 403, -1 }, /* (403) compare_op ::= NK_EQ */ - { 403, -1 }, /* (404) compare_op ::= LIKE */ - { 403, -2 }, /* (405) compare_op ::= NOT LIKE */ - { 403, -1 }, /* (406) compare_op ::= MATCH */ - { 403, -1 }, /* (407) compare_op ::= NMATCH */ - { 403, -1 }, /* (408) compare_op ::= CONTAINS */ - { 404, -1 }, /* (409) in_op ::= IN */ - { 404, -2 }, /* (410) in_op ::= NOT IN */ - { 405, -3 }, /* (411) in_predicate_value ::= NK_LP literal_list NK_RP */ - { 406, -1 }, /* (412) boolean_value_expression ::= boolean_primary */ - { 406, -2 }, /* (413) boolean_value_expression ::= NOT boolean_primary */ - { 406, -3 }, /* (414) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 406, -3 }, /* (415) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 407, -1 }, /* (416) boolean_primary ::= predicate */ - { 407, -3 }, /* (417) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 400, -1 }, /* (418) common_expression ::= expr_or_subquery */ - { 400, -1 }, /* (419) common_expression ::= boolean_value_expression */ - { 408, 0 }, /* (420) from_clause_opt ::= */ - { 408, -2 }, /* (421) from_clause_opt ::= FROM table_reference_list */ - { 409, -1 }, /* (422) table_reference_list ::= table_reference */ - { 409, -3 }, /* (423) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 410, -1 }, /* (424) table_reference ::= table_primary */ - { 410, -1 }, /* (425) table_reference ::= joined_table */ - { 411, -2 }, /* (426) table_primary ::= table_name alias_opt */ - { 411, -4 }, /* (427) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 411, -2 }, /* (428) table_primary ::= subquery alias_opt */ - { 411, -1 }, /* (429) table_primary ::= parenthesized_joined_table */ - { 413, 0 }, /* (430) alias_opt ::= */ - { 413, -1 }, /* (431) alias_opt ::= table_alias */ - { 413, -2 }, /* (432) alias_opt ::= AS table_alias */ - { 414, -3 }, /* (433) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 414, -3 }, /* (434) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 412, -6 }, /* (435) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 415, 0 }, /* (436) join_type ::= */ - { 415, -1 }, /* (437) join_type ::= INNER */ - { 417, -12 }, /* (438) query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - { 418, 0 }, /* (439) set_quantifier_opt ::= */ - { 418, -1 }, /* (440) set_quantifier_opt ::= DISTINCT */ - { 418, -1 }, /* (441) set_quantifier_opt ::= ALL */ - { 419, -1 }, /* (442) select_list ::= select_item */ - { 419, -3 }, /* (443) select_list ::= select_list NK_COMMA select_item */ - { 427, -1 }, /* (444) select_item ::= NK_STAR */ - { 427, -1 }, /* (445) select_item ::= common_expression */ - { 427, -2 }, /* (446) select_item ::= common_expression column_alias */ - { 427, -3 }, /* (447) select_item ::= common_expression AS column_alias */ - { 427, -3 }, /* (448) select_item ::= table_name NK_DOT NK_STAR */ - { 380, 0 }, /* (449) where_clause_opt ::= */ - { 380, -2 }, /* (450) where_clause_opt ::= WHERE search_condition */ - { 420, 0 }, /* (451) partition_by_clause_opt ::= */ - { 420, -3 }, /* (452) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 424, 0 }, /* (453) twindow_clause_opt ::= */ - { 424, -6 }, /* (454) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 424, -4 }, /* (455) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ - { 424, -6 }, /* (456) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 424, -8 }, /* (457) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 367, 0 }, /* (458) sliding_opt ::= */ - { 367, -4 }, /* (459) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 423, 0 }, /* (460) fill_opt ::= */ - { 423, -4 }, /* (461) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 423, -6 }, /* (462) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 428, -1 }, /* (463) fill_mode ::= NONE */ - { 428, -1 }, /* (464) fill_mode ::= PREV */ - { 428, -1 }, /* (465) fill_mode ::= NULL */ - { 428, -1 }, /* (466) fill_mode ::= LINEAR */ - { 428, -1 }, /* (467) fill_mode ::= NEXT */ - { 425, 0 }, /* (468) group_by_clause_opt ::= */ - { 425, -3 }, /* (469) group_by_clause_opt ::= GROUP BY group_by_list */ - { 429, -1 }, /* (470) group_by_list ::= expr_or_subquery */ - { 429, -3 }, /* (471) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ - { 426, 0 }, /* (472) having_clause_opt ::= */ - { 426, -2 }, /* (473) having_clause_opt ::= HAVING search_condition */ - { 421, 0 }, /* (474) range_opt ::= */ - { 421, -6 }, /* (475) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ - { 422, 0 }, /* (476) every_opt ::= */ - { 422, -4 }, /* (477) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - { 430, -4 }, /* (478) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 431, -1 }, /* (479) query_simple ::= query_specification */ - { 431, -1 }, /* (480) query_simple ::= union_query_expression */ - { 435, -4 }, /* (481) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ - { 435, -3 }, /* (482) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ - { 436, -1 }, /* (483) query_simple_or_subquery ::= query_simple */ - { 436, -1 }, /* (484) query_simple_or_subquery ::= subquery */ - { 372, -1 }, /* (485) query_or_subquery ::= query_expression */ - { 372, -1 }, /* (486) query_or_subquery ::= subquery */ - { 432, 0 }, /* (487) order_by_clause_opt ::= */ - { 432, -3 }, /* (488) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 433, 0 }, /* (489) slimit_clause_opt ::= */ - { 433, -2 }, /* (490) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 433, -4 }, /* (491) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 433, -4 }, /* (492) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 434, 0 }, /* (493) limit_clause_opt ::= */ - { 434, -2 }, /* (494) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 434, -4 }, /* (495) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 434, -4 }, /* (496) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 388, -3 }, /* (497) subquery ::= NK_LP query_expression NK_RP */ - { 388, -3 }, /* (498) subquery ::= NK_LP subquery NK_RP */ - { 416, -1 }, /* (499) search_condition ::= common_expression */ - { 437, -1 }, /* (500) sort_specification_list ::= sort_specification */ - { 437, -3 }, /* (501) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 438, -3 }, /* (502) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ - { 439, 0 }, /* (503) ordering_specification_opt ::= */ - { 439, -1 }, /* (504) ordering_specification_opt ::= ASC */ - { 439, -1 }, /* (505) ordering_specification_opt ::= DESC */ - { 440, 0 }, /* (506) null_ordering_opt ::= */ - { 440, -2 }, /* (507) null_ordering_opt ::= NULLS FIRST */ - { 440, -2 }, /* (508) null_ordering_opt ::= NULLS LAST */ + { 317, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + { 317, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + { 318, 0 }, /* (2) account_options ::= */ + { 318, -3 }, /* (3) account_options ::= account_options PPS literal */ + { 318, -3 }, /* (4) account_options ::= account_options TSERIES literal */ + { 318, -3 }, /* (5) account_options ::= account_options STORAGE literal */ + { 318, -3 }, /* (6) account_options ::= account_options STREAMS literal */ + { 318, -3 }, /* (7) account_options ::= account_options QTIME literal */ + { 318, -3 }, /* (8) account_options ::= account_options DBS literal */ + { 318, -3 }, /* (9) account_options ::= account_options USERS literal */ + { 318, -3 }, /* (10) account_options ::= account_options CONNS literal */ + { 318, -3 }, /* (11) account_options ::= account_options STATE literal */ + { 319, -1 }, /* (12) alter_account_options ::= alter_account_option */ + { 319, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + { 321, -2 }, /* (14) alter_account_option ::= PASS literal */ + { 321, -2 }, /* (15) alter_account_option ::= PPS literal */ + { 321, -2 }, /* (16) alter_account_option ::= TSERIES literal */ + { 321, -2 }, /* (17) alter_account_option ::= STORAGE literal */ + { 321, -2 }, /* (18) alter_account_option ::= STREAMS literal */ + { 321, -2 }, /* (19) alter_account_option ::= QTIME literal */ + { 321, -2 }, /* (20) alter_account_option ::= DBS literal */ + { 321, -2 }, /* (21) alter_account_option ::= USERS literal */ + { 321, -2 }, /* (22) alter_account_option ::= CONNS literal */ + { 321, -2 }, /* (23) alter_account_option ::= STATE literal */ + { 317, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ + { 317, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 317, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ + { 317, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ + { 317, -3 }, /* (28) cmd ::= DROP USER user_name */ + { 323, 0 }, /* (29) sysinfo_opt ::= */ + { 323, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ + { 317, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ + { 317, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ + { 324, -1 }, /* (33) privileges ::= ALL */ + { 324, -1 }, /* (34) privileges ::= priv_type_list */ + { 326, -1 }, /* (35) priv_type_list ::= priv_type */ + { 326, -3 }, /* (36) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + { 327, -1 }, /* (37) priv_type ::= READ */ + { 327, -1 }, /* (38) priv_type ::= WRITE */ + { 325, -3 }, /* (39) priv_level ::= NK_STAR NK_DOT NK_STAR */ + { 325, -3 }, /* (40) priv_level ::= db_name NK_DOT NK_STAR */ + { 317, -3 }, /* (41) cmd ::= CREATE DNODE dnode_endpoint */ + { 317, -5 }, /* (42) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ + { 317, -3 }, /* (43) cmd ::= DROP DNODE NK_INTEGER */ + { 317, -3 }, /* (44) cmd ::= DROP DNODE dnode_endpoint */ + { 317, -4 }, /* (45) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + { 317, -5 }, /* (46) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + { 317, -4 }, /* (47) cmd ::= ALTER ALL DNODES NK_STRING */ + { 317, -5 }, /* (48) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + { 329, -1 }, /* (49) dnode_endpoint ::= NK_STRING */ + { 329, -1 }, /* (50) dnode_endpoint ::= NK_ID */ + { 329, -1 }, /* (51) dnode_endpoint ::= NK_IPTOKEN */ + { 317, -3 }, /* (52) cmd ::= ALTER LOCAL NK_STRING */ + { 317, -4 }, /* (53) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + { 317, -5 }, /* (54) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 317, -5 }, /* (55) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 317, -5 }, /* (56) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + { 317, -5 }, /* (57) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + { 317, -5 }, /* (58) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + { 317, -5 }, /* (59) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + { 317, -5 }, /* (60) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + { 317, -5 }, /* (61) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + { 317, -5 }, /* (62) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 317, -4 }, /* (63) cmd ::= DROP DATABASE exists_opt db_name */ + { 317, -2 }, /* (64) cmd ::= USE db_name */ + { 317, -4 }, /* (65) cmd ::= ALTER DATABASE db_name alter_db_options */ + { 317, -3 }, /* (66) cmd ::= FLUSH DATABASE db_name */ + { 317, -4 }, /* (67) cmd ::= TRIM DATABASE db_name speed_opt */ + { 330, -3 }, /* (68) not_exists_opt ::= IF NOT EXISTS */ + { 330, 0 }, /* (69) not_exists_opt ::= */ + { 332, -2 }, /* (70) exists_opt ::= IF EXISTS */ + { 332, 0 }, /* (71) exists_opt ::= */ + { 331, 0 }, /* (72) db_options ::= */ + { 331, -3 }, /* (73) db_options ::= db_options BUFFER NK_INTEGER */ + { 331, -3 }, /* (74) db_options ::= db_options CACHEMODEL NK_STRING */ + { 331, -3 }, /* (75) db_options ::= db_options CACHESIZE NK_INTEGER */ + { 331, -3 }, /* (76) db_options ::= db_options COMP NK_INTEGER */ + { 331, -3 }, /* (77) db_options ::= db_options DURATION NK_INTEGER */ + { 331, -3 }, /* (78) db_options ::= db_options DURATION NK_VARIABLE */ + { 331, -3 }, /* (79) db_options ::= db_options MAXROWS NK_INTEGER */ + { 331, -3 }, /* (80) db_options ::= db_options MINROWS NK_INTEGER */ + { 331, -3 }, /* (81) db_options ::= db_options KEEP integer_list */ + { 331, -3 }, /* (82) db_options ::= db_options KEEP variable_list */ + { 331, -3 }, /* (83) db_options ::= db_options PAGES NK_INTEGER */ + { 331, -3 }, /* (84) db_options ::= db_options PAGESIZE NK_INTEGER */ + { 331, -3 }, /* (85) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ + { 331, -3 }, /* (86) db_options ::= db_options PRECISION NK_STRING */ + { 331, -3 }, /* (87) db_options ::= db_options REPLICA NK_INTEGER */ + { 331, -3 }, /* (88) db_options ::= db_options STRICT NK_STRING */ + { 331, -3 }, /* (89) db_options ::= db_options VGROUPS NK_INTEGER */ + { 331, -3 }, /* (90) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 331, -3 }, /* (91) db_options ::= db_options RETENTIONS retention_list */ + { 331, -3 }, /* (92) db_options ::= db_options SCHEMALESS NK_INTEGER */ + { 331, -3 }, /* (93) db_options ::= db_options WAL_LEVEL NK_INTEGER */ + { 331, -3 }, /* (94) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ + { 331, -3 }, /* (95) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ + { 331, -4 }, /* (96) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + { 331, -3 }, /* (97) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ + { 331, -4 }, /* (98) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + { 331, -3 }, /* (99) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ + { 331, -3 }, /* (100) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ + { 331, -3 }, /* (101) db_options ::= db_options STT_TRIGGER NK_INTEGER */ + { 331, -3 }, /* (102) db_options ::= db_options TABLE_PREFIX NK_INTEGER */ + { 331, -3 }, /* (103) db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ + { 333, -1 }, /* (104) alter_db_options ::= alter_db_option */ + { 333, -2 }, /* (105) alter_db_options ::= alter_db_options alter_db_option */ + { 338, -2 }, /* (106) alter_db_option ::= CACHEMODEL NK_STRING */ + { 338, -2 }, /* (107) alter_db_option ::= CACHESIZE NK_INTEGER */ + { 338, -2 }, /* (108) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ + { 338, -2 }, /* (109) alter_db_option ::= KEEP integer_list */ + { 338, -2 }, /* (110) alter_db_option ::= KEEP variable_list */ + { 338, -2 }, /* (111) alter_db_option ::= WAL_LEVEL NK_INTEGER */ + { 338, -2 }, /* (112) alter_db_option ::= STT_TRIGGER NK_INTEGER */ + { 335, -1 }, /* (113) integer_list ::= NK_INTEGER */ + { 335, -3 }, /* (114) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + { 336, -1 }, /* (115) variable_list ::= NK_VARIABLE */ + { 336, -3 }, /* (116) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + { 337, -1 }, /* (117) retention_list ::= retention */ + { 337, -3 }, /* (118) retention_list ::= retention_list NK_COMMA retention */ + { 339, -3 }, /* (119) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + { 334, 0 }, /* (120) speed_opt ::= */ + { 334, -2 }, /* (121) speed_opt ::= MAX_SPEED NK_INTEGER */ + { 317, -9 }, /* (122) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 317, -3 }, /* (123) cmd ::= CREATE TABLE multi_create_clause */ + { 317, -9 }, /* (124) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 317, -3 }, /* (125) cmd ::= DROP TABLE multi_drop_clause */ + { 317, -4 }, /* (126) cmd ::= DROP STABLE exists_opt full_table_name */ + { 317, -3 }, /* (127) cmd ::= ALTER TABLE alter_table_clause */ + { 317, -3 }, /* (128) cmd ::= ALTER STABLE alter_table_clause */ + { 347, -2 }, /* (129) alter_table_clause ::= full_table_name alter_table_options */ + { 347, -5 }, /* (130) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 347, -4 }, /* (131) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 347, -5 }, /* (132) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 347, -5 }, /* (133) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 347, -5 }, /* (134) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 347, -4 }, /* (135) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 347, -5 }, /* (136) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 347, -5 }, /* (137) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 347, -6 }, /* (138) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + { 344, -1 }, /* (139) multi_create_clause ::= create_subtable_clause */ + { 344, -2 }, /* (140) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 352, -10 }, /* (141) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ + { 346, -1 }, /* (142) multi_drop_clause ::= drop_table_clause */ + { 346, -2 }, /* (143) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 355, -2 }, /* (144) drop_table_clause ::= exists_opt full_table_name */ + { 353, 0 }, /* (145) specific_cols_opt ::= */ + { 353, -3 }, /* (146) specific_cols_opt ::= NK_LP col_name_list NK_RP */ + { 340, -1 }, /* (147) full_table_name ::= table_name */ + { 340, -3 }, /* (148) full_table_name ::= db_name NK_DOT table_name */ + { 341, -1 }, /* (149) column_def_list ::= column_def */ + { 341, -3 }, /* (150) column_def_list ::= column_def_list NK_COMMA column_def */ + { 358, -2 }, /* (151) column_def ::= column_name type_name */ + { 358, -4 }, /* (152) column_def ::= column_name type_name COMMENT NK_STRING */ + { 350, -1 }, /* (153) type_name ::= BOOL */ + { 350, -1 }, /* (154) type_name ::= TINYINT */ + { 350, -1 }, /* (155) type_name ::= SMALLINT */ + { 350, -1 }, /* (156) type_name ::= INT */ + { 350, -1 }, /* (157) type_name ::= INTEGER */ + { 350, -1 }, /* (158) type_name ::= BIGINT */ + { 350, -1 }, /* (159) type_name ::= FLOAT */ + { 350, -1 }, /* (160) type_name ::= DOUBLE */ + { 350, -4 }, /* (161) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 350, -1 }, /* (162) type_name ::= TIMESTAMP */ + { 350, -4 }, /* (163) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 350, -2 }, /* (164) type_name ::= TINYINT UNSIGNED */ + { 350, -2 }, /* (165) type_name ::= SMALLINT UNSIGNED */ + { 350, -2 }, /* (166) type_name ::= INT UNSIGNED */ + { 350, -2 }, /* (167) type_name ::= BIGINT UNSIGNED */ + { 350, -1 }, /* (168) type_name ::= JSON */ + { 350, -4 }, /* (169) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 350, -1 }, /* (170) type_name ::= MEDIUMBLOB */ + { 350, -1 }, /* (171) type_name ::= BLOB */ + { 350, -4 }, /* (172) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 350, -1 }, /* (173) type_name ::= DECIMAL */ + { 350, -4 }, /* (174) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 350, -6 }, /* (175) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 342, 0 }, /* (176) tags_def_opt ::= */ + { 342, -1 }, /* (177) tags_def_opt ::= tags_def */ + { 345, -4 }, /* (178) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 343, 0 }, /* (179) table_options ::= */ + { 343, -3 }, /* (180) table_options ::= table_options COMMENT NK_STRING */ + { 343, -3 }, /* (181) table_options ::= table_options MAX_DELAY duration_list */ + { 343, -3 }, /* (182) table_options ::= table_options WATERMARK duration_list */ + { 343, -5 }, /* (183) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + { 343, -3 }, /* (184) table_options ::= table_options TTL NK_INTEGER */ + { 343, -5 }, /* (185) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 348, -1 }, /* (186) alter_table_options ::= alter_table_option */ + { 348, -2 }, /* (187) alter_table_options ::= alter_table_options alter_table_option */ + { 361, -2 }, /* (188) alter_table_option ::= COMMENT NK_STRING */ + { 361, -2 }, /* (189) alter_table_option ::= TTL NK_INTEGER */ + { 359, -1 }, /* (190) duration_list ::= duration_literal */ + { 359, -3 }, /* (191) duration_list ::= duration_list NK_COMMA duration_literal */ + { 360, -1 }, /* (192) rollup_func_list ::= rollup_func_name */ + { 360, -3 }, /* (193) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + { 363, -1 }, /* (194) rollup_func_name ::= function_name */ + { 363, -1 }, /* (195) rollup_func_name ::= FIRST */ + { 363, -1 }, /* (196) rollup_func_name ::= LAST */ + { 356, -1 }, /* (197) col_name_list ::= col_name */ + { 356, -3 }, /* (198) col_name_list ::= col_name_list NK_COMMA col_name */ + { 365, -1 }, /* (199) col_name ::= column_name */ + { 317, -2 }, /* (200) cmd ::= SHOW DNODES */ + { 317, -2 }, /* (201) cmd ::= SHOW USERS */ + { 317, -2 }, /* (202) cmd ::= SHOW DATABASES */ + { 317, -4 }, /* (203) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + { 317, -4 }, /* (204) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + { 317, -3 }, /* (205) cmd ::= SHOW db_name_cond_opt VGROUPS */ + { 317, -2 }, /* (206) cmd ::= SHOW MNODES */ + { 317, -2 }, /* (207) cmd ::= SHOW MODULES */ + { 317, -2 }, /* (208) cmd ::= SHOW QNODES */ + { 317, -2 }, /* (209) cmd ::= SHOW FUNCTIONS */ + { 317, -5 }, /* (210) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 317, -2 }, /* (211) cmd ::= SHOW STREAMS */ + { 317, -2 }, /* (212) cmd ::= SHOW ACCOUNTS */ + { 317, -2 }, /* (213) cmd ::= SHOW APPS */ + { 317, -2 }, /* (214) cmd ::= SHOW CONNECTIONS */ + { 317, -2 }, /* (215) cmd ::= SHOW LICENCES */ + { 317, -2 }, /* (216) cmd ::= SHOW GRANTS */ + { 317, -4 }, /* (217) cmd ::= SHOW CREATE DATABASE db_name */ + { 317, -4 }, /* (218) cmd ::= SHOW CREATE TABLE full_table_name */ + { 317, -4 }, /* (219) cmd ::= SHOW CREATE STABLE full_table_name */ + { 317, -2 }, /* (220) cmd ::= SHOW QUERIES */ + { 317, -2 }, /* (221) cmd ::= SHOW SCORES */ + { 317, -2 }, /* (222) cmd ::= SHOW TOPICS */ + { 317, -2 }, /* (223) cmd ::= SHOW VARIABLES */ + { 317, -3 }, /* (224) cmd ::= SHOW LOCAL VARIABLES */ + { 317, -4 }, /* (225) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ + { 317, -2 }, /* (226) cmd ::= SHOW BNODES */ + { 317, -2 }, /* (227) cmd ::= SHOW SNODES */ + { 317, -2 }, /* (228) cmd ::= SHOW CLUSTER */ + { 317, -2 }, /* (229) cmd ::= SHOW TRANSACTIONS */ + { 317, -4 }, /* (230) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + { 317, -2 }, /* (231) cmd ::= SHOW CONSUMERS */ + { 317, -2 }, /* (232) cmd ::= SHOW SUBSCRIPTIONS */ + { 317, -5 }, /* (233) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ + { 317, -6 }, /* (234) cmd ::= SHOW TABLE TAGS FROM table_name_cond from_db_opt */ + { 317, -3 }, /* (235) cmd ::= SHOW VNODES NK_INTEGER */ + { 317, -3 }, /* (236) cmd ::= SHOW VNODES NK_STRING */ + { 366, 0 }, /* (237) db_name_cond_opt ::= */ + { 366, -2 }, /* (238) db_name_cond_opt ::= db_name NK_DOT */ + { 367, 0 }, /* (239) like_pattern_opt ::= */ + { 367, -2 }, /* (240) like_pattern_opt ::= LIKE NK_STRING */ + { 368, -1 }, /* (241) table_name_cond ::= table_name */ + { 369, 0 }, /* (242) from_db_opt ::= */ + { 369, -2 }, /* (243) from_db_opt ::= FROM db_name */ + { 317, -8 }, /* (244) cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ + { 317, -4 }, /* (245) cmd ::= DROP INDEX exists_opt full_table_name */ + { 370, -10 }, /* (246) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + { 370, -12 }, /* (247) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ + { 371, -1 }, /* (248) func_list ::= func */ + { 371, -3 }, /* (249) func_list ::= func_list NK_COMMA func */ + { 374, -4 }, /* (250) func ::= function_name NK_LP expression_list NK_RP */ + { 373, 0 }, /* (251) sma_stream_opt ::= */ + { 373, -3 }, /* (252) sma_stream_opt ::= stream_options WATERMARK duration_literal */ + { 373, -3 }, /* (253) sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ + { 317, -6 }, /* (254) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ + { 317, -7 }, /* (255) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ + { 317, -9 }, /* (256) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ + { 317, -7 }, /* (257) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ + { 317, -9 }, /* (258) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ + { 317, -4 }, /* (259) cmd ::= DROP TOPIC exists_opt topic_name */ + { 317, -7 }, /* (260) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + { 317, -2 }, /* (261) cmd ::= DESC full_table_name */ + { 317, -2 }, /* (262) cmd ::= DESCRIBE full_table_name */ + { 317, -3 }, /* (263) cmd ::= RESET QUERY CACHE */ + { 317, -4 }, /* (264) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + { 379, 0 }, /* (265) analyze_opt ::= */ + { 379, -1 }, /* (266) analyze_opt ::= ANALYZE */ + { 380, 0 }, /* (267) explain_options ::= */ + { 380, -3 }, /* (268) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 380, -3 }, /* (269) explain_options ::= explain_options RATIO NK_FLOAT */ + { 317, -10 }, /* (270) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + { 317, -4 }, /* (271) cmd ::= DROP FUNCTION exists_opt function_name */ + { 381, 0 }, /* (272) agg_func_opt ::= */ + { 381, -1 }, /* (273) agg_func_opt ::= AGGREGATE */ + { 382, 0 }, /* (274) bufsize_opt ::= */ + { 382, -2 }, /* (275) bufsize_opt ::= BUFSIZE NK_INTEGER */ + { 317, -11 }, /* (276) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery */ + { 317, -4 }, /* (277) cmd ::= DROP STREAM exists_opt stream_name */ + { 375, 0 }, /* (278) stream_options ::= */ + { 375, -3 }, /* (279) stream_options ::= stream_options TRIGGER AT_ONCE */ + { 375, -3 }, /* (280) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + { 375, -4 }, /* (281) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + { 375, -3 }, /* (282) stream_options ::= stream_options WATERMARK duration_literal */ + { 375, -4 }, /* (283) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + { 384, 0 }, /* (284) subtable_opt ::= */ + { 384, -4 }, /* (285) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + { 317, -3 }, /* (286) cmd ::= KILL CONNECTION NK_INTEGER */ + { 317, -3 }, /* (287) cmd ::= KILL QUERY NK_STRING */ + { 317, -3 }, /* (288) cmd ::= KILL TRANSACTION NK_INTEGER */ + { 317, -2 }, /* (289) cmd ::= BALANCE VGROUP */ + { 317, -4 }, /* (290) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + { 317, -4 }, /* (291) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + { 317, -3 }, /* (292) cmd ::= SPLIT VGROUP NK_INTEGER */ + { 386, -2 }, /* (293) dnode_list ::= DNODE NK_INTEGER */ + { 386, -3 }, /* (294) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 317, -4 }, /* (295) cmd ::= DELETE FROM full_table_name where_clause_opt */ + { 317, -1 }, /* (296) cmd ::= query_or_subquery */ + { 317, -7 }, /* (297) cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + { 317, -4 }, /* (298) cmd ::= INSERT INTO full_table_name query_or_subquery */ + { 320, -1 }, /* (299) literal ::= NK_INTEGER */ + { 320, -1 }, /* (300) literal ::= NK_FLOAT */ + { 320, -1 }, /* (301) literal ::= NK_STRING */ + { 320, -1 }, /* (302) literal ::= NK_BOOL */ + { 320, -2 }, /* (303) literal ::= TIMESTAMP NK_STRING */ + { 320, -1 }, /* (304) literal ::= duration_literal */ + { 320, -1 }, /* (305) literal ::= NULL */ + { 320, -1 }, /* (306) literal ::= NK_QUESTION */ + { 362, -1 }, /* (307) duration_literal ::= NK_VARIABLE */ + { 388, -1 }, /* (308) signed ::= NK_INTEGER */ + { 388, -2 }, /* (309) signed ::= NK_PLUS NK_INTEGER */ + { 388, -2 }, /* (310) signed ::= NK_MINUS NK_INTEGER */ + { 388, -1 }, /* (311) signed ::= NK_FLOAT */ + { 388, -2 }, /* (312) signed ::= NK_PLUS NK_FLOAT */ + { 388, -2 }, /* (313) signed ::= NK_MINUS NK_FLOAT */ + { 351, -1 }, /* (314) signed_literal ::= signed */ + { 351, -1 }, /* (315) signed_literal ::= NK_STRING */ + { 351, -1 }, /* (316) signed_literal ::= NK_BOOL */ + { 351, -2 }, /* (317) signed_literal ::= TIMESTAMP NK_STRING */ + { 351, -1 }, /* (318) signed_literal ::= duration_literal */ + { 351, -1 }, /* (319) signed_literal ::= NULL */ + { 351, -1 }, /* (320) signed_literal ::= literal_func */ + { 351, -1 }, /* (321) signed_literal ::= NK_QUESTION */ + { 390, -1 }, /* (322) literal_list ::= signed_literal */ + { 390, -3 }, /* (323) literal_list ::= literal_list NK_COMMA signed_literal */ + { 328, -1 }, /* (324) db_name ::= NK_ID */ + { 357, -1 }, /* (325) table_name ::= NK_ID */ + { 349, -1 }, /* (326) column_name ::= NK_ID */ + { 364, -1 }, /* (327) function_name ::= NK_ID */ + { 391, -1 }, /* (328) table_alias ::= NK_ID */ + { 392, -1 }, /* (329) column_alias ::= NK_ID */ + { 322, -1 }, /* (330) user_name ::= NK_ID */ + { 376, -1 }, /* (331) topic_name ::= NK_ID */ + { 383, -1 }, /* (332) stream_name ::= NK_ID */ + { 378, -1 }, /* (333) cgroup_name ::= NK_ID */ + { 393, -1 }, /* (334) expr_or_subquery ::= expression */ + { 393, -1 }, /* (335) expr_or_subquery ::= subquery */ + { 385, -1 }, /* (336) expression ::= literal */ + { 385, -1 }, /* (337) expression ::= pseudo_column */ + { 385, -1 }, /* (338) expression ::= column_reference */ + { 385, -1 }, /* (339) expression ::= function_expression */ + { 385, -1 }, /* (340) expression ::= case_when_expression */ + { 385, -3 }, /* (341) expression ::= NK_LP expression NK_RP */ + { 385, -2 }, /* (342) expression ::= NK_PLUS expr_or_subquery */ + { 385, -2 }, /* (343) expression ::= NK_MINUS expr_or_subquery */ + { 385, -3 }, /* (344) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + { 385, -3 }, /* (345) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + { 385, -3 }, /* (346) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + { 385, -3 }, /* (347) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + { 385, -3 }, /* (348) expression ::= expr_or_subquery NK_REM expr_or_subquery */ + { 385, -3 }, /* (349) expression ::= column_reference NK_ARROW NK_STRING */ + { 385, -3 }, /* (350) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + { 385, -3 }, /* (351) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + { 354, -1 }, /* (352) expression_list ::= expr_or_subquery */ + { 354, -3 }, /* (353) expression_list ::= expression_list NK_COMMA expr_or_subquery */ + { 396, -1 }, /* (354) column_reference ::= column_name */ + { 396, -3 }, /* (355) column_reference ::= table_name NK_DOT column_name */ + { 395, -1 }, /* (356) pseudo_column ::= ROWTS */ + { 395, -1 }, /* (357) pseudo_column ::= TBNAME */ + { 395, -3 }, /* (358) pseudo_column ::= table_name NK_DOT TBNAME */ + { 395, -1 }, /* (359) pseudo_column ::= QSTART */ + { 395, -1 }, /* (360) pseudo_column ::= QEND */ + { 395, -1 }, /* (361) pseudo_column ::= QDURATION */ + { 395, -1 }, /* (362) pseudo_column ::= WSTART */ + { 395, -1 }, /* (363) pseudo_column ::= WEND */ + { 395, -1 }, /* (364) pseudo_column ::= WDURATION */ + { 395, -1 }, /* (365) pseudo_column ::= IROWTS */ + { 395, -1 }, /* (366) pseudo_column ::= QTAGS */ + { 397, -4 }, /* (367) function_expression ::= function_name NK_LP expression_list NK_RP */ + { 397, -4 }, /* (368) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + { 397, -6 }, /* (369) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + { 397, -1 }, /* (370) function_expression ::= literal_func */ + { 389, -3 }, /* (371) literal_func ::= noarg_func NK_LP NK_RP */ + { 389, -1 }, /* (372) literal_func ::= NOW */ + { 401, -1 }, /* (373) noarg_func ::= NOW */ + { 401, -1 }, /* (374) noarg_func ::= TODAY */ + { 401, -1 }, /* (375) noarg_func ::= TIMEZONE */ + { 401, -1 }, /* (376) noarg_func ::= DATABASE */ + { 401, -1 }, /* (377) noarg_func ::= CLIENT_VERSION */ + { 401, -1 }, /* (378) noarg_func ::= SERVER_VERSION */ + { 401, -1 }, /* (379) noarg_func ::= SERVER_STATUS */ + { 401, -1 }, /* (380) noarg_func ::= CURRENT_USER */ + { 401, -1 }, /* (381) noarg_func ::= USER */ + { 399, -1 }, /* (382) star_func ::= COUNT */ + { 399, -1 }, /* (383) star_func ::= FIRST */ + { 399, -1 }, /* (384) star_func ::= LAST */ + { 399, -1 }, /* (385) star_func ::= LAST_ROW */ + { 400, -1 }, /* (386) star_func_para_list ::= NK_STAR */ + { 400, -1 }, /* (387) star_func_para_list ::= other_para_list */ + { 402, -1 }, /* (388) other_para_list ::= star_func_para */ + { 402, -3 }, /* (389) other_para_list ::= other_para_list NK_COMMA star_func_para */ + { 403, -1 }, /* (390) star_func_para ::= expr_or_subquery */ + { 403, -3 }, /* (391) star_func_para ::= table_name NK_DOT NK_STAR */ + { 398, -4 }, /* (392) case_when_expression ::= CASE when_then_list case_when_else_opt END */ + { 398, -5 }, /* (393) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + { 404, -1 }, /* (394) when_then_list ::= when_then_expr */ + { 404, -2 }, /* (395) when_then_list ::= when_then_list when_then_expr */ + { 407, -4 }, /* (396) when_then_expr ::= WHEN common_expression THEN common_expression */ + { 405, 0 }, /* (397) case_when_else_opt ::= */ + { 405, -2 }, /* (398) case_when_else_opt ::= ELSE common_expression */ + { 408, -3 }, /* (399) predicate ::= expr_or_subquery compare_op expr_or_subquery */ + { 408, -5 }, /* (400) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + { 408, -6 }, /* (401) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + { 408, -3 }, /* (402) predicate ::= expr_or_subquery IS NULL */ + { 408, -4 }, /* (403) predicate ::= expr_or_subquery IS NOT NULL */ + { 408, -3 }, /* (404) predicate ::= expr_or_subquery in_op in_predicate_value */ + { 409, -1 }, /* (405) compare_op ::= NK_LT */ + { 409, -1 }, /* (406) compare_op ::= NK_GT */ + { 409, -1 }, /* (407) compare_op ::= NK_LE */ + { 409, -1 }, /* (408) compare_op ::= NK_GE */ + { 409, -1 }, /* (409) compare_op ::= NK_NE */ + { 409, -1 }, /* (410) compare_op ::= NK_EQ */ + { 409, -1 }, /* (411) compare_op ::= LIKE */ + { 409, -2 }, /* (412) compare_op ::= NOT LIKE */ + { 409, -1 }, /* (413) compare_op ::= MATCH */ + { 409, -1 }, /* (414) compare_op ::= NMATCH */ + { 409, -1 }, /* (415) compare_op ::= CONTAINS */ + { 410, -1 }, /* (416) in_op ::= IN */ + { 410, -2 }, /* (417) in_op ::= NOT IN */ + { 411, -3 }, /* (418) in_predicate_value ::= NK_LP literal_list NK_RP */ + { 412, -1 }, /* (419) boolean_value_expression ::= boolean_primary */ + { 412, -2 }, /* (420) boolean_value_expression ::= NOT boolean_primary */ + { 412, -3 }, /* (421) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 412, -3 }, /* (422) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 413, -1 }, /* (423) boolean_primary ::= predicate */ + { 413, -3 }, /* (424) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 406, -1 }, /* (425) common_expression ::= expr_or_subquery */ + { 406, -1 }, /* (426) common_expression ::= boolean_value_expression */ + { 414, 0 }, /* (427) from_clause_opt ::= */ + { 414, -2 }, /* (428) from_clause_opt ::= FROM table_reference_list */ + { 415, -1 }, /* (429) table_reference_list ::= table_reference */ + { 415, -3 }, /* (430) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 416, -1 }, /* (431) table_reference ::= table_primary */ + { 416, -1 }, /* (432) table_reference ::= joined_table */ + { 417, -2 }, /* (433) table_primary ::= table_name alias_opt */ + { 417, -4 }, /* (434) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 417, -2 }, /* (435) table_primary ::= subquery alias_opt */ + { 417, -1 }, /* (436) table_primary ::= parenthesized_joined_table */ + { 419, 0 }, /* (437) alias_opt ::= */ + { 419, -1 }, /* (438) alias_opt ::= table_alias */ + { 419, -2 }, /* (439) alias_opt ::= AS table_alias */ + { 420, -3 }, /* (440) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 420, -3 }, /* (441) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 418, -6 }, /* (442) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 421, 0 }, /* (443) join_type ::= */ + { 421, -1 }, /* (444) join_type ::= INNER */ + { 423, -12 }, /* (445) query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + { 424, 0 }, /* (446) set_quantifier_opt ::= */ + { 424, -1 }, /* (447) set_quantifier_opt ::= DISTINCT */ + { 424, -1 }, /* (448) set_quantifier_opt ::= ALL */ + { 425, -1 }, /* (449) select_list ::= select_item */ + { 425, -3 }, /* (450) select_list ::= select_list NK_COMMA select_item */ + { 433, -1 }, /* (451) select_item ::= NK_STAR */ + { 433, -1 }, /* (452) select_item ::= common_expression */ + { 433, -2 }, /* (453) select_item ::= common_expression column_alias */ + { 433, -3 }, /* (454) select_item ::= common_expression AS column_alias */ + { 433, -3 }, /* (455) select_item ::= table_name NK_DOT NK_STAR */ + { 387, 0 }, /* (456) where_clause_opt ::= */ + { 387, -2 }, /* (457) where_clause_opt ::= WHERE search_condition */ + { 426, 0 }, /* (458) partition_by_clause_opt ::= */ + { 426, -3 }, /* (459) partition_by_clause_opt ::= PARTITION BY partition_list */ + { 434, -1 }, /* (460) partition_list ::= partition_item */ + { 434, -3 }, /* (461) partition_list ::= partition_list NK_COMMA partition_item */ + { 435, -1 }, /* (462) partition_item ::= expr_or_subquery */ + { 435, -2 }, /* (463) partition_item ::= expr_or_subquery column_alias */ + { 435, -3 }, /* (464) partition_item ::= expr_or_subquery AS column_alias */ + { 430, 0 }, /* (465) twindow_clause_opt ::= */ + { 430, -6 }, /* (466) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 430, -4 }, /* (467) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + { 430, -6 }, /* (468) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 430, -8 }, /* (469) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 372, 0 }, /* (470) sliding_opt ::= */ + { 372, -4 }, /* (471) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 429, 0 }, /* (472) fill_opt ::= */ + { 429, -4 }, /* (473) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 429, -6 }, /* (474) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 436, -1 }, /* (475) fill_mode ::= NONE */ + { 436, -1 }, /* (476) fill_mode ::= PREV */ + { 436, -1 }, /* (477) fill_mode ::= NULL */ + { 436, -1 }, /* (478) fill_mode ::= LINEAR */ + { 436, -1 }, /* (479) fill_mode ::= NEXT */ + { 431, 0 }, /* (480) group_by_clause_opt ::= */ + { 431, -3 }, /* (481) group_by_clause_opt ::= GROUP BY group_by_list */ + { 437, -1 }, /* (482) group_by_list ::= expr_or_subquery */ + { 437, -3 }, /* (483) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + { 432, 0 }, /* (484) having_clause_opt ::= */ + { 432, -2 }, /* (485) having_clause_opt ::= HAVING search_condition */ + { 427, 0 }, /* (486) range_opt ::= */ + { 427, -6 }, /* (487) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + { 428, 0 }, /* (488) every_opt ::= */ + { 428, -4 }, /* (489) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + { 438, -4 }, /* (490) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 439, -1 }, /* (491) query_simple ::= query_specification */ + { 439, -1 }, /* (492) query_simple ::= union_query_expression */ + { 443, -4 }, /* (493) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + { 443, -3 }, /* (494) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + { 444, -1 }, /* (495) query_simple_or_subquery ::= query_simple */ + { 444, -1 }, /* (496) query_simple_or_subquery ::= subquery */ + { 377, -1 }, /* (497) query_or_subquery ::= query_expression */ + { 377, -1 }, /* (498) query_or_subquery ::= subquery */ + { 440, 0 }, /* (499) order_by_clause_opt ::= */ + { 440, -3 }, /* (500) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 441, 0 }, /* (501) slimit_clause_opt ::= */ + { 441, -2 }, /* (502) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 441, -4 }, /* (503) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 441, -4 }, /* (504) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 442, 0 }, /* (505) limit_clause_opt ::= */ + { 442, -2 }, /* (506) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 442, -4 }, /* (507) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 442, -4 }, /* (508) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 394, -3 }, /* (509) subquery ::= NK_LP query_expression NK_RP */ + { 394, -3 }, /* (510) subquery ::= NK_LP subquery NK_RP */ + { 422, -1 }, /* (511) search_condition ::= common_expression */ + { 445, -1 }, /* (512) sort_specification_list ::= sort_specification */ + { 445, -3 }, /* (513) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 446, -3 }, /* (514) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + { 447, 0 }, /* (515) ordering_specification_opt ::= */ + { 447, -1 }, /* (516) ordering_specification_opt ::= ASC */ + { 447, -1 }, /* (517) ordering_specification_opt ::= DESC */ + { 448, 0 }, /* (518) null_ordering_opt ::= */ + { 448, -2 }, /* (519) null_ordering_opt ::= NULLS FIRST */ + { 448, -2 }, /* (520) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3507,11 +3618,11 @@ static YYACTIONTYPE yy_reduce( YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,314,&yymsp[0].minor); + yy_destructor(yypParser,318,&yymsp[0].minor); break; case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,315,&yymsp[0].minor); + yy_destructor(yypParser,319,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -3525,20 +3636,20 @@ static YYACTIONTYPE yy_reduce( case 9: /* account_options ::= account_options USERS literal */ yytestcase(yyruleno==9); case 10: /* account_options ::= account_options CONNS literal */ yytestcase(yyruleno==10); case 11: /* account_options ::= account_options STATE literal */ yytestcase(yyruleno==11); -{ yy_destructor(yypParser,314,&yymsp[-2].minor); +{ yy_destructor(yypParser,318,&yymsp[-2].minor); { } - yy_destructor(yypParser,316,&yymsp[0].minor); + yy_destructor(yypParser,320,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,317,&yymsp[0].minor); +{ yy_destructor(yypParser,321,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,315,&yymsp[-1].minor); +{ yy_destructor(yypParser,319,&yymsp[-1].minor); { } - yy_destructor(yypParser,317,&yymsp[0].minor); + yy_destructor(yypParser,321,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -3552,72 +3663,72 @@ static YYACTIONTYPE yy_reduce( case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22); case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); { } - yy_destructor(yypParser,316,&yymsp[0].minor); + yy_destructor(yypParser,320,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy659, &yymsp[-1].minor.yy0, yymsp[0].minor.yy341); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy181, &yymsp[-1].minor.yy0, yymsp[0].minor.yy293); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy659, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy181, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; case 26: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy659, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy181, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } break; case 27: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy659, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy181, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } break; case 28: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy659); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy181); } break; case 29: /* sysinfo_opt ::= */ -{ yymsp[1].minor.yy341 = 1; } +{ yymsp[1].minor.yy293 = 1; } break; case 30: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ -{ yymsp[-1].minor.yy341 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy293 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } break; case 31: /* cmd ::= GRANT privileges ON priv_level TO user_name */ -{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy459, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy659); } +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy831, &yymsp[-2].minor.yy181, &yymsp[0].minor.yy181); } break; case 32: /* cmd ::= REVOKE privileges ON priv_level FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy459, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy659); } +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy831, &yymsp[-2].minor.yy181, &yymsp[0].minor.yy181); } break; case 33: /* privileges ::= ALL */ -{ yymsp[0].minor.yy459 = PRIVILEGE_TYPE_ALL; } +{ yymsp[0].minor.yy831 = PRIVILEGE_TYPE_ALL; } break; case 34: /* privileges ::= priv_type_list */ case 35: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==35); -{ yylhsminor.yy459 = yymsp[0].minor.yy459; } - yymsp[0].minor.yy459 = yylhsminor.yy459; +{ yylhsminor.yy831 = yymsp[0].minor.yy831; } + yymsp[0].minor.yy831 = yylhsminor.yy831; break; case 36: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy459 = yymsp[-2].minor.yy459 | yymsp[0].minor.yy459; } - yymsp[-2].minor.yy459 = yylhsminor.yy459; +{ yylhsminor.yy831 = yymsp[-2].minor.yy831 | yymsp[0].minor.yy831; } + yymsp[-2].minor.yy831 = yylhsminor.yy831; break; case 37: /* priv_type ::= READ */ -{ yymsp[0].minor.yy459 = PRIVILEGE_TYPE_READ; } +{ yymsp[0].minor.yy831 = PRIVILEGE_TYPE_READ; } break; case 38: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy459 = PRIVILEGE_TYPE_WRITE; } +{ yymsp[0].minor.yy831 = PRIVILEGE_TYPE_WRITE; } break; case 39: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy659 = yymsp[-2].minor.yy0; } - yymsp[-2].minor.yy659 = yylhsminor.yy659; +{ yylhsminor.yy181 = yymsp[-2].minor.yy0; } + yymsp[-2].minor.yy181 = yylhsminor.yy181; break; case 40: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy659 = yymsp[-2].minor.yy659; } - yymsp[-2].minor.yy659 = yylhsminor.yy659; +{ yylhsminor.yy181 = yymsp[-2].minor.yy181; } + yymsp[-2].minor.yy181 = yylhsminor.yy181; break; case 41: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy659, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy181, NULL); } break; case 42: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy181, &yymsp[0].minor.yy0); } break; case 43: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; case 44: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy659); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy181); } break; case 45: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -3634,31 +3745,31 @@ static YYACTIONTYPE yy_reduce( case 49: /* dnode_endpoint ::= NK_STRING */ case 50: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==50); case 51: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==51); - case 319: /* db_name ::= NK_ID */ yytestcase(yyruleno==319); - case 320: /* table_name ::= NK_ID */ yytestcase(yyruleno==320); - case 321: /* column_name ::= NK_ID */ yytestcase(yyruleno==321); - case 322: /* function_name ::= NK_ID */ yytestcase(yyruleno==322); - case 323: /* table_alias ::= NK_ID */ yytestcase(yyruleno==323); - case 324: /* column_alias ::= NK_ID */ yytestcase(yyruleno==324); - case 325: /* user_name ::= NK_ID */ yytestcase(yyruleno==325); - case 326: /* topic_name ::= NK_ID */ yytestcase(yyruleno==326); - case 327: /* stream_name ::= NK_ID */ yytestcase(yyruleno==327); - case 328: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==328); - case 366: /* noarg_func ::= NOW */ yytestcase(yyruleno==366); - case 367: /* noarg_func ::= TODAY */ yytestcase(yyruleno==367); - case 368: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==368); - case 369: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==369); - case 370: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==370); - case 371: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==371); - case 372: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==372); - case 373: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==373); - case 374: /* noarg_func ::= USER */ yytestcase(yyruleno==374); - case 375: /* star_func ::= COUNT */ yytestcase(yyruleno==375); - case 376: /* star_func ::= FIRST */ yytestcase(yyruleno==376); - case 377: /* star_func ::= LAST */ yytestcase(yyruleno==377); - case 378: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==378); -{ yylhsminor.yy659 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy659 = yylhsminor.yy659; + case 324: /* db_name ::= NK_ID */ yytestcase(yyruleno==324); + case 325: /* table_name ::= NK_ID */ yytestcase(yyruleno==325); + case 326: /* column_name ::= NK_ID */ yytestcase(yyruleno==326); + case 327: /* function_name ::= NK_ID */ yytestcase(yyruleno==327); + case 328: /* table_alias ::= NK_ID */ yytestcase(yyruleno==328); + case 329: /* column_alias ::= NK_ID */ yytestcase(yyruleno==329); + case 330: /* user_name ::= NK_ID */ yytestcase(yyruleno==330); + case 331: /* topic_name ::= NK_ID */ yytestcase(yyruleno==331); + case 332: /* stream_name ::= NK_ID */ yytestcase(yyruleno==332); + case 333: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==333); + case 373: /* noarg_func ::= NOW */ yytestcase(yyruleno==373); + case 374: /* noarg_func ::= TODAY */ yytestcase(yyruleno==374); + case 375: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==375); + case 376: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==376); + case 377: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==377); + case 378: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==378); + case 379: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==379); + case 380: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==380); + case 381: /* noarg_func ::= USER */ yytestcase(yyruleno==381); + case 382: /* star_func ::= COUNT */ yytestcase(yyruleno==382); + case 383: /* star_func ::= FIRST */ yytestcase(yyruleno==383); + case 384: /* star_func ::= LAST */ yytestcase(yyruleno==384); + case 385: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==385); +{ yylhsminor.yy181 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy181 = yylhsminor.yy181; break; case 52: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -3691,1303 +3802,1317 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } break; case 62: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy173, &yymsp[-1].minor.yy659, yymsp[0].minor.yy560); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy39, &yymsp[-1].minor.yy181, yymsp[0].minor.yy778); } break; case 63: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy173, &yymsp[0].minor.yy659); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy39, &yymsp[0].minor.yy181); } break; case 64: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy659); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy181); } break; case 65: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy659, yymsp[0].minor.yy560); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy181, yymsp[0].minor.yy778); } break; case 66: /* cmd ::= FLUSH DATABASE db_name */ -{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy659); } +{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy181); } break; - case 67: /* cmd ::= TRIM DATABASE db_name */ -{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[0].minor.yy659); } + case 67: /* cmd ::= TRIM DATABASE db_name speed_opt */ +{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy181, yymsp[0].minor.yy276); } break; case 68: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy173 = true; } +{ yymsp[-2].minor.yy39 = true; } break; case 69: /* not_exists_opt ::= */ case 71: /* exists_opt ::= */ yytestcase(yyruleno==71); - case 262: /* analyze_opt ::= */ yytestcase(yyruleno==262); - case 269: /* agg_func_opt ::= */ yytestcase(yyruleno==269); - case 439: /* set_quantifier_opt ::= */ yytestcase(yyruleno==439); -{ yymsp[1].minor.yy173 = false; } + case 265: /* analyze_opt ::= */ yytestcase(yyruleno==265); + case 272: /* agg_func_opt ::= */ yytestcase(yyruleno==272); + case 446: /* set_quantifier_opt ::= */ yytestcase(yyruleno==446); +{ yymsp[1].minor.yy39 = false; } break; case 70: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy173 = true; } +{ yymsp[-1].minor.yy39 = true; } break; case 72: /* db_options ::= */ -{ yymsp[1].minor.yy560 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy778 = createDefaultDatabaseOptions(pCxt); } break; case 73: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 74: /* db_options ::= db_options CACHEMODEL NK_STRING */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 75: /* db_options ::= db_options CACHESIZE NK_INTEGER */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 76: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 77: /* db_options ::= db_options DURATION NK_INTEGER */ case 78: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==78); -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 79: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 80: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 81: /* db_options ::= db_options KEEP integer_list */ case 82: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==82); -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_KEEP, yymsp[0].minor.yy334); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_KEEP, yymsp[0].minor.yy282); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 83: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 84: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 85: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 86: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 87: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 88: /* db_options ::= db_options STRICT NK_STRING */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 89: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 90: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 91: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_RETENTIONS, yymsp[0].minor.yy334); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_RETENTIONS, yymsp[0].minor.yy282); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 92: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 93: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 94: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 95: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 96: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-3].minor.yy560, DB_OPTION_WAL_RETENTION_PERIOD, &t); + yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-3].minor.yy778, DB_OPTION_WAL_RETENTION_PERIOD, &t); } - yymsp[-3].minor.yy560 = yylhsminor.yy560; + yymsp[-3].minor.yy778 = yylhsminor.yy778; break; case 97: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 98: /* db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-3].minor.yy560, DB_OPTION_WAL_RETENTION_SIZE, &t); + yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-3].minor.yy778, DB_OPTION_WAL_RETENTION_SIZE, &t); } - yymsp[-3].minor.yy560 = yylhsminor.yy560; + yymsp[-3].minor.yy778 = yylhsminor.yy778; break; case 99: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 100: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 101: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 102: /* db_options ::= db_options TABLE_PREFIX NK_INTEGER */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_TABLE_PREFIX, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_TABLE_PREFIX, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 103: /* db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ -{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_TABLE_SUFFIX, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setDatabaseOption(pCxt, yymsp[-2].minor.yy778, DB_OPTION_TABLE_SUFFIX, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 104: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy560 = createAlterDatabaseOptions(pCxt); yylhsminor.yy560 = setAlterDatabaseOption(pCxt, yylhsminor.yy560, &yymsp[0].minor.yy515); } - yymsp[0].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = createAlterDatabaseOptions(pCxt); yylhsminor.yy778 = setAlterDatabaseOption(pCxt, yylhsminor.yy778, &yymsp[0].minor.yy645); } + yymsp[0].minor.yy778 = yylhsminor.yy778; break; case 105: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy560 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy560, &yymsp[0].minor.yy515); } - yymsp[-1].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy778, &yymsp[0].minor.yy645); } + yymsp[-1].minor.yy778 = yylhsminor.yy778; break; case 106: /* alter_db_option ::= CACHEMODEL NK_STRING */ -{ yymsp[-1].minor.yy515.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy515.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy645.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy645.val = yymsp[0].minor.yy0; } break; case 107: /* alter_db_option ::= CACHESIZE NK_INTEGER */ -{ yymsp[-1].minor.yy515.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy515.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy645.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy645.val = yymsp[0].minor.yy0; } break; case 108: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ -{ yymsp[-1].minor.yy515.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy515.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy645.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy645.val = yymsp[0].minor.yy0; } break; case 109: /* alter_db_option ::= KEEP integer_list */ case 110: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==110); -{ yymsp[-1].minor.yy515.type = DB_OPTION_KEEP; yymsp[-1].minor.yy515.pList = yymsp[0].minor.yy334; } +{ yymsp[-1].minor.yy645.type = DB_OPTION_KEEP; yymsp[-1].minor.yy645.pList = yymsp[0].minor.yy282; } break; case 111: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ -{ yymsp[-1].minor.yy515.type = DB_OPTION_WAL; yymsp[-1].minor.yy515.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy645.type = DB_OPTION_WAL; yymsp[-1].minor.yy645.val = yymsp[0].minor.yy0; } break; case 112: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */ -{ yymsp[-1].minor.yy515.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy515.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy645.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy645.val = yymsp[0].minor.yy0; } break; case 113: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy334 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy334 = yylhsminor.yy334; +{ yylhsminor.yy282 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy282 = yylhsminor.yy282; break; case 114: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 289: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==289); -{ yylhsminor.yy334 = addNodeToList(pCxt, yymsp[-2].minor.yy334, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy334 = yylhsminor.yy334; + case 294: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==294); +{ yylhsminor.yy282 = addNodeToList(pCxt, yymsp[-2].minor.yy282, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy282 = yylhsminor.yy282; break; case 115: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy334 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy334 = yylhsminor.yy334; +{ yylhsminor.yy282 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy282 = yylhsminor.yy282; break; case 116: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy334 = addNodeToList(pCxt, yymsp[-2].minor.yy334, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy334 = yylhsminor.yy334; +{ yylhsminor.yy282 = addNodeToList(pCxt, yymsp[-2].minor.yy282, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy282 = yylhsminor.yy282; break; case 117: /* retention_list ::= retention */ - case 137: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==137); - case 140: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==140); - case 147: /* column_def_list ::= column_def */ yytestcase(yyruleno==147); - case 190: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==190); - case 195: /* col_name_list ::= col_name */ yytestcase(yyruleno==195); - case 245: /* func_list ::= func */ yytestcase(yyruleno==245); - case 317: /* literal_list ::= signed_literal */ yytestcase(yyruleno==317); - case 381: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==381); - case 387: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==387); - case 442: /* select_list ::= select_item */ yytestcase(yyruleno==442); - case 500: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==500); -{ yylhsminor.yy334 = createNodeList(pCxt, yymsp[0].minor.yy560); } - yymsp[0].minor.yy334 = yylhsminor.yy334; + case 139: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==139); + case 142: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==142); + case 149: /* column_def_list ::= column_def */ yytestcase(yyruleno==149); + case 192: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==192); + case 197: /* col_name_list ::= col_name */ yytestcase(yyruleno==197); + case 248: /* func_list ::= func */ yytestcase(yyruleno==248); + case 322: /* literal_list ::= signed_literal */ yytestcase(yyruleno==322); + case 388: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==388); + case 394: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==394); + case 449: /* select_list ::= select_item */ yytestcase(yyruleno==449); + case 460: /* partition_list ::= partition_item */ yytestcase(yyruleno==460); + case 512: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==512); +{ yylhsminor.yy282 = createNodeList(pCxt, yymsp[0].minor.yy778); } + yymsp[0].minor.yy282 = yylhsminor.yy282; break; case 118: /* retention_list ::= retention_list NK_COMMA retention */ - case 148: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==148); - case 191: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==191); - case 196: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==196); - case 246: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==246); - case 318: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==318); - case 382: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==382); - case 443: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==443); - case 501: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==501); -{ yylhsminor.yy334 = addNodeToList(pCxt, yymsp[-2].minor.yy334, yymsp[0].minor.yy560); } - yymsp[-2].minor.yy334 = yylhsminor.yy334; + case 150: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==150); + case 193: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==193); + case 198: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==198); + case 249: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==249); + case 323: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==323); + case 389: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==389); + case 450: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==450); + case 461: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==461); + case 513: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==513); +{ yylhsminor.yy282 = addNodeToList(pCxt, yymsp[-2].minor.yy282, yymsp[0].minor.yy778); } + yymsp[-2].minor.yy282 = yylhsminor.yy282; break; case 119: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -{ yylhsminor.yy560 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; +{ yylhsminor.yy778 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 120: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - case 122: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==122); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy173, yymsp[-5].minor.yy560, yymsp[-3].minor.yy334, yymsp[-1].minor.yy334, yymsp[0].minor.yy560); } + case 120: /* speed_opt ::= */ + case 274: /* bufsize_opt ::= */ yytestcase(yyruleno==274); +{ yymsp[1].minor.yy276 = 0; } break; - case 121: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy334); } + case 121: /* speed_opt ::= MAX_SPEED NK_INTEGER */ + case 275: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==275); +{ yymsp[-1].minor.yy276 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 123: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy334); } + case 122: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + case 124: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==124); +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy39, yymsp[-5].minor.yy778, yymsp[-3].minor.yy282, yymsp[-1].minor.yy282, yymsp[0].minor.yy778); } break; - case 124: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy173, yymsp[0].minor.yy560); } + case 123: /* cmd ::= CREATE TABLE multi_create_clause */ +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy282); } break; - case 125: /* cmd ::= ALTER TABLE alter_table_clause */ - case 291: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==291); -{ pCxt->pRootNode = yymsp[0].minor.yy560; } + case 125: /* cmd ::= DROP TABLE multi_drop_clause */ +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy282); } break; - case 126: /* cmd ::= ALTER STABLE alter_table_clause */ -{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy560); } + case 126: /* cmd ::= DROP STABLE exists_opt full_table_name */ +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy39, yymsp[0].minor.yy778); } break; - case 127: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy560 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy560, yymsp[0].minor.yy560); } - yymsp[-1].minor.yy560 = yylhsminor.yy560; + case 127: /* cmd ::= ALTER TABLE alter_table_clause */ + case 296: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==296); +{ pCxt->pRootNode = yymsp[0].minor.yy778; } break; - case 128: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy560 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy560, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy659, yymsp[0].minor.yy574); } - yymsp[-4].minor.yy560 = yylhsminor.yy560; + case 128: /* cmd ::= ALTER STABLE alter_table_clause */ +{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy778); } break; - case 129: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy560 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy560, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy659); } - yymsp[-3].minor.yy560 = yylhsminor.yy560; + case 129: /* alter_table_clause ::= full_table_name alter_table_options */ +{ yylhsminor.yy778 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy778, yymsp[0].minor.yy778); } + yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 130: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy560 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy560, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy659, yymsp[0].minor.yy574); } - yymsp[-4].minor.yy560 = yylhsminor.yy560; + case 130: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ +{ yylhsminor.yy778 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy778, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy181, yymsp[0].minor.yy380); } + yymsp[-4].minor.yy778 = yylhsminor.yy778; break; - case 131: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy560 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy560, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy659, &yymsp[0].minor.yy659); } - yymsp[-4].minor.yy560 = yylhsminor.yy560; + case 131: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ +{ yylhsminor.yy778 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy778, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy181); } + yymsp[-3].minor.yy778 = yylhsminor.yy778; break; - case 132: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy560 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy560, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy659, yymsp[0].minor.yy574); } - yymsp[-4].minor.yy560 = yylhsminor.yy560; + case 132: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ +{ yylhsminor.yy778 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy778, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy181, yymsp[0].minor.yy380); } + yymsp[-4].minor.yy778 = yylhsminor.yy778; break; - case 133: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy560 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy560, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy659); } - yymsp[-3].minor.yy560 = yylhsminor.yy560; + case 133: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ +{ yylhsminor.yy778 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy778, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy181, &yymsp[0].minor.yy181); } + yymsp[-4].minor.yy778 = yylhsminor.yy778; break; - case 134: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy560 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy560, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy659, yymsp[0].minor.yy574); } - yymsp[-4].minor.yy560 = yylhsminor.yy560; + case 134: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ +{ yylhsminor.yy778 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy778, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy181, yymsp[0].minor.yy380); } + yymsp[-4].minor.yy778 = yylhsminor.yy778; break; - case 135: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy560 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy560, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy659, &yymsp[0].minor.yy659); } - yymsp[-4].minor.yy560 = yylhsminor.yy560; + case 135: /* alter_table_clause ::= full_table_name DROP TAG column_name */ +{ yylhsminor.yy778 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy778, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy181); } + yymsp[-3].minor.yy778 = yylhsminor.yy778; break; - case 136: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy560 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy560, &yymsp[-2].minor.yy659, yymsp[0].minor.yy560); } - yymsp[-5].minor.yy560 = yylhsminor.yy560; + case 136: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ +{ yylhsminor.yy778 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy778, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy181, yymsp[0].minor.yy380); } + yymsp[-4].minor.yy778 = yylhsminor.yy778; break; - case 138: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 141: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==141); - case 388: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==388); -{ yylhsminor.yy334 = addNodeToList(pCxt, yymsp[-1].minor.yy334, yymsp[0].minor.yy560); } - yymsp[-1].minor.yy334 = yylhsminor.yy334; + case 137: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ +{ yylhsminor.yy778 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy778, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy181, &yymsp[0].minor.yy181); } + yymsp[-4].minor.yy778 = yylhsminor.yy778; break; - case 139: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ -{ yylhsminor.yy560 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy173, yymsp[-8].minor.yy560, yymsp[-6].minor.yy560, yymsp[-5].minor.yy334, yymsp[-2].minor.yy334, yymsp[0].minor.yy560); } - yymsp[-9].minor.yy560 = yylhsminor.yy560; + case 138: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ +{ yylhsminor.yy778 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy778, &yymsp[-2].minor.yy181, yymsp[0].minor.yy778); } + yymsp[-5].minor.yy778 = yylhsminor.yy778; break; - case 142: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy560 = createDropTableClause(pCxt, yymsp[-1].minor.yy173, yymsp[0].minor.yy560); } - yymsp[-1].minor.yy560 = yylhsminor.yy560; + case 140: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ + case 143: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==143); + case 395: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==395); +{ yylhsminor.yy282 = addNodeToList(pCxt, yymsp[-1].minor.yy282, yymsp[0].minor.yy778); } + yymsp[-1].minor.yy282 = yylhsminor.yy282; break; - case 143: /* specific_cols_opt ::= */ - case 174: /* tags_def_opt ::= */ yytestcase(yyruleno==174); - case 451: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==451); - case 468: /* group_by_clause_opt ::= */ yytestcase(yyruleno==468); - case 487: /* order_by_clause_opt ::= */ yytestcase(yyruleno==487); -{ yymsp[1].minor.yy334 = NULL; } + case 141: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ +{ yylhsminor.yy778 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy39, yymsp[-8].minor.yy778, yymsp[-6].minor.yy778, yymsp[-5].minor.yy282, yymsp[-2].minor.yy282, yymsp[0].minor.yy778); } + yymsp[-9].minor.yy778 = yylhsminor.yy778; break; - case 144: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy334 = yymsp[-1].minor.yy334; } + case 144: /* drop_table_clause ::= exists_opt full_table_name */ +{ yylhsminor.yy778 = createDropTableClause(pCxt, yymsp[-1].minor.yy39, yymsp[0].minor.yy778); } + yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 145: /* full_table_name ::= table_name */ -{ yylhsminor.yy560 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy659, NULL); } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 145: /* specific_cols_opt ::= */ + case 176: /* tags_def_opt ::= */ yytestcase(yyruleno==176); + case 458: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==458); + case 480: /* group_by_clause_opt ::= */ yytestcase(yyruleno==480); + case 499: /* order_by_clause_opt ::= */ yytestcase(yyruleno==499); +{ yymsp[1].minor.yy282 = NULL; } break; - case 146: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy560 = createRealTableNode(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy659, NULL); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + case 146: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ +{ yymsp[-2].minor.yy282 = yymsp[-1].minor.yy282; } break; - case 149: /* column_def ::= column_name type_name */ -{ yylhsminor.yy560 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy659, yymsp[0].minor.yy574, NULL); } - yymsp[-1].minor.yy560 = yylhsminor.yy560; + case 147: /* full_table_name ::= table_name */ +{ yylhsminor.yy778 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy181, NULL); } + yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 150: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy560 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy659, yymsp[-2].minor.yy574, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy560 = yylhsminor.yy560; + case 148: /* full_table_name ::= db_name NK_DOT table_name */ +{ yylhsminor.yy778 = createRealTableNode(pCxt, &yymsp[-2].minor.yy181, &yymsp[0].minor.yy181, NULL); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 151: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_BOOL); } + case 151: /* column_def ::= column_name type_name */ +{ yylhsminor.yy778 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy181, yymsp[0].minor.yy380, NULL); } + yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 152: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_TINYINT); } + case 152: /* column_def ::= column_name type_name COMMENT NK_STRING */ +{ yylhsminor.yy778 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy181, yymsp[-2].minor.yy380, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy778 = yylhsminor.yy778; break; - case 153: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_SMALLINT); } + case 153: /* type_name ::= BOOL */ +{ yymsp[0].minor.yy380 = createDataType(TSDB_DATA_TYPE_BOOL); } break; - case 154: /* type_name ::= INT */ - case 155: /* type_name ::= INTEGER */ yytestcase(yyruleno==155); -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_INT); } + case 154: /* type_name ::= TINYINT */ +{ yymsp[0].minor.yy380 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; - case 156: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_BIGINT); } + case 155: /* type_name ::= SMALLINT */ +{ yymsp[0].minor.yy380 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; - case 157: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_FLOAT); } + case 156: /* type_name ::= INT */ + case 157: /* type_name ::= INTEGER */ yytestcase(yyruleno==157); +{ yymsp[0].minor.yy380 = createDataType(TSDB_DATA_TYPE_INT); } break; - case 158: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_DOUBLE); } + case 158: /* type_name ::= BIGINT */ +{ yymsp[0].minor.yy380 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; - case 159: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy574 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } + case 159: /* type_name ::= FLOAT */ +{ yymsp[0].minor.yy380 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; - case 160: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } + case 160: /* type_name ::= DOUBLE */ +{ yymsp[0].minor.yy380 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; - case 161: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy574 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } + case 161: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy380 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; - case 162: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy574 = createDataType(TSDB_DATA_TYPE_UTINYINT); } + case 162: /* type_name ::= TIMESTAMP */ +{ yymsp[0].minor.yy380 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; - case 163: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy574 = createDataType(TSDB_DATA_TYPE_USMALLINT); } + case 163: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy380 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; - case 164: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy574 = createDataType(TSDB_DATA_TYPE_UINT); } + case 164: /* type_name ::= TINYINT UNSIGNED */ +{ yymsp[-1].minor.yy380 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; - case 165: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy574 = createDataType(TSDB_DATA_TYPE_UBIGINT); } + case 165: /* type_name ::= SMALLINT UNSIGNED */ +{ yymsp[-1].minor.yy380 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; - case 166: /* type_name ::= JSON */ -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_JSON); } + case 166: /* type_name ::= INT UNSIGNED */ +{ yymsp[-1].minor.yy380 = createDataType(TSDB_DATA_TYPE_UINT); } break; - case 167: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy574 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } + case 167: /* type_name ::= BIGINT UNSIGNED */ +{ yymsp[-1].minor.yy380 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; - case 168: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } + case 168: /* type_name ::= JSON */ +{ yymsp[0].minor.yy380 = createDataType(TSDB_DATA_TYPE_JSON); } break; - case 169: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_BLOB); } + case 169: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy380 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; - case 170: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy574 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } + case 170: /* type_name ::= MEDIUMBLOB */ +{ yymsp[0].minor.yy380 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; - case 171: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 171: /* type_name ::= BLOB */ +{ yymsp[0].minor.yy380 = createDataType(TSDB_DATA_TYPE_BLOB); } break; - case 172: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy574 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 172: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy380 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; - case 173: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy574 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 173: /* type_name ::= DECIMAL */ +{ yymsp[0].minor.yy380 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 175: /* tags_def_opt ::= tags_def */ - case 380: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==380); -{ yylhsminor.yy334 = yymsp[0].minor.yy334; } - yymsp[0].minor.yy334 = yylhsminor.yy334; + case 174: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy380 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 176: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy334 = yymsp[-1].minor.yy334; } + case 175: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy380 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 177: /* table_options ::= */ -{ yymsp[1].minor.yy560 = createDefaultTableOptions(pCxt); } + case 177: /* tags_def_opt ::= tags_def */ + case 387: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==387); +{ yylhsminor.yy282 = yymsp[0].minor.yy282; } + yymsp[0].minor.yy282 = yylhsminor.yy282; break; - case 178: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy560 = setTableOption(pCxt, yymsp[-2].minor.yy560, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + case 178: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ +{ yymsp[-3].minor.yy282 = yymsp[-1].minor.yy282; } break; - case 179: /* table_options ::= table_options MAX_DELAY duration_list */ -{ yylhsminor.yy560 = setTableOption(pCxt, yymsp[-2].minor.yy560, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy334); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + case 179: /* table_options ::= */ +{ yymsp[1].minor.yy778 = createDefaultTableOptions(pCxt); } break; - case 180: /* table_options ::= table_options WATERMARK duration_list */ -{ yylhsminor.yy560 = setTableOption(pCxt, yymsp[-2].minor.yy560, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy334); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + case 180: /* table_options ::= table_options COMMENT NK_STRING */ +{ yylhsminor.yy778 = setTableOption(pCxt, yymsp[-2].minor.yy778, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 181: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -{ yylhsminor.yy560 = setTableOption(pCxt, yymsp[-4].minor.yy560, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy334); } - yymsp[-4].minor.yy560 = yylhsminor.yy560; + case 181: /* table_options ::= table_options MAX_DELAY duration_list */ +{ yylhsminor.yy778 = setTableOption(pCxt, yymsp[-2].minor.yy778, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy282); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 182: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy560 = setTableOption(pCxt, yymsp[-2].minor.yy560, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + case 182: /* table_options ::= table_options WATERMARK duration_list */ +{ yylhsminor.yy778 = setTableOption(pCxt, yymsp[-2].minor.yy778, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy282); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 183: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy560 = setTableOption(pCxt, yymsp[-4].minor.yy560, TABLE_OPTION_SMA, yymsp[-1].minor.yy334); } - yymsp[-4].minor.yy560 = yylhsminor.yy560; + case 183: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ +{ yylhsminor.yy778 = setTableOption(pCxt, yymsp[-4].minor.yy778, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy282); } + yymsp[-4].minor.yy778 = yylhsminor.yy778; break; - case 184: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy560 = createAlterTableOptions(pCxt); yylhsminor.yy560 = setTableOption(pCxt, yylhsminor.yy560, yymsp[0].minor.yy515.type, &yymsp[0].minor.yy515.val); } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 184: /* table_options ::= table_options TTL NK_INTEGER */ +{ yylhsminor.yy778 = setTableOption(pCxt, yymsp[-2].minor.yy778, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 185: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy560 = setTableOption(pCxt, yymsp[-1].minor.yy560, yymsp[0].minor.yy515.type, &yymsp[0].minor.yy515.val); } - yymsp[-1].minor.yy560 = yylhsminor.yy560; + case 185: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ +{ yylhsminor.yy778 = setTableOption(pCxt, yymsp[-4].minor.yy778, TABLE_OPTION_SMA, yymsp[-1].minor.yy282); } + yymsp[-4].minor.yy778 = yylhsminor.yy778; break; - case 186: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy515.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy515.val = yymsp[0].minor.yy0; } + case 186: /* alter_table_options ::= alter_table_option */ +{ yylhsminor.yy778 = createAlterTableOptions(pCxt); yylhsminor.yy778 = setTableOption(pCxt, yylhsminor.yy778, yymsp[0].minor.yy645.type, &yymsp[0].minor.yy645.val); } + yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 187: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy515.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy515.val = yymsp[0].minor.yy0; } + case 187: /* alter_table_options ::= alter_table_options alter_table_option */ +{ yylhsminor.yy778 = setTableOption(pCxt, yymsp[-1].minor.yy778, yymsp[0].minor.yy645.type, &yymsp[0].minor.yy645.val); } + yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 188: /* duration_list ::= duration_literal */ - case 347: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==347); -{ yylhsminor.yy334 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy560)); } - yymsp[0].minor.yy334 = yylhsminor.yy334; + case 188: /* alter_table_option ::= COMMENT NK_STRING */ +{ yymsp[-1].minor.yy645.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy645.val = yymsp[0].minor.yy0; } break; - case 189: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 348: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==348); -{ yylhsminor.yy334 = addNodeToList(pCxt, yymsp[-2].minor.yy334, releaseRawExprNode(pCxt, yymsp[0].minor.yy560)); } - yymsp[-2].minor.yy334 = yylhsminor.yy334; + case 189: /* alter_table_option ::= TTL NK_INTEGER */ +{ yymsp[-1].minor.yy645.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy645.val = yymsp[0].minor.yy0; } break; - case 192: /* rollup_func_name ::= function_name */ -{ yylhsminor.yy560 = createFunctionNode(pCxt, &yymsp[0].minor.yy659, NULL); } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 190: /* duration_list ::= duration_literal */ + case 352: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==352); +{ yylhsminor.yy282 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy778)); } + yymsp[0].minor.yy282 = yylhsminor.yy282; break; - case 193: /* rollup_func_name ::= FIRST */ - case 194: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==194); -{ yylhsminor.yy560 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 191: /* duration_list ::= duration_list NK_COMMA duration_literal */ + case 353: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==353); +{ yylhsminor.yy282 = addNodeToList(pCxt, yymsp[-2].minor.yy282, releaseRawExprNode(pCxt, yymsp[0].minor.yy778)); } + yymsp[-2].minor.yy282 = yylhsminor.yy282; break; - case 197: /* col_name ::= column_name */ -{ yylhsminor.yy560 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy659); } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 194: /* rollup_func_name ::= function_name */ +{ yylhsminor.yy778 = createFunctionNode(pCxt, &yymsp[0].minor.yy181, NULL); } + yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 198: /* cmd ::= SHOW DNODES */ + case 195: /* rollup_func_name ::= FIRST */ + case 196: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==196); +{ yylhsminor.yy778 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy778 = yylhsminor.yy778; + break; + case 199: /* col_name ::= column_name */ +{ yylhsminor.yy778 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy181); } + yymsp[0].minor.yy778 = yylhsminor.yy778; + break; + case 200: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } break; - case 199: /* cmd ::= SHOW USERS */ + case 201: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); } break; - case 200: /* cmd ::= SHOW DATABASES */ + case 202: /* cmd ::= SHOW DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); } break; - case 201: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy560, yymsp[0].minor.yy560, OP_TYPE_LIKE); } + case 203: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy778, yymsp[0].minor.yy778, OP_TYPE_LIKE); } break; - case 202: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy560, yymsp[0].minor.yy560, OP_TYPE_LIKE); } + case 204: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy778, yymsp[0].minor.yy778, OP_TYPE_LIKE); } break; - case 203: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy560, NULL, OP_TYPE_LIKE); } + case 205: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy778, NULL, OP_TYPE_LIKE); } break; - case 204: /* cmd ::= SHOW MNODES */ + case 206: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } break; - case 205: /* cmd ::= SHOW MODULES */ + case 207: /* cmd ::= SHOW MODULES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MODULES_STMT); } break; - case 206: /* cmd ::= SHOW QNODES */ + case 208: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); } break; - case 207: /* cmd ::= SHOW FUNCTIONS */ + case 209: /* cmd ::= SHOW FUNCTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } break; - case 208: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy560, yymsp[-1].minor.yy560, OP_TYPE_EQUAL); } + case 210: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy778, yymsp[-1].minor.yy778, OP_TYPE_EQUAL); } break; - case 209: /* cmd ::= SHOW STREAMS */ + case 211: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } break; - case 210: /* cmd ::= SHOW ACCOUNTS */ + case 212: /* cmd ::= SHOW ACCOUNTS */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } break; - case 211: /* cmd ::= SHOW APPS */ + case 213: /* cmd ::= SHOW APPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); } break; - case 212: /* cmd ::= SHOW CONNECTIONS */ + case 214: /* cmd ::= SHOW CONNECTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); } break; - case 213: /* cmd ::= SHOW LICENCES */ - case 214: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==214); + case 215: /* cmd ::= SHOW LICENCES */ + case 216: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==216); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); } break; - case 215: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy659); } + case 217: /* cmd ::= SHOW CREATE DATABASE db_name */ +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy181); } break; - case 216: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy560); } + case 218: /* cmd ::= SHOW CREATE TABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy778); } break; - case 217: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy560); } + case 219: /* cmd ::= SHOW CREATE STABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy778); } break; - case 218: /* cmd ::= SHOW QUERIES */ + case 220: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } break; - case 219: /* cmd ::= SHOW SCORES */ + case 221: /* cmd ::= SHOW SCORES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); } break; - case 220: /* cmd ::= SHOW TOPICS */ + case 222: /* cmd ::= SHOW TOPICS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); } break; - case 221: /* cmd ::= SHOW VARIABLES */ + case 223: /* cmd ::= SHOW VARIABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLES_STMT); } break; - case 222: /* cmd ::= SHOW LOCAL VARIABLES */ + case 224: /* cmd ::= SHOW LOCAL VARIABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } break; - case 223: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ + case 225: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ { pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-1].minor.yy0)); } break; - case 224: /* cmd ::= SHOW BNODES */ + case 226: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } break; - case 225: /* cmd ::= SHOW SNODES */ + case 227: /* cmd ::= SHOW SNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); } break; - case 226: /* cmd ::= SHOW CLUSTER */ + case 228: /* cmd ::= SHOW CLUSTER */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); } break; - case 227: /* cmd ::= SHOW TRANSACTIONS */ + case 229: /* cmd ::= SHOW TRANSACTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } break; - case 228: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy560); } + case 230: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy778); } break; - case 229: /* cmd ::= SHOW CONSUMERS */ + case 231: /* cmd ::= SHOW CONSUMERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } break; - case 230: /* cmd ::= SHOW SUBSCRIPTIONS */ + case 232: /* cmd ::= SHOW SUBSCRIPTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } break; - case 231: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy560, yymsp[-1].minor.yy560, OP_TYPE_EQUAL); } + case 233: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy778, yymsp[-1].minor.yy778, OP_TYPE_EQUAL); } break; - case 232: /* cmd ::= SHOW VNODES NK_INTEGER */ + case 234: /* cmd ::= SHOW TABLE TAGS FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLE_TAGS_STMT, yymsp[0].minor.yy778, yymsp[-1].minor.yy778, OP_TYPE_EQUAL); } + break; + case 235: /* cmd ::= SHOW VNODES NK_INTEGER */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); } break; - case 233: /* cmd ::= SHOW VNODES NK_STRING */ + case 236: /* cmd ::= SHOW VNODES NK_STRING */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, createValueNode(pCxt, TSDB_DATA_TYPE_VARCHAR, &yymsp[0].minor.yy0)); } break; - case 234: /* db_name_cond_opt ::= */ - case 239: /* from_db_opt ::= */ yytestcase(yyruleno==239); -{ yymsp[1].minor.yy560 = createDefaultDatabaseCondValue(pCxt); } + case 237: /* db_name_cond_opt ::= */ + case 242: /* from_db_opt ::= */ yytestcase(yyruleno==242); +{ yymsp[1].minor.yy778 = createDefaultDatabaseCondValue(pCxt); } break; - case 235: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy659); } - yymsp[-1].minor.yy560 = yylhsminor.yy560; + case 238: /* db_name_cond_opt ::= db_name NK_DOT */ +{ yylhsminor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy181); } + yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 236: /* like_pattern_opt ::= */ - case 390: /* case_when_else_opt ::= */ yytestcase(yyruleno==390); - case 420: /* from_clause_opt ::= */ yytestcase(yyruleno==420); - case 449: /* where_clause_opt ::= */ yytestcase(yyruleno==449); - case 453: /* twindow_clause_opt ::= */ yytestcase(yyruleno==453); - case 458: /* sliding_opt ::= */ yytestcase(yyruleno==458); - case 460: /* fill_opt ::= */ yytestcase(yyruleno==460); - case 472: /* having_clause_opt ::= */ yytestcase(yyruleno==472); - case 474: /* range_opt ::= */ yytestcase(yyruleno==474); - case 476: /* every_opt ::= */ yytestcase(yyruleno==476); - case 489: /* slimit_clause_opt ::= */ yytestcase(yyruleno==489); - case 493: /* limit_clause_opt ::= */ yytestcase(yyruleno==493); -{ yymsp[1].minor.yy560 = NULL; } + case 239: /* like_pattern_opt ::= */ + case 284: /* subtable_opt ::= */ yytestcase(yyruleno==284); + case 397: /* case_when_else_opt ::= */ yytestcase(yyruleno==397); + case 427: /* from_clause_opt ::= */ yytestcase(yyruleno==427); + case 456: /* where_clause_opt ::= */ yytestcase(yyruleno==456); + case 465: /* twindow_clause_opt ::= */ yytestcase(yyruleno==465); + case 470: /* sliding_opt ::= */ yytestcase(yyruleno==470); + case 472: /* fill_opt ::= */ yytestcase(yyruleno==472); + case 484: /* having_clause_opt ::= */ yytestcase(yyruleno==484); + case 486: /* range_opt ::= */ yytestcase(yyruleno==486); + case 488: /* every_opt ::= */ yytestcase(yyruleno==488); + case 501: /* slimit_clause_opt ::= */ yytestcase(yyruleno==501); + case 505: /* limit_clause_opt ::= */ yytestcase(yyruleno==505); +{ yymsp[1].minor.yy778 = NULL; } break; - case 237: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + case 240: /* like_pattern_opt ::= LIKE NK_STRING */ +{ yymsp[-1].minor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; - case 238: /* table_name_cond ::= table_name */ -{ yylhsminor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy659); } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 241: /* table_name_cond ::= table_name */ +{ yylhsminor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy181); } + yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 240: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy659); } + case 243: /* from_db_opt ::= FROM db_name */ +{ yymsp[-1].minor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy181); } break; - case 241: /* cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy173, yymsp[-3].minor.yy560, yymsp[-1].minor.yy560, NULL, yymsp[0].minor.yy560); } + case 244: /* cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy39, yymsp[-3].minor.yy778, yymsp[-1].minor.yy778, NULL, yymsp[0].minor.yy778); } break; - case 242: /* cmd ::= DROP INDEX exists_opt full_table_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy173, yymsp[0].minor.yy560); } + case 245: /* cmd ::= DROP INDEX exists_opt full_table_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy39, yymsp[0].minor.yy778); } break; - case 243: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-9].minor.yy560 = createIndexOption(pCxt, yymsp[-7].minor.yy334, releaseRawExprNode(pCxt, yymsp[-3].minor.yy560), NULL, yymsp[-1].minor.yy560, yymsp[0].minor.yy560); } + case 246: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ +{ yymsp[-9].minor.yy778 = createIndexOption(pCxt, yymsp[-7].minor.yy282, releaseRawExprNode(pCxt, yymsp[-3].minor.yy778), NULL, yymsp[-1].minor.yy778, yymsp[0].minor.yy778); } break; - case 244: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-11].minor.yy560 = createIndexOption(pCxt, yymsp[-9].minor.yy334, releaseRawExprNode(pCxt, yymsp[-5].minor.yy560), releaseRawExprNode(pCxt, yymsp[-3].minor.yy560), yymsp[-1].minor.yy560, yymsp[0].minor.yy560); } + case 247: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ +{ yymsp[-11].minor.yy778 = createIndexOption(pCxt, yymsp[-9].minor.yy282, releaseRawExprNode(pCxt, yymsp[-5].minor.yy778), releaseRawExprNode(pCxt, yymsp[-3].minor.yy778), yymsp[-1].minor.yy778, yymsp[0].minor.yy778); } break; - case 247: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy560 = createFunctionNode(pCxt, &yymsp[-3].minor.yy659, yymsp[-1].minor.yy334); } - yymsp[-3].minor.yy560 = yylhsminor.yy560; + case 250: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy778 = createFunctionNode(pCxt, &yymsp[-3].minor.yy181, yymsp[-1].minor.yy282); } + yymsp[-3].minor.yy778 = yylhsminor.yy778; break; - case 248: /* sma_stream_opt ::= */ - case 275: /* stream_options ::= */ yytestcase(yyruleno==275); -{ yymsp[1].minor.yy560 = createStreamOptions(pCxt); } + case 251: /* sma_stream_opt ::= */ + case 278: /* stream_options ::= */ yytestcase(yyruleno==278); +{ yymsp[1].minor.yy778 = createStreamOptions(pCxt); } break; - case 249: /* sma_stream_opt ::= stream_options WATERMARK duration_literal */ - case 279: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==279); -{ ((SStreamOptions*)yymsp[-2].minor.yy560)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy560); yylhsminor.yy560 = yymsp[-2].minor.yy560; } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + case 252: /* sma_stream_opt ::= stream_options WATERMARK duration_literal */ + case 282: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==282); +{ ((SStreamOptions*)yymsp[-2].minor.yy778)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy778); yylhsminor.yy778 = yymsp[-2].minor.yy778; } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 250: /* sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy560)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy560); yylhsminor.yy560 = yymsp[-2].minor.yy560; } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + case 253: /* sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy778)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy778); yylhsminor.yy778 = yymsp[-2].minor.yy778; } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 251: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy173, &yymsp[-2].minor.yy659, yymsp[0].minor.yy560); } + case 254: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy39, &yymsp[-2].minor.yy181, yymsp[0].minor.yy778); } break; - case 252: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy173, &yymsp[-3].minor.yy659, &yymsp[0].minor.yy659, false); } + case 255: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy39, &yymsp[-3].minor.yy181, &yymsp[0].minor.yy181, false); } break; - case 253: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy173, &yymsp[-5].minor.yy659, &yymsp[0].minor.yy659, true); } + case 256: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy39, &yymsp[-5].minor.yy181, &yymsp[0].minor.yy181, true); } break; - case 254: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy173, &yymsp[-3].minor.yy659, yymsp[0].minor.yy560, false); } + case 257: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy39, &yymsp[-3].minor.yy181, yymsp[0].minor.yy778, false); } break; - case 255: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy173, &yymsp[-5].minor.yy659, yymsp[0].minor.yy560, true); } + case 258: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy39, &yymsp[-5].minor.yy181, yymsp[0].minor.yy778, true); } break; - case 256: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy173, &yymsp[0].minor.yy659); } + case 259: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy39, &yymsp[0].minor.yy181); } break; - case 257: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy173, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy659); } + case 260: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy39, &yymsp[-2].minor.yy181, &yymsp[0].minor.yy181); } break; - case 258: /* cmd ::= DESC full_table_name */ - case 259: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==259); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy560); } + case 261: /* cmd ::= DESC full_table_name */ + case 262: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==262); +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy778); } break; - case 260: /* cmd ::= RESET QUERY CACHE */ + case 263: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; - case 261: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy173, yymsp[-1].minor.yy560, yymsp[0].minor.yy560); } + case 264: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy39, yymsp[-1].minor.yy778, yymsp[0].minor.yy778); } break; - case 263: /* analyze_opt ::= ANALYZE */ - case 270: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==270); - case 440: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==440); -{ yymsp[0].minor.yy173 = true; } + case 266: /* analyze_opt ::= ANALYZE */ + case 273: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==273); + case 447: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==447); +{ yymsp[0].minor.yy39 = true; } break; - case 264: /* explain_options ::= */ -{ yymsp[1].minor.yy560 = createDefaultExplainOptions(pCxt); } + case 267: /* explain_options ::= */ +{ yymsp[1].minor.yy778 = createDefaultExplainOptions(pCxt); } break; - case 265: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy560 = setExplainVerbose(pCxt, yymsp[-2].minor.yy560, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + case 268: /* explain_options ::= explain_options VERBOSE NK_BOOL */ +{ yylhsminor.yy778 = setExplainVerbose(pCxt, yymsp[-2].minor.yy778, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 266: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy560 = setExplainRatio(pCxt, yymsp[-2].minor.yy560, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + case 269: /* explain_options ::= explain_options RATIO NK_FLOAT */ +{ yylhsminor.yy778 = setExplainRatio(pCxt, yymsp[-2].minor.yy778, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 267: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ -{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy173, yymsp[-8].minor.yy173, &yymsp[-5].minor.yy659, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy574, yymsp[0].minor.yy676); } + case 270: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy39, yymsp[-8].minor.yy39, &yymsp[-5].minor.yy181, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy380, yymsp[0].minor.yy276); } break; - case 268: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy173, &yymsp[0].minor.yy659); } + case 271: /* cmd ::= DROP FUNCTION exists_opt function_name */ +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy39, &yymsp[0].minor.yy181); } break; - case 271: /* bufsize_opt ::= */ -{ yymsp[1].minor.yy676 = 0; } + case 276: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery */ +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-8].minor.yy39, &yymsp[-7].minor.yy181, yymsp[-4].minor.yy778, yymsp[-6].minor.yy778, yymsp[-3].minor.yy282, yymsp[-2].minor.yy778, yymsp[0].minor.yy778); } break; - case 272: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ -{ yymsp[-1].minor.yy676 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } + case 277: /* cmd ::= DROP STREAM exists_opt stream_name */ +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy39, &yymsp[0].minor.yy181); } break; - case 273: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name AS query_or_subquery */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-6].minor.yy173, &yymsp[-5].minor.yy659, yymsp[-2].minor.yy560, yymsp[-4].minor.yy560, yymsp[0].minor.yy560); } + case 279: /* stream_options ::= stream_options TRIGGER AT_ONCE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy778)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy778 = yymsp[-2].minor.yy778; } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 274: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy173, &yymsp[0].minor.yy659); } + case 280: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy778)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy778 = yymsp[-2].minor.yy778; } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 276: /* stream_options ::= stream_options TRIGGER AT_ONCE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy560)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy560 = yymsp[-2].minor.yy560; } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + case 281: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-3].minor.yy778)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy778)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy778); yylhsminor.yy778 = yymsp[-3].minor.yy778; } + yymsp[-3].minor.yy778 = yylhsminor.yy778; break; - case 277: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy560)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy560 = yymsp[-2].minor.yy560; } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + case 283: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ +{ ((SStreamOptions*)yymsp[-3].minor.yy778)->ignoreExpired = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy778 = yymsp[-3].minor.yy778; } + yymsp[-3].minor.yy778 = yylhsminor.yy778; break; - case 278: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-3].minor.yy560)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy560)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy560); yylhsminor.yy560 = yymsp[-3].minor.yy560; } - yymsp[-3].minor.yy560 = yylhsminor.yy560; + case 285: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + case 471: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ yytestcase(yyruleno==471); + case 489: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==489); +{ yymsp[-3].minor.yy778 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy778); } break; - case 280: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ -{ ((SStreamOptions*)yymsp[-3].minor.yy560)->ignoreExpired = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy560 = yymsp[-3].minor.yy560; } - yymsp[-3].minor.yy560 = yylhsminor.yy560; - break; - case 281: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 286: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 282: /* cmd ::= KILL QUERY NK_STRING */ + case 287: /* cmd ::= KILL QUERY NK_STRING */ { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 283: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 288: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } break; - case 284: /* cmd ::= BALANCE VGROUP */ + case 289: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } break; - case 285: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 290: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 286: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy334); } + case 291: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy282); } break; - case 287: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 292: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 288: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy334 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + case 293: /* dnode_list ::= DNODE NK_INTEGER */ +{ yymsp[-1].minor.yy282 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; - case 290: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy560, yymsp[0].minor.yy560); } + case 295: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy778, yymsp[0].minor.yy778); } break; - case 292: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ -{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-4].minor.yy560, yymsp[-2].minor.yy334, yymsp[0].minor.yy560); } + case 297: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ +{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-4].minor.yy778, yymsp[-2].minor.yy282, yymsp[0].minor.yy778); } break; - case 293: /* cmd ::= INSERT INTO full_table_name query_or_subquery */ -{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-1].minor.yy560, NULL, yymsp[0].minor.yy560); } + case 298: /* cmd ::= INSERT INTO full_table_name query_or_subquery */ +{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-1].minor.yy778, NULL, yymsp[0].minor.yy778); } break; - case 294: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy560 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 299: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy778 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 295: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy560 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 300: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy778 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 296: /* literal ::= NK_STRING */ -{ yylhsminor.yy560 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 301: /* literal ::= NK_STRING */ +{ yylhsminor.yy778 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 297: /* literal ::= NK_BOOL */ -{ yylhsminor.yy560 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 302: /* literal ::= NK_BOOL */ +{ yylhsminor.yy778 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 298: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy560 = yylhsminor.yy560; + case 303: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 299: /* literal ::= duration_literal */ - case 309: /* signed_literal ::= signed */ yytestcase(yyruleno==309); - case 329: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==329); - case 330: /* expr_or_subquery ::= subquery */ yytestcase(yyruleno==330); - case 331: /* expression ::= literal */ yytestcase(yyruleno==331); - case 332: /* expression ::= pseudo_column */ yytestcase(yyruleno==332); - case 333: /* expression ::= column_reference */ yytestcase(yyruleno==333); - case 334: /* expression ::= function_expression */ yytestcase(yyruleno==334); - case 335: /* expression ::= case_when_expression */ yytestcase(yyruleno==335); - case 363: /* function_expression ::= literal_func */ yytestcase(yyruleno==363); - case 412: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==412); - case 416: /* boolean_primary ::= predicate */ yytestcase(yyruleno==416); - case 418: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==418); - case 419: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==419); - case 422: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==422); - case 424: /* table_reference ::= table_primary */ yytestcase(yyruleno==424); - case 425: /* table_reference ::= joined_table */ yytestcase(yyruleno==425); - case 429: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==429); - case 479: /* query_simple ::= query_specification */ yytestcase(yyruleno==479); - case 480: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==480); - case 483: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==483); - case 485: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==485); -{ yylhsminor.yy560 = yymsp[0].minor.yy560; } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 304: /* literal ::= duration_literal */ + case 314: /* signed_literal ::= signed */ yytestcase(yyruleno==314); + case 334: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==334); + case 335: /* expr_or_subquery ::= subquery */ yytestcase(yyruleno==335); + case 336: /* expression ::= literal */ yytestcase(yyruleno==336); + case 337: /* expression ::= pseudo_column */ yytestcase(yyruleno==337); + case 338: /* expression ::= column_reference */ yytestcase(yyruleno==338); + case 339: /* expression ::= function_expression */ yytestcase(yyruleno==339); + case 340: /* expression ::= case_when_expression */ yytestcase(yyruleno==340); + case 370: /* function_expression ::= literal_func */ yytestcase(yyruleno==370); + case 419: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==419); + case 423: /* boolean_primary ::= predicate */ yytestcase(yyruleno==423); + case 425: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==425); + case 426: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==426); + case 429: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==429); + case 431: /* table_reference ::= table_primary */ yytestcase(yyruleno==431); + case 432: /* table_reference ::= joined_table */ yytestcase(yyruleno==432); + case 436: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==436); + case 491: /* query_simple ::= query_specification */ yytestcase(yyruleno==491); + case 492: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==492); + case 495: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==495); + case 497: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==497); +{ yylhsminor.yy778 = yymsp[0].minor.yy778; } + yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 300: /* literal ::= NULL */ -{ yylhsminor.yy560 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 305: /* literal ::= NULL */ +{ yylhsminor.yy778 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 301: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy560 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 306: /* literal ::= NK_QUESTION */ +{ yylhsminor.yy778 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 302: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy560 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 307: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy778 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 303: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 308: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 304: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + case 309: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } break; - case 305: /* signed ::= NK_MINUS NK_INTEGER */ + case 310: /* signed ::= NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy560 = yylhsminor.yy560; + yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 306: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 311: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 307: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 312: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 308: /* signed ::= NK_MINUS NK_FLOAT */ + case 313: /* signed ::= NK_MINUS NK_FLOAT */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy560 = yylhsminor.yy560; + yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 310: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 315: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 311: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 316: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 312: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 317: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 313: /* signed_literal ::= duration_literal */ - case 315: /* signed_literal ::= literal_func */ yytestcase(yyruleno==315); - case 383: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==383); - case 445: /* select_item ::= common_expression */ yytestcase(yyruleno==445); - case 484: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==484); - case 486: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==486); - case 499: /* search_condition ::= common_expression */ yytestcase(yyruleno==499); -{ yylhsminor.yy560 = releaseRawExprNode(pCxt, yymsp[0].minor.yy560); } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 318: /* signed_literal ::= duration_literal */ + case 320: /* signed_literal ::= literal_func */ yytestcase(yyruleno==320); + case 390: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==390); + case 452: /* select_item ::= common_expression */ yytestcase(yyruleno==452); + case 462: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==462); + case 496: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==496); + case 498: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==498); + case 511: /* search_condition ::= common_expression */ yytestcase(yyruleno==511); +{ yylhsminor.yy778 = releaseRawExprNode(pCxt, yymsp[0].minor.yy778); } + yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 314: /* signed_literal ::= NULL */ -{ yylhsminor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 319: /* signed_literal ::= NULL */ +{ yylhsminor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 316: /* signed_literal ::= NK_QUESTION */ -{ yylhsminor.yy560 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 321: /* signed_literal ::= NK_QUESTION */ +{ yylhsminor.yy778 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 336: /* expression ::= NK_LP expression NK_RP */ - case 417: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==417); - case 498: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==498); -{ yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy560)); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + case 341: /* expression ::= NK_LP expression NK_RP */ + case 424: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==424); + case 510: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==510); +{ yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy778)); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 337: /* expression ::= NK_PLUS expr_or_subquery */ + case 342: /* expression ::= NK_PLUS expr_or_subquery */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); - yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy560)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); + yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy778)); } - yymsp[-1].minor.yy560 = yylhsminor.yy560; + yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 338: /* expression ::= NK_MINUS expr_or_subquery */ + case 343: /* expression ::= NK_MINUS expr_or_subquery */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); - yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy560), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); + yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy778), NULL)); } - yymsp[-1].minor.yy560 = yylhsminor.yy560; + yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 339: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + case 344: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); - yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); + yylhsminor.yy778 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy778), releaseRawExprNode(pCxt, yymsp[0].minor.yy778))); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 340: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + case 345: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); - yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); + yylhsminor.yy778 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy778), releaseRawExprNode(pCxt, yymsp[0].minor.yy778))); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 341: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + case 346: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); - yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); + yylhsminor.yy778 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy778), releaseRawExprNode(pCxt, yymsp[0].minor.yy778))); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 342: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + case 347: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); - yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); + yylhsminor.yy778 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy778), releaseRawExprNode(pCxt, yymsp[0].minor.yy778))); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 343: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ + case 348: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); - yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); + yylhsminor.yy778 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy778), releaseRawExprNode(pCxt, yymsp[0].minor.yy778))); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 344: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 349: /* expression ::= column_reference NK_ARROW NK_STRING */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); - yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); + yylhsminor.yy778 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy778), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 345: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + case 350: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); - yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); + yylhsminor.yy778 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy778), releaseRawExprNode(pCxt, yymsp[0].minor.yy778))); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 346: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + case 351: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); - yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); + yylhsminor.yy778 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy778), releaseRawExprNode(pCxt, yymsp[0].minor.yy778))); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 349: /* column_reference ::= column_name */ -{ yylhsminor.yy560 = createRawExprNode(pCxt, &yymsp[0].minor.yy659, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy659)); } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 354: /* column_reference ::= column_name */ +{ yylhsminor.yy778 = createRawExprNode(pCxt, &yymsp[0].minor.yy181, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy181)); } + yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 350: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy659, createColumnNode(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy659)); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + case 355: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy181, &yymsp[0].minor.yy181, createColumnNode(pCxt, &yymsp[-2].minor.yy181, &yymsp[0].minor.yy181)); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 351: /* pseudo_column ::= ROWTS */ - case 352: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==352); - case 354: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==354); - case 355: /* pseudo_column ::= QEND */ yytestcase(yyruleno==355); - case 356: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==356); - case 357: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==357); - case 358: /* pseudo_column ::= WEND */ yytestcase(yyruleno==358); - case 359: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==359); - case 365: /* literal_func ::= NOW */ yytestcase(yyruleno==365); -{ yylhsminor.yy560 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 356: /* pseudo_column ::= ROWTS */ + case 357: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==357); + case 359: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==359); + case 360: /* pseudo_column ::= QEND */ yytestcase(yyruleno==360); + case 361: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==361); + case 362: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==362); + case 363: /* pseudo_column ::= WEND */ yytestcase(yyruleno==363); + case 364: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==364); + case 365: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==365); + case 366: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==366); + case 372: /* literal_func ::= NOW */ yytestcase(yyruleno==372); +{ yylhsminor.yy778 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 353: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy659)))); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + case 358: /* pseudo_column ::= table_name NK_DOT TBNAME */ +{ yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy181, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy181)))); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 360: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 361: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==361); -{ yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy659, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy659, yymsp[-1].minor.yy334)); } - yymsp[-3].minor.yy560 = yylhsminor.yy560; + case 367: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 368: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==368); +{ yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy181, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy181, yymsp[-1].minor.yy282)); } + yymsp[-3].minor.yy778 = yylhsminor.yy778; break; - case 362: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ -{ yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy560), yymsp[-1].minor.yy574)); } - yymsp[-5].minor.yy560 = yylhsminor.yy560; + case 369: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ +{ yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy778), yymsp[-1].minor.yy380)); } + yymsp[-5].minor.yy778 = yylhsminor.yy778; break; - case 364: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy659, NULL)); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + case 371: /* literal_func ::= noarg_func NK_LP NK_RP */ +{ yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy181, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy181, NULL)); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 379: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy334 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy334 = yylhsminor.yy334; + case 386: /* star_func_para_list ::= NK_STAR */ +{ yylhsminor.yy282 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy282 = yylhsminor.yy282; break; - case 384: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 448: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==448); -{ yylhsminor.yy560 = createColumnNode(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + case 391: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 455: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==455); +{ yylhsminor.yy778 = createColumnNode(pCxt, &yymsp[-2].minor.yy181, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 385: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ -{ yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy334, yymsp[-1].minor.yy560)); } - yymsp[-3].minor.yy560 = yylhsminor.yy560; + case 392: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ +{ yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy282, yymsp[-1].minor.yy778)); } + yymsp[-3].minor.yy778 = yylhsminor.yy778; break; - case 386: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ -{ yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy560), yymsp[-2].minor.yy334, yymsp[-1].minor.yy560)); } - yymsp[-4].minor.yy560 = yylhsminor.yy560; + case 393: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ +{ yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy778), yymsp[-2].minor.yy282, yymsp[-1].minor.yy778)); } + yymsp[-4].minor.yy778 = yylhsminor.yy778; break; - case 389: /* when_then_expr ::= WHEN common_expression THEN common_expression */ -{ yymsp[-3].minor.yy560 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560)); } + case 396: /* when_then_expr ::= WHEN common_expression THEN common_expression */ +{ yymsp[-3].minor.yy778 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy778), releaseRawExprNode(pCxt, yymsp[0].minor.yy778)); } break; - case 391: /* case_when_else_opt ::= ELSE common_expression */ -{ yymsp[-1].minor.yy560 = releaseRawExprNode(pCxt, yymsp[0].minor.yy560); } + case 398: /* case_when_else_opt ::= ELSE common_expression */ +{ yymsp[-1].minor.yy778 = releaseRawExprNode(pCxt, yymsp[0].minor.yy778); } break; - case 392: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ - case 397: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==397); + case 399: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ + case 404: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==404); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); - yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy128, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); + yylhsminor.yy778 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy682, releaseRawExprNode(pCxt, yymsp[-2].minor.yy778), releaseRawExprNode(pCxt, yymsp[0].minor.yy778))); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 393: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + case 400: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy560); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); - yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy560), releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy778); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); + yylhsminor.yy778 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy778), releaseRawExprNode(pCxt, yymsp[-2].minor.yy778), releaseRawExprNode(pCxt, yymsp[0].minor.yy778))); } - yymsp[-4].minor.yy560 = yylhsminor.yy560; + yymsp[-4].minor.yy778 = yylhsminor.yy778; break; - case 394: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + case 401: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy560); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); - yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy560), releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy778); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); + yylhsminor.yy778 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy778), releaseRawExprNode(pCxt, yymsp[-2].minor.yy778), releaseRawExprNode(pCxt, yymsp[0].minor.yy778))); } - yymsp[-5].minor.yy560 = yylhsminor.yy560; + yymsp[-5].minor.yy778 = yylhsminor.yy778; break; - case 395: /* predicate ::= expr_or_subquery IS NULL */ + case 402: /* predicate ::= expr_or_subquery IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); - yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); + yylhsminor.yy778 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy778), NULL)); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 396: /* predicate ::= expr_or_subquery IS NOT NULL */ + case 403: /* predicate ::= expr_or_subquery IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy560); - yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy560), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy778); + yylhsminor.yy778 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy778), NULL)); } - yymsp[-3].minor.yy560 = yylhsminor.yy560; + yymsp[-3].minor.yy778 = yylhsminor.yy778; break; - case 398: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy128 = OP_TYPE_LOWER_THAN; } + case 405: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy682 = OP_TYPE_LOWER_THAN; } break; - case 399: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy128 = OP_TYPE_GREATER_THAN; } + case 406: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy682 = OP_TYPE_GREATER_THAN; } break; - case 400: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy128 = OP_TYPE_LOWER_EQUAL; } + case 407: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy682 = OP_TYPE_LOWER_EQUAL; } break; - case 401: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy128 = OP_TYPE_GREATER_EQUAL; } + case 408: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy682 = OP_TYPE_GREATER_EQUAL; } break; - case 402: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy128 = OP_TYPE_NOT_EQUAL; } + case 409: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy682 = OP_TYPE_NOT_EQUAL; } break; - case 403: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy128 = OP_TYPE_EQUAL; } + case 410: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy682 = OP_TYPE_EQUAL; } break; - case 404: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy128 = OP_TYPE_LIKE; } + case 411: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy682 = OP_TYPE_LIKE; } break; - case 405: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy128 = OP_TYPE_NOT_LIKE; } + case 412: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy682 = OP_TYPE_NOT_LIKE; } break; - case 406: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy128 = OP_TYPE_MATCH; } + case 413: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy682 = OP_TYPE_MATCH; } break; - case 407: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy128 = OP_TYPE_NMATCH; } + case 414: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy682 = OP_TYPE_NMATCH; } break; - case 408: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy128 = OP_TYPE_JSON_CONTAINS; } + case 415: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy682 = OP_TYPE_JSON_CONTAINS; } break; - case 409: /* in_op ::= IN */ -{ yymsp[0].minor.yy128 = OP_TYPE_IN; } + case 416: /* in_op ::= IN */ +{ yymsp[0].minor.yy682 = OP_TYPE_IN; } break; - case 410: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy128 = OP_TYPE_NOT_IN; } + case 417: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy682 = OP_TYPE_NOT_IN; } break; - case 411: /* in_predicate_value ::= NK_LP literal_list NK_RP */ -{ yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy334)); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + case 418: /* in_predicate_value ::= NK_LP literal_list NK_RP */ +{ yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy282)); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 413: /* boolean_value_expression ::= NOT boolean_primary */ + case 420: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); - yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy560), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); + yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy778), NULL)); } - yymsp[-1].minor.yy560 = yylhsminor.yy560; + yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 414: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 421: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); - yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); + yylhsminor.yy778 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy778), releaseRawExprNode(pCxt, yymsp[0].minor.yy778))); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 415: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 422: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); - yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); + yylhsminor.yy778 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy778), releaseRawExprNode(pCxt, yymsp[0].minor.yy778))); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 421: /* from_clause_opt ::= FROM table_reference_list */ - case 450: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==450); - case 473: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==473); -{ yymsp[-1].minor.yy560 = yymsp[0].minor.yy560; } + case 428: /* from_clause_opt ::= FROM table_reference_list */ + case 457: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==457); + case 485: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==485); +{ yymsp[-1].minor.yy778 = yymsp[0].minor.yy778; } break; - case 423: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy560 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy560, yymsp[0].minor.yy560, NULL); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + case 430: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy778 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy778, yymsp[0].minor.yy778, NULL); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 426: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy560 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy659, &yymsp[0].minor.yy659); } - yymsp[-1].minor.yy560 = yylhsminor.yy560; + case 433: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy778 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy181, &yymsp[0].minor.yy181); } + yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 427: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy560 = createRealTableNode(pCxt, &yymsp[-3].minor.yy659, &yymsp[-1].minor.yy659, &yymsp[0].minor.yy659); } - yymsp[-3].minor.yy560 = yylhsminor.yy560; + case 434: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy778 = createRealTableNode(pCxt, &yymsp[-3].minor.yy181, &yymsp[-1].minor.yy181, &yymsp[0].minor.yy181); } + yymsp[-3].minor.yy778 = yylhsminor.yy778; break; - case 428: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy560 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy560), &yymsp[0].minor.yy659); } - yymsp[-1].minor.yy560 = yylhsminor.yy560; + case 435: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy778 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy778), &yymsp[0].minor.yy181); } + yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 430: /* alias_opt ::= */ -{ yymsp[1].minor.yy659 = nil_token; } + case 437: /* alias_opt ::= */ +{ yymsp[1].minor.yy181 = nil_token; } break; - case 431: /* alias_opt ::= table_alias */ -{ yylhsminor.yy659 = yymsp[0].minor.yy659; } - yymsp[0].minor.yy659 = yylhsminor.yy659; + case 438: /* alias_opt ::= table_alias */ +{ yylhsminor.yy181 = yymsp[0].minor.yy181; } + yymsp[0].minor.yy181 = yylhsminor.yy181; break; - case 432: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy659 = yymsp[0].minor.yy659; } + case 439: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy181 = yymsp[0].minor.yy181; } break; - case 433: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 434: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==434); -{ yymsp[-2].minor.yy560 = yymsp[-1].minor.yy560; } + case 440: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 441: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==441); +{ yymsp[-2].minor.yy778 = yymsp[-1].minor.yy778; } break; - case 435: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy560 = createJoinTableNode(pCxt, yymsp[-4].minor.yy540, yymsp[-5].minor.yy560, yymsp[-2].minor.yy560, yymsp[0].minor.yy560); } - yymsp[-5].minor.yy560 = yylhsminor.yy560; + case 442: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy778 = createJoinTableNode(pCxt, yymsp[-4].minor.yy202, yymsp[-5].minor.yy778, yymsp[-2].minor.yy778, yymsp[0].minor.yy778); } + yymsp[-5].minor.yy778 = yylhsminor.yy778; break; - case 436: /* join_type ::= */ -{ yymsp[1].minor.yy540 = JOIN_TYPE_INNER; } + case 443: /* join_type ::= */ +{ yymsp[1].minor.yy202 = JOIN_TYPE_INNER; } break; - case 437: /* join_type ::= INNER */ -{ yymsp[0].minor.yy540 = JOIN_TYPE_INNER; } + case 444: /* join_type ::= INNER */ +{ yymsp[0].minor.yy202 = JOIN_TYPE_INNER; } break; - case 438: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 445: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { - yymsp[-11].minor.yy560 = createSelectStmt(pCxt, yymsp[-10].minor.yy173, yymsp[-9].minor.yy334, yymsp[-8].minor.yy560); - yymsp[-11].minor.yy560 = addWhereClause(pCxt, yymsp[-11].minor.yy560, yymsp[-7].minor.yy560); - yymsp[-11].minor.yy560 = addPartitionByClause(pCxt, yymsp[-11].minor.yy560, yymsp[-6].minor.yy334); - yymsp[-11].minor.yy560 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy560, yymsp[-2].minor.yy560); - yymsp[-11].minor.yy560 = addGroupByClause(pCxt, yymsp[-11].minor.yy560, yymsp[-1].minor.yy334); - yymsp[-11].minor.yy560 = addHavingClause(pCxt, yymsp[-11].minor.yy560, yymsp[0].minor.yy560); - yymsp[-11].minor.yy560 = addRangeClause(pCxt, yymsp[-11].minor.yy560, yymsp[-5].minor.yy560); - yymsp[-11].minor.yy560 = addEveryClause(pCxt, yymsp[-11].minor.yy560, yymsp[-4].minor.yy560); - yymsp[-11].minor.yy560 = addFillClause(pCxt, yymsp[-11].minor.yy560, yymsp[-3].minor.yy560); + yymsp[-11].minor.yy778 = createSelectStmt(pCxt, yymsp[-10].minor.yy39, yymsp[-9].minor.yy282, yymsp[-8].minor.yy778); + yymsp[-11].minor.yy778 = addWhereClause(pCxt, yymsp[-11].minor.yy778, yymsp[-7].minor.yy778); + yymsp[-11].minor.yy778 = addPartitionByClause(pCxt, yymsp[-11].minor.yy778, yymsp[-6].minor.yy282); + yymsp[-11].minor.yy778 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy778, yymsp[-2].minor.yy778); + yymsp[-11].minor.yy778 = addGroupByClause(pCxt, yymsp[-11].minor.yy778, yymsp[-1].minor.yy282); + yymsp[-11].minor.yy778 = addHavingClause(pCxt, yymsp[-11].minor.yy778, yymsp[0].minor.yy778); + yymsp[-11].minor.yy778 = addRangeClause(pCxt, yymsp[-11].minor.yy778, yymsp[-5].minor.yy778); + yymsp[-11].minor.yy778 = addEveryClause(pCxt, yymsp[-11].minor.yy778, yymsp[-4].minor.yy778); + yymsp[-11].minor.yy778 = addFillClause(pCxt, yymsp[-11].minor.yy778, yymsp[-3].minor.yy778); } break; - case 441: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy173 = false; } + case 448: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy39 = false; } break; - case 444: /* select_item ::= NK_STAR */ -{ yylhsminor.yy560 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy560 = yylhsminor.yy560; + case 451: /* select_item ::= NK_STAR */ +{ yylhsminor.yy778 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 446: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy560 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy560), &yymsp[0].minor.yy659); } - yymsp[-1].minor.yy560 = yylhsminor.yy560; + case 453: /* select_item ::= common_expression column_alias */ + case 463: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==463); +{ yylhsminor.yy778 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy778), &yymsp[0].minor.yy181); } + yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 447: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy560 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), &yymsp[0].minor.yy659); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + case 454: /* select_item ::= common_expression AS column_alias */ + case 464: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==464); +{ yylhsminor.yy778 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy778), &yymsp[0].minor.yy181); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 452: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 469: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==469); - case 488: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==488); -{ yymsp[-2].minor.yy334 = yymsp[0].minor.yy334; } + case 459: /* partition_by_clause_opt ::= PARTITION BY partition_list */ + case 481: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==481); + case 500: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==500); +{ yymsp[-2].minor.yy282 = yymsp[0].minor.yy282; } break; - case 454: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy560 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy560), releaseRawExprNode(pCxt, yymsp[-1].minor.yy560)); } + case 466: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ +{ yymsp[-5].minor.yy778 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy778), releaseRawExprNode(pCxt, yymsp[-1].minor.yy778)); } break; - case 455: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ -{ yymsp[-3].minor.yy560 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy560)); } + case 467: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ +{ yymsp[-3].minor.yy778 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy778)); } break; - case 456: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy560 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy560), NULL, yymsp[-1].minor.yy560, yymsp[0].minor.yy560); } + case 468: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy778 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy778), NULL, yymsp[-1].minor.yy778, yymsp[0].minor.yy778); } break; - case 457: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy560 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy560), releaseRawExprNode(pCxt, yymsp[-3].minor.yy560), yymsp[-1].minor.yy560, yymsp[0].minor.yy560); } + case 469: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy778 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy778), releaseRawExprNode(pCxt, yymsp[-3].minor.yy778), yymsp[-1].minor.yy778, yymsp[0].minor.yy778); } break; - case 459: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - case 477: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==477); -{ yymsp[-3].minor.yy560 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy560); } + case 473: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy778 = createFillNode(pCxt, yymsp[-1].minor.yy381, NULL); } break; - case 461: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy560 = createFillNode(pCxt, yymsp[-1].minor.yy18, NULL); } + case 474: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy778 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy282)); } break; - case 462: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy560 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy334)); } + case 475: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy381 = FILL_MODE_NONE; } break; - case 463: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy18 = FILL_MODE_NONE; } + case 476: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy381 = FILL_MODE_PREV; } break; - case 464: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy18 = FILL_MODE_PREV; } + case 477: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy381 = FILL_MODE_NULL; } break; - case 465: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy18 = FILL_MODE_NULL; } + case 478: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy381 = FILL_MODE_LINEAR; } break; - case 466: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy18 = FILL_MODE_LINEAR; } + case 479: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy381 = FILL_MODE_NEXT; } break; - case 467: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy18 = FILL_MODE_NEXT; } + case 482: /* group_by_list ::= expr_or_subquery */ +{ yylhsminor.yy282 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy778))); } + yymsp[0].minor.yy282 = yylhsminor.yy282; break; - case 470: /* group_by_list ::= expr_or_subquery */ -{ yylhsminor.yy334 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); } - yymsp[0].minor.yy334 = yylhsminor.yy334; + case 483: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ +{ yylhsminor.yy282 = addNodeToList(pCxt, yymsp[-2].minor.yy282, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy778))); } + yymsp[-2].minor.yy282 = yylhsminor.yy282; break; - case 471: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ -{ yylhsminor.yy334 = addNodeToList(pCxt, yymsp[-2].minor.yy334, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); } - yymsp[-2].minor.yy334 = yylhsminor.yy334; + case 487: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ +{ yymsp[-5].minor.yy778 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy778), releaseRawExprNode(pCxt, yymsp[-1].minor.yy778)); } break; - case 475: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ -{ yymsp[-5].minor.yy560 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy560), releaseRawExprNode(pCxt, yymsp[-1].minor.yy560)); } - break; - case 478: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 490: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy560 = addOrderByClause(pCxt, yymsp[-3].minor.yy560, yymsp[-2].minor.yy334); - yylhsminor.yy560 = addSlimitClause(pCxt, yylhsminor.yy560, yymsp[-1].minor.yy560); - yylhsminor.yy560 = addLimitClause(pCxt, yylhsminor.yy560, yymsp[0].minor.yy560); + yylhsminor.yy778 = addOrderByClause(pCxt, yymsp[-3].minor.yy778, yymsp[-2].minor.yy282); + yylhsminor.yy778 = addSlimitClause(pCxt, yylhsminor.yy778, yymsp[-1].minor.yy778); + yylhsminor.yy778 = addLimitClause(pCxt, yylhsminor.yy778, yymsp[0].minor.yy778); } - yymsp[-3].minor.yy560 = yylhsminor.yy560; + yymsp[-3].minor.yy778 = yylhsminor.yy778; break; - case 481: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ -{ yylhsminor.yy560 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy560, yymsp[0].minor.yy560); } - yymsp[-3].minor.yy560 = yylhsminor.yy560; + case 493: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ +{ yylhsminor.yy778 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy778, yymsp[0].minor.yy778); } + yymsp[-3].minor.yy778 = yylhsminor.yy778; break; - case 482: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ -{ yylhsminor.yy560 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy560, yymsp[0].minor.yy560); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + case 494: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ +{ yylhsminor.yy778 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy778, yymsp[0].minor.yy778); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 490: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 494: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==494); -{ yymsp[-1].minor.yy560 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 502: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 506: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==506); +{ yymsp[-1].minor.yy778 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 491: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 495: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==495); -{ yymsp[-3].minor.yy560 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 503: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 507: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==507); +{ yymsp[-3].minor.yy778 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 492: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 496: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==496); -{ yymsp[-3].minor.yy560 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 504: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 508: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==508); +{ yymsp[-3].minor.yy778 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 497: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy560); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + case 509: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy778); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 502: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy560 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), yymsp[-1].minor.yy596, yymsp[0].minor.yy487); } - yymsp[-2].minor.yy560 = yylhsminor.yy560; + case 514: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy778 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy778), yymsp[-1].minor.yy14, yymsp[0].minor.yy305); } + yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 503: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy596 = ORDER_ASC; } + case 515: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy14 = ORDER_ASC; } break; - case 504: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy596 = ORDER_ASC; } + case 516: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy14 = ORDER_ASC; } break; - case 505: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy596 = ORDER_DESC; } + case 517: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy14 = ORDER_DESC; } break; - case 506: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy487 = NULL_ORDER_DEFAULT; } + case 518: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy305 = NULL_ORDER_DEFAULT; } break; - case 507: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy487 = NULL_ORDER_FIRST; } + case 519: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy305 = NULL_ORDER_FIRST; } break; - case 508: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy487 = NULL_ORDER_LAST; } + case 520: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy305 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/mockCatalog.cpp b/source/libs/parser/test/mockCatalog.cpp index 7725674200..fcaa5af05c 100644 --- a/source/libs/parser/test/mockCatalog.cpp +++ b/source/libs/parser/test/mockCatalog.cpp @@ -85,6 +85,10 @@ void generateInformationSchema(MockCatalogService* mcs) { .addColumn("dnode_id", TSDB_DATA_TYPE_INT) .addColumn("dnode_ep", TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN) .done(); + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TAGS, TSDB_SYSTEM_TABLE, 2) + .addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN) + .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) + .done(); } void generatePerformanceSchema(MockCatalogService* mcs) { diff --git a/source/libs/parser/test/parInitialCTest.cpp b/source/libs/parser/test/parInitialCTest.cpp index a159d797fa..121bbaa733 100644 --- a/source/libs/parser/test/parInitialCTest.cpp +++ b/source/libs/parser/test/parInitialCTest.cpp @@ -610,6 +610,20 @@ TEST_F(ParserInitialCTest, createStream) { expect.igExpired = igExpired; }; + auto addTag = [&](const char* pFieldName, uint8_t type, int32_t bytes = 0) { + SField field = {0}; + strcpy(field.name, pFieldName); + field.type = type; + field.bytes = bytes > 0 ? bytes : tDataTypes[type].bytes; + field.flags |= COL_SMA_ON; + + if (NULL == expect.pTags) { + expect.pTags = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SField)); + } + taosArrayPush(expect.pTags, &field); + expect.numOfTags += 1; + }; + setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) { ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_CREATE_STREAM_STMT); SCMCreateStreamReq req = {0}; @@ -625,6 +639,19 @@ TEST_F(ParserInitialCTest, createStream) { ASSERT_EQ(req.maxDelay, expect.maxDelay); ASSERT_EQ(req.watermark, expect.watermark); ASSERT_EQ(req.igExpired, expect.igExpired); + ASSERT_EQ(req.numOfTags, expect.numOfTags); + if (expect.numOfTags > 0) { + ASSERT_EQ(taosArrayGetSize(req.pTags), expect.numOfTags); + ASSERT_EQ(taosArrayGetSize(req.pTags), taosArrayGetSize(expect.pTags)); + for (int32_t i = 0; i < expect.numOfTags; ++i) { + SField* pField = (SField*)taosArrayGet(req.pTags, i); + SField* pExpectField = (SField*)taosArrayGet(expect.pTags, i); + ASSERT_EQ(std::string(pField->name), std::string(pExpectField->name)); + ASSERT_EQ(pField->type, pExpectField->type); + ASSERT_EQ(pField->bytes, pExpectField->bytes); + ASSERT_EQ(pField->flags, pExpectField->flags); + } + } tFreeSCMCreateStreamReq(&req); }); @@ -640,6 +667,17 @@ TEST_F(ParserInitialCTest, createStream) { run("CREATE STREAM IF NOT EXISTS s1 TRIGGER MAX_DELAY 20s WATERMARK 10s IGNORE EXPIRED 0 INTO st1 AS SELECT COUNT(*) " "FROM t1 INTERVAL(10S)"); clearCreateStreamReq(); + + setCreateStreamReqFunc( + "s1", "test", + "create stream s1 into st3 tags(tname varchar(10), id int) subtable(concat('new-', tname)) as " + "select _wstart wstart, count(*) cnt from st1 partition by tbname tname, tag1 id interval(10s)", + "st3"); + addTag("tname", TSDB_DATA_TYPE_VARCHAR, 10 + VARSTR_HEADER_SIZE); + addTag("id", TSDB_DATA_TYPE_INT); + run("CREATE STREAM s1 INTO st3 TAGS(tname VARCHAR(10), id INT) SUBTABLE(CONCAT('new-', tname)) " + "AS SELECT _WSTART wstart, COUNT(*) cnt FROM st1 PARTITION BY TBNAME tname, tag1 id INTERVAL(10S)"); + clearCreateStreamReq(); } TEST_F(ParserInitialCTest, createStreamSemanticCheck) { diff --git a/source/libs/parser/test/parShowToUse.cpp b/source/libs/parser/test/parShowToUse.cpp index e33252c072..36e70dd015 100644 --- a/source/libs/parser/test/parShowToUse.cpp +++ b/source/libs/parser/test/parShowToUse.cpp @@ -196,6 +196,12 @@ TEST_F(ParserShowToUseTest, showTableDistributed) { run("SHOW TABLE DISTRIBUTED st1"); } +TEST_F(ParserShowToUseTest, showTags) { + useDb("root", "test"); + + run("SHOW TAGS FROM st1s1"); +} + // todo SHOW topics TEST_F(ParserShowToUseTest, showUsers) { @@ -213,9 +219,9 @@ TEST_F(ParserShowToUseTest, showVariables) { TEST_F(ParserShowToUseTest, showVgroups) { useDb("root", "test"); - run("SHOW vgroups"); + run("SHOW VGROUPS"); - run("SHOW test.vgroups"); + run("SHOW test.VGROUPS"); } TEST_F(ParserShowToUseTest, showVnodes) { @@ -250,7 +256,10 @@ TEST_F(ParserShowToUseTest, trimDatabase) { STrimDbReq expect = {0}; - auto setTrimDbReq = [&](const char* pDb) { snprintf(expect.db, sizeof(expect.db), "0.%s", pDb); }; + auto setTrimDbReq = [&](const char* pDb, int32_t maxSpeed = 0) { + snprintf(expect.db, sizeof(expect.db), "0.%s", pDb); + expect.maxSpeed = maxSpeed; + }; setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) { ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_TRIM_DATABASE_STMT); @@ -258,10 +267,14 @@ TEST_F(ParserShowToUseTest, trimDatabase) { STrimDbReq req = {0}; ASSERT_EQ(tDeserializeSTrimDbReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req), TSDB_CODE_SUCCESS); ASSERT_EQ(std::string(req.db), std::string(expect.db)); + ASSERT_EQ(req.maxSpeed, expect.maxSpeed); }); setTrimDbReq("wxy_db"); run("TRIM DATABASE wxy_db"); + + setTrimDbReq("wxy_db", 100); + run("TRIM DATABASE wxy_db MAX_SPEED 100"); } TEST_F(ParserShowToUseTest, useDatabase) { diff --git a/source/libs/parser/test/parTestMain.cpp b/source/libs/parser/test/parTestMain.cpp index bcaccbab07..9e67249238 100644 --- a/source/libs/parser/test/parTestMain.cpp +++ b/source/libs/parser/test/parTestMain.cpp @@ -86,6 +86,7 @@ static void parseArg(int argc, char* argv[]) { {"dump", no_argument, NULL, 'd'}, {"async", required_argument, NULL, 'a'}, {"skipSql", required_argument, NULL, 's'}, + {"log", required_argument, NULL, 'l'}, {0, 0, 0, 0} }; // clang-format on @@ -100,6 +101,9 @@ static void parseArg(int argc, char* argv[]) { case 's': setSkipSqlNum(optarg); break; + case 'l': + setLogLevel(optarg); + break; default: break; } diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index fea2be55f9..8c87f60b9f 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -611,6 +611,8 @@ static int32_t createIndefRowsFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt return code; } +static bool isInterpFunc(int32_t funcId) { return fmIsInterpFunc(funcId) || fmIsInterpPseudoColumnFunc(funcId); } + static int32_t createInterpFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) { if (!pSelect->hasInterpFunc) { return TSDB_CODE_SUCCESS; @@ -625,7 +627,7 @@ static int32_t createInterpFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt* p pInterpFunc->node.requireDataOrder = getRequireDataOrder(true, pSelect); pInterpFunc->node.resultDataOrder = pInterpFunc->node.requireDataOrder; - int32_t code = nodesCollectFuncs(pSelect, SQL_CLAUSE_SELECT, fmIsInterpFunc, &pInterpFunc->pFuncs); + int32_t code = nodesCollectFuncs(pSelect, SQL_CLAUSE_SELECT, isInterpFunc, &pInterpFunc->pFuncs); if (TSDB_CODE_SUCCESS == code) { code = rewriteExprsForSelect(pInterpFunc->pFuncs, pSelect, SQL_CLAUSE_SELECT); } @@ -1022,6 +1024,20 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS } } + if (TSDB_CODE_SUCCESS == code && NULL != pSelect->pTags) { + pPartition->pTags = nodesCloneList(pSelect->pTags); + if (NULL == pPartition->pTags) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + } + + if (TSDB_CODE_SUCCESS == code && NULL != pSelect->pSubtable) { + pPartition->pSubtable = nodesCloneNode(pSelect->pSubtable); + if (NULL == pPartition->pSubtable) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + } + if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pPartition; } else { diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index a700a21301..927969bf9c 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -1615,6 +1615,8 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub SScanLogicNode* pScan = (SScanLogicNode*)nodesListGetNode(pNode->pChildren, 0); if (QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pNode)) { TSWAP(((SPartitionLogicNode*)pNode)->pPartitionKeys, pScan->pGroupTags); + TSWAP(((SPartitionLogicNode*)pNode)->pTags, pScan->pTags); + TSWAP(((SPartitionLogicNode*)pNode)->pSubtable, pScan->pSubtable); int32_t code = replaceLogicNode(pLogicSubplan, pNode, (SLogicNode*)pScan); if (TSDB_CODE_SUCCESS == code) { code = adjustLogicNodeDataRequirement((SLogicNode*)pScan, pNode->resultDataOrder); diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index ec7050fdbc..810b82b9fc 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -563,7 +563,16 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp pTableScan->igExpired = pScanLogicNode->igExpired; pTableScan->assignBlockUid = pCxt->pPlanCxt->rSmaQuery ? true : false; - return createScanPhysiNodeFinalize(pCxt, pSubplan, pScanLogicNode, (SScanPhysiNode*)pTableScan, pPhyNode); + int32_t code = createScanPhysiNodeFinalize(pCxt, pSubplan, pScanLogicNode, (SScanPhysiNode*)pTableScan, pPhyNode); + if (TSDB_CODE_SUCCESS == code) { + code = setListSlotId(pCxt, pTableScan->scan.node.pOutputDataBlockDesc->dataBlockId, -1, pScanLogicNode->pTags, + &pTableScan->pTags); + } + if (TSDB_CODE_SUCCESS == code) { + code = setNodeSlotId(pCxt, pTableScan->scan.node.pOutputDataBlockDesc->dataBlockId, -1, pScanLogicNode->pSubtable, + &pTableScan->pSubtable); + } + return code; } static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, @@ -1322,11 +1331,10 @@ static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren return code; } -static int32_t createPartitionPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, - SPartitionLogicNode* pPartLogicNode, SPhysiNode** pPhyNode) { - SPartitionPhysiNode* pPart = (SPartitionPhysiNode*)makePhysiNode( - pCxt, (SLogicNode*)pPartLogicNode, - pCxt->pPlanCxt->streamQuery ? QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION : QUERY_NODE_PHYSICAL_PLAN_PARTITION); +static int32_t createPartitionPhysiNodeImpl(SPhysiPlanContext* pCxt, SNodeList* pChildren, + SPartitionLogicNode* pPartLogicNode, ENodeType type, + SPhysiNode** pPhyNode) { + SPartitionPhysiNode* pPart = (SPartitionPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pPartLogicNode, type); if (NULL == pPart) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -1371,9 +1379,39 @@ static int32_t createPartitionPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChi return code; } +static int32_t createStreamPartitionPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, + SPartitionLogicNode* pPartLogicNode, SPhysiNode** pPhyNode) { + SStreamPartitionPhysiNode* pPart = NULL; + int32_t code = createPartitionPhysiNodeImpl(pCxt, pChildren, pPartLogicNode, + QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION, (SPhysiNode**)&pPart); + SDataBlockDescNode* pChildTupe = (((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc); + if (TSDB_CODE_SUCCESS == code) { + code = setListSlotId(pCxt, pChildTupe->dataBlockId, -1, pPartLogicNode->pTags, &pPart->pTags); + } + if (TSDB_CODE_SUCCESS == code) { + code = setNodeSlotId(pCxt, pChildTupe->dataBlockId, -1, pPartLogicNode->pSubtable, &pPart->pSubtable); + } + if (TSDB_CODE_SUCCESS == code) { + *pPhyNode = (SPhysiNode*)pPart; + } else { + nodesDestroyNode((SNode*)pPart); + } + return code; +} + +static int32_t createPartitionPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, + SPartitionLogicNode* pPartLogicNode, SPhysiNode** pPhyNode) { + if (pCxt->pPlanCxt->streamQuery) { + return createStreamPartitionPhysiNode(pCxt, pChildren, pPartLogicNode, pPhyNode); + } + return createPartitionPhysiNodeImpl(pCxt, pChildren, pPartLogicNode, QUERY_NODE_PHYSICAL_PLAN_PARTITION, pPhyNode); +} + static int32_t createFillPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SFillLogicNode* pFillNode, SPhysiNode** pPhyNode) { - SFillPhysiNode* pFill = (SFillPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pFillNode, QUERY_NODE_PHYSICAL_PLAN_FILL); + SFillPhysiNode* pFill = (SFillPhysiNode*)makePhysiNode( + pCxt, (SLogicNode*)pFillNode, + pCxt->pPlanCxt->streamQuery ? QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL : QUERY_NODE_PHYSICAL_PLAN_FILL); if (NULL == pFill) { return TSDB_CODE_OUT_OF_MEMORY; } diff --git a/source/libs/planner/test/planBasicTest.cpp b/source/libs/planner/test/planBasicTest.cpp index c7769b15b1..0baec147a2 100644 --- a/source/libs/planner/test/planBasicTest.cpp +++ b/source/libs/planner/test/planBasicTest.cpp @@ -101,6 +101,8 @@ TEST_F(PlanBasicTest, interpFunc) { useDb("root", "test"); run("SELECT INTERP(c1) FROM t1 RANGE('2017-7-14 18:00:00', '2017-7-14 19:00:00') EVERY(5s) FILL(LINEAR)"); + + run("SELECT _IROWTS, INTERP(c1) FROM t1 RANGE('2017-7-14 18:00:00', '2017-7-14 19:00:00') EVERY(5s) FILL(LINEAR)"); } TEST_F(PlanBasicTest, lastRowFunc) { @@ -178,6 +180,8 @@ TEST_F(PlanBasicTest, pseudoColumn) { run("SELECT _QSTART, _QEND, _QDURATION, _WSTART, _WEND, _WDURATION, COUNT(*) FROM t1 " "WHERE ts BETWEEN '2017-7-14 18:00:00' AND '2017-7-14 19:00:00' INTERVAL(10S)"); + + run("SELECT _TAGS, * FROM st1s1"); } TEST_F(PlanBasicTest, indefiniteRowsFunc) { diff --git a/source/libs/planner/test/planOtherTest.cpp b/source/libs/planner/test/planOtherTest.cpp index 350ccd0d92..a934fb615c 100644 --- a/source/libs/planner/test/planOtherTest.cpp +++ b/source/libs/planner/test/planOtherTest.cpp @@ -32,6 +32,12 @@ TEST_F(PlanOtherTest, createStream) { run("create stream if not exists s1 trigger window_close watermark 10s into st1 as select count(*) from t1 " "interval(10s)"); + + run("CREATE STREAM s1 INTO st3 TAGS(tname VARCHAR(10), id INT) SUBTABLE(CONCAT('new-', tname)) " + "AS SELECT _WSTART wstart, COUNT(*) cnt FROM st1 PARTITION BY TBNAME tname, c1 id INTERVAL(10S)"); + + run("CREATE STREAM s1 INTO st3 TAGS(tname VARCHAR(10), id INT) SUBTABLE(CONCAT('new-', tname)) " + "AS SELECT _WSTART wstart, COUNT(*) cnt FROM st1 PARTITION BY TBNAME tname, tag1 id INTERVAL(10S)"); } TEST_F(PlanOtherTest, createStreamUseSTable) { @@ -78,6 +84,10 @@ TEST_F(PlanOtherTest, show) { run("SHOW TABLE DISTRIBUTED st1"); run("SHOW DNODE 1 VARIABLES"); + + run("SHOW TAGS FROM st1s1"); + + run("SHOW TABLE TAGS FROM st1"); } TEST_F(PlanOtherTest, delete) { diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c index 3c102938d0..ae9dd82a58 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -107,9 +107,12 @@ int32_t qwExecTask(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *queryStop) { QW_TASK_DLOG("start to execTask, loopIdx:%d", i++); // if *taskHandle is NULL, it's killed right now + bool hasMore = false; + if (taskHandle) { qwDbgSimulateSleep(); - code = qExecTaskOpt(taskHandle, pResList, &useconds, &localFetch); + + code = qExecTaskOpt(taskHandle, pResList, &useconds, &hasMore, &localFetch); if (code) { if (code != TSDB_CODE_OPS_NOT_SUPPORT) { QW_TASK_ELOG("qExecTask failed, code:%x - %s", code, tstrerror(code)); @@ -122,20 +125,8 @@ int32_t qwExecTask(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *queryStop) { ++execNum; - if (taosArrayGetSize(pResList) == 0) { - QW_TASK_DLOG("qExecTask end with empty res, useconds:%" PRIu64, useconds); - dsEndPut(sinkHandle, useconds); - - QW_ERR_JRET(qwHandleTaskComplete(QW_FPARAMS(), ctx)); - - if (queryStop) { - *queryStop = true; - } - - break; - } - - for (int32_t j = 0; j < taosArrayGetSize(pResList); ++j) { + size_t numOfResBlock = taosArrayGetSize(pResList); + for (int32_t j = 0; j < numOfResBlock; ++j) { SSDataBlock *pRes = taosArrayGetP(pResList, j); ASSERT(pRes->info.rows > 0); @@ -149,6 +140,23 @@ int32_t qwExecTask(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *queryStop) { QW_TASK_DLOG("data put into sink, rows:%d, continueExecTask:%d", pRes->info.rows, qcontinue); } + if (numOfResBlock == 0 || (hasMore == false)) { + if (numOfResBlock == 0) { + QW_TASK_DLOG("qExecTask end with empty res, useconds:%" PRIu64, useconds); + } else { + QW_TASK_DLOG("qExecTask done", ""); + } + + dsEndPut(sinkHandle, useconds); + QW_ERR_JRET(qwHandleTaskComplete(QW_FPARAMS(), ctx)); + + if (queryStop) { + *queryStop = true; + } + + break; + } + if (!qcontinue) { if (queryStop) { *queryStop = true; diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index b82cc2fd26..52393d0839 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -3093,6 +3093,8 @@ static FORCE_INLINE bool filterExecuteImplIsNull(void *pinfo, int32_t numOfRows, if (p[i] == 0) { all = false; + } else { + (*numOfQualified) += 1; } } @@ -3117,6 +3119,8 @@ static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows p[i] = ((colData != NULL) && !colDataIsNull((SColumnInfoData *)info->cunits[uidx].colData, 0, i, NULL)); if (p[i] == 0) { all = false; + } else { + (*numOfQualified) += 1; } } @@ -3196,6 +3200,8 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, SColumnInfoData *pRes if (p[i] == 0) { all = false; + } else { + (*numOfQualified) += 1; } } @@ -3269,6 +3275,8 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, SColumnInfoData *pRes, SC if (p[i] == 0) { all = false; + } else { + (*numOfQualified) += 1; } } diff --git a/source/libs/scheduler/src/schJob.c b/source/libs/scheduler/src/schJob.c index 5e47c0a0ed..69495c8b7a 100644 --- a/source/libs/scheduler/src/schJob.c +++ b/source/libs/scheduler/src/schJob.c @@ -47,8 +47,7 @@ void schUpdateJobErrCode(SSchJob *pJob, int32_t errCode) { return; _return: - - SCH_JOB_DLOG("job errCode updated to %x - %s", errCode, tstrerror(errCode)); + SCH_JOB_DLOG("job errCode updated to %s", tstrerror(errCode)); } bool schJobDone(SSchJob *pJob) { @@ -491,7 +490,7 @@ int32_t schProcessOnJobFailure(SSchJob *pJob, int32_t errCode) { int32_t code = atomic_load_32(&pJob->errCode); if (code) { - SCH_JOB_DLOG("job failed with error: %s", tstrerror(code)); + SCH_JOB_DLOG("job failed with error %s", tstrerror(code)); } schPostJobRes(pJob, 0); diff --git a/source/libs/stream/src/streamState.c b/source/libs/stream/src/streamState.c index fde8bca77b..da0d0fbd6d 100644 --- a/source/libs/stream/src/streamState.c +++ b/source/libs/stream/src/streamState.c @@ -18,6 +18,37 @@ #include "tcommon.h" #include "ttimer.h" +// todo refactor +typedef struct SStateKey { + SWinKey key; + int64_t opNum; +} SStateKey; + +static inline int SStateKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, int kLen2) { + SStateKey* pWin1 = (SStateKey*)pKey1; + SStateKey* pWin2 = (SStateKey*)pKey2; + + if (pWin1->opNum > pWin2->opNum) { + return 1; + } else if (pWin1->opNum < pWin2->opNum) { + return -1; + } + + if (pWin1->key.ts > pWin2->key.ts) { + return 1; + } else if (pWin1->key.ts < pWin2->key.ts) { + return -1; + } + + if (pWin1->key.groupId > pWin2->key.groupId) { + return 1; + } else if (pWin1->key.groupId < pWin2->key.groupId) { + return -1; + } + + return 0; +} + SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath) { SStreamState* pState = taosMemoryCalloc(1, sizeof(SStreamState)); if (pState == NULL) { @@ -29,14 +60,19 @@ SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath) { if (!specPath) { sprintf(statePath, "%s/%d", path, pTask->taskId); } else { - memcpy(statePath, path, 300); + strncpy(statePath, path, 300); } if (tdbOpen(statePath, 4096, 256, &pState->db) < 0) { goto _err; } // open state storage backend - if (tdbTbOpen("state.db", sizeof(SWinKey), -1, SWinKeyCmpr, pState->db, &pState->pStateDb) < 0) { + if (tdbTbOpen("state.db", sizeof(SStateKey), -1, SStateKeyCmpr, pState->db, &pState->pStateDb) < 0) { + goto _err; + } + + // todo refactor + if (tdbTbOpen("func.state.db", sizeof(SWinKey), -1, SWinKeyCmpr, pState->db, &pState->pFillStateDb) < 0) { goto _err; } @@ -55,6 +91,7 @@ SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath) { _err: tdbTbClose(pState->pStateDb); tdbTbClose(pState->pFuncStateDb); + tdbTbClose(pState->pFillStateDb); tdbClose(pState->db); taosMemoryFree(pState); return NULL; @@ -64,6 +101,7 @@ void streamStateClose(SStreamState* pState) { tdbCommit(pState->db, &pState->txn); tdbTbClose(pState->pStateDb); tdbTbClose(pState->pFuncStateDb); + tdbTbClose(pState->pFillStateDb); tdbClose(pState->db); taosMemoryFree(pState); @@ -123,15 +161,55 @@ int32_t streamStateFuncDel(SStreamState* pState, const STupleKey* key) { return tdbTbDelete(pState->pFuncStateDb, key, sizeof(STupleKey), &pState->txn); } +// todo refactor int32_t streamStatePut(SStreamState* pState, const SWinKey* key, const void* value, int32_t vLen) { - return tdbTbUpsert(pState->pStateDb, key, sizeof(SWinKey), value, vLen, &pState->txn); -} -int32_t streamStateGet(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen) { - return tdbTbGet(pState->pStateDb, key, sizeof(SWinKey), pVal, pVLen); + SStateKey sKey = {.key = *key, .opNum = pState->number}; + return tdbTbUpsert(pState->pStateDb, &sKey, sizeof(SStateKey), value, vLen, &pState->txn); } +// todo refactor +int32_t streamStateFillPut(SStreamState* pState, const SWinKey* key, const void* value, int32_t vLen) { + return tdbTbUpsert(pState->pFillStateDb, key, sizeof(SWinKey), value, vLen, &pState->txn); +} + +// todo refactor +int32_t streamStateGet(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen) { + SStateKey sKey = {.key = *key, .opNum = pState->number}; + return tdbTbGet(pState->pStateDb, &sKey, sizeof(SStateKey), pVal, pVLen); +} + +// todo refactor +int32_t streamStateFillGet(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen) { + return tdbTbGet(pState->pFillStateDb, key, sizeof(SWinKey), pVal, pVLen); +} + +// todo refactor int32_t streamStateDel(SStreamState* pState, const SWinKey* key) { - return tdbTbDelete(pState->pStateDb, key, sizeof(SWinKey), &pState->txn); + SStateKey sKey = {.key = *key, .opNum = pState->number}; + return tdbTbDelete(pState->pStateDb, &sKey, sizeof(SStateKey), &pState->txn); +} + +int32_t streamStateClear(SStreamState* pState) { + SWinKey key = {.ts = 0, .groupId = 0}; + streamStatePut(pState, &key, NULL, 0); + while (1) { + SStreamStateCur* pCur = streamStateSeekKeyNext(pState, &key); + SWinKey delKey = {0}; + int32_t code = streamStateGetKVByCur(pCur, &delKey, NULL, 0); + if (code == 0) { + streamStateDel(pState, &delKey); + } else { + break; + } + } + return 0; +} + +void streamStateSetNumber(SStreamState* pState, int32_t number) { pState->number = number; } + +// todo refactor +int32_t streamStateFillDel(SStreamState* pState, const SWinKey* key) { + return tdbTbDelete(pState->pFillStateDb, key, sizeof(SWinKey), &pState->txn); } int32_t streamStateAddIfNotExist(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen) { @@ -156,6 +234,22 @@ SStreamStateCur* streamStateGetCur(SStreamState* pState, const SWinKey* key) { if (pCur == NULL) return NULL; tdbTbcOpen(pState->pStateDb, &pCur->pCur, NULL); + int32_t c; + SStateKey sKey = {.key = *key, .opNum = pState->number}; + tdbTbcMoveTo(pCur->pCur, key, sizeof(SWinKey), &c); + if (c != 0) { + taosMemoryFree(pCur); + return NULL; + } + pCur->number = pState->number; + return pCur; +} + +SStreamStateCur* streamStateFillGetCur(SStreamState* pState, const SWinKey* key) { + SStreamStateCur* pCur = taosMemoryCalloc(1, sizeof(SStreamStateCur)); + if (pCur == NULL) return NULL; + tdbTbcOpen(pState->pFillStateDb, &pCur->pCur, NULL); + int32_t c; tdbTbcMoveTo(pCur->pCur, key, sizeof(SWinKey), &c); if (c != 0) { @@ -165,7 +259,37 @@ SStreamStateCur* streamStateGetCur(SStreamState* pState, const SWinKey* key) { return pCur; } +SStreamStateCur* streamStateGetAndCheckCur(SStreamState* pState, SWinKey* key) { + SStreamStateCur* pCur = streamStateFillGetCur(pState, key); + if (pCur) { + int32_t code = streamStateGetGroupKVByCur(pCur, key, NULL, 0); + if (code == 0) { + return pCur; + } + } + return NULL; +} + int32_t streamStateGetKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen) { + if (!pCur) { + return -1; + } + const SStateKey* pKTmp = NULL; + int32_t kLen; + if (tdbTbcGet(pCur->pCur, (const void**)&pKTmp, &kLen, pVal, pVLen) < 0) { + return -1; + } + if (pKTmp->opNum != pCur->number) { + return -1; + } + *pKey = pKTmp->key; + return 0; +} + +int32_t streamStateFillGetKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen) { + if (!pCur) { + return -1; + } const SWinKey* pKTmp = NULL; int32_t kLen; if (tdbTbcGet(pCur->pCur, (const void**)&pKTmp, &kLen, pVal, pVLen) < 0) { @@ -175,6 +299,27 @@ int32_t streamStateGetKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const void** return 0; } +int32_t streamStateGetGroupKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen) { + uint64_t groupId = pKey->groupId; + int32_t code = streamStateFillGetKVByCur(pCur, pKey, pVal, pVLen); + if (code == 0) { + if (pKey->groupId == groupId) { + return 0; + } + } + return -1; +} + +int32_t streamStateGetFirst(SStreamState* pState, SWinKey* key) { + // todo refactor + SWinKey tmp = {.ts = 0, .groupId = 0}; + streamStatePut(pState, &tmp, NULL, 0); + SStreamStateCur* pCur = streamStateSeekKeyNext(pState, &tmp); + int32_t code = streamStateGetKVByCur(pCur, key, NULL, 0); + streamStateDel(pState, &tmp); + return code; +} + int32_t streamStateSeekFirst(SStreamState* pState, SStreamStateCur* pCur) { // return tdbTbcMoveToFirst(pCur->pCur); @@ -190,11 +335,39 @@ SStreamStateCur* streamStateSeekKeyNext(SStreamState* pState, const SWinKey* key if (pCur == NULL) { return NULL; } + pCur->number = pState->number; if (tdbTbcOpen(pState->pStateDb, &pCur->pCur, NULL) < 0) { taosMemoryFree(pCur); return NULL; } + SStateKey sKey = {.key = *key, .opNum = pState->number}; + int32_t c; + if (tdbTbcMoveTo(pCur->pCur, &sKey, sizeof(SStateKey), &c) < 0) { + tdbTbcClose(pCur->pCur); + taosMemoryFree(pCur); + return NULL; + } + if (c > 0) return pCur; + + if (tdbTbcMoveToNext(pCur->pCur) < 0) { + taosMemoryFree(pCur); + return NULL; + } + + return pCur; +} + +SStreamStateCur* streamStateFillSeekKeyNext(SStreamState* pState, const SWinKey* key) { + SStreamStateCur* pCur = taosMemoryCalloc(1, sizeof(SStreamStateCur)); + if (pCur == NULL) { + return NULL; + } + if (tdbTbcOpen(pState->pFillStateDb, &pCur->pCur, NULL) < 0) { + taosMemoryFree(pCur); + return NULL; + } + int32_t c; if (tdbTbcMoveTo(pCur->pCur, key, sizeof(SWinKey), &c) < 0) { tdbTbcClose(pCur->pCur); @@ -211,12 +384,12 @@ SStreamStateCur* streamStateSeekKeyNext(SStreamState* pState, const SWinKey* key return pCur; } -SStreamStateCur* streamStateSeekKeyPrev(SStreamState* pState, const SWinKey* key) { +SStreamStateCur* streamStateFillSeekKeyPrev(SStreamState* pState, const SWinKey* key) { SStreamStateCur* pCur = taosMemoryCalloc(1, sizeof(SStreamStateCur)); if (pCur == NULL) { return NULL; } - if (tdbTbcOpen(pState->pStateDb, &pCur->pCur, NULL) < 0) { + if (tdbTbcOpen(pState->pFillStateDb, &pCur->pCur, NULL) < 0) { taosMemoryFree(pCur); return NULL; } @@ -244,9 +417,15 @@ int32_t streamStateCurNext(SStreamState* pState, SStreamStateCur* pCur) { int32_t streamStateCurPrev(SStreamState* pState, SStreamStateCur* pCur) { // + if (!pCur) { + return -1; + } return tdbTbcMoveToPrev(pCur->pCur); } void streamStateFreeCur(SStreamStateCur* pCur) { + if (!pCur) { + return; + } tdbTbcClose(pCur->pCur); taosMemoryFree(pCur); } diff --git a/source/libs/sync/inc/syncUtil.h b/source/libs/sync/inc/syncUtil.h index 7ecff7ae97..96e22720e8 100644 --- a/source/libs/sync/inc/syncUtil.h +++ b/source/libs/sync/inc/syncUtil.h @@ -32,7 +32,7 @@ uint64_t syncUtilAddr2U64(const char* host, uint16_t port); void syncUtilU642Addr(uint64_t u64, char* host, size_t len, uint16_t* port); void syncUtilnodeInfo2EpSet(const SNodeInfo* pNodeInfo, SEpSet* pEpSet); void syncUtilraftId2EpSet(const SRaftId* raftId, SEpSet* pEpSet); -void syncUtilnodeInfo2raftId(const SNodeInfo* pNodeInfo, SyncGroupId vgId, SRaftId* raftId); +bool syncUtilnodeInfo2raftId(const SNodeInfo* pNodeInfo, SyncGroupId vgId, SRaftId* raftId); bool syncUtilSameId(const SRaftId* pId1, const SRaftId* pId2); bool syncUtilEmptyId(const SRaftId* pId); diff --git a/source/libs/sync/src/syncIndexMgr.c b/source/libs/sync/src/syncIndexMgr.c index 3bda9bcd51..28b5313ac5 100644 --- a/source/libs/sync/src/syncIndexMgr.c +++ b/source/libs/sync/src/syncIndexMgr.c @@ -20,7 +20,10 @@ SSyncIndexMgr *syncIndexMgrCreate(SSyncNode *pSyncNode) { SSyncIndexMgr *pSyncIndexMgr = taosMemoryMalloc(sizeof(SSyncIndexMgr)); - ASSERT(pSyncIndexMgr != NULL); + if (pSyncIndexMgr == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } memset(pSyncIndexMgr, 0, sizeof(SSyncIndexMgr)); pSyncIndexMgr->replicas = &(pSyncNode->replicasId); @@ -248,4 +251,4 @@ SyncTerm syncIndexMgrGetTerm(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftI } ASSERT(0); return -1; -} \ No newline at end of file +} diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 17157fbd23..76fd345bdd 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -51,15 +51,17 @@ static int32_t syncNodeAppendNoop(SSyncNode* ths); int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg); int32_t syncNodeOnPingReplyCb(SSyncNode* ths, SyncPingReply* pMsg); -// life cycle -static void syncFreeNode(void* param); // --------------------------------- +static void syncNodeFreeCb(void *param) { + syncNodeClose(param); + param = NULL; +} int32_t syncInit() { int32_t ret = 0; if (!syncEnvIsStart()) { - tsNodeRefId = taosOpenRef(200, syncFreeNode); + tsNodeRefId = taosOpenRef(200, syncNodeFreeCb); if (tsNodeRefId < 0) { sError("failed to init node ref"); syncCleanUp(); @@ -86,11 +88,15 @@ void syncCleanUp() { int64_t syncOpen(const SSyncInfo* pSyncInfo) { SSyncNode* pSyncNode = syncNodeOpen(pSyncInfo); - ASSERT(pSyncNode != NULL); + if (pSyncNode == NULL) { + sError("failed to open sync node. vgId:%d", pSyncInfo->vgId); + return -1; + } pSyncNode->rid = taosAddRef(tsNodeRefId, pSyncNode); if (pSyncNode->rid < 0) { - syncFreeNode(pSyncNode); + syncNodeClose(pSyncNode); + pSyncNode = NULL; return -1; } @@ -136,11 +142,9 @@ void syncStartStandBy(int64_t rid) { void syncStop(int64_t rid) { SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid); if (pSyncNode == NULL) return; - int32_t vgId = pSyncNode->vgId; - syncNodeClose(pSyncNode); - taosReleaseRef(tsNodeRefId, pSyncNode->rid); + taosRemoveRef(tsNodeRefId, rid); sDebug("vgId:%d, sync rid:%" PRId64 " is removed from rsetId:%" PRId64, vgId, rid, tsNodeRefId); } @@ -210,7 +214,7 @@ int32_t syncReconfigBuild(int64_t rid, const SSyncCfg* pNewCfg, SRpcMsg* pRpcMsg if (!syncNodeCheckNewConfig(pSyncNode, pNewCfg)) { taosReleaseRef(tsNodeRefId, pSyncNode->rid); terrno = TSDB_CODE_SYN_NEW_CONFIG_ERROR; - sError("syncNodeCheckNewConfig error"); + sError("invalid new config. vgId:%d", pSyncNode->vgId); return -1; } @@ -237,7 +241,7 @@ int32_t syncReconfig(int64_t rid, const SSyncCfg* pNewCfg) { if (!syncNodeCheckNewConfig(pSyncNode, pNewCfg)) { taosReleaseRef(tsNodeRefId, pSyncNode->rid); terrno = TSDB_CODE_SYN_NEW_CONFIG_ERROR; - sError("syncNodeCheckNewConfig error"); + sError("invalid new config. vgId:%d", pSyncNode->vgId); return -1; } @@ -392,29 +396,6 @@ bool syncIsReady(int64_t rid) { return b; } -bool syncIsReadyForRead(int64_t rid) { - SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid); - if (pSyncNode == NULL) { - return false; - } - ASSERT(rid == pSyncNode->rid); - - // TODO: last not noop? - SyncIndex lastIndex = syncNodeGetLastIndex(pSyncNode); - bool b = (pSyncNode->state == TAOS_SYNC_STATE_LEADER) && (pSyncNode->commitIndex >= lastIndex - SYNC_MAX_READ_RANGE); - taosReleaseRef(tsNodeRefId, pSyncNode->rid); - - // if false, set error code - if (false == b) { - if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) { - terrno = TSDB_CODE_SYN_NOT_LEADER; - } else { - terrno = TSDB_CODE_APP_NOT_READY; - } - } - return b; -} - bool syncIsRestoreFinish(int64_t rid) { SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid); if (pSyncNode == NULL) { @@ -941,16 +922,18 @@ _END: SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { SSyncInfo* pSyncInfo = (SSyncInfo*)pOldSyncInfo; - SSyncNode* pSyncNode = (SSyncNode*)taosMemoryMalloc(sizeof(SSyncNode)); - ASSERT(pSyncNode != NULL); - memset(pSyncNode, 0, sizeof(SSyncNode)); + SSyncNode* pSyncNode = (SSyncNode*)taosMemoryCalloc(1, sizeof(SSyncNode)); + if (pSyncNode == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _error; + } int32_t ret = 0; if (!taosDirExist((char*)(pSyncInfo->path))) { if (taosMkDir(pSyncInfo->path) != 0) { terrno = TAOS_SYSTEM_ERROR(errno); sError("failed to create dir:%s since %s", pSyncInfo->path, terrstr()); - return NULL; + goto _error; } } @@ -963,15 +946,21 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { meta.lastConfigIndex = SYNC_INDEX_INVALID; meta.batchSize = pSyncInfo->batchSize; ret = raftCfgCreateFile((SSyncCfg*)&(pSyncInfo->syncCfg), meta, pSyncNode->configPath); - ASSERT(ret == 0); - + if (ret != 0) { + sError("failed to create raft cfg file. configPath: %s", pSyncNode->configPath); + goto _error; + } } else { // update syncCfg by raft_config.json pSyncNode->pRaftCfg = raftCfgOpen(pSyncNode->configPath); - ASSERT(pSyncNode->pRaftCfg != NULL); + if (pSyncNode->pRaftCfg == NULL) { + sError("failed to open raft cfg file. path:%s", pSyncNode->configPath); + goto _error; + } pSyncInfo->syncCfg = pSyncNode->pRaftCfg->cfg; raftCfgClose(pSyncNode->pRaftCfg); + pSyncNode->pRaftCfg = NULL; } // init by SSyncInfo @@ -988,11 +977,17 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { // init raft config pSyncNode->pRaftCfg = raftCfgOpen(pSyncNode->configPath); - ASSERT(pSyncNode->pRaftCfg != NULL); + if (pSyncNode->pRaftCfg == NULL) { + sError("failed to open raft cfg file. path:%s", pSyncNode->configPath); + goto _error; + } // init internal pSyncNode->myNodeInfo = pSyncNode->pRaftCfg->cfg.nodeInfo[pSyncNode->pRaftCfg->cfg.myIndex]; - syncUtilnodeInfo2raftId(&pSyncNode->myNodeInfo, pSyncNode->vgId, &pSyncNode->myRaftId); + if (!syncUtilnodeInfo2raftId(&pSyncNode->myNodeInfo, pSyncNode->vgId, &pSyncNode->myRaftId)) { + sError("failed to determine my raft member id. vgId:%d", pSyncNode->vgId); + goto _error; + } // init peersNum, peers, peersId pSyncNode->peersNum = pSyncNode->pRaftCfg->cfg.replicaNum - 1; @@ -1004,17 +999,24 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { } } for (int i = 0; i < pSyncNode->peersNum; ++i) { - syncUtilnodeInfo2raftId(&pSyncNode->peersNodeInfo[i], pSyncNode->vgId, &pSyncNode->peersId[i]); + if (!syncUtilnodeInfo2raftId(&pSyncNode->peersNodeInfo[i], pSyncNode->vgId, &pSyncNode->peersId[i])) { + sError("failed to determine raft member id. vgId:%d, peer:%d", pSyncNode->vgId, i); + goto _error; + } } // init replicaNum, replicasId pSyncNode->replicaNum = pSyncNode->pRaftCfg->cfg.replicaNum; for (int i = 0; i < pSyncNode->pRaftCfg->cfg.replicaNum; ++i) { - syncUtilnodeInfo2raftId(&pSyncNode->pRaftCfg->cfg.nodeInfo[i], pSyncNode->vgId, &pSyncNode->replicasId[i]); + if(!syncUtilnodeInfo2raftId(&pSyncNode->pRaftCfg->cfg.nodeInfo[i], pSyncNode->vgId, &pSyncNode->replicasId[i])) { + sError("failed to determine raft member id. vgId:%d, replica:%d", pSyncNode->vgId, i); + goto _error; + } } // init raft algorithm pSyncNode->pFsm = pSyncInfo->pFsm; + pSyncInfo->pFsm = NULL; pSyncNode->quorum = syncUtilQuorum(pSyncNode->pRaftCfg->cfg.replicaNum); pSyncNode->leaderCache = EMPTY_RAFT_ID; @@ -1047,29 +1049,50 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { // init TLA+ server vars pSyncNode->state = TAOS_SYNC_STATE_FOLLOWER; pSyncNode->pRaftStore = raftStoreOpen(pSyncNode->raftStorePath); - ASSERT(pSyncNode->pRaftStore != NULL); + if (pSyncNode->pRaftStore == NULL) { + sError("failed to open raft store. path: %s", pSyncNode->raftStorePath); + goto _error; + } // init TLA+ candidate vars pSyncNode->pVotesGranted = voteGrantedCreate(pSyncNode); - ASSERT(pSyncNode->pVotesGranted != NULL); + if (pSyncNode->pVotesGranted == NULL) { + sError("failed to create VotesGranted. vgId:%d", pSyncNode->vgId); + goto _error; + } pSyncNode->pVotesRespond = votesRespondCreate(pSyncNode); - ASSERT(pSyncNode->pVotesRespond != NULL); + if (pSyncNode->pVotesRespond == NULL) { + sError("failed to create VotesRespond. vgId:%d", pSyncNode->vgId); + goto _error; + } // init TLA+ leader vars pSyncNode->pNextIndex = syncIndexMgrCreate(pSyncNode); - ASSERT(pSyncNode->pNextIndex != NULL); + if (pSyncNode->pNextIndex == NULL) { + sError("failed to create SyncIndexMgr. vgId:%d", pSyncNode->vgId); + goto _error; + } pSyncNode->pMatchIndex = syncIndexMgrCreate(pSyncNode); - ASSERT(pSyncNode->pMatchIndex != NULL); + if (pSyncNode->pMatchIndex == NULL) { + sError("failed to create SyncIndexMgr. vgId:%d", pSyncNode->vgId); + goto _error; + } // init TLA+ log vars pSyncNode->pLogStore = logStoreCreate(pSyncNode); - ASSERT(pSyncNode->pLogStore != NULL); + if (pSyncNode->pLogStore == NULL) { + sError("failed to create SyncLogStore. vgId:%d", pSyncNode->vgId); + goto _error; + } SyncIndex commitIndex = SYNC_INDEX_INVALID; if (pSyncNode->pFsm != NULL && pSyncNode->pFsm->FpGetSnapshotInfo != NULL) { SSnapshot snapshot = {0}; int32_t code = pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); - ASSERT(code == 0); + if (code != 0) { + sError("failed to get snapshot info. vgId:%d, code:%d", pSyncNode->vgId, code); + goto _error; + } if (snapshot.lastApplyIndex > commitIndex) { commitIndex = snapshot.lastApplyIndex; syncNodeEventLog(pSyncNode, "reset commit index by snapshot"); @@ -1132,7 +1155,10 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { // tools pSyncNode->pSyncRespMgr = syncRespMgrCreate(pSyncNode, SYNC_RESP_TTL_MS); - ASSERT(pSyncNode->pSyncRespMgr != NULL); + if (pSyncNode->pSyncRespMgr == NULL) { + sError("failed to create SyncRespMgr. vgId:%d", pSyncNode->vgId); + goto _error; + } // restore state pSyncNode->restoreFinish = false; @@ -1162,6 +1188,15 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { syncNodeEventLog(pSyncNode, "sync open"); return pSyncNode; + +_error: + if (pSyncInfo->pFsm) { + taosMemoryFree(pSyncInfo->pFsm); + pSyncInfo->pFsm = NULL; + } + syncNodeClose(pSyncNode); + pSyncNode = NULL; + return NULL; } void syncNodeMaybeUpdateCommitBySnapshot(SSyncNode* pSyncNode) { @@ -1214,20 +1249,28 @@ void syncNodeStartStandBy(SSyncNode* pSyncNode) { void syncNodeClose(SSyncNode* pSyncNode) { syncNodeEventLog(pSyncNode, "sync close"); - + if (pSyncNode == NULL) { + return; + } int32_t ret; - ASSERT(pSyncNode != NULL); ret = raftStoreClose(pSyncNode->pRaftStore); ASSERT(ret == 0); syncRespMgrDestroy(pSyncNode->pSyncRespMgr); + pSyncNode->pSyncRespMgr = NULL; voteGrantedDestroy(pSyncNode->pVotesGranted); + pSyncNode->pVotesGranted = NULL; votesRespondDestory(pSyncNode->pVotesRespond); + pSyncNode->pVotesRespond = NULL; syncIndexMgrDestroy(pSyncNode->pNextIndex); + pSyncNode->pNextIndex = NULL; syncIndexMgrDestroy(pSyncNode->pMatchIndex); + pSyncNode->pMatchIndex = NULL; logStoreDestory(pSyncNode->pLogStore); + pSyncNode->pLogStore = NULL; raftCfgClose(pSyncNode->pRaftCfg); + pSyncNode->pRaftCfg = NULL; syncNodeStopPingTimer(pSyncNode); syncNodeStopElectTimer(pSyncNode); @@ -1249,8 +1292,7 @@ void syncNodeClose(SSyncNode* pSyncNode) { pSyncNode->pNewNodeReceiver = NULL; } - // free memory in syncFreeNode - // taosMemoryFree(pSyncNode); + taosMemoryFree(pSyncNode); } // option @@ -2534,7 +2576,7 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) { return; } } else { - sError("syncNodeEqHeartbeatTimer FpEqMsg is NULL"); + sError("vgId:%d, enqueue msg cb ptr (i.e. FpEqMsg) not set.", pSyncNode->vgId); } syncTimeoutDestroy(pSyncMsg); @@ -2774,14 +2816,6 @@ int32_t syncNodeOnClientRequestBatchCb(SSyncNode* ths, SyncClientRequestBatch* p return 0; } -static void syncFreeNode(void* param) { - SSyncNode* pNode = param; - // inner object already free - // syncNodePrint2((char*)"==syncFreeNode==", pNode); - - taosMemoryFree(pNode); -} - const char* syncStr(ESyncState state) { switch (state) { case TAOS_SYNC_STATE_FOLLOWER: @@ -2908,7 +2942,7 @@ static int32_t syncNodeConfigChangeFinish(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyn cbMeta.newCfgTerm = pFinish->newCfgTerm; cbMeta.newCfgSeqNum = pFinish->newCfgSeqNum; - ths->pFsm->FpReConfigCb(ths->pFsm, pRpcMsg, cbMeta); + ths->pFsm->FpReConfigCb(ths->pFsm, pRpcMsg, &cbMeta); } // clear changing diff --git a/source/libs/sync/src/syncRaftCfg.c b/source/libs/sync/src/syncRaftCfg.c index ab404d1b9a..57126d0871 100644 --- a/source/libs/sync/src/syncRaftCfg.c +++ b/source/libs/sync/src/syncRaftCfg.c @@ -364,8 +364,6 @@ int32_t raftCfgCreateFile(SSyncCfg *pCfg, SRaftCfgMeta meta, const char *path) { int32_t sysErr = errno; const char *sysErrStr = strerror(errno); sError("create raft cfg file error, err:%d %X, msg:%s, syserr:%d, sysmsg:%s", err, err, errStr, sysErr, sysErrStr); - ASSERT(0); - return -1; } diff --git a/source/libs/sync/src/syncRaftStore.c b/source/libs/sync/src/syncRaftStore.c index 9085873036..22b47a2c45 100644 --- a/source/libs/sync/src/syncRaftStore.c +++ b/source/libs/sync/src/syncRaftStore.c @@ -28,7 +28,7 @@ SRaftStore *raftStoreOpen(const char *path) { SRaftStore *pRaftStore = taosMemoryMalloc(sizeof(SRaftStore)); if (pRaftStore == NULL) { - sError("raftStoreOpen malloc error"); + terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } memset(pRaftStore, 0, sizeof(*pRaftStore)); @@ -46,7 +46,7 @@ SRaftStore *raftStoreOpen(const char *path) { ASSERT(pRaftStore->pFile != NULL); int len = taosReadFile(pRaftStore->pFile, storeBuf, RAFT_STORE_BLOCK_SIZE); - ASSERT(len == RAFT_STORE_BLOCK_SIZE); + ASSERT(len > 0); ret = raftStoreDeserialize(pRaftStore, storeBuf, len); ASSERT(ret == 0); @@ -72,7 +72,9 @@ static int32_t raftStoreInit(SRaftStore *pRaftStore) { } int32_t raftStoreClose(SRaftStore *pRaftStore) { - ASSERT(pRaftStore != NULL); + if (pRaftStore == NULL) { + return 0; + } taosCloseFile(&pRaftStore->pFile); taosMemoryFree(pRaftStore); diff --git a/source/libs/sync/src/syncRespMgr.c b/source/libs/sync/src/syncRespMgr.c index d7ed864180..103c225476 100644 --- a/source/libs/sync/src/syncRespMgr.c +++ b/source/libs/sync/src/syncRespMgr.c @@ -19,6 +19,10 @@ SSyncRespMgr *syncRespMgrCreate(void *data, int64_t ttl) { SSyncRespMgr *pObj = (SSyncRespMgr *)taosMemoryMalloc(sizeof(SSyncRespMgr)); + if (pObj == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } memset(pObj, 0, sizeof(SSyncRespMgr)); pObj->pRespHash = diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 0be3392a9a..68d81813ac 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -35,7 +35,10 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI SSyncSnapshotSender *pSender = NULL; if (condition) { pSender = taosMemoryMalloc(sizeof(SSyncSnapshotSender)); - ASSERT(pSender != NULL); + if (pSender == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } memset(pSender, 0, sizeof(*pSender)); pSender->start = false; diff --git a/source/libs/sync/src/syncUtil.c b/source/libs/sync/src/syncUtil.c index 15e94baee4..6f234631da 100644 --- a/source/libs/sync/src/syncUtil.c +++ b/source/libs/sync/src/syncUtil.c @@ -26,7 +26,8 @@ uint64_t syncUtilAddr2U64(const char* host, uint16_t port) { uint32_t hostU32 = taosGetIpv4FromFqdn(host); if (hostU32 == (uint32_t)-1) { - sError("Get IP address error"); + sError("failed to resolve ipv4 addr. host:%s", host); + terrno = TSDB_CODE_TSC_INVALID_FQDN; return -1; } @@ -57,7 +58,7 @@ void syncUtilU642Addr(uint64_t u64, char* host, size_t len, uint16_t* port) { struct in_addr addr; addr.s_addr = hostU32; - snprintf(host, len, "%s", taosInetNtoa(addr)); + taosInetNtoa(addr, host, len); *port = (uint16_t)((u64 & 0x00000000FFFF0000) >> 16); } @@ -84,13 +85,18 @@ void syncUtilraftId2EpSet(const SRaftId* raftId, SEpSet* pEpSet) { addEpIntoEpSet(pEpSet, host, port); } -void syncUtilnodeInfo2raftId(const SNodeInfo* pNodeInfo, SyncGroupId vgId, SRaftId* raftId) { +bool syncUtilnodeInfo2raftId(const SNodeInfo* pNodeInfo, SyncGroupId vgId, SRaftId* raftId) { uint32_t ipv4 = taosGetIpv4FromFqdn(pNodeInfo->nodeFqdn); - ASSERT(ipv4 != 0xFFFFFFFF); + if (ipv4 == 0xFFFFFFFF || ipv4 == 1) { + sError("failed to resolve ipv4 addr. fqdn: %s", pNodeInfo->nodeFqdn); + terrno = TSDB_CODE_TSC_INVALID_FQDN; + return false; + } char ipbuf[128] = {0}; tinet_ntoa(ipbuf, ipv4); raftId->addr = syncUtilAddr2U64(ipbuf, pNodeInfo->nodePort); raftId->vgId = vgId; + return true; } bool syncUtilSameId(const SRaftId* pId1, const SRaftId* pId2) { @@ -310,4 +316,4 @@ void syncUtilJson2Line(char* jsonStr) { q++; } } -} \ No newline at end of file +} diff --git a/source/libs/sync/src/syncVoteMgr.c b/source/libs/sync/src/syncVoteMgr.c index 1d46d71a05..641bb32d2d 100644 --- a/source/libs/sync/src/syncVoteMgr.c +++ b/source/libs/sync/src/syncVoteMgr.c @@ -24,7 +24,10 @@ static void voteGrantedClearVotes(SVotesGranted *pVotesGranted) { SVotesGranted *voteGrantedCreate(SSyncNode *pSyncNode) { SVotesGranted *pVotesGranted = taosMemoryMalloc(sizeof(SVotesGranted)); - ASSERT(pVotesGranted != NULL); + if (pVotesGranted == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } memset(pVotesGranted, 0, sizeof(SVotesGranted)); pVotesGranted->replicas = &(pSyncNode->replicasId); diff --git a/source/libs/sync/test/syncConfigChangeSnapshotTest.cpp b/source/libs/sync/test/syncConfigChangeSnapshotTest.cpp index 714d233984..fbfc4cda8e 100644 --- a/source/libs/sync/test/syncConfigChangeSnapshotTest.cpp +++ b/source/libs/sync/test/syncConfigChangeSnapshotTest.cpp @@ -149,9 +149,9 @@ int32_t SnapshotDoWrite(struct SSyncFSM* pFsm, void* pWriter, void* pBuf, int32_ void RestoreFinishCb(struct SSyncFSM* pFsm) { sTrace("==callback== ==RestoreFinishCb=="); } -void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta cbMeta) { +void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta *cbMeta) { sTrace("==callback== ==ReConfigCb== flag:0x%lX, index:%" PRId64 ", code:%d, currentTerm:%" PRIu64 ", term:%" PRIu64, - cbMeta.flag, cbMeta.index, cbMeta.code, cbMeta.currentTerm, cbMeta.term); + cbMeta->flag, cbMeta->index, cbMeta->code, cbMeta->currentTerm, cbMeta->term); } SSyncFSM* createFsm() { diff --git a/source/libs/sync/test/syncConfigChangeTest.cpp b/source/libs/sync/test/syncConfigChangeTest.cpp index ba3fc77650..cfab3b6ae3 100644 --- a/source/libs/sync/test/syncConfigChangeTest.cpp +++ b/source/libs/sync/test/syncConfigChangeTest.cpp @@ -80,9 +80,9 @@ int32_t GetSnapshotCb(struct SSyncFSM* pFsm, SSnapshot* pSnapshot) { void RestoreFinishCb(struct SSyncFSM* pFsm) { sTrace("==callback== ==RestoreFinishCb=="); } -void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta cbMeta) { +void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta *cbMeta) { sTrace("==callback== ==ReConfigCb== flag:0x%lX, index:%" PRId64 ", code:%d, currentTerm:%" PRIu64 ", term:%" PRIu64, - cbMeta.flag, cbMeta.index, cbMeta.code, cbMeta.currentTerm, cbMeta.term); + cbMeta->flag, cbMeta->index, cbMeta->code, cbMeta->currentTerm, cbMeta->term); } SSyncFSM* createFsm() { diff --git a/source/libs/sync/test/syncTestTool.cpp b/source/libs/sync/test/syncTestTool.cpp index 9e9769224f..e718d37376 100644 --- a/source/libs/sync/test/syncTestTool.cpp +++ b/source/libs/sync/test/syncTestTool.cpp @@ -153,11 +153,11 @@ int32_t SnapshotDoWrite(struct SSyncFSM* pFsm, void* pWriter, void* pBuf, int32_ void RestoreFinishCb(struct SSyncFSM* pFsm) { sTrace("==callback== ==RestoreFinishCb== pFsm:%p", pFsm); } -void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta cbMeta) { +void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta* cbMeta) { char* s = syncCfg2Str(&(cbMeta.newCfg)); sTrace("==callback== ==ReConfigCb== flag:0x%lX, index:%" PRId64 ", code:%d, currentTerm:%" PRIu64 ", term:%" PRIu64 ", newCfg:%s", - cbMeta.flag, cbMeta.index, cbMeta.code, cbMeta.currentTerm, cbMeta.term, s); + cbMeta->flag, cbMeta->index, cbMeta->code, cbMeta->currentTerm, cbMeta->term, s); taosMemoryFree(s); } diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index 5f3171ee0e..ae9f3155b4 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -193,7 +193,7 @@ bool transReadComplete(SConnBuffer* connBuf) { int transSetConnOption(uv_tcp_t* stream) { uv_tcp_nodelay(stream, 1); - int ret = uv_tcp_keepalive(stream, 5, 5); + int ret = uv_tcp_keepalive(stream, 5, 60); return ret; } diff --git a/source/os/src/osDir.c b/source/os/src/osDir.c index 418e86a40a..cf74525543 100644 --- a/source/os/src/osDir.c +++ b/source/os/src/osDir.c @@ -58,6 +58,24 @@ int wordexp(char *words, wordexp_t *pwordexp, int flags) { void wordfree(wordexp_t *pwordexp) {} +#elif defined(DARWIN) + +#include +#include +#include +#include +#include + +typedef struct dirent dirent; +typedef struct dirent TdDirEntry; + +typedef struct TdDir { + TdDirEntry dirEntry; + TdDirEntry dirEntry1; + TdDirEntryPtr dirEntryPtr; + DIR *pDir; +} TdDir; + #else #include @@ -343,7 +361,7 @@ char *taosDirName(char *name) { name[0] = 0; } return name; -#elif defined(_TD_DARWIN_64) +#else char *end = strrchr(name, '/'); if (end != NULL) { *end = '\0'; @@ -351,8 +369,6 @@ char *taosDirName(char *name) { name[0] = 0; } return name; -#else - return dirname(name); #endif } @@ -362,7 +378,9 @@ char *taosDirEntryBaseName(char *name) { _splitpath(name, NULL, NULL, Filename1, Ext1); return name + (strlen(name) - strlen(Filename1) - strlen(Ext1)); #else - return (char *)basename(name); + char *pPoint = strchr(name, '.'); + if (pPoint != NULL) pPoint = 0; + return name; #endif } @@ -386,6 +404,13 @@ TdDirPtr taosOpenDir(const char *dirname) { return NULL; } return pDir; +#elif defined(DARWIN) + DIR *pDir = opendir(dirname); + if (pDir == NULL) return NULL; + TdDirPtr dirPtr = (TdDirPtr)taosMemoryMalloc(sizeof(TdDir)); + dirPtr->dirEntryPtr = (TdDirEntryPtr)&(dirPtr->dirEntry1); + dirPtr->pDir = pDir; + return dirPtr; #else return (TdDirPtr)opendir(dirname); #endif @@ -400,6 +425,12 @@ TdDirEntryPtr taosReadDir(TdDirPtr pDir) { return NULL; } return (TdDirEntryPtr) & (pDir->dirEntry.findFileData); +#elif defined(DARWIN) + if (readdir_r(pDir->pDir, (dirent*)&(pDir->dirEntry), (dirent**)&(pDir->dirEntryPtr)) == 0) { + return pDir->dirEntryPtr; + } else { + return NULL; + } #else return (TdDirEntryPtr)readdir((DIR *)pDir); #endif @@ -436,6 +467,11 @@ int32_t taosCloseDir(TdDirPtr *ppDir) { taosMemoryFree(*ppDir); *ppDir = NULL; return 0; +#elif defined(DARWIN) + closedir((*ppDir)->pDir); + taosMemoryFree(*ppDir); + *ppDir = NULL; + return 0; #else closedir((DIR *)*ppDir); *ppDir = NULL; diff --git a/source/os/src/osSemaphore.c b/source/os/src/osSemaphore.c index 5baba5af1e..310804da8d 100644 --- a/source/os/src/osSemaphore.c +++ b/source/os/src/osSemaphore.c @@ -106,293 +106,8 @@ int32_t tsem_timewait(tsem_t* sem, int64_t nanosecs) { #elif defined(_TD_DARWIN_64) -/* - * darwin implementation - */ - #include -// #define SEM_USE_PTHREAD -// #define SEM_USE_POSIX -// #define SEM_USE_SEM - -// #ifdef SEM_USE_SEM -// #include -// #include -// #include -// #include - -// static TdThread sem_thread; -// static TdThreadOnce sem_once; -// static task_t sem_port; -// static volatile int sem_inited = 0; -// static semaphore_t sem_exit; - -// static void *sem_thread_routine(void *arg) { -// (void)arg; -// setThreadName("sem_thrd"); - -// sem_port = mach_task_self(); -// kern_return_t ret = semaphore_create(sem_port, &sem_exit, SYNC_POLICY_FIFO, 0); -// if (ret != KERN_SUCCESS) { -// fprintf(stderr, "==%s[%d]%s()==failed to create sem_exit\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__); -// sem_inited = -1; -// return NULL; -// } -// sem_inited = 1; -// semaphore_wait(sem_exit); -// return NULL; -// } - -// static void once_init(void) { -// int r = 0; -// r = taosThreadCreate(&sem_thread, NULL, sem_thread_routine, NULL); -// if (r) { -// fprintf(stderr, "==%s[%d]%s()==failed to create thread\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__); -// return; -// } -// while (sem_inited == 0) { -// ; -// } -// } -// #endif - -// struct tsem_s { -// #ifdef SEM_USE_PTHREAD -// TdThreadMutex lock; -// TdThreadCond cond; -// volatile int64_t val; -// #elif defined(SEM_USE_POSIX) -// size_t id; -// sem_t *sem; -// #elif defined(SEM_USE_SEM) -// semaphore_t sem; -// #else // SEM_USE_PTHREAD -// dispatch_semaphore_t sem; -// #endif // SEM_USE_PTHREAD - -// volatile unsigned int valid : 1; -// }; - -// int tsem_init(tsem_t *sem, int pshared, unsigned int value) { -// // fprintf(stderr, "==%s[%d]%s():[%p]==creating\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, sem); -// if (*sem) { -// fprintf(stderr, "==%s[%d]%s():[%p]==already initialized\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, -// sem); -// abort(); -// } -// struct tsem_s *p = (struct tsem_s *)taosMemoryCalloc(1, sizeof(*p)); -// if (!p) { -// fprintf(stderr, "==%s[%d]%s():[%p]==out of memory\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, sem); -// abort(); -// } - -// #ifdef SEM_USE_PTHREAD -// int r = taosThreadMutexInit(&p->lock, NULL); -// do { -// if (r) break; -// r = taosThreadCondInit(&p->cond, NULL); -// if (r) { -// taosThreadMutexDestroy(&p->lock); -// break; -// } -// p->val = value; -// } while (0); -// if (r) { -// fprintf(stderr, "==%s[%d]%s():[%p]==not created\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, sem); -// abort(); -// } -// #elif defined(SEM_USE_POSIX) -// static size_t tick = 0; -// do { -// size_t id = atomic_add_fetch_64(&tick, 1); -// if (id == SEM_VALUE_MAX) { -// atomic_store_64(&tick, 0); -// id = 0; -// } -// char name[NAME_MAX - 4]; -// snprintf(name, sizeof(name), "/t" PRId64, id); -// p->sem = sem_open(name, O_CREAT | O_EXCL, pshared, value); -// p->id = id; -// if (p->sem != SEM_FAILED) break; -// int e = errno; -// if (e == EEXIST) continue; -// if (e == EINTR) continue; -// fprintf(stderr, "==%s[%d]%s():[%p]==not created[%d]%s\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, -// sem, -// e, strerror(e)); -// abort(); -// } while (p->sem == SEM_FAILED); -// #elif defined(SEM_USE_SEM) -// taosThreadOnce(&sem_once, once_init); -// if (sem_inited != 1) { -// fprintf(stderr, "==%s[%d]%s():[%p]==internal resource init failed\n", taosDirEntryBaseName(__FILE__), __LINE__, -// __func__, sem); -// errno = ENOMEM; -// return -1; -// } -// kern_return_t ret = semaphore_create(sem_port, &p->sem, SYNC_POLICY_FIFO, value); -// if (ret != KERN_SUCCESS) { -// fprintf(stderr, "==%s[%d]%s():[%p]==semophore_create failed\n", taosDirEntryBaseName(__FILE__), __LINE__, -// __func__, -// sem); -// // we fail-fast here, because we have less-doc about semaphore_create for the moment -// abort(); -// } -// #else // SEM_USE_PTHREAD -// p->sem = dispatch_semaphore_create(value); -// if (p->sem == NULL) { -// fprintf(stderr, "==%s[%d]%s():[%p]==not created\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, sem); -// abort(); -// } -// #endif // SEM_USE_PTHREAD - -// p->valid = 1; - -// *sem = p; - -// return 0; -// } - -// int tsem_wait(tsem_t *sem) { -// if (!*sem) { -// fprintf(stderr, "==%s[%d]%s():[%p]==not initialized\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, sem); -// abort(); -// } -// struct tsem_s *p = *sem; -// if (!p->valid) { -// fprintf(stderr, "==%s[%d]%s():[%p]==already destroyed\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, -// sem); abort(); -// } -// #ifdef SEM_USE_PTHREAD -// if (taosThreadMutexLock(&p->lock)) { -// fprintf(stderr, "==%s[%d]%s():[%p]==internal logic error\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, -// sem); -// abort(); -// } -// p->val -= 1; -// if (p->val < 0) { -// if (taosThreadCondWait(&p->cond, &p->lock)) { -// fprintf(stderr, "==%s[%d]%s():[%p]==internal logic error\n", taosDirEntryBaseName(__FILE__), __LINE__, -// __func__, -// sem); -// abort(); -// } -// } -// if (taosThreadMutexUnlock(&p->lock)) { -// fprintf(stderr, "==%s[%d]%s():[%p]==internal logic error\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, -// sem); -// abort(); -// } -// return 0; -// #elif defined(SEM_USE_POSIX) -// return sem_wait(p->sem); -// #elif defined(SEM_USE_SEM) -// return semaphore_wait(p->sem); -// #else // SEM_USE_PTHREAD -// return dispatch_semaphore_wait(p->sem, DISPATCH_TIME_FOREVER); -// #endif // SEM_USE_PTHREAD -// } - -// int tsem_post(tsem_t *sem) { -// if (!*sem) { -// fprintf(stderr, "==%s[%d]%s():[%p]==not initialized\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, sem); -// abort(); -// } -// struct tsem_s *p = *sem; -// if (!p->valid) { -// fprintf(stderr, "==%s[%d]%s():[%p]==already destroyed\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, -// sem); abort(); -// } -// #ifdef SEM_USE_PTHREAD -// if (taosThreadMutexLock(&p->lock)) { -// fprintf(stderr, "==%s[%d]%s():[%p]==internal logic error\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, -// sem); -// abort(); -// } -// p->val += 1; -// if (p->val <= 0) { -// if (taosThreadCondSignal(&p->cond)) { -// fprintf(stderr, "==%s[%d]%s():[%p]==internal logic error\n", taosDirEntryBaseName(__FILE__), __LINE__, -// __func__, -// sem); -// abort(); -// } -// } -// if (taosThreadMutexUnlock(&p->lock)) { -// fprintf(stderr, "==%s[%d]%s():[%p]==internal logic error\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, -// sem); -// abort(); -// } -// return 0; -// #elif defined(SEM_USE_POSIX) -// return sem_post(p->sem); -// #elif defined(SEM_USE_SEM) -// return semaphore_signal(p->sem); -// #else // SEM_USE_PTHREAD -// return dispatch_semaphore_signal(p->sem); -// #endif // SEM_USE_PTHREAD -// } - -// int tsem_destroy(tsem_t *sem) { -// // fprintf(stderr, "==%s[%d]%s():[%p]==destroying\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, sem); -// if (!*sem) { -// // fprintf(stderr, "==%s[%d]%s():[%p]==not initialized\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, -// sem); -// // abort(); -// return 0; -// } -// struct tsem_s *p = *sem; -// if (!p->valid) { -// // fprintf(stderr, "==%s[%d]%s():[%p]==already destroyed\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, -// // sem); abort(); -// return 0; -// } -// #ifdef SEM_USE_PTHREAD -// if (taosThreadMutexLock(&p->lock)) { -// fprintf(stderr, "==%s[%d]%s():[%p]==internal logic error\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, -// sem); -// abort(); -// } -// p->valid = 0; -// if (taosThreadCondDestroy(&p->cond)) { -// fprintf(stderr, "==%s[%d]%s():[%p]==internal logic error\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, -// sem); -// abort(); -// } -// if (taosThreadMutexUnlock(&p->lock)) { -// fprintf(stderr, "==%s[%d]%s():[%p]==internal logic error\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, -// sem); -// abort(); -// } -// if (taosThreadMutexDestroy(&p->lock)) { -// fprintf(stderr, "==%s[%d]%s():[%p]==internal logic error\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, -// sem); -// abort(); -// } -// #elif defined(SEM_USE_POSIX) -// char name[NAME_MAX - 4]; -// snprintf(name, sizeof(name), "/t" PRId64, p->id); -// int r = sem_unlink(name); -// if (r) { -// int e = errno; -// fprintf(stderr, "==%s[%d]%s():[%p]==unlink failed[%d]%s\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, -// sem, -// e, strerror(e)); -// abort(); -// } -// #elif defined(SEM_USE_SEM) -// semaphore_destroy(sem_port, p->sem); -// #else // SEM_USE_PTHREAD -// #endif // SEM_USE_PTHREAD - -// p->valid = 0; -// taosMemoryFree(p); - -// *sem = NULL; -// return 0; -// } - int tsem_init(tsem_t *psem, int flags, unsigned int count) { *psem = dispatch_semaphore_create(count); if (*psem == NULL) return -1; @@ -401,8 +116,8 @@ int tsem_init(tsem_t *psem, int flags, unsigned int count) { int tsem_destroy(tsem_t *psem) { if (psem == NULL || *psem == NULL) return -1; - dispatch_release(*psem); - *psem = NULL; + // dispatch_release(*psem); + // *psem = NULL; return 0; } diff --git a/source/os/src/osSocket.c b/source/os/src/osSocket.c index f34032056c..b34d071773 100644 --- a/source/os/src/osSocket.c +++ b/source/os/src/osSocket.c @@ -312,14 +312,8 @@ uint32_t taosInetAddr(const char *ipAddr) { return inet_addr(ipAddr); #endif } -const char *taosInetNtoa(struct in_addr ipInt) { -#ifdef WINDOWS - // not thread safe, only for debug usage while print log - static char tmpDstStr[16]; - return inet_ntop(AF_INET, &ipInt, tmpDstStr, INET6_ADDRSTRLEN); -#else - return inet_ntoa(ipInt); -#endif +const char *taosInetNtoa(struct in_addr ipInt, char *dstStr, int32_t len) { + return inet_ntop(AF_INET, &ipInt, dstStr, len); } #ifndef SIGPIPE @@ -670,7 +664,7 @@ int taosGetLocalIp(const char *eth, char *ip) { return -1; } memcpy(&sin, &ifr.ifr_addr, sizeof(sin)); - snprintf(ip, 64, "%s", inet_ntoa(sin.sin_addr)); + taosInetNtoa(sin.sin_addr, ip, 64); taosCloseSocketNoCheck1(fd); #endif return 0; diff --git a/source/os/src/osString.c b/source/os/src/osString.c index db3aaa49a6..3619e95847 100644 --- a/source/os/src/osString.c +++ b/source/os/src/osString.c @@ -306,8 +306,6 @@ int32_t taosMbsToWchars(TdWchar *pWchars, const char *pStrs, int32_t size) { ret int32_t taosWcharToMb(char *pStr, TdWchar wchar) { return wctomb(pStr, wchar); } -int32_t taosWcharsToMbs(char *pStrs, TdWchar *pWchars, int32_t size) { return wcstombs(pStrs, pWchars, size); } - char *taosStrCaseStr(const char *str, const char *pattern) { size_t i; @@ -326,6 +324,9 @@ char *taosStrCaseStr(const char *str, const char *pattern) { int64_t taosStr2Int64(const char *str, char **pEnd, int32_t radix) { int64_t tmp = strtoll(str, pEnd, radix); +#ifdef DARWIN + if (errno == EINVAL) errno = 0; +#endif #ifdef TD_CHECK_STR_TO_INT_ERROR assert(errno != ERANGE); assert(errno != EINVAL); @@ -335,6 +336,9 @@ int64_t taosStr2Int64(const char *str, char **pEnd, int32_t radix) { uint64_t taosStr2UInt64(const char *str, char **pEnd, int32_t radix) { uint64_t tmp = strtoull(str, pEnd, radix); +#ifdef DARWIN + if (errno == EINVAL) errno = 0; +#endif #ifdef TD_CHECK_STR_TO_INT_ERROR assert(errno != ERANGE); assert(errno != EINVAL); @@ -344,6 +348,9 @@ uint64_t taosStr2UInt64(const char *str, char **pEnd, int32_t radix) { int32_t taosStr2Int32(const char *str, char **pEnd, int32_t radix) { int32_t tmp = strtol(str, pEnd, radix); +#ifdef DARWIN + if (errno == EINVAL) errno = 0; +#endif #ifdef TD_CHECK_STR_TO_INT_ERROR assert(errno != ERANGE); assert(errno != EINVAL); @@ -353,6 +360,9 @@ int32_t taosStr2Int32(const char *str, char **pEnd, int32_t radix) { uint32_t taosStr2UInt32(const char *str, char **pEnd, int32_t radix) { uint32_t tmp = strtol(str, pEnd, radix); +#ifdef DARWIN + if (errno == EINVAL) errno = 0; +#endif #ifdef TD_CHECK_STR_TO_INT_ERROR assert(errno != ERANGE); assert(errno != EINVAL); @@ -362,6 +372,9 @@ uint32_t taosStr2UInt32(const char *str, char **pEnd, int32_t radix) { int16_t taosStr2Int16(const char *str, char **pEnd, int32_t radix) { int32_t tmp = strtol(str, pEnd, radix); +#ifdef DARWIN + if (errno == EINVAL) errno = 0; +#endif #ifdef TD_CHECK_STR_TO_INT_ERROR assert(errno != ERANGE); assert(errno != EINVAL); @@ -373,6 +386,9 @@ int16_t taosStr2Int16(const char *str, char **pEnd, int32_t radix) { uint16_t taosStr2UInt16(const char *str, char **pEnd, int32_t radix) { uint32_t tmp = strtoul(str, pEnd, radix); +#ifdef DARWIN + if (errno == EINVAL) errno = 0; +#endif #ifdef TD_CHECK_STR_TO_INT_ERROR assert(errno != ERANGE); assert(errno != EINVAL); @@ -394,6 +410,9 @@ int8_t taosStr2Int8(const char *str, char **pEnd, int32_t radix) { uint8_t taosStr2UInt8(const char *str, char **pEnd, int32_t radix) { uint32_t tmp = strtoul(str, pEnd, radix); +#ifdef DARWIN + if (errno == EINVAL) errno = 0; +#endif #ifdef TD_CHECK_STR_TO_INT_ERROR assert(errno != ERANGE); assert(errno != EINVAL); diff --git a/source/os/src/osSysinfo.c b/source/os/src/osSysinfo.c index 6867c1373b..a57bd4ee63 100644 --- a/source/os/src/osSysinfo.c +++ b/source/os/src/osSysinfo.c @@ -143,8 +143,11 @@ static int32_t taosGetSysCpuInfo(SysCpuInfo *cpuInfo) { cpuInfo->user = CompareFileTime(&pre_userTime, &userTime); cpuInfo->nice = 0; } -#elif defined(_TD_DARWIN_64) - assert(0); +#elif defined(DARWIN) + cpuInfo->idle = 0; + cpuInfo->system = 0; + cpuInfo->user = 0; + cpuInfo->nice = 0; #else TdFilePtr pFile = taosOpenFile(tsSysCpuFile, TD_FILE_READ | TD_FILE_STREAM); if (pFile == NULL) { @@ -180,8 +183,11 @@ static int32_t taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) { cpuInfo->cutime = 0; cpuInfo->cstime = 0; } -#elif defined(_TD_DARWIN_64) - assert(0); +#elif defined(DARWIN) + cpuInfo->stime = 0; + cpuInfo->utime = 0; + cpuInfo->cutime = 0; + cpuInfo->cstime = 0; #else TdFilePtr pFile = taosOpenFile(tsProcCpuFile, TD_FILE_READ | TD_FILE_STREAM); if (pFile == NULL) { @@ -359,7 +365,7 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) { pCmd = taosOpenCmd("sysctl -n machdep.cpu.core_count"); if (pCmd == NULL) return code; memset(buf, 0, sizeof(buf)); - if (taosGetsCmd(pCmd, maxLen, cpuModel) > 0) { + if (taosGetsCmd(pCmd, sizeof(buf) - 1, buf) > 0) { code = 0; done |= 2; *numOfCores = atof(buf); diff --git a/source/os/src/osTimezone.c b/source/os/src/osTimezone.c index 2ce2033a00..34a09c3e6c 100644 --- a/source/os/src/osTimezone.c +++ b/source/os/src/osTimezone.c @@ -891,6 +891,7 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { time_t tx1 = taosGetTimestampSec(); struct tm tm1; taosLocalTime(&tx1, &tm1); + daylight = tm1.tm_isdst; /* * format example: diff --git a/source/util/src/tqueue.c b/source/util/src/tqueue.c index eb70002680..eb62e12a19 100644 --- a/source/util/src/tqueue.c +++ b/source/util/src/tqueue.c @@ -151,15 +151,15 @@ int64_t taosQueueMemorySize(STaosQueue *queue) { void *taosAllocateQitem(int32_t size, EQItype itype) { STaosQnode *pNode = taosMemoryCalloc(1, sizeof(STaosQnode) + size); - pNode->size = size; - pNode->itype = itype; - pNode->timestamp = taosGetTimestampUs(); - if (pNode == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } + pNode->size = size; + pNode->itype = itype; + pNode->timestamp = taosGetTimestampUs(); + if (itype == RPC_QITEM) { int64_t alloced = atomic_add_fetch_64(&tsRpcQueueMemoryUsed, size); if (alloced > tsRpcQueueMemoryAllowed) { diff --git a/source/util/src/tuuid.c b/source/util/src/tuuid.c index 7460ccbc82..d192b1229d 100644 --- a/source/util/src/tuuid.c +++ b/source/util/src/tuuid.c @@ -20,8 +20,8 @@ static int32_t tUUIDSerialNo = 0; int32_t tGenIdPI32(void) { if (tUUIDHashId == 0) { - char uid[64]; - int32_t code = taosGetSystemUUID(uid, tListLen(uid)); + char uid[65] = {0}; + int32_t code = taosGetSystemUUID(uid, sizeof(uid)); if (code != TSDB_CODE_SUCCESS) { terrno = TAOS_SYSTEM_ERROR(errno); } else { diff --git a/source/util/src/tworker.c b/source/util/src/tworker.c index 1f0731812c..d9ded20070 100644 --- a/source/util/src/tworker.c +++ b/source/util/src/tworker.c @@ -46,7 +46,7 @@ int32_t tQWorkerInit(SQWorkerPool *pool) { void tQWorkerCleanup(SQWorkerPool *pool) { for (int32_t i = 0; i < pool->max; ++i) { SQWorker *worker = pool->workers + i; - if (worker == NULL) continue; + // if (worker == NULL) continue; if (taosCheckPthreadValid(worker->thread)) { taosQsetThreadResume(pool->qset); } @@ -54,7 +54,7 @@ void tQWorkerCleanup(SQWorkerPool *pool) { for (int32_t i = 0; i < pool->max; ++i) { SQWorker *worker = pool->workers + i; - if (worker == NULL) continue; + // if (worker == NULL) continue; if (taosCheckPthreadValid(worker->thread)) { taosThreadJoin(worker->thread, NULL); taosThreadClear(&worker->thread); @@ -138,8 +138,8 @@ STaosQueue *tQWorkerAllocQueue(SQWorkerPool *pool, void *ahandle, FItem fp) { } void tQWorkerFreeQueue(SQWorkerPool *pool, STaosQueue *queue) { - taosCloseQueue(queue); uDebug("worker:%s, queue:%p is freed", pool->name, queue); + taosCloseQueue(queue); } int32_t tWWorkerInit(SWWorkerPool *pool) { @@ -283,8 +283,8 @@ STaosQueue *tWWorkerAllocQueue(SWWorkerPool *pool, void *ahandle, FItems fp) { } void tWWorkerFreeQueue(SWWorkerPool *pool, STaosQueue *queue) { - taosCloseQueue(queue); uDebug("worker:%s, queue:%p is freed", pool->name, queue); + taosCloseQueue(queue); } int32_t tSingleWorkerInit(SSingleWorker *pWorker, const SSingleWorkerCfg *pCfg) { diff --git a/tests/docs-examples-test/node.sh b/tests/docs-examples-test/node.sh index 0283904815..41acf7c7b4 100644 --- a/tests/docs-examples-test/node.sh +++ b/tests/docs-examples-test/node.sh @@ -23,7 +23,7 @@ node query_example.js node async_query_example.js -node subscribe_demo.js +# node subscribe_demo.js taos -s "drop topic if exists topic_name_example" taos -s "drop database if exists power" @@ -39,4 +39,4 @@ taos -s "drop database if exists test" node opentsdb_telnet_example.js taos -s "drop database if exists test" -node opentsdb_json_example.js \ No newline at end of file +node opentsdb_json_example.js diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index 89b7fe00eb..4bcbe190d5 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -415,23 +415,15 @@ class TDDnode: i += 1 if i > 50: break - tailCmdStr = 'tail -f ' - popen = subprocess.Popen( - tailCmdStr + logFile, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - shell=True) - pid = popen.pid - # print('Popen.pid:' + str(pid)) - timeout = time.time() + 60 * 2 - while True: - line = popen.stdout.readline().strip() - if bkey in line: - popen.kill() - break - if time.time() > timeout: - tdLog.exit('wait too long for taosd start') - tdLog.debug("the dnode:%d has been started." % (self.index)) + with open(logFile) as f: + timeout = time.time() + 60 * 2 + while True: + line = f.readline().encode('utf-8') + if bkey in line: + break + if time.time() > timeout: + tdLog.exit('wait too long for taosd start') + tdLog.debug("the dnode:%d has been started." % (self.index)) else: tdLog.debug( "wait 10 seconds for the dnode:%d to start." % @@ -480,19 +472,21 @@ class TDDnode: toBeKilled = "valgrind.bin" if self.running != 0: - psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs" % toBeKilled processID = subprocess.check_output( - psCmd, shell=True).decode("utf-8") + psCmd, shell=True).decode("utf-8").strip() onlyKillOnceWindows = 0 while(processID): if not platform.system().lower() == 'windows' or (onlyKillOnceWindows == 0 and platform.system().lower() == 'windows'): killCmd = "kill -INT %s > /dev/null 2>&1" % processID + if platform.system().lower() == 'windows': + killCmd = "kill -INT %s > nul 2>&1" % processID os.system(killCmd) onlyKillOnceWindows = 1 time.sleep(1) processID = subprocess.check_output( - psCmd, shell=True).decode("utf-8") + psCmd, shell=True).decode("utf-8").strip() if not platform.system().lower() == 'windows': for port in range(6030, 6041): fuserCmd = "fuser -k -n tcp %d > /dev/null" % port @@ -516,11 +510,11 @@ class TDDnode: if self.running != 0: if platform.system().lower() == 'windows': - psCmd = "for /f %%a in ('wmic process where \"name='taosd.exe' and CommandLine like '%%dnode%d%%'\" get processId ^| xargs echo ^| awk ^'{print $2}^' ^&^& echo aa') do @(ps | grep %%a | awk '{print $1}' )" % (self.index) + psCmd = "for /f %%a in ('wmic process where \"name='taosd.exe' and CommandLine like '%%dnode%d%%'\" get processId ^| xargs echo ^| awk ^'{print $2}^' ^&^& echo aa') do @(ps | grep %%a | awk '{print $1}' | xargs)" % (self.index) else: - psCmd = "ps -ef|grep -w %s| grep dnode%d|grep -v grep | awk '{print $2}'" % (toBeKilled,self.index) + psCmd = "ps -ef|grep -w %s| grep dnode%d|grep -v grep | awk '{print $2}' | xargs" % (toBeKilled,self.index) processID = subprocess.check_output( - psCmd, shell=True).decode("utf-8") + psCmd, shell=True).decode("utf-8").strip() onlyKillOnceWindows = 0 while(processID): @@ -530,7 +524,7 @@ class TDDnode: onlyKillOnceWindows = 1 time.sleep(1) processID = subprocess.check_output( - psCmd, shell=True).decode("utf-8") + psCmd, shell=True).decode("utf-8").strip() if self.valgrind: time.sleep(2) @@ -547,9 +541,9 @@ class TDDnode: toBeKilled = "valgrind.bin" if self.running != 0: - psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs" % toBeKilled processID = subprocess.check_output( - psCmd, shell=True).decode("utf-8") + psCmd, shell=True).decode("utf-8").strip() onlyKillOnceWindows = 0 while(processID): @@ -559,7 +553,7 @@ class TDDnode: onlyKillOnceWindows = 1 time.sleep(1) processID = subprocess.check_output( - psCmd, shell=True).decode("utf-8") + psCmd, shell=True).decode("utf-8").strip() for port in range(6030, 6041): fuserCmd = "fuser -k -n tcp %d" % port os.system(fuserCmd) @@ -704,15 +698,15 @@ class TDDnodes: for i in range(len(self.dnodes)): self.dnodes[i].stop() - psCmd = "ps -ef | grep -w taosd | grep 'root' | grep -v grep| grep -v defunct | awk '{print $2}'" - processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + psCmd = "ps -ef | grep -w taosd | grep 'root' | grep -v grep| grep -v defunct | awk '{print $2}' | xargs" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip() if processID: cmd = "sudo systemctl stop taosd" os.system(cmd) # if os.system(cmd) != 0 : # tdLog.exit(cmd) - psCmd = "ps -ef|grep -w taosd| grep -v grep| grep -v defunct | awk '{print $2}'" - processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + psCmd = "ps -ef|grep -w taosd| grep -v grep| grep -v defunct | awk '{print $2}' | xargs" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip() while(processID): if platform.system().lower() == 'windows': killCmd = "kill -9 %s > nul 2>&1" % processID @@ -721,11 +715,11 @@ class TDDnodes: os.system(killCmd) time.sleep(1) processID = subprocess.check_output( - psCmd, shell=True).decode("utf-8") + psCmd, shell=True).decode("utf-8").strip() if self.killValgrind == 1: - psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" - processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}' | xargs" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip() while(processID): if platform.system().lower() == 'windows': killCmd = "kill -TERM %s > nul 2>&1" % processID @@ -734,7 +728,7 @@ class TDDnodes: os.system(killCmd) time.sleep(1) processID = subprocess.check_output( - psCmd, shell=True).decode("utf-8") + psCmd, shell=True).decode("utf-8").strip() # if os.system(cmd) != 0 : # tdLog.exit(cmd) diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 161c878440..82f73a4fdd 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -303,7 +303,7 @@ ./test.sh -f tsim/insert/backquote.sim -m # unsupport ./test.sh -f tsim/parser/fourArithmetic-basic.sim -m ./test.sh -f tsim/query/interval-offset.sim -m -./test.sh -f tsim/tmq/basic3.sim -m +# unsupport ./test.sh -f tsim/tmq/basic3.sim -m ./test.sh -f tsim/stable/vnode3.sim -m ./test.sh -f tsim/qnode/basic1.sim -m # unsupport ./test.sh -f tsim/mnode/basic1.sim -m diff --git a/tests/script/tsim/stream/deleteInterval.sim b/tests/script/tsim/stream/deleteInterval.sim index 00d10afad9..7532b2d5de 100644 --- a/tests/script/tsim/stream/deleteInterval.sim +++ b/tests/script/tsim/stream/deleteInterval.sim @@ -413,13 +413,8 @@ if $data12 != 3 then goto loop14 endi -return 1 -sql drop stream if exists streams3; -sql drop database if exists test3; -sql drop database if exists test; sql create database test3 vgroups 4; -sql create database test vgroups 1; sql use test3; sql create stable st(ts timestamp, a int, b int, c int, d double) tags(ta int,tb int,tc int); sql create table t1 using st tags(1,1,1); @@ -435,7 +430,7 @@ sql delete from t1; loop15: sleep 200 -sql select * from test.streamt2 order by c1, c2, c3; +sql select * from test.streamt3 order by c1, c2, c3; $loop_count = $loop_count + 1 if $loop_count == 10 then @@ -453,7 +448,7 @@ sql delete from t1 where ts > 100; loop16: sleep 200 -sql select * from test.streamt2 order by c1, c2, c3; +sql select * from test.streamt3 order by c1, c2, c3; $loop_count = $loop_count + 1 if $loop_count == 10 then @@ -471,7 +466,7 @@ sql delete from st; loop17: sleep 200 -sql select * from test.streamt2 order by c1, c2, c3; +sql select * from test.streamt3 order by c1, c2, c3; $loop_count = $loop_count + 1 if $loop_count == 10 then diff --git a/tests/script/tsim/stream/distributeInterval0.sim b/tests/script/tsim/stream/distributeInterval0.sim index 9b2e940556..1d58922928 100644 --- a/tests/script/tsim/stream/distributeInterval0.sim +++ b/tests/script/tsim/stream/distributeInterval0.sim @@ -33,7 +33,8 @@ if $data(2)[4] != ready then endi print ===== step2 - +sql drop stream if exists stream_t1; +sql drop database if exists test; sql create database test vgroups 4; sql use test; sql create stable st(ts timestamp, a int, b int , c int, d double) tags(ta int,tb int,tc int); diff --git a/tests/script/tsim/stream/fillIntervalDelete0.sim b/tests/script/tsim/stream/fillIntervalDelete0.sim new file mode 100644 index 0000000000..77d09d5ae8 --- /dev/null +++ b/tests/script/tsim/stream/fillIntervalDelete0.sim @@ -0,0 +1,375 @@ +$loop_all = 0 +looptest: + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 200 +sql connect + +sql drop stream if exists streams1; +sql drop stream if exists streams2; +sql drop stream if exists streams3; +sql drop stream if exists streams4; +sql drop stream if exists streams5; +sql drop database if exists test1; +sql create database test1 vgroups 1; +sql use test1; +sql create table t1(ts timestamp, a int, b int , c int, d double, s varchar(20)); +sql create stream streams1 trigger at_once into streamt1 as select _wstart as ts, max(a), sum(b), count(*) from t1 where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(NULL); +sql create stream streams2 trigger at_once into streamt2 as select _wstart as ts, max(a), sum(b), count(*) from t1 where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(value,100,200,300); +sql create stream streams3 trigger at_once into streamt3 as select _wstart as ts, max(a), sum(b), count(*) from t1 where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(next); +sql create stream streams4 trigger at_once into streamt4 as select _wstart as ts, max(a), sum(b), count(*) from t1 where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(prev); +sql create stream streams5 trigger at_once into streamt5 as select _wstart as ts, max(a), sum(b), count(*) from t1 where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(linear); +sql insert into t1 values(1648791213000,1,1,1,1.0,'aaa'); +sleep 200 + +$loop_count = 0 + +loop0: +sleep 200 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamt1 order by ts; + +if $rows != 1 then + print =====rows=$rows + goto loop0 +endi + +sql delete from t1; + +$loop_count = 0 + +loop1: +sleep 200 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamt1 order by ts; + +if $rows != 0 then + print =====rows1=$rows + goto loop1 +endi + +sql select * from streamt2 order by ts; + +if $rows != 0 then + print =====rows2=$rows + goto loop1 +endi + +sql select * from streamt3 order by ts; + +if $rows != 0 then + print =====rows3=$rows + goto loop1 +endi + +sql select * from streamt4 order by ts; + +if $rows != 0 then + print =====rows4=$rows + goto loop1 +endi + +sql select * from streamt5 order by ts; + +if $rows != 0 then + print =====rows5=$rows + goto loop1 +endi + +sql insert into t1 values(1648791210000,4,4,4,4.0,'ddd'); +sql insert into t1 values(1648791215000,2,2,2,2.0,'bbb'); +sql insert into t1 values(1648791217000,3,3,3,3.0,'ccc'); +sql insert into t1 values(1648791219000,5,5,5,5.0,'eee'); + +$loop_count = 0 + +loop2: +sleep 200 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamt1 order by ts; + +if $rows != 10 then + print =====rows=$rows + goto loop2 +endi + +#temp +system sh/stop_dnodes.sh +return 1 + +sql delete from t1 where ts >= 1648791214000; + +$loop_count = 0 + +loop3: +sleep 200 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamt1 order by ts; + +if $rows != 1 then + print =====rows1=$rows + goto loop3 +endi + +sql select * from streamt2 order by ts; + +if $rows != 1 then + print =====rows2=$rows + goto loop3 +endi + +sql select * from streamt3 order by ts; + +if $rows != 1 then + print =====rows3=$rows + goto loop3 +endi + +sql select * from streamt4 order by ts; + +if $rows != 1 then + print =====rows4=$rows + goto loop3 +endi + +sql select * from streamt5 order by ts; + +if $rows != 1 then + print =====rows5=$rows + goto loop3 +endi + +if $data01 != 4 then + print =====data01=$data01 + return -1 +endi + + + +sql insert into t1 values(1648791213000,5,5,5,5.0,'eee'); +sql insert into t1 values(1648791215000,5,5,5,5.0,'eee'); +sql insert into t1 values(1648791219000,6,6,6,6.0,'fff'); + +$loop_count = 0 + +loop4: +sleep 200 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamt1 order by ts; + +if $rows != 4 then + print =====rows=$rows + goto loop4 +endi + + +sql delete from t1 where ts <= 1648791216000; + +$loop_count = 0 + +loop5: +sleep 200 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamt1 order by ts; + +if $rows != 1 then + print =====rows1=$rows + goto loop5 +endi + +sql select * from streamt2 order by ts; + +if $rows != 1 then + print =====rows2=$rows + goto loop5 +endi + +sql select * from streamt3 order by ts; + +if $rows != 1 then + print =====rows3=$rows + goto loop5 +endi + +sql select * from streamt4 order by ts; + +if $rows != 1 then + print =====rows4=$rows + goto loop5 +endi + +sql select * from streamt5 order by ts; + +if $rows != 1 then + print =====rows5=$rows + goto loop5 +endi + +if $data01 != 6 then + print =====data01=$data01 + return -1 +endi + + + + +sql drop stream if exists streams6; +sql drop stream if exists streams7; +sql drop stream if exists streams8; +sql drop stream if exists streams9; +sql drop stream if exists streams10; +sql drop database if exists test6; +sql create database test6 vgroups 1; +sql use test6; +sql create stable st(ts timestamp, a int, b int , c int, d double, s varchar(20)) tags(ta int,tb int,tc int); +sql create table t1 using st tags(1,1,1); +sql create table t2 using st tags(1,1,1); +sql create stream streams6 trigger at_once into streamt6 as select _wstart as ts, max(a), sum(b), count(*) from st where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(NULL); +sql create stream streams7 trigger at_once into streamt7 as select _wstart as ts, max(a), sum(b), count(*) from st where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(value,100,200,300); +sql create stream streams8 trigger at_once into streamt8 as select _wstart as ts, max(a), sum(b), count(*) from st where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(next); +sql create stream streams9 trigger at_once into streamt9 as select _wstart as ts, max(a), sum(b), count(*) from st where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(prev); +sql create stream streams10 trigger at_once into streamt10 as select _wstart as ts, max(a), sum(b), count(*) from st where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(linear); + +sql insert into t1 values(1648791210000,1,1,1,1.0,'aaa'); +sql insert into t1 values(1648791217000,1,1,1,1.0,'aaa'); + +sql insert into t2 values(1648791215000,1,1,1,1.0,'aaa'); + +sleep 200 + +$loop_count = 0 + +loop7: +sleep 200 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamt6 order by ts; + +if $rows != 8 then + print =====rows=$rows + goto loop7 +endi + +sql delete from t1; + +$loop_count = 0 + +loop8: +sleep 200 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamt6 order by ts; + +if $rows != 0 then + print =====rows6=$rows + goto loop8 +endi + +sql select * from streamt7 order by ts; + +if $rows != 0 then + print =====rows7=$rows + goto loop8 +endi + +sql select * from streamt8 order by ts; + +if $rows != 0 then + print =====rows8=$rows + goto loop8 +endi + +sql select * from streamt9 order by ts; + +if $rows != 0 then + print =====rows9=$rows + goto loop8 +endi + +sql select * from streamt10 order by ts; + +if $rows != 0 then + print =====rows10=$rows + goto loop8 +endi + + + + + + + + + + + + + + + + + + + + + +sql drop stream if exists streams0; +sql drop stream if exists streams1; +sql drop stream if exists streams2; +sql drop stream if exists streams3; +sql drop stream if exists streams4; +sql drop stream if exists streams5; +sql drop stream if exists streams6; +sql drop stream if exists streams7; +sql drop stream if exists streams8; + +sql use test1; +sql select * from t1; +print $data00 + +$loop_all = $loop_all + 1 +print ============loop_all=$loop_all + +system sh/stop_dnodes.sh + +#goto looptest \ No newline at end of file diff --git a/tests/script/tsim/stream/fillIntervalDelete1.sim b/tests/script/tsim/stream/fillIntervalDelete1.sim new file mode 100644 index 0000000000..8e6972975e --- /dev/null +++ b/tests/script/tsim/stream/fillIntervalDelete1.sim @@ -0,0 +1,379 @@ +$loop_all = 0 +looptest: + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 200 +sql connect + +sql drop stream if exists streams1; +sql drop stream if exists streams2; +sql drop stream if exists streams3; +sql drop stream if exists streams4; +sql drop stream if exists streams5; +sql drop database if exists test1; +sql create database test1 vgroups 1; +sql use test1; +sql create table t1(ts timestamp, a int, b int , c int, d double, s varchar(20)); +sql create stream streams1 trigger at_once into streamt1 as select _wstart as ts, max(a), sum(b), count(*) from t1 where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(NULL); +sql create stream streams2 trigger at_once into streamt2 as select _wstart as ts, max(a), sum(b), count(*) from t1 where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(value,100,200,300); +sql create stream streams3 trigger at_once into streamt3 as select _wstart as ts, max(a), sum(b), count(*) from t1 where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(next); +sql create stream streams4 trigger at_once into streamt4 as select _wstart as ts, max(a), sum(b), count(*) from t1 where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(prev); +sql create stream streams5 trigger at_once into streamt5 as select _wstart as ts, max(a), sum(b), count(*) from t1 where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(linear); + +sql insert into t1 values(1648791210000,0,0,0,0.0,'aaa'); +sql insert into t1 values(1648791213000,1,1,1,1.0,'bbb'); +sql insert into t1 values(1648791215000,5,5,5,5.0,'ccc'); +sql insert into t1 values(1648791217000,6,6,6,6.0,'ddd'); + +$loop_count = 0 + +loop0: +sleep 200 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamt1 order by ts; + +if $rows != 8 then + print =====rows=$rows + goto loop0 +endi + + +sql delete from t1 where ts = 1648791213000; + +$loop_count = 0 + +loop2: +sleep 200 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + + +sql select * from streamt1 order by ts; + +if $rows != 8 then + print ====streamt1=rows1=$rows + goto loop2 +endi +if $data31 != NULL then + print ====streamt1=data31=$data31 + goto loop2 +endi + +sql select * from streamt2 order by ts; + +if $rows != 8 then + print ====streamt2=rows2=$rows + goto loop2 +endi +if $data31 != 100 then + print ====streamt2=data31=$data31 + goto loop2 +endi + +sql select * from streamt3 order by ts; + +if $rows != 8 then + print ====streamt3=rows3=$rows + goto loop2 +endi +if $data31 != 5 then + print ====streamt3=data31=$data31 + goto loop2 +endi + +sql select * from streamt4 order by ts; + +if $rows != 8 then + print ====streamt4=rows4=$rows + goto loop2 +endi +if $data31 != 0 then + print ====streamt4=data31=$data31 + goto loop2 +endi + +sql select * from streamt5 order by ts; + +if $rows != 8 then + print ====streamt5=rows5=$rows + goto loop2 +endi +if $data31 != 3 then + print ====streamt5=data31=$data31 + goto loop2 +endi + + +sql insert into t1 values(1648791212000,5,5,5,5.0,'eee'); +sql insert into t1 values(1648791213000,6,6,6,6.0,'fff'); + +$loop_count = 0 + +loop3: +sleep 200 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamt1 order by ts; + +if $data21 != 5 then + print ====133=rows=$rows + goto loop3 +endi +if $data31 != 6 then + print ====137=rows=$rows + goto loop3 +endi + + +sql delete from t1 where ts >= 1648791211000 and ts <= 1648791214000; + +$loop_count = 0 + +loop4: +sleep 200 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamt1 order by ts; + +if $rows != 8 then + print ====streamt1=rows1=$rows + goto loop4 +endi +if $data31 != NULL then + print ====streamt1=data31=$data31 + goto loop4 +endi + +sql select * from streamt2 order by ts; + +if $rows != 8 then + print ====streamt2=rows2=$rows + goto loop4 +endi +if $data31 != 100 then + print ====streamt2=data31=$data31 + goto loop4 +endi + +sql select * from streamt3 order by ts; + +if $rows != 8 then + print ====streamt3=rows3=$rows + goto loop4 +endi +if $data31 != 5 then + print ====streamt3=data31=$data31 + goto loop4 +endi + +sql select * from streamt4 order by ts; + +if $rows != 8 then + print ====streamt4=rows4=$rows + goto loop4 +endi +if $data31 != 0 then + print ====streamt4=data31=$data31 + goto loop4 +endi + +sql select * from streamt5 order by ts; + +if $rows != 8 then + print ====streamt5=rows5=$rows + goto loop4 +endi +if $data31 != 3 then + print ====streamt5=data31=$data31 + goto loop4 +endi + + + +sql drop stream if exists streams6; +sql drop stream if exists streams7; +sql drop stream if exists streams8; +sql drop stream if exists streams9; +sql drop stream if exists streams10; +sql drop database if exists test6; +sql create database test6 vgroups 1; +sql use test6; +sql create stable st(ts timestamp, a int, b int , c int, d double, s varchar(20)) tags(ta int,tb int,tc int); +sql create table t1 using st tags(1,1,1); +sql create table t2 using st tags(1,1,1); +sql create stream streams6 trigger at_once into streamt6 as select _wstart as ts, max(a), sum(b), count(*) from st where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(NULL); +sql create stream streams7 trigger at_once into streamt7 as select _wstart as ts, max(a), sum(b), count(*) from st where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(value,100,200,300); +sql create stream streams8 trigger at_once into streamt8 as select _wstart as ts, max(a), sum(b), count(*) from st where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(next); +sql create stream streams9 trigger at_once into streamt9 as select _wstart as ts, max(a), sum(b), count(*) from st where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(prev); +sql create stream streams10 trigger at_once into streamt10 as select _wstart as ts, max(a), sum(b), count(*) from st where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(linear); + +sql insert into t1 values(1648791210000,1,1,1,1.0,'aaa'); +sql insert into t1 values(1648791215000,6,8,8,8.0,'bbb'); +sql insert into t1 values(1648791220000,11,10,10,10.0,'ccc'); +sql insert into t1 values(1648791221000,6,6,6,6.0,'fff'); + +sql insert into t2 values(1648791212000,4,4,4,4.0,'ddd'); +sql insert into t2 values(1648791214000,5,5,5,5.0,'eee'); +sql insert into t2 values(1648791216000,2,2,2,2.0,'bbb'); +sql insert into t2 values(1648791222000,6,6,6,6.0,'fff'); + +$loop_count = 0 + +loop5: +sleep 200 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamt6 order by ts; + +if $rows != 13 then + print ====streamt6=rows1=$rows + goto loop5 +endi +if $data21 != 4 then + print ====streamt6=data21=$data21 + goto loop5 +endi + +sql delete from t2; +print delete from t2; + +$loop_count = 0 + +loop6: + +sleep 200 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamt6 order by ts; + +if $rows != 12 then + print ====streamt6=rows2=$rows + goto loop6 +endi +if $data31 != NULL then + print ====streamt6=data31=$data31 + goto loop6 +endi + + +sql select * from streamt7 order by ts; + +if $rows != 12 then + print ====streamt7=rows2=$rows + goto loop6 +endi +if $data31 != 100 then + print ====streamt7=data31=$data31 + goto loop6 +endi + +sql select * from streamt8 order by ts; + +if $rows != 12 then + print ====streamt8=rows3=$rows + goto loop6 +endi +if $data31 != 6 then + print ====streamt8=data31=$data31 + goto loop6 +endi + +sql select * from streamt9 order by ts; + +if $rows != 12 then + print ====streamt9=rows4=$rows + goto loop6 +endi +if $data31 != 1 then + print ====streamt9=data31=$data31 + goto loop6 +endi + +sql select * from streamt10 order by ts; + +if $rows != 12 then + print ====streamt10=rows5=$rows + goto loop6 +endi +if $data21 != 3 then + print ====streamt10=data21=$data21 + return -1 +endi +if $data31 != 4 then + print ====streamt10=data31=$data31 + return -1 +endi +if $data71 != 8 then + print ====streamt10=data71=$data71 + return -1 +endi +if $data91 != 10 then + print ====streamt10=data91=$data91 + return -1 +endi + + + + + + + + + + + + + + + + + + +sql drop stream if exists streams0; +sql drop stream if exists streams1; +sql drop stream if exists streams2; +sql drop stream if exists streams3; +sql drop stream if exists streams4; +sql drop stream if exists streams5; +sql drop stream if exists streams6; +sql drop stream if exists streams7; +sql drop stream if exists streams8; +sql drop stream if exists streams9; +sql drop stream if exists streams10; + +sql use test1; +sql select * from t1; +print $data00 + +$loop_all = $loop_all + 1 +print ============loop_all=$loop_all + +system sh/stop_dnodes.sh + +#goto looptest \ No newline at end of file diff --git a/tests/script/tsim/stream/fillIntervalLinear.sim b/tests/script/tsim/stream/fillIntervalLinear.sim new file mode 100644 index 0000000000..46ff785fd3 --- /dev/null +++ b/tests/script/tsim/stream/fillIntervalLinear.sim @@ -0,0 +1,695 @@ +$loop_all = 0 +looptest: + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 200 +sql connect + +sql drop stream if exists streams1; +sql drop database if exists test1; +sql create database test1 vgroups 1; +sql use test1; +sql create table t1(ts timestamp, a int, b int , c int, d double, s varchar(20)); +sql create stream streams1 trigger at_once into streamt1 as select _wstart as ts, max(a)+sum(c), avg(b), first(s), count(*) from t1 where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(linear); +sql insert into t1 values(1648791213000,4,4,4,4.0,'aaa') (1648791216000,5,5,5,5.0,'bbb'); +sql insert into t1 values(1648791210000,1,1,1,1.0,'ccc') (1648791219000,2,2,2,2.0,'ddd') (1648791222000,3,3,3,3.0,'eee'); + + +$loop_count = 0 + +loop1: +sleep 200 +sql use test1; +sql select * from streamt1 order by ts; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 13 then + print =====rows=$rows + goto loop1 +endi + +if $data01 != 2.000000000 then + print =====data01=$data01 + return -1 +endi +if $data02 != 1.000000000 then + print =====data02=$data02 + return -1 +endi +if $data03 != ccc then + print =====data03=$data03 + return -1 +endi +if $data04 != 1 then + print =====data04=$data04 + return -1 +endi + + +if $data11 != 4.000000000 then + print =====data11=$data11 + return -1 +endi +if $data12 != 2.000000000 then + print =====data12=$data12 + return -1 +endi +if $data13 != NULL then + print =====data13=$data13 + return -1 +endi + + +if $data21 != 6.000000000 then + print =====data21=$data21 + return -1 +endi +if $data22 != 3.000000000 then + print =====data22=$data22 + return -1 +endi +if $data23 != NULL then + print =====data23=$data23 + return -1 +endi + + +if $data31 != 8.000000000 then + print =====data31=$data31 + return -1 +endi +if $data32 != 4.000000000 then + print =====data32=$data32 + return -1 +endi +if $data33 != aaa then + print =====data33=$data33 + return -1 +endi + + +if $data41 != 8.666666667 then + print =====data41=$data41 + return -1 +endi +if $data42 != 4.333333333 then + print =====data42=$data42 + return -1 +endi +if $data43 != NULL then + print =====data43=$data43 + return -1 +endi + + +if $data51 != 9.333333333 then + print =====data01=$data01 + return -1 +endi +if $data52 != 4.666666667 then + print =====data52=$data52 + return -1 +endi +if $data53 != NULL then + print =====data53=$data53 + return -1 +endi + + +if $data61 != 10.000000000 then + print =====data61=$data61 + return -1 +endi +if $data62 != 5.000000000 then + print =====data62=$data62 + return -1 +endi + + +if $data71 != 8.000000000 then + print =====data71=$data71 + return -1 +endi +if $data72 != 4.000000000 then + print =====data72=$data72 + return -1 +endi + + +if $data81 != 6.000000000 then + print =====data81=$data81 + return -1 +endi +if $data82 != 3.000000000 then + print =====data82=$data82 + return -1 +endi + + +if $data91 != 4.000000000 then + print =====data91=$data91 + return -1 +endi +if $data92 != 2.000000000 then + print =====data92=$data92 + return -1 +endi + +if $data[10][1] != 4.666666667 then + print =====data[10][1]=$data[10][1] + return -1 +endi +if $data[10][2] != 2.333333333 then + print =====data[10][2]=$data[10][2] + return -1 +endi + + +if $data[11][1] != 5.333333333 then + print =====data[11][1]=$data[11][1] + return -1 +endi +if $data[11][2] != 2.666666667 then + print =====data[11][2]=$data[11][2] + return -1 +endi + + +if $data[12][1] != 6.000000000 then + print =====data[12][1]=$data[12][1] + return -1 +endi +if $data[12][2] != 3.000000000 then + print =====data[12][2]=$data[12][2] + return -1 +endi + + + +sql drop stream if exists streams2; +sql drop database if exists test2; +sql create database test2 vgroups 1; +sql use test2; +sql create table t1(ts timestamp, a int, b int , c int, d double, s varchar(20)); +sql create stream streams2 trigger at_once into streamt2 as select _wstart as ts, max(a)+sum(c), avg(b), first(s), count(*) from t1 where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(linear); +sql insert into t1 values(1648791210000,1,1,1,1.0,'ccc') (1648791219000,2,2,2,2.0,'ddd') (1648791222000,3,3,3,3.0,'eee'); +sql insert into t1 values(1648791213000,4,4,4,4.0,'aaa') (1648791216000,5,5,5,5.0,'bbb'); + + +$loop_count = 0 + +loop2: + +sleep 200 + +sql select * from streamt2 order by ts; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 13 then + print =====rows=$rows + goto loop2 +endi + +if $data01 != 2.000000000 then + print =====data01=$data01 + return -1 +endi +if $data02 != 1.000000000 then + print =====data02=$data02 + return -1 +endi +if $data03 != ccc then + print =====data03=$data03 + return -1 +endi +if $data04 != 1 then + print =====data04=$data04 + return -1 +endi + + +if $data11 != 4.000000000 then + print =====data11=$data11 + return -1 +endi +if $data12 != 2.000000000 then + print =====data12=$data12 + return -1 +endi +if $data13 != NULL then + print =====data13=$data13 + return -1 +endi + + +if $data21 != 6.000000000 then + print =====data21=$data21 + return -1 +endi +if $data22 != 3.000000000 then + print =====data22=$data22 + return -1 +endi +if $data23 != NULL then + print =====data23=$data23 + return -1 +endi + + +if $data31 != 8.000000000 then + print =====data31=$data31 + return -1 +endi +if $data32 != 4.000000000 then + print =====data32=$data32 + return -1 +endi +if $data33 != aaa then + print =====data33=$data33 + return -1 +endi + + +if $data41 != 8.666666667 then + print =====data41=$data41 + return -1 +endi +if $data42 != 4.333333333 then + print =====data42=$data42 + return -1 +endi +if $data43 != NULL then + print =====data43=$data43 + return -1 +endi + + +if $data51 != 9.333333333 then + print =====data01=$data01 + return -1 +endi +if $data52 != 4.666666667 then + print =====data52=$data52 + return -1 +endi +if $data53 != NULL then + print =====data53=$data53 + return -1 +endi + + +if $data61 != 10.000000000 then + print =====data61=$data61 + return -1 +endi +if $data62 != 5.000000000 then + print =====data62=$data62 + return -1 +endi + + +if $data71 != 8.000000000 then + print =====data71=$data71 + return -1 +endi +if $data72 != 4.000000000 then + print =====data72=$data72 + return -1 +endi + + +if $data81 != 6.000000000 then + print =====data81=$data81 + return -1 +endi +if $data82 != 3.000000000 then + print =====data82=$data82 + return -1 +endi + + +if $data91 != 4.000000000 then + print =====data91=$data91 + return -1 +endi +if $data92 != 2.000000000 then + print =====data92=$data92 + return -1 +endi + +if $data[10][1] != 4.666666667 then + print =====data[10][1]=$data[10][1] + return -1 +endi +if $data[10][2] != 2.333333333 then + print =====data[10][2]=$data[10][2] + return -1 +endi + + +if $data[11][1] != 5.333333333 then + print =====data[11][1]=$data[11][1] + return -1 +endi +if $data[11][2] != 2.666666667 then + print =====data[11][2]=$data[11][2] + return -1 +endi + + +if $data[12][1] != 6.000000000 then + print =====data[12][1]=$data[12][1] + return -1 +endi +if $data[12][2] != 3.000000000 then + print =====data[12][2]=$data[12][2] + return -1 +endi + + + +sql drop stream if exists streams3; +sql drop database if exists test3; +sql create database test3 vgroups 1; +sql use test3; +sql create table t1(ts timestamp, a int, b int , c int, d double, s varchar(20)); +sql create stream streams3 trigger at_once into streamt3 as select _wstart as ts, max(a), b+c, s, b+1, 1 from t1 where ts >= 1648791150000 and ts < 1648791261000 interval(1s) fill(linear); +sql insert into t1 values(1648791215000,1,1,1,1.0,'aaa'); +sql insert into t1 values(1648791217000,2,2,2,2.0,'bbb'); +sql insert into t1 values(1648791211000,3,3,3,3.0,'ccc'); +sql insert into t1 values(1648791213000,4,4,4,4.0,'ddd'); + + +$loop_count = 0 + +loop3: +sleep 300 +sql select * from streamt3 order by ts; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + + +if $rows != 7 then + print =====rows=$rows + goto loop3 +endi + + +if $data01 != 3 then + print =====data01=$data01 + return -1 +endi +if $data02 != 6.000000000 then + print =====data02=$data02 + return -1 +endi +if $data03 != ccc then + print =====data03=$data03 + return -1 +endi + +if $data11 != 3 then + print =====data11=$data11 + return -1 +endi +if $data12 != 7.000000000 then + print =====data12=$data12 + return -1 +endi +if $data13 != NULL then + print =====data13=$data13 + return -1 +endi + + +if $data21 != 4 then + print =====data21=$data21 + return -1 +endi +if $data22 != 8.000000000 then + print =====data22=$data22 + return -1 +endi +if $data23 != ddd then + print =====data23=$data23 + return -1 +endi + + +if $data31 != 2 then + print =====data31=$data31 + return -1 +endi +if $data32 != 5.000000000 then + print =====data32=$data32 + return -1 +endi +if $data33 != NULL then + print =====data33=$data33 + return -1 +endi + + +if $data41 != 1 then + print =====data41=$data41 + return -1 +endi +if $data42 != 2.000000000 then + print =====data42=$data42 + return -1 +endi +if $data43 != aaa then + print =====data43=$data43 + return -1 +endi + + +if $data51 != 1 then + print =====data51=$data51 + return -1 +endi +if $data52 != 3.000000000 then + print =====data52=$data52 + return -1 +endi +if $data53 != NULL then + print =====data53=$data53 + return -1 +endi + + +if $data61 != 2 then + print =====data61=$data61 + return -1 +endi +if $data62 != 4.000000000 then + print =====data62=$data62 + return -1 +endi +if $data63 != bbb then + print =====data63=$data63 + return -1 +endi + + +sql insert into t1 values(1648791212000,5,5,5,5.0,'eee'); +sql insert into t1 values(1648791207000,6,6,6,6.0,'fff') (1648791209000,7,7,7,7.0,'ggg') (1648791219000,8,8,8,8.0,'hhh') (1648791221000,9,9,9,9.0,'iii'); + + + +$loop_count = 0 + +loop4: + +sleep 200 + +sql select * from test3.streamt3 order by ts; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + + +if $rows != 15 then + print =====rows=$rows + goto loop4 +endi + + +if $data01 != 6 then + print =====data01=$data01 + return -1 +endi +if $data02 != 12.000000000 then + print =====data02=$data02 + return -1 +endi +if $data03 != fff then + print =====data03=$data03 + return -1 +endi + +if $data11 != 6 then + print =====data11=$data11 + return -1 +endi +if $data12 != 13.000000000 then + print =====data12=$data12 + return -1 +endi +if $data13 != NULL then + print =====data13=$data13 + return -1 +endi + + +if $data21 != 7 then + print =====data21=$data21 + return -1 +endi +if $data22 != 14.000000000 then + print =====data22=$data22 + return -1 +endi +if $data23 != ggg then + print =====data23=$data23 + return -1 +endi + + +if $data31 != 5 then + print =====data31=$data31 + return -1 +endi +if $data32 != 10.000000000 then + print =====data32=$data32 + return -1 +endi +if $data33 != NULL then + print =====data33=$data33 + return -1 +endi + +if $data51 != 5 then + print =====data51=$data51 + return -1 +endi +if $data52 != 10.000000000 then + print =====data52=$data52 + return -1 +endi +if $data53 != eee then + print =====data53=$data53 + return -1 +endi + + +if $data[11][1] != 5 then + print =====data[11][1]=$data[11][1] + return -1 +endi +if $data[11][2] != 10.000000000 then + print =====data[11][2]=$data[11][2] + return -1 +endi +if $data[11][3] != NULL then + print =====data[11][3]=$data[11][3] + return -1 +endi + +if $data[12][1] != 8 then + print =====data[12][1]=$data[12][1] + return -1 +endi +if $data[12][2] != 16.000000000 then + print =====data[12][2]=$data[12][2] + return -1 +endi +if $data[12][3] != hhh then + print =====data[12][3]=$data[12][3] + return -1 +endi + +if $data[13][1] != 8 then + print =====data[13][1]=$data[13][1] + return -1 +endi +if $data[13][2] != 17.000000000 then + print =====data[13][2]=$data[13][2] + return -1 +endi +if $data[13][3] != NULL then + print =====data[13][3]=$data[13][3] + return -1 +endi + +if $data[14][1] != 9 then + print =====data[14][1]=$data[14][1] + return -1 +endi +if $data[14][2] != 18.000000000 then + print =====data[14][2]=$data[14][2] + return -1 +endi +if $data[14][3] != iii then + print =====data[14][3]=$data[14][3] + return -1 +endi + + + + + + + + + + + + + + + + + + + + + + + + +sql drop stream if exists streams0; +sql drop stream if exists streams1; +sql drop stream if exists streams2; +sql drop stream if exists streams3; +sql drop stream if exists streams4; +sql drop stream if exists streams5; +sql drop stream if exists streams6; +sql drop stream if exists streams7; +sql drop stream if exists streams8; + +sql use test1; +sql select * from t1; +print $data00 + +$loop_all = $loop_all + 1 +print ============loop_all=$loop_all + +system sh/stop_dnodes.sh + +#goto looptest \ No newline at end of file diff --git a/tests/script/tsim/stream/fillIntervalPartitionBy.sim b/tests/script/tsim/stream/fillIntervalPartitionBy.sim new file mode 100644 index 0000000000..384aa2c8e4 --- /dev/null +++ b/tests/script/tsim/stream/fillIntervalPartitionBy.sim @@ -0,0 +1,171 @@ +$loop_all = 0 +looptest: + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 200 +sql connect + +sql drop stream if exists streams1; +sql drop stream if exists streams2; +sql drop stream if exists streams3; +sql drop stream if exists streams4; +sql drop stream if exists streams5; +sql drop database if exists test1; +sql create database test1 vgroups 1; +sql use test1; +sql create stable st(ts timestamp, a int, b int , c int, d double, s varchar(20)) tags(ta int,tb int,tc int); +sql create table t1 using st tags(1,1,1); +sql create table t2 using st tags(2,2,2); +sql create stream streams1 trigger at_once into streamt1 as select _wstart as ts, max(a) c1, sum(b), count(*) from st where ts >= 1648791210000 and ts < 1648791261000 partition by ta interval(1s) fill(NULL); +sql create stream streams2 trigger at_once into streamt2 as select _wstart as ts, max(a) c1, sum(b), count(*) from st where ts >= 1648791210000 and ts < 1648791261000 partition by ta interval(1s) fill(value,100,200,300); +sql create stream streams3 trigger at_once into streamt3 as select _wstart as ts, max(a) c1, sum(b), count(*) from st where ts >= 1648791210000 and ts < 1648791261000 partition by ta interval(1s) fill(next); +sql create stream streams4 trigger at_once into streamt4 as select _wstart as ts, max(a) c1, sum(b), count(*) from st where ts >= 1648791210000 and ts < 1648791261000 partition by ta interval(1s) fill(prev); +sql create stream streams5 trigger at_once into streamt5 as select _wstart as ts, max(a) c1, sum(b), count(*) from st where ts >= 1648791210000 and ts < 1648791261000 partition by ta interval(1s) fill(linear); + +sql insert into t1 values(1648791210000,0,0,0,0.0,'aaa'); +sql insert into t1 values(1648791213000,1,1,1,1.0,'bbb'); +sql insert into t1 values(1648791215000,5,5,5,5.0,'ccc'); +sql insert into t1 values(1648791216000,6,6,6,6.0,'ddd'); +sql insert into t2 values(1648791210000,7,0,0,0.0,'aaa'); +sql insert into t2 values(1648791213000,8,1,1,1.0,'bbb'); +sql insert into t2 values(1648791215000,9,5,5,5.0,'ccc'); +sql insert into t2 values(1648791216000,10,6,6,6.0,'ddd'); + +$loop_count = 0 + +loop2: +sleep 200 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + + +sql select * from streamt1 order by group_id, ts; + +if $rows != 14 then + print ====streamt1=rows1=$rows + goto loop2 +endi + +sql select * from streamt2 order by group_id, ts; + +if $rows != 14 then + print ====streamt2=rows2=$rows + goto loop2 +endi + +sql select * from streamt3 order by group_id, ts; + +if $rows != 14 then + print ====streamt3=rows3=$rows + goto loop2 +endi + +sql select * from streamt4 order by group_id, ts; + +if $rows != 14 then + print ====streamt4=rows4=$rows + goto loop2 +endi + +sql select * from streamt5 order by group_id, ts; + +if $rows != 14 then + print ====streamt5=rows5=$rows + goto loop2 +endi + +sql delete from t1 where ts = 1648791216000; +print ======delete from t1 where ts = 1648791216000; + +$loop_count = 0 + +loop3: +sleep 200 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamt1 order by group_id, ts; + +if $rows != 13 then + print ====streamt1=rows1=$rows + goto loop3 +endi + +sql select * from streamt2 order by group_id, ts; + +if $rows != 13 then + print ====streamt2=rows2=$rows + goto loop3 +endi + +sql select * from streamt3 order by group_id, ts; + +if $rows != 13 then + print ====streamt3=rows3=$rows + goto loop3 +endi + +sql select * from streamt4 order by group_id, ts; + +if $rows != 13 then + print ====streamt4=rows4=$rows + goto loop3 +endi + +sql select * from streamt5 order by group_id, ts; + +if $rows != 13 then + print ====streamt5=rows5=$rows + goto loop3 +endi + + + + + + + + + + + + + + + + + + + + + +sql drop stream if exists streams0; +sql drop stream if exists streams1; +sql drop stream if exists streams2; +sql drop stream if exists streams3; +sql drop stream if exists streams4; +sql drop stream if exists streams5; +sql drop stream if exists streams6; +sql drop stream if exists streams7; +sql drop stream if exists streams8; +sql drop stream if exists streams9; +sql drop stream if exists streams10; + +sql use test1; +sql select * from t1; +print $data00 + +$loop_all = $loop_all + 1 +print ============loop_all=$loop_all + +system sh/stop_dnodes.sh + +#goto looptest \ No newline at end of file diff --git a/tests/script/tsim/stream/fillIntervalPrevNext.sim b/tests/script/tsim/stream/fillIntervalPrevNext.sim new file mode 100644 index 0000000000..5eab5fdac1 --- /dev/null +++ b/tests/script/tsim/stream/fillIntervalPrevNext.sim @@ -0,0 +1,1036 @@ +$loop_all = 0 +looptest: + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 200 +sql connect + +sql drop stream if exists streams1; +sql drop stream if exists streams2; +sql drop database if exists test1; +sql create database test1 vgroups 1; +sql use test1; +sql create table t1(ts timestamp, a int, b int , c int, d double, s varchar(20)); +sql create stream streams1 trigger at_once into streamt1 as select _wstart as ts, count(*) c1, max(b)+sum(a) from t1 where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(prev); +sql create stream streams2 trigger at_once into streamt2 as select _wstart as ts, count(*) c1, max(a)+min(c), avg(b) from t1 where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(next); +sql insert into t1 values(1648791213000,4,4,4,4.0,'aaa') (1648791215000,5,5,5,5.0,'aaa'); +sql insert into t1 values(1648791211000,1,1,1,1.0,'aaa') (1648791217000,2,2,2,2.0,'aaa') (1648791220000,3,3,3,3.0,'aaa'); + + +$loop_count = 0 + +loop1: +sleep 200 +sql use test1; +sql select * from streamt1 order by ts; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 10 then + print =====rows=$rows + goto loop1 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop1 +endi + +if $data02 != 2.000000000 then + print =====data02=$data02 + goto loop1 +endi + + +if $data11 != 1 then + print =====data11=$data11 + goto loop1 +endi + +if $data12 != 2.000000000 then + print =====data12=$data12 + goto loop1 +endi + + +if $data21 != 1 then + print =====data21=$data21 + goto loop1 +endi + +if $data22 != 8.000000000 then + print =====data22=$data22 + goto loop1 +endi + + +if $data31 != 1 then + print =====data31=$data31 + goto loop1 +endi + +if $data32 != 8.000000000 then + print =====data32=$data32 + goto loop1 +endi + + +if $data41 != 1 then + print =====data41=$data41 + goto loop1 +endi + +if $data42 != 10.000000000 then + print =====data42=$data42 + goto loop1 +endi + + +if $data51 != 1 then + print =====data01=$data01 + goto loop1 +endi + +if $data52 != 10.000000000 then + print =====data52=$data52 + goto loop1 +endi + + +if $data61 != 1 then + print =====data61=$data61 + goto loop1 +endi + +if $data62 != 4.000000000 then + print =====data62=$data62 + goto loop1 +endi + + +if $data71 != 1 then + print =====data71=$data71 + goto loop1 +endi + +if $data72 != 4.000000000 then + print =====data72=$data72 + goto loop1 +endi + + +if $data81 != 1 then + print =====data81=$data81 + goto loop1 +endi + +if $data82 != 4.000000000 then + print =====data82=$data82 + goto loop1 +endi + + +if $data91 != 1 then + print =====data91=$data91 + goto loop1 +endi + +if $data92 != 6.000000000 then + print =====data92=$data92 + goto loop1 +endi + +sql use test1; +sql select * from streamt2 order by ts; + +print next----------------------151 + +if $rows != 10 then + print =====rows=$rows + goto loop1 +endi + +if $data02 != 2.000000000 then + print =====data02=$data02 + goto loop1 +endi +if $data03 != 1.000000000 then + print =====data03=$data03 + goto loop1 +endi + +if $data12 != 8.000000000 then + print =====data12=$data12 + goto loop1 +endi +if $data13 != 4.000000000 then + print =====data13=$data13 + goto loop1 +endi + + +if $data22 != 8.000000000 then + print =====data22=$data22 + goto loop1 +endi +if $data23 != 4.000000000 then + print =====data23=$data23 + goto loop1 +endi + + +if $data32 != 10.000000000 then + print =====data32=$data32 + goto loop1 +endi +if $data33 != 5.000000000 then + print =====data33=$data33 + goto loop1 +endi + + +if $data42 != 10.000000000 then + print =====data42=$data42 + goto loop1 +endi +if $data43 != 5.000000000 then + print =====data43=$data43 + goto loop1 +endi + + +if $data52 != 4.000000000 then + print =====data52=$data52 + goto loop1 +endi +if $data53 != 2.000000000 then + print =====data53=$data53 + goto loop1 +endi + + +if $data62 != 4.000000000 then + print =====data62=$data62 + goto loop1 +endi +if $data63 != 2.000000000 then + print =====data63=$data63 + goto loop1 +endi + + +if $data72 != 6.000000000 then + print =====data72=$data72 + return -1 +endi +if $data73 != 3.000000000 then + print =====data73=$data73 + return -1 +endi + + +if $data82 != 6.000000000 then + print =====data82=$data82 + return -1 +endi +if $data83 != 3.000000000 then + print =====data83=$data83 + return -1 +endi + + +if $data92 != 6.000000000 then + print =====data92=$data92 + return -1 +endi +if $data93 != 3.000000000 then + print =====data93=$data93 + return -1 +endi + + + +sql drop stream if exists streams5; +sql drop stream if exists streams6; +sql drop database if exists test5; +sql create database test5 vgroups 1; +sql use test5; +sql create table t1(ts timestamp, a int, b int , c int, d double, s varchar(20)); +sql create stream streams5 trigger at_once into streamt5 as select _wstart as ts, count(*) c1, max(b)+sum(a) from t1 where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(prev); +sql create stream streams6 trigger at_once into streamt6 as select _wstart as ts, count(*) c1, max(a)+min(c), avg(b) from t1 where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(next); +sql insert into t1 values(1648791211000,1,1,1,1.0,'aaa') (1648791217000,2,2,2,2.0,'aaa') (1648791220000,3,3,3,3.0,'aaa'); +sql insert into t1 values(1648791213000,4,4,4,4.0,'aaa') (1648791215000,5,5,5,5.0,'aaa'); + +$loop_count = 0 + +loop5: +sleep 200 +sql select * from streamt5 order by ts; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 10 then + print =====rows=$rows + goto loop5 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop5 +endi + +if $data02 != 2.000000000 then + print =====data02=$data02 + goto loop5 +endi + + +if $data11 != 1 then + print =====data11=$data11 + goto loop5 +endi + +if $data12 != 2.000000000 then + print =====data12=$data12 + goto loop5 +endi + + +if $data21 != 1 then + print =====data21=$data21 + goto loop5 +endi + +if $data22 != 8.000000000 then + print =====data22=$data22 + goto loop5 +endi + + +if $data31 != 1 then + print =====data31=$data31 + goto loop5 +endi + +if $data32 != 8.000000000 then + print =====data32=$data32 + goto loop5 +endi + + +if $data41 != 1 then + print =====data41=$data41 + goto loop5 +endi + +if $data42 != 10.000000000 then + print =====data42=$data42 + goto loop5 +endi + + +if $data51 != 1 then + print =====data01=$data01 + goto loop5 +endi + +if $data52 != 10.000000000 then + print =====data52=$data52 + goto loop5 +endi + + +if $data61 != 1 then + print =====data61=$data61 + goto loop5 +endi + +if $data62 != 4.000000000 then + print =====data62=$data62 + goto loop5 +endi + + +if $data71 != 1 then + print =====data71=$data71 + goto loop5 +endi + +if $data72 != 4.000000000 then + print =====data72=$data72 + goto loop5 +endi + + +if $data81 != 1 then + print =====data81=$data81 + goto loop5 +endi + +if $data82 != 4.000000000 then + print =====data82=$data82 + goto loop5 +endi + + +if $data91 != 1 then + print =====data91=$data91 + goto loop5 +endi + +if $data92 != 6.000000000 then + print =====data92=$data92 + goto loop5 +endi + + +$loop_count = 0 + +loop6: + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sleep 200 + +sql select * from streamt6 order by ts; + +if $rows != 10 then + print =====rows=$rows + goto loop6 +endi + +if $data02 != 2.000000000 then + print =====data02=$data02 + goto loop6 +endi +if $data03 != 1.000000000 then + print =====data03=$data03 + goto loop6 +endi + +if $data12 != 8.000000000 then + print =====data12=$data12 + goto loop6 +endi +if $data13 != 4.000000000 then + print =====data13=$data13 + goto loop6 +endi + + +if $data22 != 8.000000000 then + print =====data22=$data22 + goto loop6 +endi +if $data23 != 4.000000000 then + print =====data23=$data23 + goto loop6 +endi + + +if $data32 != 10.000000000 then + print =====data32=$data32 + goto loop6 +endi +if $data33 != 5.000000000 then + print =====data33=$data33 + goto loop6 +endi + + +if $data42 != 10.000000000 then + print =====data42=$data42 + goto loop6 +endi +if $data43 != 5.000000000 then + print =====data43=$data43 + goto loop6 +endi + + +if $data52 != 4.000000000 then + print =====data52=$data52 + goto loop6 +endi +if $data53 != 2.000000000 then + print =====data53=$data53 + goto loop6 +endi + + +if $data62 != 4.000000000 then + print =====data62=$data62 + goto loop6 +endi +if $data63 != 2.000000000 then + print =====data63=$data63 + goto loop6 +endi + + +if $data72 != 6.000000000 then + print =====data72=$data72 + return -1 +endi +if $data73 != 3.000000000 then + print =====data73=$data73 + return -1 +endi + + +if $data82 != 6.000000000 then + print =====data82=$data82 + return -1 +endi +if $data83 != 3.000000000 then + print =====data83=$data83 + return -1 +endi + + +if $data92 != 6.000000000 then + print =====data92=$data92 + return -1 +endi +if $data93 != 3.000000000 then + print =====data93=$data93 + return -1 +endi + + + +sql drop stream if exists streams7; +sql drop stream if exists streams8; +sql drop database if exists test7; +sql create database test7 vgroups 1; +sql use test7; +sql create table t1(ts timestamp, a int, b int , c int, d double, s varchar(20)); +sql create stream streams7 trigger at_once into streamt7 as select _wstart as ts, max(a), b+c, s from t1 where ts >= 1648791150000 and ts < 1648791261000 interval(1s) fill(prev); +sql create stream streams8 trigger at_once into streamt8 as select _wstart as ts, max(a), 1, b+1 from t1 where ts >= 1648791150000 and ts < 1648791261000 interval(1s) fill(next); +sql insert into t1 values(1648791215000,1,1,1,1.0,'aaa'); +sql insert into t1 values(1648791217000,2,2,2,2.0,'bbb'); +sql insert into t1 values(1648791211000,3,3,3,3.0,'ccc'); +sql insert into t1 values(1648791213000,4,4,4,4.0,'ddd'); + + +$loop_count = 0 + +loop7: +sleep 300 +sql select * from streamt7 order by ts; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + + +if $rows != 7 then + print =====rows=$rows + goto loop7 +endi + + +if $data01 != 3 then + print =====data01=$data01 + return -1 +endi +if $data02 != 6.000000000 then + print =====data02=$data02 + return -1 +endi +if $data03 != ccc then + print =====data03=$data03 + return -1 +endi + +if $data11 != 3 then + print =====data11=$data11 + return -1 +endi +if $data12 != 6.000000000 then + print =====data12=$data12 + return -1 +endi +if $data13 != ccc then + print =====data13=$data13 + return -1 +endi + + +if $data21 != 4 then + print =====data21=$data21 + return -1 +endi +if $data22 != 8.000000000 then + print =====data22=$data22 + return -1 +endi +if $data23 != ddd then + print =====data23=$data23 + return -1 +endi + + +if $data31 != 4 then + print =====data31=$data31 + return -1 +endi +if $data32 != 8.000000000 then + print =====data32=$data32 + return -1 +endi +if $data33 != ddd then + print =====data33=$data33 + return -1 +endi + + +if $data41 != 1 then + print =====data41=$data41 + return -1 +endi +if $data42 != 2.000000000 then + print =====data42=$data42 + return -1 +endi +if $data43 != aaa then + print =====data43=$data43 + return -1 +endi + + +if $data51 != 1 then + print =====data51=$data51 + return -1 +endi +if $data52 != 2.000000000 then + print =====data52=$data52 + return -1 +endi +if $data53 != aaa then + print =====data53=$data53 + return -1 +endi + + +if $data61 != 2 then + print =====data61=$data61 + return -1 +endi +if $data62 != 4.000000000 then + print =====data62=$data62 + return -1 +endi +if $data63 != bbb then + print =====data63=$data63 + return -1 +endi + +#-------------- + +sleep 200 +sql select * from streamt8 order by ts; + + +if $rows != 7 then + print =====rows=$rows + return -1 +endi + + +if $data01 != 3 then + print =====data01=$data01 + return -1 +endi +if $data02 != 1 then + print =====data02=$data02 + return -1 +endi +if $data03 != 4.000000000 then + print =====data03=$data03 + return -1 +endi + +if $data11 != 4 then + print =====data11=$data11 + return -1 +endi +if $data12 != 1 then + print =====data12=$data12 + return -1 +endi +if $data13 != 5.000000000 then + print =====data13=$data13 + return -1 +endi + + +if $data21 != 4 then + print =====data21=$data21 + return -1 +endi +if $data22 != 1 then + print =====data22=$data22 + return -1 +endi +if $data23 != 5.000000000 then + print =====data23=$data23 + return -1 +endi + + +if $data31 != 1 then + print =====data31=$data31 + return -1 +endi +if $data32 != 1 then + print =====data32=$data32 + return -1 +endi +if $data33 != 2.000000000 then + print =====data33=$data33 + return -1 +endi + + +if $data41 != 1 then + print =====data41=$data41 + return -1 +endi +if $data42 != 1 then + print =====data42=$data42 + return -1 +endi +if $data43 != 2.000000000 then + print =====data43=$data43 + return -1 +endi + + +if $data51 != 2 then + print =====data51=$data51 + return -1 +endi +if $data52 != 1 then + print =====data52=$data52 + return -1 +endi +if $data53 != 3.000000000 then + print =====data53=$data53 + return -1 +endi + + +if $data61 != 2 then + print =====data61=$data61 + return -1 +endi +if $data62 != 1 then + print =====data62=$data62 + return -1 +endi +if $data63 != 3.000000000 then + print =====data63=$data63 + return -1 +endi + +sql insert into t1 values(1648791212000,5,5,5,5.0,'eee'); +sql insert into t1 values(1648791207000,6,6,6,6.0,'fff') (1648791209000,7,7,7,7.0,'ggg') (1648791219000,8,8,8,8.0,'hhh') (1648791221000,9,9,9,9.0,'iii'); + + + +$loop_count = 0 + +loop8: +sleep 200 +sql select * from streamt7 order by ts; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + + +if $rows != 15 then + print =====rows=$rows + goto loop8 +endi + + +if $data01 != 6 then + print =====data01=$data01 + return -1 +endi +if $data02 != 12.000000000 then + print =====data02=$data02 + return -1 +endi +if $data03 != fff then + print =====data03=$data03 + return -1 +endi + +if $data11 != 6 then + print =====data11=$data11 + return -1 +endi +if $data12 != 12.000000000 then + print =====data12=$data12 + return -1 +endi +if $data13 != fff then + print =====data13=$data13 + return -1 +endi + + +if $data21 != 7 then + print =====data21=$data21 + return -1 +endi +if $data22 != 14.000000000 then + print =====data22=$data22 + return -1 +endi +if $data23 != ggg then + print =====data23=$data23 + return -1 +endi + + +if $data31 != 7 then + print =====data31=$data31 + return -1 +endi +if $data32 != 14.000000000 then + print =====data32=$data32 + return -1 +endi +if $data33 != ggg then + print =====data33=$data33 + return -1 +endi + +if $data51 != 5 then + print =====data51=$data51 + return -1 +endi +if $data52 != 10.000000000 then + print =====data52=$data52 + return -1 +endi +if $data53 != eee then + print =====data53=$data53 + return -1 +endi + + +if $data[11][1] != 2 then + print =====data[11][1]=$data[11][1] + return -1 +endi +if $data[11][2] != 4.000000000 then + print =====data[11][2]=$data[11][2] + return -1 +endi +if $data[11][3] != bbb then + print =====data[11][3]=$data[11][3] + return -1 +endi + +if $data[12][1] != 8 then + print =====data[12][1]=$data[12][1] + return -1 +endi +if $data[12][2] != 16.000000000 then + print =====data[12][2]=$data[12][2] + return -1 +endi +if $data[12][3] != hhh then + print =====data[12][3]=$data[12][3] + return -1 +endi + +if $data[13][1] != 8 then + print =====data[13][1]=$data[13][1] + return -1 +endi +if $data[13][2] != 16.000000000 then + print =====data[13][2]=$data[13][2] + return -1 +endi +if $data[13][3] != hhh then + print =====data[13][3]=$data[13][3] + return -1 +endi + +if $data[14][1] != 9 then + print =====data[14][1]=$data[14][1] + return -1 +endi +if $data[14][2] != 18.000000000 then + print =====data[14][2]=$data[14][2] + return -1 +endi +if $data[14][3] != iii then + print =====data[14][3]=$data[14][3] + return -1 +endi + +print fill next-----------------890 +sql use test7; +sql select * from streamt8 order by ts; + +if $rows != 15 then + print =====rows=$rows + goto loop8 +endi + + +if $data01 != 6 then + print =====data01=$data01 + return -1 +endi +if $data02 != 1 then + print =====data02=$data02 + return -1 +endi +if $data03 != 7.000000000 then + print =====data03=$data03 + return -1 +endi + +if $data11 != 7 then + print =====data11=$data11 + return -1 +endi +if $data13 != 8.000000000 then + print =====data13=$data13 + return -1 +endi + + +if $data21 != 7 then + print =====data21=$data21 + return -1 +endi +if $data23 != 8.000000000 then + print =====data23=$data23 + return -1 +endi + + +if $data31 != 3 then + print =====data31=$data31 + return -1 +endi +if $data33 != 4.000000000 then + print =====data33=$data33 + return -1 +endi + +if $data51 != 5 then + print =====data51=$data51 + return -1 +endi +if $data53 != 6.000000000 then + print =====data53=$data53 + return -1 +endi + + +if $data[11][1] != 8 then + print =====data[11][1]=$data[11][1] + return -1 +endi +if $data[11][2] != 1 then + print =====data[11][2]=$data[11][2] + return -1 +endi +if $data[11][3] != 9.000000000 then + print =====data[11][3]=$data[11][3] + return -1 +endi + +if $data[12][1] != 8 then + print =====data[12][1]=$data[12][1] + return -1 +endi +if $data[12][3] != 9.000000000 then + print =====data[12][3]=$data[12][3] + return -1 +endi + +if $data[13][1] != 9 then + print =====data[13][1]=$data[13][1] + return -1 +endi +if $data[13][3] != 10.000000000 then + print =====data[13][3]=$data[13][3] + return -1 +endi + +if $data[14][1] != 9 then + print =====data[14][1]=$data[14][1] + return -1 +endi +if $data[14][3] != 10.000000000 then + print =====data[14][3]=$data[14][3] + return -1 +endi + + + + + + + + + + + + + + + + + + + + + + + + +sql drop stream if exists streams0; +sql drop stream if exists streams1; +sql drop stream if exists streams2; +sql drop stream if exists streams3; +sql drop stream if exists streams4; +sql drop stream if exists streams5; +sql drop stream if exists streams6; +sql drop stream if exists streams7; +sql drop stream if exists streams8; + +sql use test1; +sql select * from t1; +print $data00 + +$loop_all = $loop_all + 1 +print ============loop_all=$loop_all + +system sh/stop_dnodes.sh + +#goto looptest \ No newline at end of file diff --git a/tests/script/tsim/stream/fillIntervalValue.sim b/tests/script/tsim/stream/fillIntervalValue.sim new file mode 100644 index 0000000000..113eae9270 --- /dev/null +++ b/tests/script/tsim/stream/fillIntervalValue.sim @@ -0,0 +1,488 @@ +$loop_all = 0 +looptest: + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 200 +sql connect + +sql drop database if exists test; +sql create database test vgroups 1; +sql use test; + +sql create table t1(ts timestamp, a int, b int , c int, d double, s varchar(20));; +sql create stream streams1 trigger at_once into streamt as select _wstart ts, count(*) c1 from t1 where ts > 1648791210000 and ts < 1648791413000 interval(10s) fill(value, 100); +sql insert into t1 values(1648791213000,1,2,3,1.0,'aaa'); +sleep 100 +sql insert into t1 values(1648791233000,1,2,3,1.0,'aaa'); +sql insert into t1 values(1648791223000,1,2,3,1.0,'aaa'); +sql insert into t1 values(1648791283000,1,2,3,1.0,'aaa'); +sql insert into t1 values(1648791253000,1,2,3,1.0,'aaa'); + +$loop_count = 0 + +loop0: +sleep 200 +sql select * from streamt order by ts; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 8 then + print =====rows=$rows + goto loop0 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop0 +endi + +if $data11 != 1 then + print =====data11=$data11 + goto loop0 +endi + +if $data21 != 1 then + print =====data21=$data21 + goto loop0 +endi + +if $data31 != 100 then + print =====data31=$data31 + goto loop0 +endi + +if $data41 != 1 then + print =====data41=$data41 + goto loop0 +endi + +if $data51 != 100 then + print =====data01=$data01 + goto loop0 +endi + +if $data61 != 100 then + print =====data61=$data61 + goto loop0 +endi + +if $data71 != 1 then + print =====data71=$data71 + goto loop0 +endi + +sql drop stream if exists streams2; +sql drop database if exists test2; +sql create database test2 vgroups 1; +sql use test2; +sql create table t1(ts timestamp, a int, b int , c int, d double, s varchar(20)); +sql create stream streams2 trigger at_once into streamt2 as select _wstart as ts, count(*) c1, max(b)+sum(a) from t1 where ts >= 1648791210000 and ts < 1648791261000 interval(1s) fill(value, 100,200); +sql insert into t1 values(1648791211000,1,1,1,1.0,'aaa') (1648791217000,2,2,2,2.0,'aaa') (1648791220000,3,3,3,3.0,'aaa'); +sql insert into t1 values(1648791213000,4,4,4,4.0,'aaa') (1648791215000,5,5,5,5.0,'aaa'); + +$loop_count = 0 + +loop1: +sleep 200 +sql select * from streamt2 order by ts; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 10 then + print =====rows=$rows + goto loop1 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop1 +endi + +if $data02 != 2.000000000 then + print =====data02=$data02 + goto loop1 +endi + + +if $data11 != 100 then + print =====data11=$data11 + goto loop1 +endi + +if $data12 != 200.000000000 then + print =====data12=$data12 + goto loop1 +endi + + +if $data21 != 1 then + print =====data21=$data21 + goto loop1 +endi + +if $data22 != 8.000000000 then + print =====data22=$data22 + goto loop1 +endi + + +if $data31 != 100 then + print =====data31=$data31 + goto loop1 +endi + +if $data32 != 200.000000000 then + print =====data32=$data32 + goto loop1 +endi + + +if $data41 != 1 then + print =====data41=$data41 + goto loop1 +endi + +if $data42 != 10.000000000 then + print =====data42=$data42 + goto loop1 +endi + + +if $data51 != 100 then + print =====data01=$data01 + goto loop1 +endi + +if $data52 != 200.000000000 then + print =====data52=$data52 + goto loop1 +endi + + +if $data61 != 1 then + print =====data61=$data61 + goto loop1 +endi + +if $data62 != 4.000000000 then + print =====data62=$data62 + goto loop1 +endi + + +if $data71 != 100 then + print =====data71=$data71 + goto loop1 +endi + +if $data72 != 200.000000000 then + print =====data72=$data72 + goto loop1 +endi + + +if $data81 != 100 then + print =====data81=$data81 + goto loop1 +endi + +if $data82 != 200.000000000 then + print =====data82=$data82 + goto loop1 +endi + + +if $data91 != 1 then + print =====data91=$data91 + goto loop1 +endi + +if $data92 != 6.000000000 then + print =====data92=$data92 + goto loop1 +endi + +sql drop stream if exists streams3; +sql drop database if exists test3; +sql create database test3 vgroups 1; +sql use test3; +sql create table t1(ts timestamp, a int, b int , c int, d double, s varchar(20)); +sql create stream streams3 trigger at_once into streamt3 as select _wstart as ts, max(b), a+b, c from t1 where ts >= 1648791200000 and ts < 1648791261000 interval(10s) sliding(3s) fill(value, 100,200,300); + +sql insert into t1 values(1648791220000,1,1,1,1.0,'aaa'); +sleep 100 +sql insert into t1 values(1648791260000,1,1,1,1.0,'aaa'); +sleep 100 +sql insert into t1 values(1648791200000,1,1,1,1.0,'aaa'); + +$loop_count = 0 + +loop3: +sleep 200 +sql select * from streamt3 order by ts; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 23 then + print =====rows=$rows + goto loop3 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop3 +endi + +if $data02 != 2.000000000 then + print =====data02=$data02 + goto loop3 +endi + +if $data03 != 1 then + print =====data03=$data03 + goto loop3 +endi + + +if $data21 != 1 then + print =====data21=$data21 + goto loop3 +endi + +if $data22 != 2.000000000 then + print =====data22=$data22 + goto loop3 +endi + +if $data23 != 1 then + print =====data23=$data23 + goto loop3 +endi + + +if $data31 != 100 then + print =====data31=$data31 + goto loop3 +endi + +if $data32 != 200.000000000 then + print =====data32=$data32 + goto loop3 +endi + +if $data33 != 300 then + print =====data33=$data33 + goto loop3 +endi + +if $data61 != 100 then + print =====data61=$data61 + goto loop3 +endi + +if $data62 != 200.000000000 then + print =====data62=$data62 + goto loop3 +endi + +if $data63 != 300 then + print =====data63=$data63 + goto loop3 +endi + + +if $data71 != 1 then + print =====data71=$data71 + goto loop3 +endi + +if $data72 != 2.000000000 then + print =====data72=$data72 + goto loop3 +endi + +if $data73 != 1 then + print =====data73=$data73 + goto loop3 +endi + + +if $data91 != 1 then + print =====data91=$data91 + goto loop3 +endi + +if $data92 != 2.000000000 then + print =====data92=$data92 + goto loop3 +endi + +if $data93 != 1 then + print =====data93=$data93 + goto loop3 +endi + + +if $data[10][1] != 100 then + print =====data[10][1]=$data[10][1] + goto loop3 +endi + +if $data[10][2] != 200.000000000 then + print =====data[10][2]=$data[10][2] + goto loop3 +endi + +if $data[10][3] != 300 then + print =====data[10][3]=$data[10][3] + goto loop3 +endi + +if $data[19][1] != 100 then + print =====data[19][1]=$data[19][1] + goto loop3 +endi + +if $data[19][2] != 200.000000000 then + print =====data[19][2]=$data[19][2] + goto loop3 +endi + +if $data[19][3] != 300 then + print =====data[19][3]=$data[19][3] + goto loop3 +endi + + +if $data[20][1] != 1 then + print =====data[20][1]=$data[20][1] + goto loop3 +endi + +if $data[20][2] != 2.000000000 then + print =====data[20][2]=$data[20][2] + goto loop3 +endi + +if $data[20][3] != 1 then + print =====data[20][3]=$data[20][3] + goto loop3 +endi + + +if $data[22][1] != 1 then + print =====data[22][1]=$data[22][1] + goto loop3 +endi + +if $data[22][2] != 2.000000000 then + print =====data[22][2]=$data[22][2] + goto loop3 +endi + +if $data[22][3] != 1 then + print =====data[22][3]=$data[22][3] + goto loop3 +endi + + +sql drop stream if exists streams4; +sql drop database if exists test4; +sql create database test4 vgroups 1; +sql use test4; + +sql create table t1(ts timestamp, a int, b int , c int, d double, s varchar(20));; +sql create stream streams4 trigger at_once into streamt4 as select _wstart ts, count(*) c1 from t1 where ts > 1648791210000 and ts < 1648791413000 interval(10s) fill(NULL); +sql insert into t1 values(1648791213000,1,2,3,1.0,'aaa'); +sql insert into t1 values(1648791233000,1,2,3,1.0,'aaa'); + +$loop_count = 0 + +loop4: +sleep 200 +sql select * from streamt4 order by ts; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 3 then + print =====rows=$rows + goto loop4 +endi + +if $data11 != NULL then + print =====data11=$data11 + goto loop4 +endi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +sql drop stream if exists streams0; +sql drop stream if exists streams1; +sql drop stream if exists streams2; +sql drop stream if exists streams3; +sql drop stream if exists streams4; +sql drop stream if exists streams5; +sql drop stream if exists streams6; +sql drop stream if exists streams7; +sql drop stream if exists streams8; + +sql use test; +sql select * from t1; +print $data00 + +$loop_all = $loop_all + 1 +print ============loop_all=$loop_all + +system sh/stop_dnodes.sh + +#goto looptest \ No newline at end of file diff --git a/tests/script/tsim/stream/partitionby.sim b/tests/script/tsim/stream/partitionby.sim index e5e02c3873..bc2c07b951 100644 --- a/tests/script/tsim/stream/partitionby.sim +++ b/tests/script/tsim/stream/partitionby.sim @@ -5,13 +5,14 @@ sleep 50 sql connect sql create database test vgroups 4; +sql create database test0 vgroups 1; sql use test; sql create stable st(ts timestamp, a int, b int , c int, d double) tags(ta int,tb int,tc int); sql create table ts1 using st tags(1,1,1); sql create table ts2 using st tags(2,2,2); sql create table ts3 using st tags(3,2,2); sql create table ts4 using st tags(4,2,2); -sql create stream stream_t1 trigger at_once into streamtST1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from st partition by ta,tb,tc interval(10s); +sql create stream stream_t1 trigger at_once into test0.streamtST1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from st partition by ta,tb,tc interval(10s); sql insert into ts1 values(1648791213001,1,12,3,1.0); sql insert into ts2 values(1648791213001,1,12,3,1.0); @@ -22,7 +23,7 @@ $loop_count = 0 loop0: sleep 300 -sql select * from streamtST1; +sql select * from test0.streamtST1; $loop_count = $loop_count + 1 if $loop_count == 10 then @@ -34,6 +35,29 @@ print =====rows=$rows goto loop0 endi +sql insert into ts1 values(1648791223001,1,12,3,1.0); +sql insert into ts2 values(1648791223001,1,12,3,1.0); + +sql insert into ts3 values(1648791223001,1,12,3,1.0); +sql insert into ts4 values(1648791223001,1,12,3,1.0); +sleep 300 +sql delete from st where ts = 1648791223001; + +loop00: +sleep 300 +sql select * from test0.streamtST1; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 4 then + print =====rows=$rows + goto loop00 +endi + + print =====loop0 sql create database test1 vgroups 1; diff --git a/tests/script/tsim/stream/partitionbyColumnInterval.sim b/tests/script/tsim/stream/partitionbyColumnInterval.sim index 24fdb9c994..fd1d796fdb 100644 --- a/tests/script/tsim/stream/partitionbyColumnInterval.sim +++ b/tests/script/tsim/stream/partitionbyColumnInterval.sim @@ -562,6 +562,53 @@ if $data21 != 1 then goto loop14 endi +sql drop stream if exists streams5; +sql drop database if exists test5; +sql create database test5 vgroups 4; +sql use test5; +sql create stable st(ts timestamp, a int, b int, c int, d double) tags(ta int,tb int,tc int); +sql create table t1 using st tags(1,1,1); +sql create table t2 using st tags(2,2,2); +sql create table t3 using st tags(2,2,2); +sql create table t4 using st tags(2,2,2); +sql create stream streams5 trigger at_once into test.streamt5 as select _wstart c1, count(*) c2, max(a) c3 from st partition by a interval(10s); + +sql insert into t1 values(1648791213000,1,2,3,1.0); +sql insert into t2 values(1648791213000,2,2,3,1.0); +sql insert into t3 values(1648791213000,3,2,3,1.0); +sql insert into t4 values(1648791213000,4,2,3,1.0); + +sql insert into t1 values(1648791223000,1,2,3,1.0); +sql insert into t2 values(1648791223000,2,2,3,1.0); +sql insert into t3 values(1648791223000,3,2,3,1.0); +sql insert into t4 values(1648791223000,4,2,3,1.0); + +sleep 300 + +sql delete from st where ts = 1648791223000; + +sql select * from test.streamt5; + +$loop_count = 0 + +loop15: +sleep 50 +sql select * from test.streamt5 order by c1, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 20 then + return -1 +endi + +if $rows != 4 then + print =====rows=$rows + print =====rows=$rows + print =====rows=$rows +# goto loop15 +endi + + + $loop_all = $loop_all + 1 print ============loop_all=$loop_all diff --git a/tests/system-test/2-query/interp.py b/tests/system-test/2-query/interp.py index 7bf0191ec1..bee20710b5 100644 --- a/tests/system-test/2-query/interp.py +++ b/tests/system-test/2-query/interp.py @@ -356,8 +356,261 @@ class TDTestCase: tdSql.query(f"select interp(c0) from {dbname}.{tbname} range('2020-02-01 00:00:16', '2020-02-01 00:00:19') every(1s) fill(linear)") tdSql.checkRows(0) + tdLog.printNoPrefix("==========step8:test _irowts with interp") - tdLog.printNoPrefix("==========step8:test intra block interpolation") + # fill null + tdSql.query(f"select _irowts,interp(c0) from {dbname}.{tbname} range('2020-02-01 00:00:08', '2020-02-01 00:00:12') every(500a) fill(null)") + tdSql.checkRows(9) + tdSql.checkCols(2) + + tdSql.checkData(0, 0, '2020-02-01 00:00:08.000') + tdSql.checkData(1, 0, '2020-02-01 00:00:08.500') + tdSql.checkData(2, 0, '2020-02-01 00:00:09.000') + tdSql.checkData(3, 0, '2020-02-01 00:00:09.500') + tdSql.checkData(4, 0, '2020-02-01 00:00:10.000') + tdSql.checkData(5, 0, '2020-02-01 00:00:10.500') + tdSql.checkData(6, 0, '2020-02-01 00:00:11.000') + tdSql.checkData(7, 0, '2020-02-01 00:00:11.500') + tdSql.checkData(8, 0, '2020-02-01 00:00:12.000') + + tdSql.query(f"select _irowts,interp(c0) from {dbname}.{tbname} range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill(null)") + tdSql.checkRows(13) + tdSql.checkCols(2) + + tdSql.checkData(0, 0, '2020-02-01 00:00:04.000') + tdSql.checkData(1, 0, '2020-02-01 00:00:05.000') + tdSql.checkData(2, 0, '2020-02-01 00:00:06.000') + tdSql.checkData(3, 0, '2020-02-01 00:00:07.000') + tdSql.checkData(4, 0, '2020-02-01 00:00:08.000') + tdSql.checkData(5, 0, '2020-02-01 00:00:09.000') + tdSql.checkData(6, 0, '2020-02-01 00:00:10.000') + tdSql.checkData(7, 0, '2020-02-01 00:00:11.000') + tdSql.checkData(8, 0, '2020-02-01 00:00:12.000') + tdSql.checkData(9, 0, '2020-02-01 00:00:13.000') + tdSql.checkData(10, 0, '2020-02-01 00:00:14.000') + tdSql.checkData(11, 0, '2020-02-01 00:00:15.000') + tdSql.checkData(12, 0, '2020-02-01 00:00:16.000') + + tdSql.query(f"select _irowts,interp(c0) from {dbname}.{tbname} range('2020-02-01 00:00:05', '2020-02-01 00:00:15') every(2s) fill(null)") + tdSql.checkRows(6) + tdSql.checkCols(2) + + tdSql.checkData(0, 0, '2020-02-01 00:00:05.000') + tdSql.checkData(1, 0, '2020-02-01 00:00:07.000') + tdSql.checkData(2, 0, '2020-02-01 00:00:09.000') + tdSql.checkData(3, 0, '2020-02-01 00:00:11.000') + tdSql.checkData(4, 0, '2020-02-01 00:00:13.000') + tdSql.checkData(5, 0, '2020-02-01 00:00:15.000') + + # fill value + tdSql.query(f"select _irowts,interp(c0) from {dbname}.{tbname} range('2020-02-01 00:00:08', '2020-02-01 00:00:12') every(500a) fill(value, 1)") + tdSql.checkRows(9) + tdSql.checkCols(2) + + tdSql.checkData(0, 0, '2020-02-01 00:00:08.000') + tdSql.checkData(1, 0, '2020-02-01 00:00:08.500') + tdSql.checkData(2, 0, '2020-02-01 00:00:09.000') + tdSql.checkData(3, 0, '2020-02-01 00:00:09.500') + tdSql.checkData(4, 0, '2020-02-01 00:00:10.000') + tdSql.checkData(5, 0, '2020-02-01 00:00:10.500') + tdSql.checkData(6, 0, '2020-02-01 00:00:11.000') + tdSql.checkData(7, 0, '2020-02-01 00:00:11.500') + tdSql.checkData(8, 0, '2020-02-01 00:00:12.000') + + tdSql.query(f"select _irowts,interp(c0) from {dbname}.{tbname} range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill(value, 1)") + tdSql.checkRows(13) + tdSql.checkCols(2) + + tdSql.checkData(0, 0, '2020-02-01 00:00:04.000') + tdSql.checkData(1, 0, '2020-02-01 00:00:05.000') + tdSql.checkData(2, 0, '2020-02-01 00:00:06.000') + tdSql.checkData(3, 0, '2020-02-01 00:00:07.000') + tdSql.checkData(4, 0, '2020-02-01 00:00:08.000') + tdSql.checkData(5, 0, '2020-02-01 00:00:09.000') + tdSql.checkData(6, 0, '2020-02-01 00:00:10.000') + tdSql.checkData(7, 0, '2020-02-01 00:00:11.000') + tdSql.checkData(8, 0, '2020-02-01 00:00:12.000') + tdSql.checkData(9, 0, '2020-02-01 00:00:13.000') + tdSql.checkData(10, 0, '2020-02-01 00:00:14.000') + tdSql.checkData(11, 0, '2020-02-01 00:00:15.000') + tdSql.checkData(12, 0, '2020-02-01 00:00:16.000') + + tdSql.query(f"select _irowts,interp(c0) from {dbname}.{tbname} range('2020-02-01 00:00:05', '2020-02-01 00:00:15') every(2s) fill(value, 1)") + tdSql.checkRows(6) + tdSql.checkCols(2) + + tdSql.checkData(0, 0, '2020-02-01 00:00:05.000') + tdSql.checkData(1, 0, '2020-02-01 00:00:07.000') + tdSql.checkData(2, 0, '2020-02-01 00:00:09.000') + tdSql.checkData(3, 0, '2020-02-01 00:00:11.000') + tdSql.checkData(4, 0, '2020-02-01 00:00:13.000') + tdSql.checkData(5, 0, '2020-02-01 00:00:15.000') + + # fill prev + tdSql.query(f"select _irowts,interp(c0) from {dbname}.{tbname} range('2020-02-01 00:00:08', '2020-02-01 00:00:12') every(500a) fill(prev)") + tdSql.checkRows(9) + tdSql.checkCols(2) + + tdSql.checkData(0, 0, '2020-02-01 00:00:08.000') + tdSql.checkData(1, 0, '2020-02-01 00:00:08.500') + tdSql.checkData(2, 0, '2020-02-01 00:00:09.000') + tdSql.checkData(3, 0, '2020-02-01 00:00:09.500') + tdSql.checkData(4, 0, '2020-02-01 00:00:10.000') + tdSql.checkData(5, 0, '2020-02-01 00:00:10.500') + tdSql.checkData(6, 0, '2020-02-01 00:00:11.000') + tdSql.checkData(7, 0, '2020-02-01 00:00:11.500') + tdSql.checkData(8, 0, '2020-02-01 00:00:12.000') + + tdSql.query(f"select _irowts,interp(c0) from {dbname}.{tbname} range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill(prev)") + tdSql.checkRows(12) + tdSql.checkCols(2) + + tdSql.checkData(0, 0, '2020-02-01 00:00:05.000') + tdSql.checkData(1, 0, '2020-02-01 00:00:06.000') + tdSql.checkData(2, 0, '2020-02-01 00:00:07.000') + tdSql.checkData(3, 0, '2020-02-01 00:00:08.000') + tdSql.checkData(4, 0, '2020-02-01 00:00:09.000') + tdSql.checkData(5, 0, '2020-02-01 00:00:10.000') + tdSql.checkData(6, 0, '2020-02-01 00:00:11.000') + tdSql.checkData(7, 0, '2020-02-01 00:00:12.000') + tdSql.checkData(8, 0, '2020-02-01 00:00:13.000') + tdSql.checkData(9, 0, '2020-02-01 00:00:14.000') + tdSql.checkData(10, 0, '2020-02-01 00:00:15.000') + tdSql.checkData(11, 0, '2020-02-01 00:00:16.000') + + tdSql.query(f"select _irowts,interp(c0) from {dbname}.{tbname} range('2020-02-01 00:00:05', '2020-02-01 00:00:15') every(2s) fill(prev)") + tdSql.checkRows(6) + tdSql.checkCols(2) + + tdSql.checkData(0, 0, '2020-02-01 00:00:05.000') + tdSql.checkData(1, 0, '2020-02-01 00:00:07.000') + tdSql.checkData(2, 0, '2020-02-01 00:00:09.000') + tdSql.checkData(3, 0, '2020-02-01 00:00:11.000') + tdSql.checkData(4, 0, '2020-02-01 00:00:13.000') + tdSql.checkData(5, 0, '2020-02-01 00:00:15.000') + + # fill next + tdSql.query(f"select _irowts,interp(c0) from {dbname}.{tbname} range('2020-02-01 00:00:08', '2020-02-01 00:00:12') every(500a) fill(next)") + tdSql.checkRows(9) + tdSql.checkCols(2) + + tdSql.checkData(0, 0, '2020-02-01 00:00:08.000') + tdSql.checkData(1, 0, '2020-02-01 00:00:08.500') + tdSql.checkData(2, 0, '2020-02-01 00:00:09.000') + tdSql.checkData(3, 0, '2020-02-01 00:00:09.500') + tdSql.checkData(4, 0, '2020-02-01 00:00:10.000') + tdSql.checkData(5, 0, '2020-02-01 00:00:10.500') + tdSql.checkData(6, 0, '2020-02-01 00:00:11.000') + tdSql.checkData(7, 0, '2020-02-01 00:00:11.500') + tdSql.checkData(8, 0, '2020-02-01 00:00:12.000') + + tdSql.query(f"select _irowts,interp(c0) from {dbname}.{tbname} range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill(next)") + tdSql.checkRows(12) + tdSql.checkCols(2) + + tdSql.checkData(0, 0, '2020-02-01 00:00:04.000') + tdSql.checkData(1, 0, '2020-02-01 00:00:05.000') + tdSql.checkData(2, 0, '2020-02-01 00:00:06.000') + tdSql.checkData(3, 0, '2020-02-01 00:00:07.000') + tdSql.checkData(4, 0, '2020-02-01 00:00:08.000') + tdSql.checkData(5, 0, '2020-02-01 00:00:09.000') + tdSql.checkData(6, 0, '2020-02-01 00:00:10.000') + tdSql.checkData(7, 0, '2020-02-01 00:00:11.000') + tdSql.checkData(8, 0, '2020-02-01 00:00:12.000') + tdSql.checkData(9, 0, '2020-02-01 00:00:13.000') + tdSql.checkData(10, 0, '2020-02-01 00:00:14.000') + tdSql.checkData(11, 0, '2020-02-01 00:00:15.000') + + tdSql.query(f"select _irowts,interp(c0) from {dbname}.{tbname} range('2020-02-01 00:00:05', '2020-02-01 00:00:15') every(2s) fill(next)") + tdSql.checkRows(6) + tdSql.checkCols(2) + + tdSql.checkData(0, 0, '2020-02-01 00:00:05.000') + tdSql.checkData(1, 0, '2020-02-01 00:00:07.000') + tdSql.checkData(2, 0, '2020-02-01 00:00:09.000') + tdSql.checkData(3, 0, '2020-02-01 00:00:11.000') + tdSql.checkData(4, 0, '2020-02-01 00:00:13.000') + tdSql.checkData(5, 0, '2020-02-01 00:00:15.000') + + # fill linear + tdSql.query(f"select _irowts,interp(c0) from {dbname}.{tbname} range('2020-02-01 00:00:08', '2020-02-01 00:00:12') every(500a) fill(linear)") + tdSql.checkRows(9) + tdSql.checkCols(2) + + tdSql.checkData(0, 0, '2020-02-01 00:00:08.000') + tdSql.checkData(1, 0, '2020-02-01 00:00:08.500') + tdSql.checkData(2, 0, '2020-02-01 00:00:09.000') + tdSql.checkData(3, 0, '2020-02-01 00:00:09.500') + tdSql.checkData(4, 0, '2020-02-01 00:00:10.000') + tdSql.checkData(5, 0, '2020-02-01 00:00:10.500') + tdSql.checkData(6, 0, '2020-02-01 00:00:11.000') + tdSql.checkData(7, 0, '2020-02-01 00:00:11.500') + tdSql.checkData(8, 0, '2020-02-01 00:00:12.000') + + tdSql.query(f"select _irowts,interp(c0) from {dbname}.{tbname} range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill(linear)") + tdSql.checkRows(11) + tdSql.checkCols(2) + + tdSql.checkData(0, 0, '2020-02-01 00:00:05.000') + tdSql.checkData(1, 0, '2020-02-01 00:00:06.000') + tdSql.checkData(2, 0, '2020-02-01 00:00:07.000') + tdSql.checkData(3, 0, '2020-02-01 00:00:08.000') + tdSql.checkData(4, 0, '2020-02-01 00:00:09.000') + tdSql.checkData(5, 0, '2020-02-01 00:00:10.000') + tdSql.checkData(6, 0, '2020-02-01 00:00:11.000') + tdSql.checkData(7, 0, '2020-02-01 00:00:12.000') + tdSql.checkData(8, 0, '2020-02-01 00:00:13.000') + tdSql.checkData(9, 0, '2020-02-01 00:00:14.000') + tdSql.checkData(10, 0, '2020-02-01 00:00:15.000') + + tdSql.query(f"select _irowts,interp(c0) from {dbname}.{tbname} range('2020-02-01 00:00:05', '2020-02-01 00:00:15') every(2s) fill(linear)") + tdSql.checkRows(6) + tdSql.checkCols(2) + + tdSql.checkData(0, 0, '2020-02-01 00:00:05.000') + tdSql.checkData(1, 0, '2020-02-01 00:00:07.000') + tdSql.checkData(2, 0, '2020-02-01 00:00:09.000') + tdSql.checkData(3, 0, '2020-02-01 00:00:11.000') + tdSql.checkData(4, 0, '2020-02-01 00:00:13.000') + tdSql.checkData(5, 0, '2020-02-01 00:00:15.000') + + # multiple _irowts + tdSql.query(f"select interp(c0),_irowts from {dbname}.{tbname} range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill(linear)") + tdSql.checkRows(11) + tdSql.checkCols(2) + + tdSql.checkData(0, 1, '2020-02-01 00:00:05.000') + tdSql.checkData(1, 1, '2020-02-01 00:00:06.000') + tdSql.checkData(2, 1, '2020-02-01 00:00:07.000') + tdSql.checkData(3, 1, '2020-02-01 00:00:08.000') + tdSql.checkData(4, 1, '2020-02-01 00:00:09.000') + tdSql.checkData(5, 1, '2020-02-01 00:00:10.000') + tdSql.checkData(6, 1, '2020-02-01 00:00:11.000') + tdSql.checkData(7, 1, '2020-02-01 00:00:12.000') + tdSql.checkData(8, 1, '2020-02-01 00:00:13.000') + tdSql.checkData(9, 1, '2020-02-01 00:00:14.000') + tdSql.checkData(10, 1, '2020-02-01 00:00:15.000') + + tdSql.query(f"select _irowts, interp(c0), interp(c0), _irowts from {dbname}.{tbname} range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill(linear)") + tdSql.checkRows(11) + tdSql.checkCols(4) + + cols = (0, 3) + for i in cols: + tdSql.checkData(0, i, '2020-02-01 00:00:05.000') + tdSql.checkData(1, i, '2020-02-01 00:00:06.000') + tdSql.checkData(2, i, '2020-02-01 00:00:07.000') + tdSql.checkData(3, i, '2020-02-01 00:00:08.000') + tdSql.checkData(4, i, '2020-02-01 00:00:09.000') + tdSql.checkData(5, i, '2020-02-01 00:00:10.000') + tdSql.checkData(6, i, '2020-02-01 00:00:11.000') + tdSql.checkData(7, i, '2020-02-01 00:00:12.000') + tdSql.checkData(8, i, '2020-02-01 00:00:13.000') + tdSql.checkData(9, i, '2020-02-01 00:00:14.000') + tdSql.checkData(10, i, '2020-02-01 00:00:15.000') + + + tdLog.printNoPrefix("==========step9:test intra block interpolation") tdSql.execute(f"drop database {dbname}"); tdSql.prepare() @@ -551,7 +804,7 @@ class TDTestCase: tdSql.checkData(0, 0, 15) tdSql.checkData(1, 0, 15) - tdLog.printNoPrefix("==========step9:test multi-interp cases") + tdLog.printNoPrefix("==========step10:test multi-interp cases") tdSql.query(f"select interp(c0),interp(c1),interp(c2),interp(c3) from {dbname}.{tbname} range('2020-02-09 00:00:05', '2020-02-13 00:00:05') every(1d) fill(null)") tdSql.checkRows(5) tdSql.checkCols(4) @@ -601,7 +854,7 @@ class TDTestCase: for i in range (tdSql.queryCols): tdSql.checkData(0, i, 13) - tdLog.printNoPrefix("==========step10:test error cases") + tdLog.printNoPrefix("==========step11:test error cases") tdSql.error(f"select interp(c0) from {dbname}.{tbname}") tdSql.error(f"select interp(c0) from {dbname}.{tbname} range('2020-02-10 00:00:05', '2020-02-15 00:00:05')") diff --git a/tests/system-test/7-tmq/subscribeDb3.py b/tests/system-test/7-tmq/subscribeDb3.py index e8e475456c..0ff609ab6b 100644 --- a/tests/system-test/7-tmq/subscribeDb3.py +++ b/tests/system-test/7-tmq/subscribeDb3.py @@ -295,7 +295,7 @@ class TDTestCase: ifManualCommit = 1 keyList = 'group.id:cgrp1,\ enable.auto.commit:true,\ - auto.commit.interval.ms:1000,\ + auto.commit.interval.ms:200,\ auto.offset.reset:earliest' self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) diff --git a/tools/shell/src/shellArguments.c b/tools/shell/src/shellArguments.c index 93f8b8a23b..eedb6d7295 100644 --- a/tools/shell/src/shellArguments.c +++ b/tools/shell/src/shellArguments.c @@ -358,7 +358,7 @@ static int32_t shellCheckArgs() { return -1; } - if (pArgs->password != NULL && (strlen(pArgs->password) <= 0)) { + if (/*pArgs->password != NULL && */ (strlen(pArgs->password) <= 0)) { printf("Invalid password\r\n"); return -1; } diff --git a/utils/test/c/CMakeLists.txt b/utils/test/c/CMakeLists.txt index 839c65b633..b048b79e9b 100644 --- a/utils/test/c/CMakeLists.txt +++ b/utils/test/c/CMakeLists.txt @@ -40,20 +40,3 @@ target_link_libraries( PUBLIC common PUBLIC os ) - -add_executable(sdbDump sdbDump.c) -target_link_libraries( - sdbDump - PUBLIC dnode - PUBLIC mnode - PUBLIC stream - PUBLIC sdb - PUBLIC os -) -target_include_directories( - sdbDump - PUBLIC "${TD_SOURCE_DIR}/include/dnode/mnode" - PRIVATE "${TD_SOURCE_DIR}/source/dnode/mnode/impl/inc" - PRIVATE "${TD_SOURCE_DIR}/source/dnode/mnode/sdb/inc" - PRIVATE "${TD_SOURCE_DIR}/source/dnode/mgmt/node_mgmt/inc" -) diff --git a/utils/test/c/createTable.c b/utils/test/c/createTable.c index 6a0f8e244e..783ed85adc 100644 --- a/utils/test/c/createTable.c +++ b/utils/test/c/createTable.c @@ -201,7 +201,7 @@ void *threadFunc(void *param) { int64_t t = pInfo->tableBeginIndex; for (; t <= pInfo->tableEndIndex;) { // int64_t batch = (pInfo->tableEndIndex - t); - // batch = MIN(batch, batchNum); + // batch = TMIN(batch, batchNum); int32_t len = sprintf(qstr, "create table"); for (int32_t i = 0; i < batchNumOfTbl;) { diff --git a/utils/test/c/sdbDump.c b/utils/test/c/sdbDump.c deleted file mode 100644 index b056fe58a3..0000000000 --- a/utils/test/c/sdbDump.c +++ /dev/null @@ -1,475 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#define _DEFAULT_SOURCE -#include "dmMgmt.h" -#include "mndInt.h" -#include "sdb.h" -#include "tconfig.h" -#include "tjson.h" - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-result" - -#define TMP_DNODE_DIR TD_TMP_DIR_PATH "dumpsdb" -#define TMP_MNODE_DIR TD_TMP_DIR_PATH "dumpsdb" TD_DIRSEP "mnode" -#define TMP_SDB_DATA_DIR TD_TMP_DIR_PATH "dumpsdb" TD_DIRSEP "mnode" TD_DIRSEP "data" -#define TMP_SDB_SYNC_DIR TD_TMP_DIR_PATH "dumpsdb" TD_DIRSEP "mnode" TD_DIRSEP "sync" -#define TMP_SDB_MNODE_JSON TD_TMP_DIR_PATH "dumpsdb" TD_DIRSEP "mnode" TD_DIRSEP "mnode.json" -#define TMP_SDB_DATA_FILE TD_TMP_DIR_PATH "dumpsdb" TD_DIRSEP "mnode" TD_DIRSEP "data" TD_DIRSEP "sdb.data" -#define TMP_SDB_RAFT_CFG_FILE TD_TMP_DIR_PATH "dumpsdb" TD_DIRSEP "mnode" TD_DIRSEP "sync" TD_DIRSEP "raft_config.json" -#define TMP_SDB_RAFT_STORE_FILE TD_TMP_DIR_PATH "dumpsdb" TD_DIRSEP "mnode" TD_DIRSEP "sync" TD_DIRSEP "raft_store.json" - -void reportStartup(const char *name, const char *desc) {} - -void sendRsp(SRpcMsg *pMsg) { rpcFreeCont(pMsg->pCont); } - -int32_t sendReq(const SEpSet *pEpSet, SRpcMsg *pMsg) { - terrno = TSDB_CODE_INVALID_PTR; - return -1; -} - -char *i642str(int64_t val) { - static char str[24] = {0}; - snprintf(str, sizeof(str), "%" PRId64, val); - return str; -} - -void dumpFunc(SSdb *pSdb, SJson *json) {} - -void dumpDb(SSdb *pSdb, SJson *json) { - void *pIter = NULL; - SJson *items = tjsonCreateObject(); - tjsonAddItemToObject(json, "dbs", items); - - while (1) { - SDbObj *pObj = NULL; - pIter = sdbFetch(pSdb, SDB_DB, pIter, (void **)&pObj); - if (pIter == NULL) break; - - SJson *item = tjsonCreateObject(); - tjsonAddItemToObject(items, "db", item); - - tjsonAddStringToObject(item, "name", pObj->name); - tjsonAddStringToObject(item, "acct", pObj->acct); - tjsonAddStringToObject(item, "createUser", pObj->createUser); - tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); - tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); - tjsonAddStringToObject(item, "uid", i642str(pObj->uid)); - tjsonAddIntegerToObject(item, "cfgVersion", pObj->cfgVersion); - tjsonAddIntegerToObject(item, "vgVersion", pObj->vgVersion); - tjsonAddIntegerToObject(item, "numOfVgroups", pObj->cfg.numOfVgroups); - tjsonAddIntegerToObject(item, "numOfStables", pObj->cfg.numOfStables); - tjsonAddIntegerToObject(item, "buffer", pObj->cfg.buffer); - tjsonAddIntegerToObject(item, "pageSize", pObj->cfg.pageSize); - tjsonAddIntegerToObject(item, "pages", pObj->cfg.pages); - tjsonAddIntegerToObject(item, "cacheLastSize", pObj->cfg.cacheLastSize); - tjsonAddIntegerToObject(item, "daysPerFile", pObj->cfg.daysPerFile); - tjsonAddIntegerToObject(item, "daysToKeep0", pObj->cfg.daysToKeep0); - tjsonAddIntegerToObject(item, "daysToKeep1", pObj->cfg.daysToKeep1); - tjsonAddIntegerToObject(item, "daysToKeep2", pObj->cfg.daysToKeep2); - tjsonAddIntegerToObject(item, "minRows", pObj->cfg.minRows); - tjsonAddIntegerToObject(item, "maxRows", pObj->cfg.maxRows); - tjsonAddIntegerToObject(item, "precision", pObj->cfg.precision); - tjsonAddIntegerToObject(item, "compression", pObj->cfg.compression); - tjsonAddIntegerToObject(item, "replications", pObj->cfg.replications); - tjsonAddIntegerToObject(item, "strict", pObj->cfg.strict); - tjsonAddIntegerToObject(item, "cacheLast", pObj->cfg.cacheLast); - tjsonAddIntegerToObject(item, "hashMethod", pObj->cfg.hashMethod); - tjsonAddIntegerToObject(item, "numOfRetensions", pObj->cfg.numOfRetensions); - tjsonAddIntegerToObject(item, "schemaless", pObj->cfg.schemaless); - tjsonAddIntegerToObject(item, "walLevel", pObj->cfg.walLevel); - tjsonAddIntegerToObject(item, "walFsyncPeriod", pObj->cfg.walFsyncPeriod); - tjsonAddIntegerToObject(item, "walRetentionPeriod", pObj->cfg.walRetentionPeriod); - tjsonAddIntegerToObject(item, "walRetentionSize", pObj->cfg.walRetentionSize); - tjsonAddIntegerToObject(item, "walRollPeriod", pObj->cfg.walRollPeriod); - tjsonAddIntegerToObject(item, "walSegmentSize", pObj->cfg.walSegmentSize); - - sdbRelease(pSdb, pObj); - } -} - -void dumpStb(SSdb *pSdb, SJson *json) { - void *pIter = NULL; - SJson *items = tjsonCreateObject(); - tjsonAddItemToObject(json, "stbs", items); - - while (1) { - SStbObj *pObj = NULL; - pIter = sdbFetch(pSdb, SDB_STB, pIter, (void **)&pObj); - if (pIter == NULL) break; - - SJson *item = tjsonCreateObject(); - tjsonAddItemToObject(items, "stb", item); - - tjsonAddStringToObject(item, "name", pObj->name); - tjsonAddStringToObject(item, "db", pObj->db); - tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); - tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); - tjsonAddStringToObject(item, "uid", i642str(pObj->uid)); - tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid)); - tjsonAddIntegerToObject(item, "tagVer", pObj->tagVer); - tjsonAddIntegerToObject(item, "colVer", pObj->colVer); - tjsonAddIntegerToObject(item, "nextColId", pObj->nextColId); - tjsonAddIntegerToObject(item, "watermark1", pObj->watermark[0]); - tjsonAddIntegerToObject(item, "watermark2", pObj->watermark[1]); - tjsonAddIntegerToObject(item, "maxdelay1", pObj->maxdelay[0]); - tjsonAddIntegerToObject(item, "maxdelay2", pObj->maxdelay[1]); - tjsonAddIntegerToObject(item, "ttl", pObj->ttl); - tjsonAddIntegerToObject(item, "numOfColumns", pObj->numOfColumns); - tjsonAddIntegerToObject(item, "numOfTags", pObj->numOfTags); - tjsonAddIntegerToObject(item, "commentLen", pObj->commentLen); - tjsonAddIntegerToObject(item, "ast1Len", pObj->ast1Len); - tjsonAddIntegerToObject(item, "ast2Len", pObj->ast2Len); - - sdbRelease(pSdb, pObj); - } -} - -void dumpSma(SSdb *pSdb, SJson *json) {} - -void dumpVgroup(SSdb *pSdb, SJson *json) {} - -void dumpTopic(SSdb *pSdb, SJson *json) {} - -void dumpConsumber(SSdb *pSdb, SJson *json) {} - -void dumpSubscribe(SSdb *pSdb, SJson *json) {} - -void dumpOffset(SSdb *pSdb, SJson *json) {} - -void dumpStream(SSdb *pSdb, SJson *json) {} - -void dumpAcct(SSdb *pSdb, SJson *json) { - void *pIter = NULL; - SJson *items = tjsonCreateObject(); - tjsonAddItemToObject(json, "accts", items); - - while (1) { - SAcctObj *pObj = NULL; - pIter = sdbFetch(pSdb, SDB_ACCT, pIter, (void **)&pObj); - if (pIter == NULL) break; - - SJson *item = tjsonCreateObject(); - tjsonAddItemToObject(items, "acct", item); - - tjsonAddStringToObject(item, "acct", pObj->acct); - tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); - tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); - tjsonAddIntegerToObject(item, "acctId", pObj->acctId); - - sdbRelease(pSdb, pObj); - } -} - -void dumpAuth(SSdb *pSdb, SJson *json) {} - -void dumpUser(SSdb *pSdb, SJson *json) { - void *pIter = NULL; - SJson *items = tjsonCreateObject(); - tjsonAddItemToObject(json, "users", items); - - while (1) { - SUserObj *pObj = NULL; - pIter = sdbFetch(pSdb, SDB_USER, pIter, (void **)&pObj); - if (pIter == NULL) break; - - SJson *item = tjsonCreateObject(); - tjsonAddItemToObject(items, "user", item); - - tjsonAddStringToObject(item, "name", pObj->user); - tjsonAddStringToObject(item, "pass", pObj->pass); - tjsonAddStringToObject(item, "acct", pObj->acct); - tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); - tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); - tjsonAddIntegerToObject(item, "superUser", pObj->superUser); - tjsonAddIntegerToObject(item, "authVersion", pObj->authVersion); - tjsonAddIntegerToObject(item, "numOfReadDbs", taosHashGetSize(pObj->readDbs)); - tjsonAddIntegerToObject(item, "numOfWriteDbs", taosHashGetSize(pObj->writeDbs)); - - sdbRelease(pSdb, pObj); - } -} - -void dumpDnode(SSdb *pSdb, SJson *json) { - void *pIter = NULL; - SJson *items = tjsonCreateObject(); - tjsonAddItemToObject(json, "dnodes", items); - - while (1) { - SDnodeObj *pObj = NULL; - pIter = sdbFetch(pSdb, SDB_DNODE, pIter, (void **)&pObj); - if (pIter == NULL) break; - - SJson *item = tjsonCreateObject(); - tjsonAddItemToObject(items, "dnode", item); - - tjsonAddIntegerToObject(item, "id", pObj->id); - tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); - tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); - tjsonAddIntegerToObject(item, "port", pObj->port); - tjsonAddStringToObject(item, "fqdn", pObj->fqdn); - - sdbRelease(pSdb, pObj); - } -} - -void dumpBnode(SSdb *pSdb, SJson *json) {} - -void dumpSnode(SSdb *pSdb, SJson *json) {} - -void dumpQnode(SSdb *pSdb, SJson *json) {} - -void dumpMnode(SSdb *pSdb, SJson *json) { - void *pIter = NULL; - SJson *items = tjsonCreateObject(); - tjsonAddItemToObject(json, "mnodes", items); - - while (1) { - SMnodeObj *pObj = NULL; - pIter = sdbFetch(pSdb, SDB_MNODE, pIter, (void **)&pObj); - if (pIter == NULL) break; - - SJson *item = tjsonCreateObject(); - tjsonAddItemToObject(items, "mnode", item); - - tjsonAddIntegerToObject(item, "id", pObj->id); - tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); - tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); - - sdbRelease(pSdb, pObj); - } -} - -void dumpCluster(SSdb *pSdb, SJson *json) { - void *pIter = NULL; - SJson *items = tjsonCreateObject(); - tjsonAddItemToObject(json, "clusters", items); - - while (1) { - SClusterObj *pObj = NULL; - pIter = sdbFetch(pSdb, SDB_CLUSTER, pIter, (void **)&pObj); - if (pIter == NULL) break; - - SJson *item = tjsonCreateObject(); - tjsonAddItemToObject(items, "cluster", item); - - tjsonAddStringToObject(item, "id", i642str(pObj->id)); - tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); - tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); - tjsonAddStringToObject(item, "name", pObj->name); - - sdbRelease(pSdb, pObj); - } -} - -void dumpTrans(SSdb *pSdb, SJson *json) { - void *pIter = NULL; - SJson *items = tjsonCreateObject(); - tjsonAddItemToObject(json, "transactions", items); - - while (1) { - STrans *pObj = NULL; - pIter = sdbFetch(pSdb, SDB_TRANS, pIter, (void **)&pObj); - if (pIter == NULL) break; - - SJson *item = tjsonCreateObject(); - tjsonAddItemToObject(items, "trans", item); - - tjsonAddIntegerToObject(item, "id", pObj->id); - tjsonAddIntegerToObject(item, "stage", pObj->stage); - tjsonAddIntegerToObject(item, "policy", pObj->policy); - tjsonAddIntegerToObject(item, "conflict", pObj->conflict); - tjsonAddIntegerToObject(item, "exec", pObj->exec); - tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); - tjsonAddStringToObject(item, "dbname", pObj->dbname); - tjsonAddStringToObject(item, "stbname", pObj->stbname); - tjsonAddIntegerToObject(item, "commitLogNum", taosArrayGetSize(pObj->commitActions)); - tjsonAddIntegerToObject(item, "redoActionNum", taosArrayGetSize(pObj->redoActions)); - tjsonAddIntegerToObject(item, "undoActionNum", taosArrayGetSize(pObj->undoActions)); - - sdbRelease(pSdb, pObj); - } -} - -void dumpHeader(SSdb *pSdb, SJson *json) { - tjsonAddIntegerToObject(json, "sver", 1); - tjsonAddStringToObject(json, "applyIndex", i642str(pSdb->applyIndex)); - tjsonAddStringToObject(json, "applyTerm", i642str(pSdb->applyTerm)); - tjsonAddStringToObject(json, "applyConfig", i642str(pSdb->applyConfig)); - - SJson *maxIdsJson = tjsonCreateObject(); - tjsonAddItemToObject(json, "maxIds", maxIdsJson); - for (int32_t i = 0; i < SDB_MAX; ++i) { - int64_t maxId = 0; - if (i < SDB_MAX) { - maxId = pSdb->maxId[i]; - } - tjsonAddStringToObject(maxIdsJson, sdbTableName(i), i642str(maxId)); - } - - SJson *tableVersJson = tjsonCreateObject(); - tjsonAddItemToObject(json, "tableVers", tableVersJson); - for (int32_t i = 0; i < SDB_MAX; ++i) { - int64_t tableVer = 0; - if (i < SDB_MAX) { - tableVer = pSdb->tableVer[i]; - } - tjsonAddStringToObject(tableVersJson, sdbTableName(i), i642str(tableVer)); - } -} - -int32_t dumpSdb() { - wDebugFlag = 0; - mDebugFlag = 0; - sDebugFlag = 0; - - SMsgCb msgCb = {0}; - msgCb.reportStartupFp = reportStartup; - msgCb.sendReqFp = sendReq; - msgCb.sendRspFp = sendRsp; - msgCb.mgmt = (SMgmtWrapper *)(&msgCb); // hack - tmsgSetDefault(&msgCb); - walInit(); - syncInit(); - - SMnodeOpt opt = {.msgCb = msgCb}; - SMnode *pMnode = mndOpen(TMP_MNODE_DIR, &opt); - if (pMnode == NULL) return -1; - - SSdb *pSdb = pMnode->pSdb; - SJson *json = tjsonCreateObject(); - dumpHeader(pSdb, json); - dumpFunc(pSdb, json); - dumpDb(pSdb, json); - dumpStb(pSdb, json); - dumpSma(pSdb, json); - dumpVgroup(pSdb, json); - dumpTopic(pSdb, json); - dumpConsumber(pSdb, json); - dumpSubscribe(pSdb, json); - dumpOffset(pSdb, json); - dumpStream(pSdb, json); - dumpAcct(pSdb, json); - dumpAuth(pSdb, json); - dumpUser(pSdb, json); - dumpDnode(pSdb, json); - dumpBnode(pSdb, json); - dumpSnode(pSdb, json); - dumpQnode(pSdb, json); - dumpMnode(pSdb, json); - dumpCluster(pSdb, json); - dumpTrans(pSdb, json); - - char *pCont = tjsonToString(json); - int32_t contLen = strlen(pCont); - char file[] = "sdb.json"; - TdFilePtr pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC); - if (pFile == NULL) { - terrno = TAOS_SYSTEM_ERROR(errno); - dError("failed to write %s since %s", file, terrstr()); - return -1; - } - taosWriteFile(pFile, pCont, contLen); - taosWriteFile(pFile, "\n", 1); - taosFsyncFile(pFile); - taosCloseFile(&pFile); - tjsonDelete(json); - taosMemoryFree(pCont); - taosRemoveDir(TMP_DNODE_DIR); - return 0; -} - -int32_t parseArgs(int32_t argc, char *argv[]) { - for (int32_t i = 1; i < argc; ++i) { - if (strcmp(argv[i], "-c") == 0) { - if (i < argc - 1) { - if (strlen(argv[++i]) >= PATH_MAX) { - printf("config file path overflow"); - return -1; - } - tstrncpy(configDir, argv[i], PATH_MAX); - } else { - printf("'-c' requires a parameter, default is %s\n", configDir); - return -1; - } - } else { - printf("-c Configuration directory. \n"); - return -1; - } - } - - if (taosCreateLog("dumplog", 1, configDir, NULL, NULL, NULL, NULL, 1) != 0) { - printf("failed to dump since init log error\n"); - return -1; - } - - if (taosInitCfg(configDir, NULL, NULL, NULL, NULL, 0) != 0) { - printf("failed to dump since read config error\n"); - return -1; - } - - char mnodeJson[PATH_MAX] = {0}; - char dataFile[PATH_MAX] = {0}; - char raftCfgFile[PATH_MAX] = {0}; - char raftStoreFile[PATH_MAX] = {0}; - snprintf(mnodeJson, PATH_MAX, "%s" TD_DIRSEP "mnode" TD_DIRSEP "mnode.json", tsDataDir); - snprintf(dataFile, PATH_MAX, "%s" TD_DIRSEP "mnode" TD_DIRSEP "data" TD_DIRSEP "sdb.data", tsDataDir); - snprintf(raftCfgFile, PATH_MAX, "%s" TD_DIRSEP "mnode" TD_DIRSEP "sync" TD_DIRSEP "raft_config.json", tsDataDir); - snprintf(raftStoreFile, PATH_MAX, "%s" TD_DIRSEP "mnode" TD_DIRSEP "sync" TD_DIRSEP "raft_store.json", tsDataDir); - - char cmd[PATH_MAX * 2] = {0}; - snprintf(cmd, sizeof(cmd), "rm -rf %s", TMP_DNODE_DIR); - - system(cmd); -#ifdef WINDOWS - taosMulMkDir(TMP_SDB_DATA_DIR); - taosMulMkDir(TMP_SDB_SYNC_DIR); - snprintf(cmd, sizeof(cmd), "cp %s %s 2>nul", mnodeJson, TMP_SDB_MNODE_JSON); - system(cmd); - snprintf(cmd, sizeof(cmd), "cp %s %s 2>nul", dataFile, TMP_SDB_DATA_FILE); - system(cmd); - snprintf(cmd, sizeof(cmd), "cp %s %s 2>nul", raftCfgFile, TMP_SDB_RAFT_CFG_FILE); - system(cmd); - snprintf(cmd, sizeof(cmd), "cp %s %s 2>nul", raftStoreFile, TMP_SDB_RAFT_STORE_FILE); - system(cmd); -#else - snprintf(cmd, sizeof(cmd), "mkdir -p %s", TMP_SDB_DATA_DIR); - system(cmd); - snprintf(cmd, sizeof(cmd), "mkdir -p %s", TMP_SDB_SYNC_DIR); - system(cmd); - snprintf(cmd, sizeof(cmd), "cp %s %s 2>/dev/null", mnodeJson, TMP_SDB_MNODE_JSON); - system(cmd); - snprintf(cmd, sizeof(cmd), "cp %s %s 2>/dev/null", dataFile, TMP_SDB_DATA_FILE); - system(cmd); - snprintf(cmd, sizeof(cmd), "cp %s %s 2>/dev/null", raftCfgFile, TMP_SDB_RAFT_CFG_FILE); - system(cmd); - snprintf(cmd, sizeof(cmd), "cp %s %s 2>/dev/null", raftStoreFile, TMP_SDB_RAFT_STORE_FILE); - system(cmd); -#endif - - strcpy(tsDataDir, TMP_DNODE_DIR); - return 0; -} - -int32_t main(int32_t argc, char *argv[]) { - if (parseArgs(argc, argv) != 0) { - return -1; - } - - return dumpSdb(); -} - -#pragma GCC diagnostic pop \ No newline at end of file diff --git a/utils/test/c/sml_test.c b/utils/test/c/sml_test.c index ca3d464da7..56ba622a9c 100644 --- a/utils/test/c/sml_test.c +++ b/utils/test/c/sml_test.c @@ -879,7 +879,7 @@ int sml_16960_Test() { "{" "\"timestamp\":" "" - "{ \"value\": 1349020800000, \"type\": \"ms\" }" + "{ \"value\": 1664418955000, \"type\": \"ms\" }" "," "\"value\":" "" @@ -916,7 +916,7 @@ int sml_16960_Test() { "{" "\"timestamp\":" "" - "{ \"value\": 1349020800001, \"type\": \"ms\" }" + "{ \"value\": 1664418955001, \"type\": \"ms\" }" "," "\"value\":" "" @@ -953,7 +953,7 @@ int sml_16960_Test() { "{" "\"timestamp\":" "" - "{ \"value\": 1349020800002, \"type\": \"ms\" }" + "{ \"value\": 1664418955002, \"type\": \"ms\" }" "," "\"value\":" "" @@ -990,7 +990,7 @@ int sml_16960_Test() { "{" "\"timestamp\":" "" - "{ \"value\": 1349020800003, \"type\": \"ms\" }" + "{ \"value\": 1664418955003, \"type\": \"ms\" }" "," "\"value\":" "" @@ -1027,7 +1027,7 @@ int sml_16960_Test() { "{" "\"timestamp\":" "" - "{ \"value\": 1349020800004, \"type\": \"ms\" }" + "{ \"value\": 1664418955004, \"type\": \"ms\" }" "," "\"value\":" "" diff --git a/utils/tsim/src/simExe.c b/utils/tsim/src/simExe.c index 16732ff9a1..5bb53287db 100644 --- a/utils/tsim/src/simExe.c +++ b/utils/tsim/src/simExe.c @@ -224,10 +224,24 @@ char *simGetVariable(SScript *script, char *varName, int32_t varLen) { } int32_t simExecuteExpression(SScript *script, char *exp) { - char *op1, *op2, *var1, *var2, *var3, *rest; - int32_t op1Len, op2Len, var1Len, var2Len, var3Len, val0, val1; - char t0[1024], t1[1024], t2[1024], t3[2048]; - int32_t result; + char *op1 = NULL; + char *op2 = NULL; + char *var1 = NULL; + char *var2 = NULL; + char *var3 = NULL; + char *rest = NULL; + int32_t op1Len = 0; + int32_t op2Len = 0; + int32_t var1Len = 0; + int32_t var2Len = 0; + int32_t var3Len = 0; + int32_t val0 = 0; + int32_t val1 = 0; + char t0[1024] = {0}; + char t1[1024] = {0}; + char t2[1024] = {0}; + char t3[2048] = {0}; + int32_t result = 0; rest = paGetToken(exp, &var1, &var1Len); rest = paGetToken(rest, &op1, &op1Len); @@ -241,9 +255,9 @@ int32_t simExecuteExpression(SScript *script, char *exp) { t0[var1Len] = 0; } - if (var2[0] == '$') - strcpy(t1, simGetVariable(script, var2 + 1, var2Len - 1)); - else { + if (var2[0] == '$') { + tstrncpy(t1, simGetVariable(script, var2 + 1, var2Len - 1), 1024); + } else { memcpy(t1, var2, var2Len); t1[var2Len] = 0; } @@ -258,14 +272,21 @@ int32_t simExecuteExpression(SScript *script, char *exp) { t2[var3Len] = 0; } + int64_t t1l = atoll(t1); + int64_t t2l = atoll(t2); + if (op2[0] == '+') { - sprintf(t3, "%lld", atoll(t1) + atoll(t2)); + sprintf(t3, "%" PRId64, t1l + t2l); } else if (op2[0] == '-') { - sprintf(t3, "%lld", atoll(t1) - atoll(t2)); + sprintf(t3, "%" PRId64, t1l - t2l); } else if (op2[0] == '*') { - sprintf(t3, "%lld", atoll(t1) * atoll(t2)); + sprintf(t3, "%" PRId64, t1l * t2l); } else if (op2[0] == '/') { - sprintf(t3, "%lld", atoll(t1) / atoll(t2)); + if (t2l == 0) { + sprintf(t3, "%" PRId64, INT64_MAX); + } else { + sprintf(t3, "%" PRId64, t1l / t2l); + } } else if (op2[0] == '.') { sprintf(t3, "%s%s", t1, t2); } @@ -636,7 +657,7 @@ bool simCreateTaosdConnect(SScript *script, char *rest) { } bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) { - char timeStr[30] = {0}; + char timeStr[80] = {0}; time_t tt; struct tm tp; SCmdLine *line = &script->lines[script->linePos]; @@ -943,7 +964,7 @@ bool simExecuteSqlErrorCmd(SScript *script, char *rest) { return true; } - TAOS_RES *pSql = pSql = taos_query(script->taos, rest); + TAOS_RES *pSql = taos_query(script->taos, rest); int32_t ret = taos_errno(pSql); taos_free_result(pSql); @@ -961,7 +982,7 @@ bool simExecuteSqlErrorCmd(SScript *script, char *rest) { } bool simExecuteLineInsertCmd(SScript *script, char *rest) { - char buf[TSDB_MAX_BINARY_LEN]; + char buf[TSDB_MAX_BINARY_LEN] = {0}; simVisuallizeOption(script, rest, buf); rest = buf; @@ -973,10 +994,7 @@ bool simExecuteLineInsertCmd(SScript *script, char *rest) { char *lines[] = {rest}; #if 0 int32_t ret = taos_insert_lines(script->taos, lines, 1); -#else - int32_t ret = 0; -#endif - if (ret == TSDB_CODE_SUCCESS) { + if (ret == TSDB_CODE_SUCCESS) { simDebug("script:%s, taos:%p, %s executed. success.", script->fileName, script->taos, rest); script->linePos++; return true; @@ -985,6 +1003,11 @@ bool simExecuteLineInsertCmd(SScript *script, char *rest) { tstrerror(ret)); return false; } +#else + simDebug("script:%s, taos:%p, %s executed. success.", script->fileName, script->taos, rest); + script->linePos++; + return true; +#endif } bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) { diff --git a/utils/tsim/src/simMain.c b/utils/tsim/src/simMain.c index 713e46df58..e58a22cf68 100644 --- a/utils/tsim/src/simMain.c +++ b/utils/tsim/src/simMain.c @@ -33,7 +33,7 @@ int32_t main(int32_t argc, char *argv[]) { if (strcmp(argv[i], "-c") == 0 && i < argc - 1) { tstrncpy(configDir, argv[++i], 128); } else if (strcmp(argv[i], "-f") == 0 && i < argc - 1) { - strcpy(scriptFile, argv[++i]); + tstrncpy(scriptFile, argv[++i], MAX_FILE_NAME_LEN); } else if (strcmp(argv[i], "-m") == 0) { useMultiProcess = true; } else if (strcmp(argv[i], "-v") == 0) { diff --git a/utils/tsim/src/simParse.c b/utils/tsim/src/simParse.c index b9f7610be8..14be10bc8a 100644 --- a/utils/tsim/src/simParse.c +++ b/utils/tsim/src/simParse.c @@ -175,14 +175,17 @@ SScript *simBuildScriptObj(char *fileName) { SScript *simParseScript(char *fileName) { TdFilePtr pFile; int32_t tokenLen, lineNum = 0; - char buffer[10*1024], name[128], *token, *rest; - SCommand *pCmd; - SScript *script; + char buffer[10 * 1024] = {0}; + char name[PATH_MAX] = {9}; + char *token = NULL; + char *rest = NULL; + SCommand *pCmd = NULL; + SScript *script = NULL; if ((fileName[0] == '.') || (fileName[0] == '/')) { - strcpy(name, fileName); + tstrncpy(name, fileName, PATH_MAX); } else { - sprintf(name, "%s" TD_DIRSEP "%s", simScriptDir, fileName); + snprintf(name, PATH_MAX, "%s" TD_DIRSEP "%s", simScriptDir, fileName); taosRealPath(name, NULL, sizeof(name)); }