Merge remote-tracking branch 'origin/3.0' into feat/caseWhen
This commit is contained in:
commit
8ab016fd9f
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|||
<CLine />
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## 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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -343,6 +343,7 @@ The following list shows all reserved keywords:
|
|||
### \_
|
||||
|
||||
- \_C0
|
||||
- \_IROWTS
|
||||
- \_QDURATION
|
||||
- \_QEND
|
||||
- \_QSTART
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ TDengine's JDBC URL specification format is:
|
|||
|
||||
For establishing connections, native connections differ slightly from REST connections.
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
<Tabs defaultValue="rest">
|
||||
<TabItem value="native" label="native connection">
|
||||
|
||||
```java
|
||||
|
|
|
@ -113,7 +113,7 @@ username:password@protocol(address)/dbname?param=value
|
|||
```
|
||||
### Connecting via connector
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
<Tabs defaultValue="rest">
|
||||
<TabItem value="native" label="native connection">
|
||||
|
||||
_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.
|
||||
|
|
|
@ -55,16 +55,6 @@ taos = "*"
|
|||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="native" label="native connection only">
|
||||
|
||||
In `cargo.toml`, add [taos][taos] and enable the native feature:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
taos = { version = "*", default-features = false, features = ["native"] }
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="rest" label="Websocket only">
|
||||
|
||||
In `cargo.toml`, add [taos][taos] and enable the ws feature:
|
||||
|
@ -75,6 +65,18 @@ taos = { version = "*", default-features = false, features = ["ws"] }
|
|||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="native" label="native connection only">
|
||||
|
||||
In `cargo.toml`, add [taos][taos] and enable the native feature:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
taos = { version = "*", default-features = false, features = ["native"] }
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
</Tabs>
|
||||
|
||||
## Establishing a connection
|
||||
|
|
|
@ -80,7 +80,7 @@ pip3 install git+https://github.com/taosdata/taos-connector-python.git
|
|||
|
||||
### Verify
|
||||
|
||||
<Tabs groupId="connect" default="native">
|
||||
<Tabs defaultValue="rest">
|
||||
<TabItem value="native" label="native connection">
|
||||
|
||||
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.
|
||||
|
||||
<Tabs>
|
||||
<Tabs defaultValue="rest">
|
||||
<TabItem value="native" label="native connection">
|
||||
|
||||
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.
|
||||
|
||||
<Tabs>
|
||||
<Tabs defaultValue="rest">
|
||||
<TabItem value="native" label="native connection" groupId="connect">
|
||||
|
||||
```python
|
||||
|
@ -219,7 +219,7 @@ All arguments to the `connect()` function are optional keyword arguments. The fo
|
|||
|
||||
### Basic Usage
|
||||
|
||||
<Tabs default="native" groupId="connect">
|
||||
<Tabs defaultValue="rest">
|
||||
<TabItem value="native" label="native connection">
|
||||
|
||||
##### TaosConnection class
|
||||
|
@ -289,7 +289,7 @@ For a more detailed description of the `sql()` method, please refer to [RestClie
|
|||
|
||||
### Used with pandas
|
||||
|
||||
<Tabs default="native" groupId="connect">
|
||||
<Tabs defaultValue="rest">
|
||||
<TabItem value="native" label="native connection">
|
||||
|
||||
```python
|
||||
|
|
|
@ -85,7 +85,7 @@ If using ARM64 Node.js on Windows 10 ARM, you must add "Visual C++ compilers and
|
|||
|
||||
### Install via npm
|
||||
|
||||
<Tabs defaultValue="install_native">
|
||||
<Tabs defaultValue="install_rest">
|
||||
<TabItem value="install_native" label="Install native connector">
|
||||
|
||||
```bash
|
||||
|
@ -124,7 +124,7 @@ node nodejsChecker.js host=localhost
|
|||
|
||||
Please choose to use one of the connectors.
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
<Tabs defaultValue="rest">
|
||||
<TabItem value="native" label="native connection">
|
||||
|
||||
Install and import the `@tdengine/client` package.
|
||||
|
|
|
@ -97,7 +97,7 @@ dotnet add exmaple.csproj reference src/TDengine.csproj
|
|||
## Establish a Connection
|
||||
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
<Tabs defaultValue="rest">
|
||||
|
||||
<TabItem value="native" label="Native Connection">
|
||||
|
||||
|
@ -173,7 +173,7 @@ ws://localhost:6041/test
|
|||
|
||||
#### SQL Write
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
<Tabs defaultValue="rest">
|
||||
|
||||
<TabItem value="native" label="Native Connection">
|
||||
|
||||
|
@ -204,7 +204,7 @@ ws://localhost:6041/test
|
|||
|
||||
#### Parameter Binding
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
<Tabs defaultValue="rest">
|
||||
|
||||
<TabItem value="native" label="Native Connection">
|
||||
|
||||
|
@ -227,7 +227,7 @@ ws://localhost:6041/test
|
|||
|
||||
#### Synchronous Query
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
<Tabs defaultValue="rest">
|
||||
|
||||
<TabItem value="native" label="Native Connection">
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 &
|
||||
```
|
||||
|
|
|
@ -22,5 +22,4 @@ An example is as follows.
|
|||
username = "root"
|
||||
password = "taosdata"
|
||||
data_format = "influx"
|
||||
influx_max_line_bytes = 250
|
||||
```
|
||||
|
|
|
@ -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.
|
||||
:::
|
||||
|
|
|
@ -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
|
||||
<Telegraf />
|
||||
|
@ -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)
|
||||
:::
|
||||
|
||||
|
|
|
@ -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.
|
||||
:::
|
||||
|
|
|
@ -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.
|
||||
:::
|
||||
|
|
|
@ -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.
|
||||
:::
|
||||
|
|
|
@ -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.
|
||||
:::
|
||||
|
|
|
@ -60,7 +60,6 @@ For the configuration method, add the following text to `/etc/telegraf/telegraf.
|
|||
username = "<TDengine's username>"
|
||||
password = "<TDengine's password>"
|
||||
data_format = "influx"
|
||||
influx_max_line_bytes = 250
|
||||
```
|
||||
|
||||
Then restart telegraf:
|
||||
|
|
|
@ -6,6 +6,14 @@ description: TDengine release history, Release Notes and download links.
|
|||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
## 3.0.1.4
|
||||
|
||||
<Release type="tdengine" version="3.0.1.4" />
|
||||
|
||||
## 3.0.1.3
|
||||
|
||||
<Release type="tdengine" version="3.0.1.3" />
|
||||
|
||||
## 3.0.1.2
|
||||
|
||||
<Release type="tdengine" version="3.0.1.2" />
|
||||
|
|
|
@ -6,6 +6,14 @@ description: taosTools release history, Release Notes, download links.
|
|||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
## 2.2.4
|
||||
|
||||
<Release type="tools" version="2.2.4" />
|
||||
|
||||
## 2.2.3
|
||||
|
||||
<Release type="tools" version="2.2.3" />
|
||||
|
||||
## 2.2.2
|
||||
|
||||
<Release type="tools" version="2.2.2" />
|
||||
|
|
|
@ -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
|
|||
<CLine />
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## 查询示例
|
||||
比如查询 location=California.LosAngeles,groupid=2 子表的数据可以通过如下sql:
|
||||
select * from meters where location=California.LosAngeles and groupid=2
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -109,7 +109,7 @@ TDengine 的 JDBC URL 规范格式为:
|
|||
|
||||
对于建立连接,原生连接与 REST 连接有细微不同。
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
<Tabs defaultValue="rest">
|
||||
<TabItem value="native" label="原生连接">
|
||||
|
||||
```java
|
||||
|
|
|
@ -114,7 +114,7 @@ username:password@protocol(address)/dbname?param=value
|
|||
```
|
||||
### 使用连接器进行连接
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
<Tabs defaultValue="rest">
|
||||
<TabItem value="native" label="原生连接">
|
||||
|
||||
_taosSql_ 通过 cgo 实现了 Go 的 `database/sql/driver` 接口。只需要引入驱动就可以使用 [`database/sql`](https://golang.org/pkg/database/sql/) 的接口。
|
||||
|
|
|
@ -55,16 +55,6 @@ taos = "*"
|
|||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="native" label="仅原生连接">
|
||||
|
||||
在 `Cargo.toml` 文件中添加 [taos][taos],并启用 `native` 特性:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
taos = { version = "*", default-features = false, features = ["native"] }
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="rest" label="仅 Websocket">
|
||||
|
||||
在 `Cargo.toml` 文件中添加 [taos][taos],并启用 `ws` 特性。
|
||||
|
@ -74,6 +64,17 @@ taos = { version = "*", default-features = false, features = ["native"] }
|
|||
taos = { version = "*", default-features = false, features = ["ws"] }
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="native" label="仅原生连接">
|
||||
|
||||
在 `Cargo.toml` 文件中添加 [taos][taos],并启用 `native` 特性:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
taos = { version = "*", default-features = false, features = ["native"] }
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ pip3 install git+https://github.com/taosdata/taos-connector-python.git
|
|||
|
||||
### 安装验证
|
||||
|
||||
<Tabs groupId="connect" default="native">
|
||||
<Tabs defaultValue="rest">
|
||||
<TabItem value="native" label="原生连接">
|
||||
|
||||
对于原生连接,需要验证客户端驱动和 Python 连接器本身是否都正确安装。如果能成功导入 `taos` 模块,则说明已经正确安装了客户端驱动和 Python 连接器。可在 Python 交互式 Shell 中输入:
|
||||
|
@ -118,7 +118,7 @@ Requirement already satisfied: taospy in c:\users\username\appdata\local\program
|
|||
|
||||
在用连接器建立连接之前,建议先测试本地 TDengine CLI 到 TDengine 集群的连通性。
|
||||
|
||||
<Tabs>
|
||||
<Tabs defaultValue="rest">
|
||||
<TabItem value="native" label="原生连接">
|
||||
|
||||
请确保 TDengine 集群已经启动, 且集群中机器的 FQDN (如果启动的是单机版,FQDN 默认为 hostname)在本机能够解析, 可用 `ping` 命令进行测试:
|
||||
|
@ -173,7 +173,7 @@ curl -u root:taosdata http://<FQDN>:<PORT>/rest/sql -d "select server_version()"
|
|||
|
||||
以下示例代码假设 TDengine 安装在本机, 且 FQDN 和 serverPort 都使用了默认配置。
|
||||
|
||||
<Tabs>
|
||||
<Tabs defaultValue="rest">
|
||||
<TabItem value="native" label="原生连接" groupId="connect">
|
||||
|
||||
```python
|
||||
|
@ -219,7 +219,7 @@ curl -u root:taosdata http://<FQDN>:<PORT>/rest/sql -d "select server_version()"
|
|||
|
||||
### 基本使用
|
||||
|
||||
<Tabs default="native" groupId="connect">
|
||||
<Tabs defaultValue="rest">
|
||||
<TabItem value="native" label="原生连接">
|
||||
|
||||
##### TaosConnection 类的使用
|
||||
|
@ -289,7 +289,7 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线
|
|||
|
||||
### 与 pandas 一起使用
|
||||
|
||||
<Tabs default="native" groupId="connect">
|
||||
<Tabs defaultValue="rest">
|
||||
<TabItem value="native" label="原生连接">
|
||||
|
||||
```python
|
||||
|
|
|
@ -85,7 +85,7 @@ REST 连接器支持所有能运行 Node.js 的平台。
|
|||
|
||||
### 使用 npm 安装
|
||||
|
||||
<Tabs defaultValue="install_native">
|
||||
<Tabs defaultValue="install_rest">
|
||||
<TabItem value="install_native" label="安装原生连接器">
|
||||
|
||||
```bash
|
||||
|
@ -124,7 +124,7 @@ node nodejsChecker.js host=localhost
|
|||
|
||||
请选择使用一种连接器。
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
<Tabs defaultValue="rest">
|
||||
<TabItem value="native" label="原生连接">
|
||||
|
||||
安装并引用 `@tdengine/client` 包。
|
||||
|
|
|
@ -35,7 +35,7 @@ import CSAsyncQuery from "../07-develop/04-query-data/_cs_async.mdx"
|
|||
|
||||
## 支持的功能特性
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
<Tabs defaultValue="rest">
|
||||
|
||||
<TabItem value="native" label="原生连接">
|
||||
|
||||
|
@ -96,7 +96,7 @@ dotnet add exmaple.csproj reference src/TDengine.csproj
|
|||
|
||||
## 建立连接
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
<Tabs defaultValue="rest">
|
||||
|
||||
<TabItem value="native" label="原生连接">
|
||||
|
||||
|
@ -171,7 +171,7 @@ namespace TDengineExample
|
|||
|
||||
#### SQL 写入
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
<Tabs defaultValue="rest">
|
||||
|
||||
<TabItem value="native" label="原生连接">
|
||||
|
||||
|
@ -203,7 +203,7 @@ namespace TDengineExample
|
|||
|
||||
#### 参数绑定
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
<Tabs defaultValue="rest">
|
||||
|
||||
<TabItem value="native" label="原生连接">
|
||||
|
||||
|
@ -227,7 +227,7 @@ namespace TDengineExample
|
|||
|
||||
#### 同步查询
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
<Tabs defaultValue="rest">
|
||||
|
||||
<TabItem value="native" label="原生连接">
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 关键字后面可以是若干个表(超级表)列表,也可以是子查询的结果。
|
||||
|
|
|
@ -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)
|
||||
```
|
||||
|
||||
**功能说明**:时间加权平均函数。统计表中某列在一段时间内的时间加权平均。
|
||||
|
|
|
@ -344,6 +344,7 @@ description: TDengine 保留关键字的详细列表
|
|||
### \_
|
||||
|
||||
- \_C0
|
||||
- \_IROWTS
|
||||
- \_QDURATION
|
||||
- \_QEND
|
||||
- \_QSTART
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 语句变更
|
||||
|
||||
|
|
|
@ -177,12 +177,21 @@ taos --dump-config
|
|||
### maxNumOfDistinctRes
|
||||
|
||||
| 属性 | 说明 |
|
||||
| -------- | -------------------------------- | --- |
|
||||
| -------- | -------------------------------- |
|
||||
| 适用范围 | 仅服务端适用 |
|
||||
| 含义 | 允许返回的 distinct 结果最大行数 |
|
||||
| 取值范围 | 默认值为 10 万,最大值 1 亿 |
|
||||
| 缺省值 | 10 万 |
|
||||
|
||||
### keepColumnName
|
||||
|
||||
| 属性 | 说明 |
|
||||
| -------- | -------------------------------- |
|
||||
| 适用范围 | 仅客户端适用 |
|
||||
| 含义 | Last、First、LastRow 函数查询时,返回的列名是否包含函数名。 |
|
||||
| 取值范围 | 0 表示包含函数名,1 表示不包含函数名。 |
|
||||
| 缺省值 | 0 |
|
||||
|
||||
## 区域相关
|
||||
|
||||
### timezone
|
||||
|
|
|
@ -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 确定的子表名来创建子表。
|
||||
|
|
|
@ -51,5 +51,6 @@ port: 8125
|
|||
增加如下内容后启动 StatsD(假设配置文件修改为 config.js)。
|
||||
|
||||
```
|
||||
npm install
|
||||
node stats.js config.js &
|
||||
```
|
||||
|
|
|
@ -22,6 +22,5 @@
|
|||
username = "root"
|
||||
password = "taosdata"
|
||||
data_format = "influx"
|
||||
influx_max_line_bytes = 250
|
||||
```
|
||||
|
||||
|
|
|
@ -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 值。
|
||||
:::
|
||||
|
|
|
@ -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中。
|
||||
|
||||
## 配置步骤
|
||||
<Telegraf />
|
||||
|
@ -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/#无模式写入行协议)
|
||||
:::
|
||||
|
||||
|
|
|
@ -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 值。
|
||||
:::
|
||||
|
|
|
@ -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.
|
||||
:::
|
||||
|
|
|
@ -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 值。
|
||||
:::
|
||||
|
|
|
@ -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 值。
|
||||
:::
|
||||
|
|
|
@ -61,7 +61,6 @@ IT 运维监测数据通常都是对时间特性比较敏感的数据,例如
|
|||
username = "<TDengine's username>"
|
||||
password = "<TDengine's password>"
|
||||
data_format = "influx"
|
||||
influx_max_line_bytes = 250
|
||||
```
|
||||
|
||||
然后重启 Telegraf:
|
||||
|
|
|
@ -6,6 +6,14 @@ description: TDengine 发布历史、Release Notes 及下载链接
|
|||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
## 3.0.1.4
|
||||
|
||||
<Release type="tdengine" version="3.0.1.4" />
|
||||
|
||||
## 3.0.1.3
|
||||
|
||||
<Release type="tdengine" version="3.0.1.3" />
|
||||
|
||||
## 3.0.1.2
|
||||
|
||||
<Release type="tdengine" version="3.0.1.2" />
|
||||
|
|
|
@ -6,6 +6,14 @@ description: taosTools 的发布历史、Release Notes 和下载链接
|
|||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
## 2.2.4
|
||||
|
||||
<Release type="tools" version="2.2.4" />
|
||||
|
||||
## 2.2.3
|
||||
|
||||
<Release type="tools" version="2.2.3" />
|
||||
|
||||
## 2.2.2
|
||||
|
||||
<Release type="tools" version="2.2.2" />
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -177,6 +177,7 @@ typedef struct SSDataBlock {
|
|||
enum {
|
||||
FETCH_TYPE__DATA = 1,
|
||||
FETCH_TYPE__META,
|
||||
FETCH_TYPE__SEP,
|
||||
FETCH_TYPE__NONE,
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -106,6 +106,8 @@ void mndPostProcessQueryMsg(SRpcMsg *pMsg);
|
|||
*/
|
||||
void mndGenerateMachineCode();
|
||||
|
||||
void mndDumpSdb();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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!"
|
||||
}
|
||||
|
||||
|
|
|
@ -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!!!"
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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));
|
||||
|
|
|
@ -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) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue