提交 86879b57 编写于 作者: B Benguang Zhao

Merge branch '2.6' into FIX/TS-1438

```c
{{#include docs-examples/c/line_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs-examples/c/json_protocol_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs-examples/c/telnet_line_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs-examples/c/insert_example.c}}
```
\ No newline at end of file
```csharp
{{#include docs-examples/csharp/InfluxDBLineExample.cs}}
```
```csharp
{{#include docs-examples/csharp/OptsJsonExample.cs}}
```
```csharp
{{#include docs-examples/csharp/OptsTelnetExample.cs}}
```
```csharp
{{#include docs-examples/csharp/SQLInsertExample.cs}}
```
```csharp
{{#include docs-examples/csharp/StmtInsertExample.cs}}
```
```go
{{#include docs-examples/go/insert/line/main.go}}
```
```go
{{#include docs-examples/go/insert/json/main.go}}
```
```go
{{#include docs-examples/go/insert/telnet/main.go}}
```
```go
{{#include docs-examples/go/insert/sql/main.go}}
```
```js
{{#include docs-examples/node/nativeexample/influxdb_line_example.js}}
```
```js
{{#include docs-examples/node/nativeexample/opentsdb_json_example.js}}
```
```js
{{#include docs-examples/node/nativeexample/opentsdb_telnet_example.js}}
```
```js
{{#include docs-examples/node/nativeexample/insert_example.js}}
```
```php
{{#include docs-examples/php/insert.php}}
```
```php
{{#include docs-examples/php/insert_stmt.php}}
```
```py
{{#include docs-examples/python/line_protocol_example.py}}
```
```py
{{#include docs-examples/python/json_protocol_example.py}}
```
```py
{{#include docs-examples/python/telnet_line_protocol_example.py}}
```
```py
{{#include docs-examples/python/native_insert_example.py}}
```
```rust
{{#include docs-examples/rust/restexample/examples/insert_example.rs}}
```
```rust
{{#include docs-examples/rust/nativeexample/examples/stmt_example.rs}}
```
```c
{{#include docs-examples/c/query_example.c}}
```
\ No newline at end of file
```c
{{#include docs-examples/c/async_query_example.c:demo}}
```
\ No newline at end of file
```csharp
{{#include docs-examples/csharp/QueryExample.cs}}
```
```csharp
{{#include docs-examples/csharp/AsyncQueryExample.cs}}
```
```go
{{#include docs-examples/go/query/sync/main.go}}
```
```go
{{#include docs-examples/go/query/async/main.go}}
```
```js
{{#include docs-examples/node/nativeexample/query_example.js}}
```
```js
{{#include docs-examples/node/nativeexample/async_query_example.js}}
```
```go
{{#include docs-examples/php/query.php}}
```
```rust
{{#include docs-examples/rust/restexample/examples/query_example.rs}}
```
```c
{{#include docs-examples/c/subscribe_demo.c}}
```
\ No newline at end of file
```csharp
{{#include docs-examples/csharp/SubscribeDemo.cs}}
```
\ No newline at end of file
```go
{{#include docs-examples/go/sub/main.go}}
```
\ No newline at end of file
```js
{{#include docs-examples/node/nativeexample/subscribe_demo.js}}
```
\ No newline at end of file
```py
{{#include docs-examples/python/subscribe_demo.py}}
```
\ No newline at end of file
```rs
{{#include docs-examples/rust/nativeexample/examples/subscribe_demo.rs}}
```
\ No newline at end of file
label: 参数限制与保留关键字
\ No newline at end of file
```c
{{#include docs-examples/c/line_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs-examples/c/json_protocol_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs-examples/c/telnet_line_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs-examples/c/insert_example.c}}
```
\ No newline at end of file
```csharp
{{#include docs-examples/csharp/InfluxDBLineExample.cs}}
```
```csharp
{{#include docs-examples/csharp/OptsJsonExample.cs}}
```
```csharp
{{#include docs-examples/csharp/OptsTelnetExample.cs}}
```
```csharp
{{#include docs-examples/csharp/SQLInsertExample.cs}}
```
```csharp
{{#include docs-examples/csharp/StmtInsertExample.cs}}
```
```go
{{#include docs-examples/go/insert/line/main.go}}
```
```go
{{#include docs-examples/go/insert/json/main.go}}
```
```go
{{#include docs-examples/go/insert/telnet/main.go}}
```
```go
{{#include docs-examples/go/insert/sql/main.go}}
```
```js
{{#include docs-examples/node/nativeexample/influxdb_line_example.js}}
```
```js
{{#include docs-examples/node/nativeexample/opentsdb_json_example.js}}
```
```js
{{#include docs-examples/node/nativeexample/opentsdb_telnet_example.js}}
```
```js
{{#include docs-examples/node/nativeexample/insert_example.js}}
```
```py
{{#include docs-examples/python/line_protocol_example.py}}
```
```py
{{#include docs-examples/python/json_protocol_example.py}}
```
```py
{{#include docs-examples/python/telnet_line_protocol_example.py}}
```
```py
{{#include docs-examples/python/native_insert_example.py}}
```
```rust
{{#include docs-examples/rust/restexample/examples/insert_example.rs}}
```
```rust
{{#include docs-examples/rust/nativeexample/examples/stmt_example.rs}}
```
```c
{{#include docs-examples/c/query_example.c}}
```
\ No newline at end of file
```c
{{#include docs-examples/c/async_query_example.c:demo}}
```
\ No newline at end of file
```csharp
{{#include docs-examples/csharp/QueryExample.cs}}
```
```csharp
{{#include docs-examples/csharp/AsyncQueryExample.cs}}
```
```go
{{#include docs-examples/go/query/sync/main.go}}
```
```go
{{#include docs-examples/go/query/async/main.go}}
```
```js
{{#include docs-examples/node/nativeexample/query_example.js}}
```
```js
{{#include docs-examples/node/nativeexample/async_query_example.js}}
```
```rust
{{#include docs-examples/rust/restexample/examples/query_example.rs}}
```
```c
{{#include docs-examples/c/subscribe_demo.c}}
```
\ No newline at end of file
```csharp
{{#include docs-examples/csharp/SubscribeDemo.cs}}
```
\ No newline at end of file
```go
{{#include docs-examples/go/sub/main.go}}
```
\ No newline at end of file
```js
{{#include docs-examples/node/nativeexample/subscribe_demo.js}}
```
\ No newline at end of file
```py
{{#include docs-examples/python/subscribe_demo.py}}
```
\ No newline at end of file
```rs
{{#include docs-examples/rust/nativeexample/examples/subscribe_demo.rs}}
```
\ No newline at end of file
---
title: Get Started
description: 'Install TDengine from Docker image, apt-get or package, and run TAOS CLI and taosBenchmark to experience the features'
description: 'Install TDengine from Docker image, apt-get or package, and run TDengine CLI and taosBenchmark to experience the features'
---
import Tabs from "@theme/Tabs";
......@@ -120,7 +120,7 @@ select * from t;
Query OK, 2 row(s) in set (0.003128s)
```
Besides executing SQL commands, system administrators can check running status, add/drop user accounts and manage the running instances. TAOS CLI with client driver can be installed and run on either Linux or Windows machines. For more details on CLI, please [check here](../reference/taos-shell/).
Besides executing SQL commands, system administrators can check running status, add/drop user accounts and manage the running instances. TDengine CLI with client driver can be installed and run on either Linux or Windows machines. For more details on CLI, please [check here](../reference/taos-shell/).
## Experience the blazing fast speed
......
```c title="Native Connection"
{{#include docs-examples/c/connect_example.c}}
{{#include docs/examples/c/connect_example.c}}
```
```csharp title="Native Connection"
{{#include docs-examples/csharp/ConnectExample.cs}}
{{#include docs/examples/csharp/ConnectExample.cs}}
```
:::info
......
#### Unified Database Access Interface
```go title="Native Connection"
{{#include docs-examples/go/connect/cgoexample/main.go}}
{{#include docs/examples/go/connect/cgoexample/main.go}}
```
```go title="REST Connection"
{{#include docs-examples/go/connect/restexample/main.go}}
{{#include docs/examples/go/connect/restexample/main.go}}
```
#### Advanced Features
......@@ -13,5 +13,5 @@
The af package of driver-go can also be used to establish connection, with this way some advanced features of TDengine, like parameter binding and subscription, can be used.
```go title="Establish native connection using af package"
{{#include docs-examples/go/connect/afconn/main.go}}
{{#include docs/examples/go/connect/afconn/main.go}}
```
```java title="Native Connection"
{{#include docs-examples/java/src/main/java/com/taos/example/JNIConnectExample.java}}
{{#include docs/examples/java/src/main/java/com/taos/example/JNIConnectExample.java}}
```
```java title="REST Connection"
{{#include docs-examples/java/src/main/java/com/taos/example/RESTConnectExample.java:main}}
{{#include docs/examples/java/src/main/java/com/taos/example/RESTConnectExample.java:main}}
```
When using REST connection, the feature of bulk pulling can be enabled if the size of resulting data set is huge.
```java title="Enable Bulk Pulling" {4}
{{#include docs-examples/java/src/main/java/com/taos/example/WSConnectExample.java:main}}
{{#include docs/examples/java/src/main/java/com/taos/example/WSConnectExample.java:main}}
```
More configuration about connection,please refer to [Java Connector](/reference/connector/java)
```js title="Native Connection"
{{#include docs-examples/node/nativeexample/connect.js}}
{{#include docs/examples/node/nativeexample/connect.js}}
```
```js title="REST Connection"
{{#include docs-examples/node/restexample/connect.js}}
{{#include docs/examples/node/restexample/connect.js}}
```
```python title="Native Connection"
{{#include docs-examples/python/connect_example.py}}
{{#include docs/examples/python/connect_example.py}}
```
```r title="Native Connection"
{{#include docs-examples/R/connect_native.r:demo}}
{{#include docs/examples/R/connect_native.r:demo}}
```
```rust title="Native Connection/REST Connection"
{{#include docs-examples/rust/nativeexample/examples/connect.rs}}
{{#include docs/examples/rust/nativeexample/examples/connect.rs}}
```
:::note
......
......@@ -37,7 +37,7 @@ USE power;
## Create STable
In a time-series application, there may be multiple kinds of data collection points. For example, in the electrical power system there are meters, transformers, bus bars, switches, etc. For easy and efficient aggregation of multiple tables, one STable needs to be created for each kind of data collection point. For example, for the meters in [table 1](/tdinternal/arch#model_table1), the SQL statement below can be used to create the super table.
In a time-series application, there may be multiple kinds of data collection points. For example, in the electrical power system there are meters, transformers, bus bars, switches, etc. For easy and efficient aggregation of multiple tables, one STable needs to be created for each kind of data collection point. For example, for the meters in [table 1](/concept/#model_table1), the SQL statement below can be used to create the super table.
```sql
CREATE STable meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int);
......
......@@ -22,7 +22,7 @@ import CStmt from "./_c_stmt.mdx";
## Introduction
Application programs can execute `INSERT` statement through connectors to insert rows. The TAOS CLI can also be used to manually insert data.
Application programs can execute `INSERT` statement through connectors to insert rows. The TDengine CLI can also be used to manually insert data.
### Insert Single Row
......
```c
{{#include docs/examples/c/line_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs/examples/c/json_protocol_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs/examples/c/telnet_line_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs/examples/c/insert_example.c}}
```
\ No newline at end of file
```c title=Single Row Binding
{{#include docs-examples/c/stmt_example.c}}
{{#include docs/examples/c/stmt_example.c}}
```
```c title=Multiple Row Binding 72:117
{{#include docs-examples/c/multi_bind_example.c}}
{{#include docs/examples/c/multi_bind_example.c}}
```
\ No newline at end of file
```csharp
{{#include docs/examples/csharp/InfluxDBLineExample.cs}}
```
```csharp
{{#include docs/examples/csharp/OptsJsonExample.cs}}
```
```csharp
{{#include docs/examples/csharp/OptsTelnetExample.cs}}
```
```csharp
{{#include docs/examples/csharp/SQLInsertExample.cs}}
```
```csharp
{{#include docs/examples/csharp/StmtInsertExample.cs}}
```
```go
{{#include docs/examples/go/insert/line/main.go}}
```
```go
{{#include docs/examples/go/insert/json/main.go}}
```
```go
{{#include docs/examples/go/insert/telnet/main.go}}
```
```go
{{#include docs/examples/go/insert/sql/main.go}}
```
```go
{{#include docs-examples/go/insert/stmt/main.go}}
{{#include docs/examples/go/insert/stmt/main.go}}
```
:::tip
......
```java
{{#include docs-examples/java/src/main/java/com/taos/example/LineProtocolExample.java}}
{{#include docs/examples/java/src/main/java/com/taos/example/LineProtocolExample.java}}
```
```java
{{#include docs-examples/java/src/main/java/com/taos/example/JSONProtocolExample.java}}
{{#include docs/examples/java/src/main/java/com/taos/example/JSONProtocolExample.java}}
```
```java
{{#include docs-examples/java/src/main/java/com/taos/example/TelnetLineProtocolExample.java}}
{{#include docs/examples/java/src/main/java/com/taos/example/TelnetLineProtocolExample.java}}
```
```java
{{#include docs-examples/java/src/main/java/com/taos/example/RestInsertExample.java:insert}}
{{#include docs/examples/java/src/main/java/com/taos/example/RestInsertExample.java:insert}}
```
\ No newline at end of file
```java
{{#include docs-examples/java/src/main/java/com/taos/example/StmtInsertExample.java}}
{{#include docs/examples/java/src/main/java/com/taos/example/StmtInsertExample.java}}
```
```js
{{#include docs/examples/node/nativeexample/influxdb_line_example.js}}
```
```js
{{#include docs/examples/node/nativeexample/opentsdb_json_example.js}}
```
```js
{{#include docs/examples/node/nativeexample/opentsdb_telnet_example.js}}
```
```js
{{#include docs/examples/node/nativeexample/insert_example.js}}
```
```js title=Single Row Binding
{{#include docs-examples/node/nativeexample/param_bind_example.js}}
{{#include docs/examples/node/nativeexample/param_bind_example.js}}
```
```js title=Multiple Row Binding
{{#include docs-examples/node/nativeexample/multi_bind_example.js:insertData}}
{{#include docs/examples/node/nativeexample/multi_bind_example.js:insertData}}
```
:::info
......
```py
{{#include docs/examples/python/line_protocol_example.py}}
```
```py
{{#include docs/examples/python/json_protocol_example.py}}
```
```py
{{#include docs/examples/python/telnet_line_protocol_example.py}}
```
```py
{{#include docs/examples/python/native_insert_example.py}}
```
```py title=Single Row Binding
{{#include docs-examples/python/bind_param_example.py}}
{{#include docs/examples/python/bind_param_example.py}}
```
```py title=Multiple Row Binding
{{#include docs-examples/python/multi_bind_example.py:bind_batch}}
{{#include docs/examples/python/multi_bind_example.py:bind_batch}}
```
:::info
......
```rust
{{#include docs-examples/rust/schemalessexample/examples/influxdb_line_example.rs}}
{{#include docs/examples/rust/schemalessexample/examples/influxdb_line_example.rs}}
```
```rust
{{#include docs-examples/rust/schemalessexample/examples/opentsdb_json_example.rs}}
{{#include docs/examples/rust/schemalessexample/examples/opentsdb_json_example.rs}}
```
```rust
{{#include docs-examples/rust/schemalessexample/examples/opentsdb_telnet_example.rs}}
{{#include docs/examples/rust/schemalessexample/examples/opentsdb_telnet_example.rs}}
```
```rust
{{#include docs/examples/rust/restexample/examples/insert_example.rs}}
```
```rust
{{#include docs/examples/rust/nativeexample/examples/stmt_example.rs}}
```
```c
{{#include docs/examples/c/query_example.c}}
```
\ No newline at end of file
```c
{{#include docs/examples/c/async_query_example.c:demo}}
```
\ No newline at end of file
```csharp
{{#include docs/examples/csharp/QueryExample.cs}}
```
```csharp
{{#include docs/examples/csharp/AsyncQueryExample.cs}}
```
```go
{{#include docs/examples/go/query/sync/main.go}}
```
```go
{{#include docs/examples/go/query/async/main.go}}
```
```java
{{#include docs-examples/java/src/main/java/com/taos/example/RestQueryExample.java}}
{{#include docs/examples/java/src/main/java/com/taos/example/RestQueryExample.java}}
```
```js
{{#include docs/examples/node/nativeexample/query_example.js}}
```
```js
{{#include docs/examples/node/nativeexample/async_query_example.js}}
```
Result set is iterated row by row.
```py
{{#include docs-examples/python/query_example.py:iter}}
{{#include docs/examples/python/query_example.py:iter}}
```
Result set is retrieved as a whole, each row is converted to a dict and returned.
```py
{{#include docs-examples/python/query_example.py:fetch_all}}
{{#include docs/examples/python/query_example.py:fetch_all}}
```
\ No newline at end of file
```py
{{#include docs-examples/python/async_query_example.py}}
{{#include docs/examples/python/async_query_example.py}}
```
:::note
......
```rust
{{#include docs/examples/rust/restexample/examples/query_example.rs}}
```
```c
{{#include docs/examples/c/subscribe_demo.c}}
```
\ No newline at end of file
```csharp
{{#include docs/examples/csharp/SubscribeDemo.cs}}
```
\ No newline at end of file
```go
{{#include docs/examples/go/sub/main.go}}
```
\ No newline at end of file
```java
{{#include docs-examples/java/src/main/java/com/taos/example/SubscribeDemo.java}}
{{#include docs/examples/java/src/main/java/com/taos/example/SubscribeDemo.java}}
```
:::note
For now Java connector doesn't provide asynchronous subscription, but `TimerTask` can be used to achieve similar purpose.
......
```js
{{#include docs/examples/node/nativeexample/subscribe_demo.js}}
```
\ No newline at end of file
```py
{{#include docs/examples/python/subscribe_demo.py}}
```
\ No newline at end of file
```rs
{{#include docs/examples/rust/nativeexample/examples/subscribe_demo.rs}}
```
\ No newline at end of file
......@@ -4,50 +4,275 @@ title: Keywords
There are about 200 keywords reserved by TDengine, they can't be used as the name of database, STable or table with either upper case, lower case or mixed case.
**Keywords List**
| | | | | |
| ----------- | ---------- | --------- | ---------- | ------------ |
| ABORT | CREATE | IGNORE | NULL | STAR |
| ACCOUNT | CTIME | IMMEDIATE | OF | STATE |
| ACCOUNTS | DATABASE | IMPORT | OFFSET | STATEMENT |
| ADD | DATABASES | IN | OR | STATE_WINDOW |
| AFTER | DAYS | INITIALLY | ORDER | STORAGE |
| ALL | DBS | INSERT | PARTITIONS | STREAM |
| ALTER | DEFERRED | INSTEAD | PASS | STREAMS |
| AND | DELIMITERS | INT | PLUS | STRING |
| AS | DESC | INTEGER | PPS | SYNCDB |
| ASC | DESCRIBE | INTERVAL | PRECISION | TABLE |
| ATTACH | DETACH | INTO | PREV | TABLES |
| BEFORE | DISTINCT | IS | PRIVILEGE | TAG |
| BEGIN | DIVIDE | ISNULL | QTIME | TAGS |
| BETWEEN | DNODE | JOIN | QUERIES | TBNAME |
| BIGINT | DNODES | KEEP | QUERY | TIMES |
| BINARY | DOT | KEY | QUORUM | TIMESTAMP |
| BITAND | DOUBLE | KILL | RAISE | TINYINT |
| BITNOT | DROP | LE | REM | TOPIC |
| BITOR | EACH | LIKE | REPLACE | TOPICS |
| BLOCKS | END | LIMIT | REPLICA | TRIGGER |
| BOOL | EQ | LINEAR | RESET | TSERIES |
| BY | EXISTS | LOCAL | RESTRICT | UMINUS |
| CACHE | EXPLAIN | LP | ROW | UNION |
| CACHELAST | FAIL | LSHIFT | RP | UNSIGNED |
| CASCADE | FILE | LT | RSHIFT | UPDATE |
| CHANGE | FILL | MATCH | SCORES | UPLUS |
| CLUSTER | FLOAT | MAXROWS | SELECT | USE |
| COLON | FOR | MINROWS | SEMI | USER |
| COLUMN | FROM | MINUS | SESSION | USERS |
| COMMA | FSYNC | MNODES | SET | USING |
| COMP | GE | MODIFY | SHOW | VALUES |
| COMPACT | GLOB | MODULES | SLASH | VARIABLE |
| CONCAT | GRANTS | NCHAR | SLIDING | VARIABLES |
| CONFLICT | GROUP | NE | SLIMIT | VGROUPS |
| CONNECTION | GT | NONE | SMALLINT | VIEW |
| CONNECTIONS | HAVING | NOT | SOFFSET | VNODES |
| CONNS | ID | NOTNULL | STable | WAL |
| COPY | IF | NOW | STableS | WHERE |
| _C0 | _QSTART | _QSTOP | _QDURATION | _WSTART |
| _WSTOP | _WDURATION |
## Keyword List
### A
- ABORT
- ACCOUNT
- ACCOUNTS
- ADD
- AFTER
- ALL
- ALTER
- AND
- AS
- ASC
- ATTACH
### B
- BEFORE
- BEGIN
- BETWEEN
- BIGINT
- BINARY
- BITAND
- BITNOT
- BITOR
- BLOCKS
- BOOL
- BY
### C
- CACHE
- CACHELAST
- CASCADE
- CHANGE
- CLUSTER
- COLON
- COLUMN
- COMMA
- COMP
- COMPACT
- CONCAT
- CONFLICT
- CONNECTION
- CONNECTIONS
- CONNS
- COPY
- CREATE
- CTIME
### D
- DATABASE
- DATABASES
- DAYS
- DBS
- DEFERRED
- DELIMITERS
- DELETE
- DESC
- DESCRIBE
- DETACH
- DISTINCT
- DIVIDE
- DNODE
- DNODES
- DOT
- DOUBLE
- DROP
### E
- END
- EQ
- EXISTS
- EXPLAIN
### F
- FAIL
- FILE
- FILL
- FLOAT
- FOR
- FROM
- FSYNC
### G
- GE
- GLOB
- GRANTS
- GROUP
- GT
### H
- HAVING
### I
- ID
- IF
- IGNORE
- IMMEDIA
- IMPORT
- IN
- INITIAL
- INSERT
- INSTEAD
- INT
- INTEGER
- INTERVA
- INTO
- IS
- ISNULL
### J
- JOIN
### K
- KEEP
- KEY
- KILL
### L
- LE
- LIKE
- LIMIT
- LINEAR
- LOCAL
- LP
- LSHIFT
- LT
### M
- MATCH
- MAXROWS
- MINROWS
- MINUS
- MNODES
- MODIFY
- MODULES
### N
- NE
- NONE
- NOT
- NOTNULL
- NOW
- NULL
### O
- OF
- OFFSET
- OR
- ORDER
### P
- PARTITION
- PASS
- PLUS
- PPS
- PRECISION
- PREV
- PRIVILEGE
### Q
- QTIME
- QUERIE
- QUERY
- QUORUM
### R
- RAISE
- REM
- REPLACE
- REPLICA
- RESET
- RESTRIC
- ROW
- RP
- RSHIFT
### S
- SCORES
- SELECT
- SEMI
- SESSION
- SET
- SHOW
- SLASH
- SLIDING
- SLIMIT
- SMALLIN
- SOFFSET
- STable
- STableS
- STAR
- STATE
- STATEMEN
- STATE_WI
- STORAGE
- STREAM
- STREAMS
- STRING
- SYNCDB
### T
- TABLE
- TABLES
- TAG
- TAGS
- TBNAME
- TIMES
- TIMESTAMP
- TINYINT
- TOPIC
- TOPICS
- TRIGGER
- TSERIES
### U
- UMINUS
- UNION
- UNSIGNED
- UPDATE
- UPLUS
- USE
- USER
- USERS
- USING
### V
- VALUES
- VARIABLE
- VARIABLES
- VGROUPS
- VIEW
- VNODES
### W
- WAL
- WHERE
### _
- _C0
- _QSTART
- _QSTOP
- _QDURATION
- _WSTART
- _WSTOP
- _WDURATION
## Explanations
### TBNAME
......@@ -56,6 +281,7 @@ There are about 200 keywords reserved by TDengine, they can't be used as the nam
Get the table name and tag values of all subtables in a STable.
```mysql
SELECT TBNAME, location FROM meters;
```
Count the number of subtables in a STable.
```mysql
......
......@@ -91,7 +91,7 @@ In this section a few sample programs which use TDengine PHP connector to access
<summary>Establish Connection</summary>
```c
{{#include docs-examples/php/connect.php}}
{{#include docs/examples/php/connect.php}}
```
</details>
......@@ -102,7 +102,7 @@ In this section a few sample programs which use TDengine PHP connector to access
<summary>Insert Data</summary>
```c
{{#include docs-examples/php/insert.php}}
{{#include docs/examples/php/insert.php}}
```
</details>
......@@ -113,7 +113,7 @@ In this section a few sample programs which use TDengine PHP connector to access
<summary>Synchronous Query</summary>
```c
{{#include docs-examples/php/query.php}}
{{#include docs/examples/php/query.php}}
```
</details>
......@@ -124,7 +124,7 @@ In this section a few sample programs which use TDengine PHP connector to access
<summary>Parameter Binding</summary>
```c
{{#include docs-examples/php/insert_stmt.php}}
{{#include docs/examples/php/insert_stmt.php}}
```
</details>
......
......@@ -169,7 +169,7 @@ The following example code assumes that TDengine is installed locally and that t
<TabItem value="native" label="native connection" groupId="connect">
```python
{{#include docs-examples/python/connect_native_reference.py}}
{{#include docs/examples/python/connect_native_reference.py}}
```
All arguments of the `connect()` function are optional keyword arguments. The following are the connection parameters specified.
......@@ -194,7 +194,7 @@ The `connect()` function returns a `taos.TaosConnection` instance. In client-sid
<TabItem value="rest" label="REST connection">
```python
{{#include docs-examples/python/connect_rest_examples.py:connect}}
{{#include docs/examples/python/connect_rest_examples.py:connect}}
```
All arguments to the `connect()` function are optional keyword arguments. The following are the connection parameters specified.
......@@ -219,11 +219,11 @@ All arguments to the `connect()` function are optional keyword arguments. The fo
The `TaosConnection` class contains both an implementation of the PEP249 Connection interface (e.g., the `cursor()` method and the `close()` method) and many extensions (e.g., the `execute()`, `query()`, `schemaless_insert()`, and `subscribe()` methods).
```python title="execute method"
{{#include docs-examples/python/connection_usage_native_reference.py:insert}}
{{#include docs/examples/python/connection_usage_native_reference.py:insert}}
```
```python title="query method"
{{#include docs-examples/python/connection_usage_native_reference.py:query}}
{{#include docs/examples/python/connection_usage_native_reference.py:query}}
```
:::tip
......@@ -235,14 +235,14 @@ The queried results can only be fetched once. For example, only one of `fetch_al
In the above example of using the `TaosConnection` class, we have shown two ways to get the result of a query: `fetch_all()` and `fetch_all_into_dict()`. In addition, `TaosResult` also provides methods to iterate through the result set by rows (`rows_iter`) or by data blocks (`blocks_iter`). Using these two methods will be more efficient in scenarios where the query has a large amount of data.
```python title="blocks_iter method"
{{#include docs-examples/python/result_set_examples.py}}
{{#include docs/examples/python/result_set_examples.py}}
```
##### Use of the TaosCursor class
The `TaosConnection` class and the `TaosResult` class already implement all the functionality of the native interface. If you are familiar with the interfaces in the PEP249 specification, you can also use the methods provided by the `TaosCursor` class.
```python title="Use of TaosCursor"
{{#include docs-examples/python/cursor_usage_native_reference.py}}
{{#include docs/examples/python/cursor_usage_native_reference.py}}
```
:::note
......@@ -258,7 +258,7 @@ The TaosCursor class uses native connections for write and query operations. In
The ``TaosRestCursor`` class is an implementation of the PEP249 Cursor interface.
```python title="Use of TaosRestCursor"
{{#include docs-examples/python/connect_rest_examples.py:basic}}
{{#include docs/examples/python/connect_rest_examples.py:basic}}
```
- `cursor.execute` : Used to execute arbitrary SQL statements.
- `cursor.rowcount` : For write operations, returns the number of successful rows written. For query operations, returns the number of rows in the result set.
......@@ -269,7 +269,7 @@ The ``TaosRestCursor`` class is an implementation of the PEP249 Cursor interface
The `RestClient` class is a direct wrapper for the [REST API](/reference/rest-api). It contains only a `sql()` method for executing arbitrary SQL statements and returning the result.
```python title="Use of RestClient"
{{#include docs-examples/python/rest_client_example.py}}
{{#include docs/examples/python/rest_client_example.py}}
```
For a more detailed description of the `sql()` method, please refer to [RestClient](https://docs.taosdata.com/api/taospy/taosrest/restclient.html).
......@@ -283,14 +283,14 @@ For a more detailed description of the `sql()` method, please refer to [RestClie
<TabItem value="native" label="native connection">
```python
{{#include docs-examples/python/conn_native_pandas.py}}
{{#include docs/examples/python/conn_native_pandas.py}}
```
</TabItem>
<TabItem value="rest" label="REST connection">
```python
{{#include docs-examples/python/conn_rest_pandas.py}}
{{#include docs/examples/python/conn_rest_pandas.py}}
```
</TabItem>
......@@ -314,7 +314,7 @@ For a more detailed description of the `sql()` method, please refer to [RestClie
All errors from database operations are thrown directly as exceptions and the error message from the database is passed up the exception stack. The application is responsible for exception handling. For example:
```python
{{#include docs-examples/python/handle_exception.py}}
{{#include docs/examples/python/handle_exception.py}}
```
### About nanoseconds
......
......@@ -40,6 +40,16 @@ export TDENGINE_API=http://tdengine.local:6041
# user + password
export TDENGINE_USER=user
export TDENGINE_PASSWORD=password
# Other useful variables
# - If to install TDengine data source, default is true
export TDENGINE_DS_ENABLED=false
# - Data source name to be created, default is TDengine
export TDENGINE_DS_NAME=TDengine
# - Data source organization id, default is 1
export GF_ORG_ID=1
# - Data source is editable in admin ui or not, default is 0 (false)
export TDENGINE_EDITABLE=1
```
Run `install.sh`:
......@@ -48,7 +58,7 @@ Run `install.sh`:
bash -c "$(curl -fsSL https://raw.githubusercontent.com/taosdata/grafanaplugin/master/install.sh)"
```
With this script, TDengine data source plugin and the Grafana data source will be installed and created automatically with Grafana provisioning configurations.
With this script, TDengine data source plugin and the Grafana data source will be installed and created automatically with Grafana provisioning configurations. Save the script and type `./install.sh --help` for the full usage of the script.
And then, restart Grafana service and open Grafana in web-browser, usually <http://localhost:3000>.
......
......@@ -108,7 +108,7 @@ Finally, click the "Create" button at bottom left corner saving the rule.
## Compose program to mock data
```javascript
{{#include docs-examples/other/mock.js}}
{{#include docs/examples/other/mock.js}}
```
Note: `CLIENT_NUM` in the code can be set to a smaller value at the beginning of the test to avoid hardware performance be not capable to handle a more significant number of concurrent clients.
......
......@@ -2,6 +2,8 @@
title: 2.4
---
[2.4.0.26](https://github.com/taosdata/TDengine/releases/tag/ver-2.4.0.26)
[2.4.0.25](https://github.com/taosdata/TDengine/releases/tag/ver-2.4.0.25)
[2.4.0.24](https://github.com/taosdata/TDengine/releases/tag/ver-2.4.0.24)
......
---
title: 立即开始
description: ' Docker,安装包或使用 apt-get 快速安装 TDengine, 通过命令行程序TAOS CLI和工具 taosdemo 快速体验 TDengine 功能'
description: ' Docker,安装包或使用 apt-get 快速安装 TDengine, 通过命令行程序TDengine CLI和工具 taosdemo 快速体验 TDengine 功能'
---
import Tabs from "@theme/Tabs";
......@@ -122,7 +122,7 @@ select * from t;
Query OK, 2 row(s) in set (0.003128s)
```
除执行 SQL 语句外,系统管理员还可以从 TDengine CLI 进行检查系统运行状态、添加删除用户账号等操作。TAOS CLI 连同应用驱动也可以独立安装在 Linux 或 Windows 机器上运行,更多细节请参考 [这里](../reference/taos-shell/)
除执行 SQL 语句外,系统管理员还可以从 TDengine CLI 进行检查系统运行状态、添加删除用户账号等操作。TDengine CLI 连同应用驱动也可以独立安装在 Linux 或 Windows 机器上运行,更多细节请参考 [这里](../reference/taos-shell/)
## 使用 taosBenchmark 体验写入速度
......
```c title="原生连接"
{{#include docs-examples/c/connect_example.c}}
{{#include docs/examples/c/connect_example.c}}
```
```csharp title="原生连接"
{{#include docs-examples/csharp/ConnectExample.cs}}
{{#include docs/examples/csharp/ConnectExample.cs}}
```
:::info
......
#### 使用数据库访问统一接口
```go title="原生连接"
{{#include docs-examples/go/connect/cgoexample/main.go}}
{{#include docs/examples/go/connect/cgoexample/main.go}}
```
```go title="REST 连接"
{{#include docs-examples/go/connect/restexample/main.go}}
{{#include docs/examples/go/connect/restexample/main.go}}
```
#### 使用高级封装
......@@ -13,5 +13,5 @@
也可以使用 driver-go 的 af 包建立连接。这个模块封装了 TDengine 的高级功能, 如:参数绑定、订阅等。
```go title="使用 af 包建立原生连接"
{{#include docs-examples/go/connect/afconn/main.go}}
{{#include docs/examples/go/connect/afconn/main.go}}
```
```java title="原生连接"
{{#include docs-examples/java/src/main/java/com/taos/example/JNIConnectExample.java}}
{{#include docs/examples/java/src/main/java/com/taos/example/JNIConnectExample.java}}
```
```java title="REST 连接"
{{#include docs-examples/java/src/main/java/com/taos/example/RESTConnectExample.java:main}}
{{#include docs/examples/java/src/main/java/com/taos/example/RESTConnectExample.java:main}}
```
使用 REST 连接时,如果查询数据量比较大,还可开启批量拉取功能。
```java title="开启批量拉取功能" {4}
{{#include docs-examples/java/src/main/java/com/taos/example/WSConnectExample.java:main}}
{{#include docs/examples/java/src/main/java/com/taos/example/WSConnectExample.java:main}}
```
更多连接参数配置,参考[Java 连接器](/reference/connector/java)
```js title="原生连接"
{{#include docs-examples/node/nativeexample/connect.js}}
{{#include docs/examples/node/nativeexample/connect.js}}
```
```js title="REST 连接"
{{#include docs-examples/node/restexample/connect.js}}
{{#include docs/examples/node/restexample/connect.js}}
```
```php title="原生连接"
{{#include docs-examples/php/connect.php}}
{{#include docs/examples/php/connect.php}}
```
```python title="原生连接"
{{#include docs-examples/python/connect_example.py}}
{{#include docs/examples/python/connect_example.py}}
```
```r title="原生连接"
{{#include docs-examples/R/connect_native.r:demo}}
{{#include docs/examples/R/connect_native.r:demo}}
```
```rust title="原生连接/REST 连接"
{{#include docs-examples/rust/nativeexample/examples/connect.rs}}
{{#include docs/examples/rust/nativeexample/examples/connect.rs}}
```
:::note
......
```c
{{#include docs/examples/c/line_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs/examples/c/json_protocol_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs/examples/c/telnet_line_example.c:main}}
```
\ No newline at end of file
```c
{{#include docs/examples/c/insert_example.c}}
```
\ No newline at end of file
```c title=一次绑定一行
{{#include docs-examples/c/stmt_example.c}}
{{#include docs/examples/c/stmt_example.c}}
```
```c title=一次绑定多行 72:117
{{#include docs-examples/c/multi_bind_example.c}}
{{#include docs/examples/c/multi_bind_example.c}}
```
\ No newline at end of file
```csharp
{{#include docs/examples/csharp/InfluxDBLineExample.cs}}
```
```csharp
{{#include docs/examples/csharp/OptsJsonExample.cs}}
```
```csharp
{{#include docs/examples/csharp/OptsTelnetExample.cs}}
```
```csharp
{{#include docs/examples/csharp/SQLInsertExample.cs}}
```
```csharp
{{#include docs/examples/csharp/StmtInsertExample.cs}}
```
```go
{{#include docs/examples/go/insert/line/main.go}}
```
```go
{{#include docs/examples/go/insert/json/main.go}}
```
```go
{{#include docs/examples/go/insert/telnet/main.go}}
```
```go
{{#include docs/examples/go/insert/sql/main.go}}
```
```go
{{#include docs-examples/go/insert/stmt/main.go}}
{{#include docs/examples/go/insert/stmt/main.go}}
```
:::tip
......
```java
{{#include docs-examples/java/src/main/java/com/taos/example/LineProtocolExample.java}}
{{#include docs/examples/java/src/main/java/com/taos/example/LineProtocolExample.java}}
```
```java
{{#include docs-examples/java/src/main/java/com/taos/example/JSONProtocolExample.java}}
{{#include docs/examples/java/src/main/java/com/taos/example/JSONProtocolExample.java}}
```
```java
{{#include docs-examples/java/src/main/java/com/taos/example/TelnetLineProtocolExample.java}}
{{#include docs/examples/java/src/main/java/com/taos/example/TelnetLineProtocolExample.java}}
```
```java
{{#include docs-examples/java/src/main/java/com/taos/example/RestInsertExample.java:insert}}
{{#include docs/examples/java/src/main/java/com/taos/example/RestInsertExample.java:insert}}
```
\ No newline at end of file
```java
{{#include docs-examples/java/src/main/java/com/taos/example/StmtInsertExample.java}}
{{#include docs/examples/java/src/main/java/com/taos/example/StmtInsertExample.java}}
```
```js
{{#include docs/examples/node/nativeexample/influxdb_line_example.js}}
```
```js
{{#include docs/examples/node/nativeexample/opentsdb_json_example.js}}
```
```js
{{#include docs/examples/node/nativeexample/opentsdb_telnet_example.js}}
```
```js
{{#include docs/examples/node/nativeexample/insert_example.js}}
```
```js title=一次绑定一行
{{#include docs-examples/node/nativeexample/param_bind_example.js}}
{{#include docs/examples/node/nativeexample/param_bind_example.js}}
```
```js title=一次绑定多行
{{#include docs-examples/node/nativeexample/multi_bind_example.js:insertData}}
{{#include docs/examples/node/nativeexample/multi_bind_example.js:insertData}}
```
:::info
......
```php
{{#include docs/examples/php/insert.php}}
```
```php
{{#include docs/examples/php/insert_stmt.php}}
```
```py
{{#include docs/examples/python/line_protocol_example.py}}
```
```py
{{#include docs/examples/python/json_protocol_example.py}}
```
```py
{{#include docs/examples/python/telnet_line_protocol_example.py}}
```
```py
{{#include docs/examples/python/native_insert_example.py}}
```
```py title=一次绑定一行
{{#include docs-examples/python/bind_param_example.py}}
{{#include docs/examples/python/bind_param_example.py}}
```
```py title=一次绑定多行
{{#include docs-examples/python/multi_bind_example.py:bind_batch}}
{{#include docs/examples/python/multi_bind_example.py:bind_batch}}
```
:::info
......
```rust
{{#include docs-examples/rust/schemalessexample/examples/influxdb_line_example.rs}}
{{#include docs/examples/rust/schemalessexample/examples/influxdb_line_example.rs}}
```
```rust
{{#include docs-examples/rust/schemalessexample/examples/opentsdb_json_example.rs}}
{{#include docs/examples/rust/schemalessexample/examples/opentsdb_json_example.rs}}
```
```rust
{{#include docs-examples/rust/schemalessexample/examples/opentsdb_telnet_example.rs}}
{{#include docs/examples/rust/schemalessexample/examples/opentsdb_telnet_example.rs}}
```
```rust
{{#include docs/examples/rust/restexample/examples/insert_example.rs}}
```
```rust
{{#include docs/examples/rust/nativeexample/examples/stmt_example.rs}}
```
```c
{{#include docs/examples/c/query_example.c}}
```
\ No newline at end of file
```c
{{#include docs/examples/c/async_query_example.c:demo}}
```
\ No newline at end of file
```csharp
{{#include docs/examples/csharp/QueryExample.cs}}
```
```csharp
{{#include docs/examples/csharp/AsyncQueryExample.cs}}
```
```go
{{#include docs/examples/go/query/sync/main.go}}
```
```go
{{#include docs/examples/go/query/async/main.go}}
```
```java
{{#include docs-examples/java/src/main/java/com/taos/example/RestQueryExample.java}}
{{#include docs/examples/java/src/main/java/com/taos/example/RestQueryExample.java}}
```
```js
{{#include docs/examples/node/nativeexample/query_example.js}}
```
```js
{{#include docs/examples/node/nativeexample/async_query_example.js}}
```
```go
{{#include docs/examples/php/query.php}}
```
通过迭代逐行获取查询结果。
```py
{{#include docs-examples/python/query_example.py:iter}}
{{#include docs/examples/python/query_example.py:iter}}
```
一次获取所有查询结果,并把每一行转化为一个字典返回。
```py
{{#include docs-examples/python/query_example.py:fetch_all}}
{{#include docs/examples/python/query_example.py:fetch_all}}
```
```py
{{#include docs-examples/python/async_query_example.py}}
{{#include docs/examples/python/async_query_example.py}}
```
:::note
......
```rust
{{#include docs/examples/rust/restexample/examples/query_example.rs}}
```
```c
{{#include docs/examples/c/subscribe_demo.c}}
```
\ No newline at end of file
```csharp
{{#include docs/examples/csharp/SubscribeDemo.cs}}
```
\ No newline at end of file
```go
{{#include docs/examples/go/sub/main.go}}
```
\ No newline at end of file
```java
{{#include docs-examples/java/src/main/java/com/taos/example/SubscribeDemo.java}}
{{#include docs/examples/java/src/main/java/com/taos/example/SubscribeDemo.java}}
```
:::note
目前 Java 接口没有提供异步订阅模式,但用户程序可以通过创建 `TimerTask` 等方式达到同样的效果。
......
```js
{{#include docs/examples/node/nativeexample/subscribe_demo.js}}
```
\ No newline at end of file
```py
{{#include docs/examples/python/subscribe_demo.py}}
```
\ No newline at end of file
```rs
{{#include docs/examples/rust/nativeexample/examples/subscribe_demo.rs}}
```
\ No newline at end of file
......@@ -45,48 +45,274 @@ title: TDengine 参数限制与保留关键字
目前 TDengine 有将近 200 个内部保留关键字,这些关键字无论大小写均不可以用作库名、表名、STable 名、数据列名及标签列名等。这些关键字列表如下:
| 关键字列表 | | | | |
| ----------- | ---------- | --------- | ---------- | ------------ |
| ABORT | CREATE | IGNORE | NULL | STAR |
| ACCOUNT | CTIME | IMMEDIATE | OF | STATE |
| ACCOUNTS | DATABASE | IMPORT | OFFSET | STATEMENT |
| ADD | DATABASES | IN | OR | STATE_WINDOW |
| AFTER | DAYS | INITIALLY | ORDER | STORAGE |
| ALL | DBS | INSERT | PARTITIONS | STREAM |
| ALTER | DEFERRED | INSTEAD | PASS | STREAMS |
| AND | DELIMITERS | INT | PLUS | STRING |
| AS | DESC | INTEGER | PPS | SYNCDB |
| ASC | DESCRIBE | INTERVAL | PRECISION | TABLE |
| ATTACH | DETACH | INTO | PREV | TABLES |
| BEFORE | DISTINCT | IS | PRIVILEGE | TAG |
| BEGIN | DIVIDE | ISNULL | QTIME | TAGS |
| BETWEEN | DNODE | JOIN | QUERIES | TBNAME |
| BIGINT | DNODES | KEEP | QUERY | TIMES |
| BINARY | DOT | KEY | QUORUM | TIMESTAMP |
| BITAND | DOUBLE | KILL | RAISE | TINYINT |
| BITNOT | DROP | LE | REM | TOPIC |
| BITOR | EACH | LIKE | REPLACE | TOPICS |
| BLOCKS | END | LIMIT | REPLICA | TRIGGER |
| BOOL | EQ | LINEAR | RESET | TSERIES |
| BY | EXISTS | LOCAL | RESTRICT | UMINUS |
| CACHE | EXPLAIN | LP | ROW | UNION |
| CACHELAST | FAIL | LSHIFT | RP | UNSIGNED |
| CASCADE | FILE | LT | RSHIFT | UPDATE |
| CHANGE | FILL | MATCH | SCORES | UPLUS |
| CLUSTER | FLOAT | MAXROWS | SELECT | USE |
| COLON | FOR | MINROWS | SEMI | USER |
| COLUMN | FROM | MINUS | SESSION | USERS |
| COMMA | FSYNC | MNODES | SET | USING |
| COMP | GE | MODIFY | SHOW | VALUES |
| COMPACT | GLOB | MODULES | SLASH | VARIABLE |
| CONCAT | GRANTS | NCHAR | SLIDING | VARIABLES |
| CONFLICT | GROUP | NE | SLIMIT | VGROUPS |
| CONNECTION | GT | NONE | SMALLINT | VIEW |
| CONNECTIONS | HAVING | NOT | SOFFSET | VNODES |
| CONNS | ID | NOTNULL | STABLE | WAL |
| COPY | IF | NOW | STABLES | WHERE |
| _C0 | _QSTART | _QSTOP | _QDURATION | _WSTART |
| _WSTOP | _WDURATION |
### A
- ABORT
- ACCOUNT
- ACCOUNTS
- ADD
- AFTER
- ALL
- ALTER
- AND
- AS
- ASC
- ATTACH
### B
- BEFORE
- BEGIN
- BETWEEN
- BIGINT
- BINARY
- BITAND
- BITNOT
- BITOR
- BLOCKS
- BOOL
- BY
### C
- CACHE
- CACHELAST
- CASCADE
- CHANGE
- CLUSTER
- COLON
- COLUMN
- COMMA
- COMP
- COMPACT
- CONCAT
- CONFLICT
- CONNECTION
- CONNECTIONS
- CONNS
- COPY
- CREATE
- CTIME
### D
- DATABASE
- DATABASES
- DAYS
- DBS
- DEFERRED
- DELETE
- DELIMITERS
- DESC
- DESCRIBE
- DETACH
- DISTINCT
- DIVIDE
- DNODE
- DNODES
- DOT
- DOUBLE
- DROP
### E
- END
- EQ
- EXISTS
- EXPLAIN
### F
- FAIL
- FILE
- FILL
- FLOAT
- FOR
- FROM
- FSYNC
### G
- GE
- GLOB
- GRANTS
- GROUP
- GT
### H
- HAVING
### I
- ID
- IF
- IGNORE
- IMMEDIA
- IMPORT
- IN
- INITIAL
- INSERT
- INSTEAD
- INT
- INTEGER
- INTERVA
- INTO
- IS
- ISNULL
### J
- JOIN
### K
- KEEP
- KEY
- KILL
### L
- LE
- LIKE
- LIMIT
- LINEAR
- LOCAL
- LP
- LSHIFT
- LT
### M
- MATCH
- MAXROWS
- MINROWS
- MINUS
- MNODES
- MODIFY
- MODULES
### N
- NE
- NONE
- NOT
- NOTNULL
- NOW
- NULL
### O
- OF
- OFFSET
- OR
- ORDER
### P
- PARTITION
- PASS
- PLUS
- PPS
- PRECISION
- PREV
- PRIVILEGE
### Q
- QTIME
- QUERIE
- QUERY
- QUORUM
### R
- RAISE
- REM
- REPLACE
- REPLICA
- RESET
- RESTRIC
- ROW
- RP
- RSHIFT
### S
- SCORES
- SELECT
- SEMI
- SESSION
- SET
- SHOW
- SLASH
- SLIDING
- SLIMIT
- SMALLIN
- SOFFSET
- STable
- STableS
- STAR
- STATE
- STATEMEN
- STATE_WI
- STORAGE
- STREAM
- STREAMS
- STRING
- SYNCDB
### T
- TABLE
- TABLES
- TAG
- TAGS
- TBNAME
- TIMES
- TIMESTAMP
- TINYINT
- TOPIC
- TOPICS
- TRIGGER
- TSERIES
### U
- UMINUS
- UNION
- UNSIGNED
- UPDATE
- UPLUS
- USE
- USER
- USERS
- USING
### V
- VALUES
- VARIABLE
- VARIABLES
- VGROUPS
- VIEW
- VNODES
### W
- WAL
- WHERE
### _
- _C0
- _QSTART
- _QSTOP
- _QDURATION
- _WSTART
- _WSTOP
- _WDURATION
## 特殊说明
### TBNAME
......@@ -95,6 +321,7 @@ title: TDengine 参数限制与保留关键字
获取一个超级表所有的子表名及相关的标签信息:
```mysql
SELECT TBNAME, location FROM meters;
```
统计超级表下辖子表数量:
```mysql
......
......@@ -91,7 +91,7 @@ phpize && ./configure --enable-swoole && make -j && make install
<summary>建立连接</summary>
```c
{{#include docs-examples/php/connect.php}}
{{#include docs/examples/php/connect.php}}
```
</details>
......@@ -102,7 +102,7 @@ phpize && ./configure --enable-swoole && make -j && make install
<summary>插入数据</summary>
```c
{{#include docs-examples/php/insert.php}}
{{#include docs/examples/php/insert.php}}
```
</details>
......@@ -113,7 +113,7 @@ phpize && ./configure --enable-swoole && make -j && make install
<summary>同步查询</summary>
```c
{{#include docs-examples/php/query.php}}
{{#include docs/examples/php/query.php}}
```
</details>
......@@ -124,7 +124,7 @@ phpize && ./configure --enable-swoole && make -j && make install
<summary>参数绑定</summary>
```c
{{#include docs-examples/php/insert_stmt.php}}
{{#include docs/examples/php/insert_stmt.php}}
```
</details>
......
......@@ -169,7 +169,7 @@ curl -u root:taosdata http://<FQDN>:<PORT>/rest/sql -d "select server_version()"
<TabItem value="native" label="原生连接" groupId="connect">
```python
{{#include docs-examples/python/connect_native_reference.py}}
{{#include docs/examples/python/connect_native_reference.py}}
```
`connect` 函数的所有参数都是可选的关键字参数。下面是连接参数的具体说明:
......@@ -194,7 +194,7 @@ curl -u root:taosdata http://<FQDN>:<PORT>/rest/sql -d "select server_version()"
<TabItem value="rest" label="REST 连接">
```python
{{#include docs-examples/python/connect_rest_examples.py:connect}}
{{#include docs/examples/python/connect_rest_examples.py:connect}}
```
`connect()` 函数的所有参数都是可选的关键字参数。下面是连接参数的具体说明:
......@@ -219,11 +219,11 @@ curl -u root:taosdata http://<FQDN>:<PORT>/rest/sql -d "select server_version()"
`TaosConnection` 类既包含对 PEP249 Connection 接口的实现(如:`cursor`方法和 `close` 方法),也包含很多扩展功能(如: `execute`、 `query`、`schemaless_insert` 和 `subscribe` 方法。
```python title="execute 方法"
{{#include docs-examples/python/connection_usage_native_reference.py:insert}}
{{#include docs/examples/python/connection_usage_native_reference.py:insert}}
```
```python title="query 方法"
{{#include docs-examples/python/connection_usage_native_reference.py:query}}
{{#include docs/examples/python/connection_usage_native_reference.py:query}}
```
:::tip
......@@ -235,14 +235,14 @@ curl -u root:taosdata http://<FQDN>:<PORT>/rest/sql -d "select server_version()"
上面 `TaosConnection` 类的使用示例中,我们已经展示了两种获取查询结果的方法: `fetch_all()` 和 `fetch_all_into_dict()`。除此之外 `TaosResult` 还提供了按行迭代(`rows_iter`)或按数据块迭代(`blocks_iter`)结果集的方法。在查询数据量较大的场景,使用这两个方法会更高效。
```python title="blocks_iter 方法"
{{#include docs-examples/python/result_set_examples.py}}
{{#include docs/examples/python/result_set_examples.py}}
```
##### TaosCursor 类的使用
`TaosConnection` 类和 `TaosResult` 类已经实现了原生接口的所有功能。如果你对 PEP249 规范中的接口比较熟悉也可以使用 `TaosCursor` 类提供的方法。
```python title="TaosCursor 的使用"
{{#include docs-examples/python/cursor_usage_native_reference.py}}
{{#include docs/examples/python/cursor_usage_native_reference.py}}
```
:::note
......@@ -258,7 +258,7 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线
`TaosRestCursor` 类是对 PEP249 Cursor 接口的实现。
```python title="TaosRestCursor 的使用"
{{#include docs-examples/python/connect_rest_examples.py:basic}}
{{#include docs/examples/python/connect_rest_examples.py:basic}}
```
- `cursor.execute` : 用来执行任意 SQL 语句。
- `cursor.rowcount`: 对于写入操作返回写入成功记录数。对于查询操作,返回结果集行数。
......@@ -269,7 +269,7 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线
`RestClient` 类是对于 [REST API](/reference/rest-api) 的直接封装。它只包含一个 `sql()` 方法用于执行任意 SQL 语句, 并返回执行结果。
```python title="RestClient 的使用"
{{#include docs-examples/python/rest_client_example.py}}
{{#include docs/examples/python/rest_client_example.py}}
```
对于 `sql()` 方法更详细的介绍, 请参考 [RestClient](https://docs.taosdata.com/api/taospy/taosrest/restclient.html)。
......@@ -285,14 +285,14 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线
<TabItem value="native" label="原生连接">
```python
{{#include docs-examples/python/conn_native_pandas.py}}
{{#include docs/examples/python/conn_native_pandas.py}}
```
</TabItem>
<TabItem value="rest" label="REST 连接">
```python
{{#include docs-examples/python/conn_rest_pandas.py}}
{{#include docs/examples/python/conn_rest_pandas.py}}
```
</TabItem>
......@@ -316,7 +316,7 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线
所有数据库操作如果出现异常,都会直接抛出来。由应用程序负责异常处理。比如:
```python
{{#include docs-examples/python/handle_exception.py}}
{{#include docs/examples/python/handle_exception.py}}
```
### 关于纳秒 (nanosecond)
......
......@@ -38,6 +38,16 @@ export TDENGINE_API=http://tdengine.local:6041
# user + password
export TDENGINE_USER=user
export TDENGINE_PASSWORD=password
# 其他环境变量:
# - 是否安装数据源,默认为 true,表示安装
export TDENGINE_DS_ENABLED=false
# - 数据源名称,默认为 TDengine
export TDENGINE_DS_NAME=TDengine
# - 数据源所属组织 ID,默认为 1
export GF_ORG_ID=1
# - 数据源是否可通过管理面板编辑,默认为 0,表示不可编辑
export TDENGINE_EDITABLE=1
```
运行安装脚本:
......@@ -48,6 +58,8 @@ bash -c "$(curl -fsSL https://raw.githubusercontent.com/taosdata/grafanaplugin/m
该脚本将自动安装 Grafana 插件并配置数据源。安装完毕后,需要重启 Grafana 服务后生效。
保存该脚本并执行 `./install.sh --help` 可查看详细帮助文档。
</TabItem>
<TabItem value="manual" label="手动安装并配置">
......
......@@ -116,7 +116,7 @@ INSERT INTO test.sensor_data VALUES(
## 编写模拟测试程序
```javascript
{{#include docs-examples/other/mock.js}}
{{#include docs/examples/other/mock.js}}
```
注意:代码中 CLIENT_NUM 在开始测试中可以先设置一个较小的值,避免硬件性能不能完全处理较大并发客户端数量。
......
......@@ -2,6 +2,8 @@
title: 2.4
---
[2.4.0.26](https://github.com/taosdata/TDengine/releases/tag/ver-2.4.0.26)
[2.4.0.25](https://github.com/taosdata/TDengine/releases/tag/ver-2.4.0.25)
[2.4.0.24](https://github.com/taosdata/TDengine/releases/tag/ver-2.4.0.24)
......
@echo off
set CUR_DIR=%~dp0
set SHELL_DIR=%cd%
set ENTERPRISE_DIR="%SHELL_DIR%\..\.."
set COMMUNITY_DIR="%SHELL_DIR%\.."
set TOOLS_DIR="%SHELL_DIR%\..\src\kit\taos-tools"
cd %ENTERPRISE_DIR%
git checkout -- .
if exist "enterprise\src\plugins\taosainternal\taosadapter" (
del /f "enterprise\src\plugins\taosainternal\taosadapter"
)
if exist "enterprise\src\plugins\taosainternal\upx.tar.xz" (
del /f "enterprise\src\plugins\taosainternal\upx.tar.xz"
)
cd %COMMUNITY_DIR%
git checkout -- .
cd %TOOLS_DIR%
git checkout -- .
if exist "packaging\tools\install-khtools.sh" (
del /f "packaging\tools\install-khtools.sh"
)
if exist "packaging\tools\uninstall-khtools.sh" (
del /f "packaging/tools/uninstall-khtools.sh"
)
if exist "packaging\tools\install-prodbtools.sh" (
del /f "packaging\tools\install-prodbtools.sh"
)
if exist "packaging\tools\uninstall-prodbtools.sh" (
del /f "packaging\tools\uninstall-prodbtools.sh"
)
cd %CUR_DIR%
\ No newline at end of file
#!/bin/bash
CUR_DIR=$(pwd)
SHELL_DIR=$(dirname $(readlink -f "$0"))
ENTERPRISE_DIR=$SHELL_DIR/../..
COMMUNITY_DIR=$SHELL_DIR/..
TOOLS_DIR=$COMMUNITY_DIR/src/kit/taos-tools
cd $ENTERPRISE_DIR
git checkout -- .
if [[ -e enterprise/src/plugins/taosainternal/taosadapter ]]; then
rm -f enterprise/src/plugins/taosainternal/taosadapter
fi
if [[ -e enterprise/src/plugins/taosainternal/upx.tar.xz ]]; then
rm -f enterprise/src/plugins/taosainternal/upx.tar.xz
fi
cd $COMMUNITY_DIR
git checkout -- .
if [[ -e src/plugins/taosadapter/taosadapter ]]; then
rm -f src/plugins/taosadapter/taosadapter
fi
if [[ -e src/plugins/taosadapter/upx.tar.xz ]]; then
rm -f src/plugins/taosadapter/upx.tar.xz
fi
cd $TOOLS_DIR
git checkout -- .
rm -f $(find packaging/tools/ -name install-*tools.sh | grep -v taos)
rm -f $(find packaging/tools/ -name uninstall-*tools.sh | grep -v taos)
rm -rf $COMMUNITY_DIR/debug/*
rm -rf $COMMUNITY_DIR/release/*
if [[ -e $COMMUNITY_DIR/rpms ]]; then
rm -rf $COMMUNITY_DIR/rpms
fi
if [[ -e $COMMUNITY_DIR/debs ]]; then
rm -rf $COMMUNITY_DIR/debs
fi
cd $CUR_DIR
#!/bin/bash
#
# Modified from original source: Elastic Search
# https://github.com/elasticsearch/elasticsearch
# Thank you to the Elastic Search authors
#
# chkconfig: 2345 99 01
#
### BEGIN INIT INFO
# Provides: TDengine
# Required-Start: $local_fs $network $syslog
# Required-Stop: $local_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts TDengine taosd
# Description: Starts TDengine taosd, a time-series database engine
### END INIT INFO
set -e
......
......@@ -6,9 +6,10 @@ cd %community_dir%
git checkout -- .
cd %community_dir%\packaging
:: %1 name %2 version
:: %1 name %2 version %3 cpuType
if !%1==! GOTO USAGE
if !%2==! GOTO USAGE
if !%3==! GOTO USAGE
if %1 == taos GOTO TAOS
if %1 == power GOTO POWER
if %1 == tq GOTO TQ
......@@ -21,42 +22,66 @@ GOTO USAGE
goto RELEASE
:POWER
cd %internal_dir%\enterprise\packaging\oem
call sed_power.bat %community_dir%
cd %community_dir%\packaging
goto RELEASE
:TQ
cd %internal_dir%\enterprise\packaging\oem
call sed_tq.bat %community_dir%
cd %community_dir%\packaging
goto RELEASE
:PRO
cd %internal_dir%\enterprise\packaging\oem
call sed_pro.bat %community_dir%
cd %community_dir%\packaging
goto RELEASE
:KH
cd %internal_dir%\enterprise\packaging\oem
call sed_kh.bat %community_dir%
cd %community_dir%\packaging
goto RELEASE
:JH
cd %internal_dir%\enterprise\packaging\oem
call sed_jh.bat %community_dir%
cd %community_dir%\packaging
goto RELEASE
:RELEASE
echo release windows-client-64 for %1, version: %2
if not exist %internal_dir%\debug\ver-%2-64bit-%1 (
md %internal_dir%\debug\ver-%2-64bit-%1
echo release windows-client for %1, version: %2, cpyType: %3
if not exist %internal_dir%\debug\ver-%2-%1-%3 (
md %internal_dir%\debug\ver-%2-%1-%3
) else (
rd /S /Q %internal_dir%\debug\ver-%2-64bit-%1
md %internal_dir%\debug\ver-%2-64bit-%1
rd /S /Q %internal_dir%\debug\ver-%2-%1-%3
md %internal_dir%\debug\ver-%2-%1-%3
)
cd %internal_dir%\debug\ver-%2-64bit-%1
cd %internal_dir%\debug\ver-%2-%1-%3
if %3% == x64 GOTO X64
if %3% == x86 GOTO X86
GOTO USAGE
:X86
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86
cmake ../../ -G "NMake Makefiles" -DVERNUMBER=%2 -DCPUTYPE=x86
GOTO MAKE_AND_INSTALL
:X64
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
cmake ../../ -G "NMake Makefiles" -DVERNUMBER=%2 -DCPUTYPE=x64
GOTO MAKE_AND_INSTALL
:MAKE_AND_INSTALL
set CL=/MP4
nmake install
goto EXIT0
:USAGE
echo Usage: release.bat $productName $version
echo Usage: release.bat $productName $version $cpuType
goto EXIT0
:EXIT0
\ No newline at end of file
......@@ -101,13 +101,13 @@ echo "verMode=${verMode} verType=${verType} cpuType=${cpuType} osType=${osType}
curr_dir=$(pwd)
if [ "$osType" == "Darwin" ]; then
script_dir="$(dirname $(readlink -f $0))"
top_dir="$(readlink -f ${script_dir}/..)"
else
script_dir=$(dirname $0)
cd ${script_dir}
script_dir="$(pwd)"
top_dir=${script_dir}/..
else
script_dir="$(dirname $(readlink -f $0))"
top_dir="$(readlink -f ${script_dir}/..)"
fi
csudo=""
......@@ -198,6 +198,7 @@ else
allocator_macro=""
fi
# 3. replace product info
if [[ "$dbName" != "taos" ]]; then
source ${enterprise_dir}/packaging/oem/sed_$dbName.sh
replace_community_$dbName
......
......@@ -207,7 +207,7 @@ function install_bin() {
[ -x ${install_main_dir}/bin/${adapterName} ] && ${csudo}ln -s ${install_main_dir}/bin/${adapterName} ${bin_link_dir}/${adapterName} || :
[ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -s ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${demoName} || :
[ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -s ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${benchmarkName} || :
[ -x ${install_main_dir}/bin/${dumpName} ] && ${csudo}ln -s ${install_main_dir}/bin/${dumpName} ${bin_link_dir}/${dumpName} || :
# [ -x ${install_main_dir}/bin/${dumpName} ] && ${csudo}ln -s ${install_main_dir}/bin/${dumpName} ${bin_link_dir}/${dumpName} || :
[ -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 || :
......
......@@ -7,6 +7,9 @@ set -e
#set -x
# -----------------------Variables definition---------------------
productName="TDengine"
emailName="taosdata.com"
script_dir=$(dirname $(readlink -f "$0"))
bin_link_dir="/usr/bin"
......@@ -83,7 +86,7 @@ else
echo " osinfo: ${osinfo}"
echo " This is an officially unverified linux system,"
echo " if there are any problems with the installation and operation, "
echo " please feel free to contact taosdata.com for support."
echo " please feel free to contact ${emailName} for support."
os_type=1
fi
......@@ -241,7 +244,7 @@ function install_service_on_systemd() {
tarbitratord_service_config="${service_config_dir}/tarbitratord.service"
${csudo}bash -c "echo '[Unit]' >> ${tarbitratord_service_config}"
${csudo}bash -c "echo 'Description=TDengine arbitrator service' >> ${tarbitratord_service_config}"
${csudo}bash -c "echo 'Description=${productName} arbitrator service' >> ${tarbitratord_service_config}"
${csudo}bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}"
${csudo}bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}"
${csudo}bash -c "echo >> ${tarbitratord_service_config}"
......@@ -273,9 +276,9 @@ function install_service() {
fi
}
function update_TDengine() {
function update_Product() {
# Start to update
echo -e "${GREEN}Start to update TDengine's arbitrator ...${NC}"
echo -e "${GREEN}Start to update ${productName}'s arbitrator ...${NC}"
# Stop the service if running
if pidof tarbitrator &>/dev/null; then
if ((${service_mod} == 0)); then
......@@ -303,12 +306,12 @@ function update_TDengine() {
echo -e "${GREEN_DARK}To start arbitrator ${NC}: ./tarbitrator${NC}"
fi
echo
echo -e "\033[44;32;1mTDengine's arbitrator is updated successfully!${NC}"
echo -e "\033[44;32;1m${productName}'s arbitrator is updated successfully!${NC}"
}
function install_TDengine() {
function install_Product() {
# Start to install
echo -e "${GREEN}Start to install TDengine's arbitrator ...${NC}"
echo -e "${GREEN}Start to install ${productName}'s arbitrator ...${NC}"
install_main_path
#install_header
......@@ -325,7 +328,7 @@ function install_TDengine() {
echo -e "${GREEN_DARK}To start arbitrator ${NC}: tarbitrator${NC}"
fi
echo -e "\033[44;32;1mTDengine's arbitrator is installed successfully!${NC}"
echo -e "\033[44;32;1m${productName}'s arbitrator is installed successfully!${NC}"
echo
}
......@@ -333,7 +336,7 @@ function install_TDengine() {
# Install server and client
if [ -x ${bin_dir}/tarbitrator ]; then
update_flag=1
update_TDengine
update_Product
else
install_TDengine
install_Product
fi
......@@ -18,6 +18,7 @@ clientName="taos"
uninstallScript="rmtaos"
configFile="taos.cfg"
tarName="taos.tar.gz"
demoName="taosdemo"
osType=Linux
pagMode=full
......@@ -29,7 +30,7 @@ if [ "$osType" != "Darwin" ]; then
data_dir=${dataDir}
log_dir=${logDir}
else
script_dir=`dirname $0`
script_dir=$(dirname $0)
cd ${script_dir}
script_dir="$(pwd)"
data_dir=${dataDir}
......@@ -65,7 +66,7 @@ GREEN_UNDERLINE='\033[4;32m'
NC='\033[0m'
csudo=""
if command -v sudo > /dev/null; then
if command -v sudo >/dev/null; then
csudo="sudo "
fi
......@@ -98,7 +99,7 @@ function install_bin() {
# Remove links
${csudo}rm -f ${bin_link_dir}/${clientName} || :
if [ "$osType" != "Darwin" ]; then
${csudo}rm -f ${bin_link_dir}/taosdemo || :
${csudo}rm -f ${bin_link_dir}/${demoName} || :
fi
${csudo}rm -f ${bin_link_dir}/${uninstallScript} || :
${csudo}rm -f ${bin_link_dir}/set_core || :
......@@ -108,7 +109,7 @@ function install_bin() {
#Make link
[ -x ${install_main_dir}/bin/${clientName} ] && ${csudo}ln -s ${install_main_dir}/bin/${clientName} ${bin_link_dir}/${clientName} || :
if [ "$osType" != "Darwin" ]; then
[ -x ${install_main_dir}/bin/taosdemo ] && ${csudo}ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || :
[ -x ${install_main_dir}/bin/${demoName} ] && ${csudo}ln -s ${install_main_dir}/bin/${demoName} ${bin_link_dir}/${demoName} || :
fi
[ -x ${install_main_dir}/bin/remove_client.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_client.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 || :
......@@ -123,7 +124,6 @@ function install_lib() {
# Remove links
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
#${csudo}rm -rf ${v15_java_app_dir} || :
${csudo}cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo}chmod 777 ${install_main_dir}/driver/*
......@@ -200,7 +200,7 @@ function install_jemalloc() {
fi
if [ -d /etc/ld.so.conf.d ]; then
echo "/usr/local/lib" | ${csudo}tee /etc/ld.so.conf.d/jemalloc.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf"
echo "/usr/local/lib" | ${csudo}tee /etc/ld.so.conf.d/jemalloc.conf >/dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf"
${csudo}ldconfig
else
echo "/etc/ld.so.conf.d not found!"
......@@ -219,7 +219,6 @@ function install_config() {
${csudo}ln -s ${cfg_install_dir}/${configFile} ${install_main_dir}/cfg
}
function install_log() {
${csudo}rm -rf ${log_dir} || :
......@@ -241,7 +240,7 @@ function install_examples() {
fi
}
function update_TDengine() {
function update_Product() {
# Start to update
if [ ! -e ${tarName} ]; then
echo "File ${tarName} does not exist"
......@@ -251,7 +250,7 @@ function update_TDengine() {
echo -e "${GREEN}Start to update ${productName} client...${NC}"
# Stop the client shell if running
if pidof ${clientName} &> /dev/null; then
if pidof ${clientName} &>/dev/null; then
kill_client
sleep 1
fi
......@@ -275,7 +274,7 @@ function update_TDengine() {
rm -rf $(tar -tf ${tarName})
}
function install_TDengine() {
function install_Product() {
# Start to install
if [ ! -e ${tarName} ]; then
echo "File ${tarName} does not exist"
......@@ -303,18 +302,17 @@ function install_TDengine() {
rm -rf $(tar -tf ${tarName})
}
## ==============================Main program starts from here============================
# Install or updata client and client
# if server is already install, don't install client
if [ -e ${bin_dir}/${serverName} ]; then
if [ -e ${bin_dir}/${serverName} ]; then
echo -e "\033[44;32;1mThere are already installed ${productName} server, so don't need install client!${NC}"
exit 0
fi
fi
if [ -x ${bin_dir}/${clientName} ]; then
if [ -x ${bin_dir}/${clientName} ]; then
update_flag=1
update_TDengine
else
install_TDengine
fi
update_Product
else
install_Product
fi
......@@ -29,7 +29,11 @@ installDir="/usr/local/taos"
productName="TDengine"
emailName="taosdata.com"
uninstallScript="rmtaos"
adapterName="taosadapter"
demoName="taosdemo"
benchmarkName="taosBenchmark"
# Dynamic directory
if [ "$osType" != "Darwin" ]; then
data_dir=${dataDir}
log_dir=${logDir}
......@@ -125,14 +129,14 @@ if [ "$osType" != "Darwin" ]; then
fi
fi
function kill_taosadapter() {
pid=$(ps -ef | grep "taosadapter" | grep -v "grep" | awk '{print $2}')
function kill_adapter() {
pid=$(ps -ef | grep "${adapterName}" | grep -v "grep" | awk '{print $2}')
if [ -n "$pid" ]; then
${csudo}kill -9 $pid || :
fi
}
function kill_taosd() {
function kill_server() {
ps -ef | grep ${serverName}
pid=$(ps -ef | grep -w ${serverName} | grep -v "grep" | awk '{print $2}')
if [ -n "$pid" ]; then
......@@ -168,40 +172,39 @@ function install_bin() {
# Remove links
${csudo}rm -f ${bin_link_dir}/${clientName} || :
${csudo}rm -f ${bin_link_dir}/${serverName} || :
${csudo}rm -f ${bin_link_dir}/taosadapter || :
${csudo}rm -f ${bin_link_dir}/taosdemo || :
${csudo}rm -f ${bin_link_dir}/taosdump || :
${csudo}rm -f ${bin_link_dir}/${adapterName} || :
${csudo}rm -f ${bin_link_dir}/${demoName} || :
if [ "$osType" != "Darwin" ]; then
${csudo}rm -f ${bin_link_dir}/perfMonitor || :
${csudo}rm -f ${bin_link_dir}/set_core || :
${csudo}rm -f ${bin_link_dir}/run_taosd_and_taosadapter.sh || :
${csudo}rm -f ${bin_link_dir}/run_${serverName}_and_${adapterName}.sh || :
${csudo}rm -f ${bin_link_dir}/${uninstallScript} || :
${csudo}cp -r ${binary_dir}/build/bin/${clientName} ${install_main_dir}/bin || :
[ -f ${binary_dir}/build/bin/taosBenchmark ] && ${csudo}cp -r ${binary_dir}/build/bin/taosBenchmark ${install_main_dir}/bin || :
[ -f ${install_main_dir}/bin/taosBenchmark ] && ${csudo}ln -sf ${install_main_dir}/bin/taosBenchmark ${install_main_dir}/bin/taosdemo || :
[ -f ${binary_dir}/build/bin/taosdump ] && ${csudo}cp -r ${binary_dir}/build/bin/taosdump ${install_main_dir}/bin || :
[ -f ${binary_dir}/build/bin/taosadapter ] && ${csudo}cp -r ${binary_dir}/build/bin/taosadapter ${install_main_dir}/bin || :
[ -f ${binary_dir}/build/bin/${benchmarkName} ] && ${csudo}cp -r ${binary_dir}/build/bin/${benchmarkName} ${install_main_dir}/bin || :
[ -f ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${benchmarkName} ${install_main_dir}/bin/${demoName} || :
# [ -f ${binary_dir}/build/bin/taosdump ] && ${csudo}cp -r ${binary_dir}/build/bin/taosdump ${install_main_dir}/bin || :
[ -f ${binary_dir}/build/bin/${adapterName} ] && ${csudo}cp -r ${binary_dir}/build/bin/${adapterName} ${install_main_dir}/bin || :
${csudo}cp -r ${binary_dir}/build/bin/${serverName} ${install_main_dir}/bin || :
${csudo}cp -r ${binary_dir}/build/bin/tarbitrator ${install_main_dir}/bin || :
${csudo}cp -r ${script_dir}/taosd-dump-cfg.gdb ${install_main_dir}/bin
${csudo}cp -r ${script_dir}/remove.sh ${install_main_dir}/bin
${csudo}cp -r ${script_dir}/set_core.sh ${install_main_dir}/bin
${csudo}cp -r ${script_dir}/run_taosd_and_taosadapter.sh ${install_main_dir}/bin
${csudo}cp -r ${script_dir}/run_${serverName}_and_${adapterName}.sh ${install_main_dir}/bin
${csudo}cp -r ${script_dir}/startPre.sh ${install_main_dir}/bin
${csudo}chmod 0555 ${install_main_dir}/bin/*
#Make link
[ -x ${install_main_dir}/bin/${clientName} ] && ${csudo}ln -s ${install_main_dir}/bin/${clientName} ${bin_link_dir}/${clientName} || :
[ -x ${install_main_dir}/bin/${serverName} ] && ${csudo}ln -s ${install_main_dir}/bin/${serverName} ${bin_link_dir}/${serverName} || :
[ -x ${install_main_dir}/bin/taosadapter ] && ${csudo}ln -s ${install_main_dir}/bin/taosadapter ${bin_link_dir}/taosadapter || :
[ -x ${install_main_dir}/bin/taosdump ] && ${csudo}ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || :
[ -x ${install_main_dir}/bin/taosdemo ] && ${csudo}ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || :
[ -x ${install_main_dir}/bin/${adapterName} ] && ${csudo}ln -s ${install_main_dir}/bin/${adapterName} ${bin_link_dir}/${adapterName} || :
# [ -x ${install_main_dir}/bin/taosdump ] && ${csudo}ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || :
[ -x ${install_main_dir}/bin/${demoName} ] && ${csudo}ln -s ${install_main_dir}/bin/${demoName} ${bin_link_dir}/${demoName} || :
[ -x ${install_main_dir}/bin/perfMonitor ] && ${csudo}ln -s ${install_main_dir}/bin/perfMonitor ${bin_link_dir}/perfMonitor || :
[ -x ${install_main_dir}/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || :
[ -x ${install_main_dir}/run_taosd_and_taosadapter.sh ] && ${csudo}ln -s ${install_main_dir}/bin/run_taosd_and_taosadapter.sh ${bin_link_dir}/run_taosd_and_taosadapter.sh || :
[ -x ${install_main_dir}/run_${serverName}_and_${adapterName}.sh ] && ${csudo}ln -s ${install_main_dir}/bin/run_${serverName}_and_${adapterName}.sh ${bin_link_dir}/run_${serverName}_and_${adapterName}.sh || :
[ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript} || :
else
......@@ -212,9 +215,9 @@ function install_bin() {
#Make link
[ -x ${install_main_dir}/bin/${clientName} ] || [ -x ${install_main_2_dir}/bin/${clientName} ] && ${csudo}ln -s ${install_main_dir}/bin/${clientName} ${bin_link_dir}/${clientName} || ${csudo}ln -s ${install_main_2_dir}/bin/${clientName} || :
[ -x ${install_main_dir}/bin/${serverName} ] || [ -x ${install_main_2_dir}/bin/${serverName} ] && ${csudo}ln -s ${install_main_dir}/bin/${serverName} ${bin_link_dir}/${serverName} || ${csudo}ln -s ${install_main_2_dir}/bin/${serverName} || :
[ -x ${install_main_dir}/bin/taosadapter ] || [ -x ${install_main_2_dir}/bin/taosadapter ] && ${csudo}ln -s ${install_main_dir}/bin/taosadapter ${bin_link_dir}/taosadapter || ${csudo}ln -s ${install_main_2_dir}/bin/taosadapter || :
[ -x ${install_main_dir}/bin/taosdump ] || [ -x ${install_main_2_dir}/bin/taosdump ] && ${csudo}ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || ln -s ${install_main_2_dir}/bin/taosdump ${bin_link_dir}/taosdump || :
[ -x ${install_main_dir}/bin/taosdemo ] || [ -x ${install_main_2_dir}/bin/taosdemo ] && ${csudo}ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || ln -s ${install_main_2_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || :
[ -x ${install_main_dir}/bin/${adapterName} ] || [ -x ${install_main_2_dir}/bin/${adapterName} ] && ${csudo}ln -s ${install_main_dir}/bin/${adapterName} ${bin_link_dir}/${adapterName} || ${csudo}ln -s ${install_main_2_dir}/bin/${adapterName} || :
# [ -x ${install_main_dir}/bin/taosdump ] || [ -x ${install_main_2_dir}/bin/taosdump ] && ${csudo}ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || ln -s ${install_main_2_dir}/bin/taosdump ${bin_link_dir}/taosdump || :
[ -x ${install_main_dir}/bin/${demoName} ] || [ -x ${install_main_2_dir}/bin/${demoName} ] && ${csudo}ln -s ${install_main_dir}/bin/${demoName} ${bin_link_dir}/${demoName} || ln -s ${install_main_2_dir}/bin/${demoName} ${bin_link_dir}/${demoName} || :
fi
}
......@@ -380,23 +383,23 @@ function install_config() {
fi
}
function install_taosadapter_config() {
if [ ! -f "${cfg_install_dir}/taosadapter.toml" ]; then
function install_adapter_config() {
if [ ! -f "${cfg_install_dir}/${adapterName}.toml" ]; then
${csudo}mkdir -p ${cfg_install_dir}
[ -f ${binary_dir}/test/cfg/taosadapter.toml ] &&
${csudo}cp ${binary_dir}/test/cfg/taosadapter.toml ${cfg_install_dir}
[ -f ${cfg_install_dir}/taosadapter.toml ] &&
${csudo}chmod 644 ${cfg_install_dir}/taosadapter.toml
[ -f ${binary_dir}/test/cfg/taosadapter.toml ] &&
${csudo}cp -f ${binary_dir}/test/cfg/taosadapter.toml \
${cfg_install_dir}/taosadapter.toml.${verNumber}
[ -f ${cfg_install_dir}/taosadapter.toml ] &&
${csudo}ln -s ${cfg_install_dir}/taosadapter.toml \
${install_main_dir}/cfg/taosadapter.toml
[ -f ${binary_dir}/test/cfg/${adapterName}.toml ] &&
${csudo}cp ${binary_dir}/test/cfg/${adapterName}.toml ${cfg_install_dir}
[ -f ${cfg_install_dir}/${adapterName}.toml ] &&
${csudo}chmod 644 ${cfg_install_dir}/${adapterName}.toml
[ -f ${binary_dir}/test/cfg/${adapterName}.toml ] &&
${csudo}cp -f ${binary_dir}/test/cfg/${adapterName}.toml \
${cfg_install_dir}/${adapterName}.toml.${verNumber}
[ -f ${cfg_install_dir}/${adapterName}.toml ] &&
${csudo}ln -s ${cfg_install_dir}/${adapterName}.toml \
${install_main_dir}/cfg/${adapterName}.toml
else
if [ -f "${binary_dir}/test/cfg/taosadapter.toml" ]; then
${csudo}cp -f ${binary_dir}/test/cfg/taosadapter.toml \
${cfg_install_dir}/taosadapter.toml.${verNumber}
if [ -f "${binary_dir}/test/cfg/${adapterName}.toml" ]; then
${csudo}cp -f ${binary_dir}/test/cfg/${adapterName}.toml \
${cfg_install_dir}/${adapterName}.toml.${verNumber}
fi
fi
}
......@@ -529,10 +532,10 @@ function install_service_on_systemd() {
${csudo}systemctl enable ${serverName}
}
function install_taosadapter_service() {
function install_adapter_service() {
if ((${service_mod} == 0)); then
[ -f ${binary_dir}/test/cfg/taosadapter.service ] &&
${csudo}cp ${binary_dir}/test/cfg/taosadapter.service \
[ -f ${binary_dir}/test/cfg/${adapterName}.service ] &&
${csudo}cp ${binary_dir}/test/cfg/${adapterName}.service \
${service_config_dir}/ || :
${csudo}systemctl daemon-reload
fi
......@@ -544,11 +547,11 @@ function install_service() {
elif ((${service_mod} == 1)); then
install_service_on_sysvinit
else
kill_taosd
kill_server
fi
}
function update_TDengine() {
function update_Product() {
echo -e "${GREEN}Start to update ${productName}...${NC}"
# Stop the service if running
......@@ -558,8 +561,8 @@ function update_TDengine() {
elif ((${service_mod} == 1)); then
${csudo}service ${serverName} stop || :
else
kill_taosadapter
kill_taosd
kill_adapter
kill_server
fi
sleep 1
fi
......@@ -574,23 +577,23 @@ function update_TDengine() {
install_bin
install_service
install_taosadapter_service
install_adapter_service
install_config
install_taosadapter_config
install_adapter_config
echo
echo -e "\033[44;32;1m${productName} is updated successfully!${NC}"
echo
echo -e "${GREEN_DARK}To configure ${productName} ${NC}: edit ${configDir}/${configFile}"
echo -e "${GREEN_DARK}To configure Taos Adapter (if has) ${NC}: edit ${configDir}/taosadapter.toml"
echo -e "${GREEN_DARK}To configure ${adapterName} (if has) ${NC}: edit ${configDir}/${adapterName}.toml"
if ((${service_mod} == 0)); then
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}systemctl start ${serverName}${NC}"
elif ((${service_mod} == 1)); then
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}service ${serverName} start${NC}"
else
echo -e "${GREEN_DARK}To start Taos Adapter (if has)${NC}: taosadapter &${NC}"
echo -e "${GREEN_DARK}To start ${adapterName} (if has)${NC}: ${adapterName} &${NC}"
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${serverName}${NC}"
fi
......@@ -599,7 +602,7 @@ function update_TDengine() {
echo -e "\033[44;32;1m${productName} is updated successfully!${NC}"
}
function install_TDengine() {
function install_Product() {
# Start to install
echo -e "${GREEN}Start to install ${productName}...${NC}"
......@@ -614,23 +617,23 @@ function install_TDengine() {
install_bin
install_service
install_taosadapter_service
install_adapter_service
install_config
install_taosadapter_config
install_adapter_config
# Ask if to start the service
echo
echo -e "\033[44;32;1m${productName} is installed successfully!${NC}"
echo
echo -e "${GREEN_DARK}To configure ${productName} ${NC}: edit ${configDir}/${configFile}"
echo -e "${GREEN_DARK}To configure taosadapter (if has) ${NC}: edit ${configDir}/taosadapter.toml"
echo -e "${GREEN_DARK}To configure ${adapterName} (if has) ${NC}: edit ${configDir}/${adapterName}.toml"
if ((${service_mod} == 0)); then
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}systemctl start ${serverName}${NC}"
elif ((${service_mod} == 1)); then
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}service ${serverName} start${NC}"
else
echo -e "${GREEN_DARK}To start Taos Adapter (if has)${NC}: taosadapter &${NC}"
echo -e "${GREEN_DARK}To start ${adapterName} (if has)${NC}: ${adapterName} &${NC}"
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ./${serverName}${NC}"
fi
......@@ -644,14 +647,14 @@ echo source directory: $1
echo binary directory: $2
if [ "$osType" != "Darwin" ]; then
if [ -x ${bin_dir}/${clientName} ]; then
update_TDengine
update_Product
else
install_TDengine
install_Product
fi
else
if [ -x ${bin_dir}/${clientName} ] || [ -x ${bin_2_dir}/${clientName} ]; then
update_TDengine
update_Product
else
install_TDengine
install_Product
fi
fi
......@@ -36,13 +36,11 @@ fi
bin_files="${build_dir}/bin/tarbitrator ${script_dir}/remove_arbi.sh"
install_files="${script_dir}/install_arbi.sh"
#header_files="${code_dir}/inc/taos.h ${code_dir}/inc/taosdef.h ${code_dir}/inc/taoserror.h"
init_file_tarbitrator_deb=${script_dir}/../deb/tarbitratord
init_file_tarbitrator_rpm=${script_dir}/../rpm/tarbitratord
# make directories.
mkdir -p ${install_dir} && cp ${install_files} ${install_dir} && chmod a+x ${install_dir}/install_arbi.sh || :
#mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc || :
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_tarbitrator_deb} ${install_dir}/init.d/tarbitratord.deb || :
mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_rpm} ${install_dir}/init.d/tarbitratord.rpm || :
......
......@@ -44,7 +44,6 @@ else
fi
# Directories and files.
if [ "$osType" != "Darwin" ]; then
if [ "$pagMode" == "lite" ]; then
strip ${build_dir}/bin/${clientName}
......@@ -182,26 +181,27 @@ if [[ $productName == "TDengine" ]]; then
fi
fi
fi
# Copy driver
mkdir -p ${install_dir}/driver
cp ${lib_files} ${install_dir}/driver
# Copy connector
connector_dir="${code_dir}/connector"
mkdir -p ${install_dir}/connector
if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then
if [ "$osType" != "Darwin" ]; then
cp ${build_dir}/lib/*.jar ${install_dir}/connector || :
fi
if find ${connector_dir}/go -mindepth 1 -maxdepth 1 | read; then
cp -r ${connector_dir}/go ${install_dir}/connector
else
echo "WARNING: go connector not found, please check if want to use it!"
fi
cp -r ${connector_dir}/python ${install_dir}/connector
cp -r ${connector_dir}/nodejs ${install_dir}/connector
fi
#connector_dir="${code_dir}/connector"
#mkdir -p ${install_dir}/connector
#
#if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then
# if [ "$osType" != "Darwin" ]; then
# cp ${build_dir}/lib/*.jar ${install_dir}/connector || :
# fi
# if find ${connector_dir}/go -mindepth 1 -maxdepth 1 | read; then
# cp -r ${connector_dir}/go ${install_dir}/connector
# else
# echo "WARNING: go connector not found, please check if want to use it!"
# fi
# cp -r ${connector_dir}/python ${install_dir}/connector
# cp -r ${connector_dir}/nodejs ${install_dir}/connector
#fi
# Copy release note
# cp ${script_dir}/release_note ${install_dir}
......
......@@ -16,12 +16,16 @@ serverName="taosd"
clientName="taos"
uninstallScript="rmtaos"
productName="TDengine"
adapterName="taosadapter"
benchmarkName="taosBenchmark"
dumpName="taosdump"
demoName="taosdemo"
#install main path
install_main_dir=${installDir}
data_link_dir=${installDir}/data
log_link_dir=${installDir}/log
cfg_link_dir=${installDir}/cfg
data_link_dir="${installDir}/data"
log_link_dir="${installDir}/log"
cfg_link_dir="${installDir}/cfg"
bin_link_dir="/usr/bin"
local_bin_link_dir="/usr/local/bin"
lib_link_dir="/usr/lib"
......@@ -31,7 +35,7 @@ install_nginxd_dir="/usr/local/nginxd"
service_config_dir="/etc/systemd/system"
taos_service_name=${serverName}
taosadapter_service_name="taosadapter"
taosadapter_service_name=${adapterName}
tarbitrator_service_name="tarbitratord"
nginx_service_name="nginxd"
csudo=""
......@@ -59,22 +63,8 @@ else
service_mod=2
fi
function kill_taosadapter() {
pid=$(ps -ef | grep "taosadapter" | grep -v "grep" | awk '{print $2}')
if [ -n "$pid" ]; then
${csudo}kill -9 $pid || :
fi
}
function kill_taosd() {
pid=$(ps -ef | grep ${serverName} | grep -v "grep" | awk '{print $2}')
if [ -n "$pid" ]; then
${csudo}kill -9 $pid || :
fi
}
function kill_tarbitrator() {
pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}')
function kill_process() {
pid=$(ps -ef | grep "$1" | grep -v "grep" | awk '{print $2}')
if [ -n "$pid" ]; then
${csudo}kill -9 $pid || :
fi
......@@ -84,14 +74,14 @@ function clean_bin() {
# Remove link
${csudo}rm -f ${bin_link_dir}/${clientName} || :
${csudo}rm -f ${bin_link_dir}/${serverName} || :
${csudo}rm -f ${bin_link_dir}/taosadapter || :
${csudo}rm -f ${bin_link_dir}/taosBenchmark || :
${csudo}rm -f ${bin_link_dir}/taosdemo || :
${csudo}rm -f ${bin_link_dir}/taosdump || :
${csudo}rm -f ${bin_link_dir}/${adapterName} || :
${csudo}rm -f ${bin_link_dir}/${benchmarkName} || :
${csudo}rm -f ${bin_link_dir}/${demoName} || :
${csudo}rm -f ${bin_link_dir}/${dumpName} || :
${csudo}rm -f ${bin_link_dir}/${uninstallScript} || :
${csudo}rm -f ${bin_link_dir}/tarbitrator || :
${csudo}rm -f ${bin_link_dir}/set_core || :
${csudo}rm -f ${bin_link_dir}/run_taosd_and_taosadapter.sh || :
${csudo}rm -f ${bin_link_dir}/run_${serverName}_and_${adapterName}.sh || :
${csudo}rm -f ${bin_link_dir}/TDinsight.sh || :
}
......@@ -133,9 +123,9 @@ function clean_service_on_systemd() {
${csudo}systemctl disable ${taos_service_name} &>/dev/null || echo &>/dev/null
${csudo}rm -f ${taosd_service_config}
taosadapter_service_config="${service_config_dir}/taosadapter.service"
taosadapter_service_config="${service_config_dir}/${adapterName}.service"
if systemctl is-active --quiet ${taosadapter_service_name}; then
echo "${productName} taosAdapter is running, stopping it..."
echo "${productName} ${adapterName} is running, stopping it..."
${csudo}systemctl stop ${taosadapter_service_name} &>/dev/null || echo &>/dev/null
fi
${csudo}systemctl disable ${taosadapter_service_name} &>/dev/null || echo &>/dev/null
......@@ -210,9 +200,9 @@ function clean_service() {
elif ((${service_mod} == 1)); then
clean_service_on_sysvinit
else
kill_taosadapter
kill_taosd
kill_tarbitrator
kill_process ${adapterName}
kill_process ${serverName}
kill_process "tarbitrator"
fi
}
......
......@@ -23,7 +23,7 @@ lib64_link_dir="/usr/lib64"
inc_link_dir="/usr/include"
csudo=""
if command -v sudo > /dev/null; then
if command -v sudo >/dev/null; then
csudo="sudo "
fi
......@@ -37,7 +37,6 @@ function clean_bin() {
# Remove link
${csudo}rm -f ${bin_link_dir}/${clientName} || :
${csudo}rm -f ${bin_link_dir}/taosdemo || :
${csudo}rm -f ${bin_link_dir}/taosdump || :
${csudo}rm -f ${bin_link_dir}/${uninstallScript} || :
${csudo}rm -f ${bin_link_dir}/set_core || :
}
......
......@@ -17,6 +17,9 @@
#define __SHELL__
#if !(defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32))
#include <sys/socket.h>
#else
#include <winsock2.h>
#pragma comment(lib,"ws2_32.lib")
#endif
#include "stdbool.h"
#include "taos.h"
......@@ -45,9 +48,11 @@ typedef struct SShellArguments {
char* database;
char* timezone;
bool restful;
char* token;
#ifdef WINDOWS
SOCKET socket;
#else
int socket;
struct sockaddr_in serv_addr;
#endif
TAOS* con;
bool is_raw_time;
bool is_use_passwd;
......@@ -63,6 +68,11 @@ typedef struct SShellArguments {
int pktNum;
char* pktType;
char* netTestRole;
char* cloudDsn;
bool cloud;
char* cloudHost;
char* cloudPort;
char* cloudToken;
} SShellArguments;
typedef enum WS_ACTION_TYPE_S { WS_CONN, WS_QUERY, WS_FETCH, WS_FETCH_BLOCK } WS_ACTION_TYPE;
......@@ -84,9 +94,6 @@ void shellCheck(TAOS* con, SShellArguments* args);
void get_history_path(char* history);
void shellCheck(TAOS* con, SShellArguments* args);
void cleanup_handler(void* arg);
int convertHostToServAddr();
char *last_strstr(const char *haystack, const char *needle);
void encode_base_64(char* base64_buf, char* user, char* password);
void exitShell();
int shellDumpResult(TAOS_RES* con, char* fname, int* error_no, bool printMode);
void shellGetGrantInfo(void* con);
......@@ -94,6 +101,8 @@ int isCommentLine(char* line);
int wsclient_handshake();
int wsclient_conn();
void wsclient_query(char* command);
int tcpConnect(char* host, int port);
int parse_cloud_dsn();
/**************** Global variable declarations ****************/
extern char PROMPT_HEADER[];
......
......@@ -54,13 +54,16 @@ void printHelp() {
printf("%s%s%s\n", indent, indent, "Script to run without enter the shell.");
printf("%s%s\n", indent, "-d");
printf("%s%s%s\n", indent, indent, "Database to use when connecting to the server.");
printf("%s%s\n", indent, "-t");
printf("%s%s\n", indent, "-z");
printf("%s%s%s\n", indent, indent, "Time zone of the shell, default is local.");
printf("%s%s\n", indent, "-D");
printf("%s%s%s\n", indent, indent, "Use multi-thread to import all SQL files in the directory separately.");
printf("%s%s\n", indent, "-T");
printf("%s%s%s\n", indent, indent, "Number of threads when using multi-thread to import data.");
printf("%s%s\n", indent, "-R");
printf("%s%s%s\n", indent, indent, "Connect and interact with TDengine use restful.");
printf("%s%s\n", indent, "-E");
printf("%s%s%s\n", indent, indent, "The DSN to use when connecting TDengine's cloud services.");
exit(EXIT_SUCCESS);
}
......@@ -74,6 +77,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
// for host
if (strcmp(argv[i], "-h") == 0) {
if (i < argc - 1) {
arguments->cloud = false;
arguments->host = argv[++i];
} else {
fprintf(stderr, "option -h requires an argument\n");
......@@ -105,6 +109,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
// for management port
else if (strcmp(argv[i], "-P") == 0) {
if (i < argc - 1) {
arguments->cloud = false;
arguments->port = atoi(argv[++i]);
} else {
fprintf(stderr, "option -P requires an argument\n");
......@@ -121,6 +126,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
}
} else if (strcmp(argv[i], "-c") == 0) {
if (i < argc - 1) {
arguments->cloud = false;
if (strlen(argv[++i]) >= TSDB_FILENAME_LEN) {
fprintf(stderr, "config file path: %s overflow max len %d\n", argv[i], TSDB_FILENAME_LEN - 1);
exit(EXIT_FAILURE);
......@@ -159,11 +165,11 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
}
}
// For time zone
else if (strcmp(argv[i], "-t") == 0) {
else if (strcmp(argv[i], "-z") == 0) {
if (i < argc - 1) {
arguments->timezone = argv[++i];
} else {
fprintf(stderr, "option -t requires an argument\n");
fprintf(stderr, "option -z requires an argument\n");
exit(EXIT_FAILURE);
}
}
......@@ -190,6 +196,21 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
exit(EXIT_FAILURE);
}
}
else if (strcmp(argv[i], "-R") == 0) {
arguments->cloud = false;
arguments->restful = true;
}
else if (strcmp(argv[i], "-E") == 0) {
if (i < argc - 1) {
arguments->cloudDsn = argv[++i];
} else {
fprintf(stderr, "options -E requires an argument\n");
exit(EXIT_FAILURE);
}
}
// For temperory command TODO
else if (strcmp(argv[i], "--help") == 0) {
printHelp();
......@@ -200,6 +221,16 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
exit(EXIT_FAILURE);
}
}
if (args.cloudDsn == NULL) {
if (args.cloud) {
args.cloudDsn = getenv("TDENGINE_CLOUD_DSN");
if (args.cloudDsn == NULL) {
args.cloud = false;
}
}
} else {
args.cloud = true;
}
}
int32_t shellReadCommand(TAOS *con, char *command) {
......@@ -547,3 +578,37 @@ void exitShell() {
tcsetattr(0, TCSANOW, &oldtio);
exit(EXIT_SUCCESS);
}
int tcpConnect(char* host, int port) {
struct sockaddr_in serv_addr;
if (port == 0) {
port = 6041;
args.port = 6041;
}
if (NULL == host) {
host = "localhost";
args.host = "localhost";
}
struct hostent *server = gethostbyname(host);
if ((server == NULL) || (server->h_addr == NULL)) {
fprintf(stderr, "no such host: %s\n", host);
return -1;
}
memset(&serv_addr, 0, sizeof(struct sockaddr_in));
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(port);
memcpy(&(serv_addr.sin_addr.s_addr), server->h_addr, server->h_length);
args.socket = socket(AF_INET, SOCK_STREAM, 0);
if (args.socket < 0) {
fprintf(stderr, "failed to create socket\n");
return -1;
}
int retConn = connect(args.socket, (struct sockaddr *)&serv_addr, sizeof(struct sockaddr));
if (retConn < 0) {
fprintf(stderr, "failed to connect\n");
close(args.socket);
return -1;
}
return 0;
}
\ No newline at end of file
......@@ -72,19 +72,7 @@ void shellInit(SShellArguments *_args) {
_args->user = TSDB_DEFAULT_USER;
}
if (_args->restful) {
_args->database = calloc(1, 128);
_args->socket = socket(AF_INET, SOCK_STREAM, 0);
if (_args->socket < 0) {
fprintf(stderr, "failed to create socket\n");
exit(EXIT_FAILURE);
}
int retConn = connect(_args->socket, (struct sockaddr *)&(_args->serv_addr), sizeof(struct sockaddr));
if (retConn < 0) {
fprintf(stderr, "failed to connect\n");
close(_args->socket);
exit(EXIT_FAILURE);
}
if (_args->restful || _args->cloud) {
if (wsclient_handshake()) {
exit(EXIT_FAILURE);
}
......@@ -170,7 +158,7 @@ static int32_t shellRunSingleCommand(TAOS *con, char *command) {
// Analyse the command.
if (regex_match(command, "^[ \t]*(quit|q|exit)[ \t;]*$", REG_EXTENDED | REG_ICASE)) {
if (args.restful) {
if (args.restful || args.cloud) {
close(args.socket);
} else {
taos_close(con);
......@@ -320,7 +308,7 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
printMode = true; // When output to a file, the switch does not work.
}
if (args.restful) {
if (args.restful || args.cloud) {
wsclient_query(command);
return;
}
......@@ -1164,41 +1152,38 @@ int taos_base64_encode(unsigned char *source, size_t sourcelen, char *target, si
return 1;
}
char *last_strstr(const char *haystack, const char *needle) {
if (*needle == '\0')
return (char *) haystack;
char *res = NULL;
for (;;) {
char *p = strstr(haystack, needle);
if (p == NULL) break;
res = p;
haystack = p + 1;
int parse_cloud_dsn() {
if (args.cloudDsn == NULL) {
fprintf(stderr, "Cannot read cloud service info\n");
return 1;
} else {
char *start = strstr(args.cloudDsn, "http://");
if (start != NULL) {
args.cloudHost = start + strlen("http://");
} else {
start = strstr(args.cloudDsn, "https://");
if (start != NULL) {
args.cloudHost = start + strlen("https://");
} else {
args.cloudHost = args.cloudDsn;
}
return res;
}
int convertHostToServAddr() {
if (args.port == 0) {
args.port = 6041;
}
if (NULL == args.host) {
args.host = "127.0.0.1";
char *port = strstr(args.cloudHost, ":");
if ((port == NULL) || (port + strlen(":")) == NULL) {
fprintf(stderr, "Invalid format in TDengine cloud dsn: %s\n", args.cloudDsn);
return 1;
}
struct hostent *server = gethostbyname(args.host);
if ((server == NULL) || (server->h_addr == NULL)) {
fprintf(stderr, "no such host: %s\n", args.host);
char *token = strstr(port + strlen(":"), "?token=");
if ((token == NULL) || (token + strlen("?token=")) == NULL ||
(strlen(token + strlen("?token=")) == 0)) {
fprintf(stderr, "Invalid format in TDengine cloud dsn: %s\n", args.cloudDsn);
return -1;
}
memset(&(args.serv_addr), 0, sizeof(struct sockaddr_in));
args.serv_addr.sin_family = AF_INET;
args.serv_addr.sin_port = htons(args.port);
#ifdef WINDOWS
args.serv_addr.sin_addr.s_addr = inet_addr(args.host);
#else
memcpy(&(args.serv_addr.sin_addr.s_addr), server->h_addr, server->h_length);
#endif
port[0] = '\0';
args.cloudPort = port + strlen(":");
token[0] = '\0';
args.cloudToken = token + strlen("?token=");
}
return 0;
}
......@@ -1215,12 +1200,12 @@ int wsclient_handshake() {
key_nonce[i] = rand() & 0xff;
}
taos_base64_encode(key_nonce, 16, websocket_key, 256);
if (args.token) {
if (args.cloud) {
snprintf(request_header, 1024,
"GET /rest/ws?token=%s HTTP/1.1\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nHost: "
"%s:%d\r\nSec-WebSocket-Key: "
"%s:%s\r\nSec-WebSocket-Key: "
"%s\r\nSec-WebSocket-Version: 13\r\n\r\n",
args.token, args.host, args.port, websocket_key);
args.cloudToken, args.cloudHost, args.cloudPort, websocket_key);
} else {
snprintf(request_header, 1024,
"GET /rest/ws HTTP/1.1\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nHost: %s:%d\r\nSec-WebSocket-Key: "
......@@ -1229,8 +1214,12 @@ int wsclient_handshake() {
}
ssize_t n = send(args.socket, request_header, strlen(request_header), 0);
if (n == 0) {
if (n <= 0) {
#ifdef WINDOWS
fprintf(stderr, "send failed with error: %d\n", WSAGetLastError());
#else
fprintf(stderr, "web socket handshake error\n");
#endif
return -1;
}
n = recv(args.socket, recv_buf, 1023, 0);
......@@ -1317,9 +1306,9 @@ int wsclient_send_sql(char *command, WS_ACTION_TYPE type, int id) {
switch (type) {
case WS_CONN:
cJSON_AddStringToObject(json, "action", "conn");
cJSON_AddStringToObject(_args, "user", "root");
cJSON_AddStringToObject(_args, "password", "taosdata");
cJSON_AddStringToObject(_args, "db", "");
cJSON_AddStringToObject(_args, "user", args.user);
cJSON_AddStringToObject(_args, "password", args.password);
cJSON_AddStringToObject(_args, "db", args.database);
break;
case WS_QUERY:
......@@ -1372,6 +1361,12 @@ int wsclient_conn() {
}
if (code->valueint == 0) {
cJSON_Delete(root);
if (args.cloud) {
fprintf(stdout, "Successfully connect to %s:%s in restful mode\n\n", args.cloudHost, args.cloudPort);
} else {
fprintf(stdout, "Successfully connect to %s:%d in restful mode\n\n", args.host, args.port);
}
return 0;
} else {
cJSON *message = cJSON_GetObjectItem(root, "message");
......
......@@ -53,8 +53,8 @@ static struct argp_option options[] = {
{"pktlen", 'l', "PKTLEN", 0, "Packet length used for net test, default is 1000 bytes."},
{"pktnum", 'N', "PKTNUM", 0, "Packet numbers used for net test, default is 100."},
{"pkttype", 'S', "PKTTYPE", 0, "Choose packet type used for net test, default is TCP. Only speed test could be either TCP or UDP."},
{"restful", 'R', 0, 0, "Connect and interact with TDengine use restful"},
{"token", 't', "TOKEN", 0, "The token to use when connecting TDengine's cloud services"},
{"restful", 'R', 0, 0, "Connect and interact with TDengine use restful."},
{0, 'E', "DSN", 0, "The DSN to use when connecting TDengine's cloud services."},
{0}};
static error_t parse_opt(int key, char *arg, struct argp_state *state) {
......@@ -64,21 +64,20 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
wordexp_t full_path;
switch (key) {
case 'h':{
char* tmp = strstr(arg, ":");
if (tmp == NULL) {
arguments->host = arg;
} else if ((tmp + 1) != NULL) {
arguments->port = atoi(tmp + 1);
tmp[0] = '\0';
arguments->host = arg;
case 'h':
if (arg) {
args.cloud = false;
args.host = arg;
} else {
fprintf(stderr, "Invalid host\n");
return -1;
}
break;
}
case 'p':
break;
case 'P':
if (arg) {
args.cloud = false;
tsDnodeShellPort = atoi(arg);
p_port = atoi(arg);
} else {
......@@ -106,6 +105,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
wordfree(&full_path);
return -1;
}
args.cloud = false;
tstrncpy(configDir, full_path.we_wordv[0], TSDB_FILENAME_LEN);
wordfree(&full_path);
break;
......@@ -173,11 +173,17 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
case OPT_ABORT:
arguments->abort = 1;
break;
case 't':
arguments->token = arg;
break;
case 'R':
arguments->restful = true;
arguments->cloud = false;
break;
case 'E':
if (arg) {
arguments->cloudDsn = arg;
} else {
fprintf(stderr, "Invalid -E option\n");
return -1;
}
break;
default:
return ARGP_ERR_UNKNOWN;
......@@ -231,8 +237,16 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
}
argp_parse(&argp, argc, argv, 0, 0, arguments);
if (arguments->token == NULL) {
arguments->port = p_port;
if (args.cloudDsn == NULL) {
if (args.cloud) {
args.cloudDsn = getenv("TDENGINE_CLOUD_DSN");
if (args.cloudDsn == NULL) {
args.cloud = false;
}
}
} else {
args.cloud = true;
}
if (arguments->abort) {
......@@ -594,3 +608,37 @@ void exitShell() {
taos_cleanup();
exit(EXIT_SUCCESS);
}
int tcpConnect(char* host, int port) {
struct sockaddr_in serv_addr;
if (port == 0) {
port = 6041;
args.port = 6041;
}
if (NULL == host) {
host = "localhost";
args.host = "localhost";
}
struct hostent *server = gethostbyname(host);
if ((server == NULL) || (server->h_addr == NULL)) {
fprintf(stderr, "no such host: %s\n", host);
return -1;
}
memset(&serv_addr, 0, sizeof(struct sockaddr_in));
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(port);
memcpy(&(serv_addr.sin_addr.s_addr), server->h_addr, server->h_length);
args.socket = socket(AF_INET, SOCK_STREAM, 0);
if (args.socket < 0) {
fprintf(stderr, "failed to create socket\n");
return -1;
}
int retConn = connect(args.socket, (struct sockaddr *)&serv_addr, sizeof(struct sockaddr));
if (retConn < 0) {
fprintf(stderr, "failed to connect\n");
close(args.socket);
return -1;
}
return 0;
}
......@@ -76,7 +76,6 @@ SShellArguments args = {.host = NULL,
.database = NULL,
.timezone = NULL,
.restful = false,
.token = NULL,
.is_raw_time = false,
.is_use_passwd = false,
.dump_config = false,
......@@ -87,7 +86,12 @@ SShellArguments args = {.host = NULL,
.pktLen = 1000,
.pktNum = 100,
.pktType = "TCP",
.netTestRole = NULL};
.netTestRole = NULL,
.cloud = true,
.cloudHost = NULL,
.cloudPort = NULL,
.cloudToken = NULL,
};
/*
* Main function.
......@@ -102,35 +106,6 @@ int main(int argc, char* argv[]) {
exit(EXIT_FAILURE);
}
char* cloud_url = getenv("TDENGINE_CLOUD_URL");
if (cloud_url != NULL) {
char* start = strstr(cloud_url, "http://");
if (start != NULL) {
cloud_url = start + strlen("http://");
} else {
start = strstr(cloud_url, "https://");
if (start != NULL) {
cloud_url = start + strlen("https://");
}
}
char* tmp = last_strstr(cloud_url, ":");
if ((tmp == NULL) && ((tmp + 1) != NULL )) {
fprintf(stderr, "Invalid format in environment variable TDENGINE_CLOUD_URL: %s\n", cloud_url);
exit(EXIT_FAILURE);
} else {
args.port = atoi(tmp + 1);
tmp[0] = '\0';
args.host = cloud_url;
}
}
char* cloud_token = getenv("TDENGINE_CLOUD_TOKEN");
if (cloud_token != NULL) {
args.token = cloud_token;
}
shellParseArgument(argc, argv, &args);
if (args.dump_config) {
......@@ -155,8 +130,15 @@ int main(int argc, char* argv[]) {
exit(0);
}
if (args.restful) {
if (convertHostToServAddr()) {
if (args.cloud) {
if (parse_cloud_dsn()) {
exit(EXIT_FAILURE);
}
if (tcpConnect(args.cloudHost, atoi(args.cloudPort))) {
exit(EXIT_FAILURE);
}
} else if (args.restful) {
if (tcpConnect(args.host, args.port)) {
exit(EXIT_FAILURE);
}
}
......
......@@ -54,7 +54,7 @@ void printHelp() {
printf("%s%s%s\n", indent, indent, "Script to run without enter the shell.");
printf("%s%s\n", indent, "-d");
printf("%s%s%s\n", indent, indent, "Database to use when connecting to the server.");
printf("%s%s\n", indent, "-t");
printf("%s%s\n", indent, "-z");
printf("%s%s%s\n", indent, indent, "Time zone of the shell, default is local.");
printf("%s%s\n", indent, "-n");
printf("%s%s%s\n", indent, indent, "Net role when network connectivity test, default is startup, options: client|server|rpc|startup|sync|speed|fqdn.");
......@@ -62,11 +62,14 @@ void printHelp() {
printf("%s%s%s\n", indent, indent, "Packet length used for net test, default is 1000 bytes.");
printf("%s%s\n", indent, "-N");
printf("%s%s%s\n", indent, indent, "Packet numbers used for net test, default is 100.");
printf("%s%s\n", indent, "-R");
printf("%s%s%s\n", indent, indent, "Connect and interact with TDengine use restful.");
printf("%s%s\n", indent, "-E");
printf("%s%s%s\n", indent, indent, "The DSN to use when connecting TDengine's cloud services.");
printf("%s%s\n", indent, "-S");
printf("%s%s%s\n", indent, indent, "Packet type used for net test, default is TCP.");
printf("%s%s\n", indent, "-V");
printf("%s%s%s\n", indent, indent, "Print program version.");
exit(EXIT_SUCCESS);
}
......@@ -77,6 +80,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
// for host
if (strcmp(argv[i], "-h") == 0) {
if (i < argc - 1) {
arguments->cloud = false;
arguments->host = argv[++i];
} else {
fprintf(stderr, "option -h requires an argument\n");
......@@ -108,6 +112,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
// for management port
else if (strcmp(argv[i], "-P") == 0) {
if (i < argc - 1) {
arguments->cloud = false;
arguments->port = atoi(argv[++i]);
} else {
fprintf(stderr, "option -P requires an argument\n");
......@@ -131,6 +136,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
}
} else if (strcmp(argv[i], "-c") == 0) {
if (i < argc - 1) {
arguments->cloud = false;
char *tmp = argv[++i];
if (strlen(tmp) >= TSDB_FILENAME_LEN) {
fprintf(stderr, "config file path: %s overflow max len %d\n", tmp, TSDB_FILENAME_LEN - 1);
......@@ -172,11 +178,11 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
}
}
// For time zone
else if (strcmp(argv[i], "-t") == 0) {
else if (strcmp(argv[i], "-z") == 0) {
if (i < argc - 1) {
arguments->timezone = argv[++i];
} else {
fprintf(stderr, "option -t requires an argument\n");
fprintf(stderr, "option -z requires an argument\n");
exit(EXIT_FAILURE);
}
}
......@@ -212,6 +218,21 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
exit(EXIT_FAILURE);
}
}
else if (strcmp(argv[i], "-R") == 0) {
arguments->cloud = false;
arguments->restful = true;
}
else if (strcmp(argv[i], "-E") == 0) {
if (i < argc - 1) {
arguments->cloudDsn = argv[++i];
} else {
fprintf(stderr, "options -E requires an argument\n");
exit(EXIT_FAILURE);
}
}
else if (strcmp(argv[i], "-V") == 0) {
printVersion();
exit(EXIT_SUCCESS);
......@@ -226,6 +247,16 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
exit(EXIT_FAILURE);
}
}
if (args.cloudDsn == NULL) {
if (args.cloud) {
args.cloudDsn = getenv("TDENGINE_CLOUD_DSN");
if (args.cloudDsn == NULL) {
args.cloud = false;
}
}
} else {
args.cloud = true;
}
}
void shellPrintContinuePrompt() { printf("%s", CONTINUE_PROMPT); }
......@@ -337,3 +368,64 @@ void get_history_path(char *history) {
}
void exitShell() { exit(EXIT_SUCCESS); }
int tcpConnect(char* host, int iport) {
int iResult;
WSADATA wsaData;
struct addrinfo *aResult = NULL,
*ptr = NULL,
hints;
if (iport == 0) {
iport = 6041;
args.port = iport;
}
if (NULL == host) {
host = "localhost";
args.host = "localhost";
}
char port[10] = {0};
sprintf_s(port, 10, "%d", iport);
iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
if (iResult != 0) {
printf("WSAStartup failed with error: %d\n", iResult);
return 1;
}
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
iResult = getaddrinfo(host, port, &hints, &aResult);
if ( iResult != 0 ) {
printf("getaddrinfo failed with error: %d\n", iResult);
WSACleanup();
return 1;
}
for(ptr=aResult; ptr != NULL ; ptr=ptr->ai_next) {
// Create a SOCKET for connecting to server
args.socket = socket(ptr->ai_family, ptr->ai_socktype,
ptr->ai_protocol);
if (args.socket == INVALID_SOCKET) {
printf("socket failed with error: %ld\n", WSAGetLastError());
WSACleanup();
return 1;
}
// Connect to server.
iResult = connect( args.socket, ptr->ai_addr, (int)ptr->ai_addrlen);
if (iResult == SOCKET_ERROR) {
closesocket(args.socket);
args.socket = INVALID_SOCKET;
continue;
}
break;
}
if (args.socket == INVALID_SOCKET) {
printf("Unable to connect to server!\n");
WSACleanup();
return 1;
}
return 0;
}
\ No newline at end of file
Subproject commit 3d5aa76f8c718dcffa100b45e4cbf313d499c356
Subproject commit 0a81480420d6601bbdb57770ee64e40f24c4ea83
......@@ -3347,6 +3347,12 @@ static void col_project_function(SQLFunctionCtx *pCtx) {
memcpy(pCtx->pOutput, pData, (size_t) numOfRows * pCtx->inputBytes);
} else {
// DESC
if (pCtx->param[0].i64 == 1) {
// only output one row, copy first row to output
memcpy(pCtx->pOutput, pData, (size_t)pCtx->inputBytes);
return ;
}
for(int32_t i = 0; i < pCtx->size; ++i) {
char* dst = pCtx->pOutput + (pCtx->size - 1 - i) * pCtx->inputBytes;
char* src = pData + i * pCtx->inputBytes;
......
......@@ -1713,7 +1713,8 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SGroupbyOperatorInfo *pIn
longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_APP_ERROR);
}
doApplyFunctions(pRuntimeEnv, pInfo->binfo.pCtx, &w, j - num, num, tsList, pSDataBlock->info.rows, pOperator->numOfOutput);
int32_t offset = QUERY_IS_ASC_QUERY(pQueryAttr) ? j - num : j - 1;
doApplyFunctions(pRuntimeEnv, pInfo->binfo.pCtx, &w, offset, num, tsList, pSDataBlock->info.rows, pOperator->numOfOutput);
num = 1;
......@@ -1733,7 +1734,8 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SGroupbyOperatorInfo *pIn
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_APP_ERROR);
}
doApplyFunctions(pRuntimeEnv, pInfo->binfo.pCtx, &w, pSDataBlock->info.rows - num, num, tsList, pSDataBlock->info.rows, pOperator->numOfOutput);
int32_t offset = QUERY_IS_ASC_QUERY(pQueryAttr) ? pSDataBlock->info.rows - num : pSDataBlock->info.rows - 1;
doApplyFunctions(pRuntimeEnv, pInfo->binfo.pCtx, &w, offset, num, tsList, pSDataBlock->info.rows, pOperator->numOfOutput);
}
}
......
......@@ -257,7 +257,13 @@ static FORCE_INLINE int tsdbAppendDFile(SDFile* pDFile, void* buf, int64_t nbyte
return -1;
}
ASSERT(pDFile->info.size == toffset);
//bug fix. To avoid data corruption,
//the end offset of current file should be checked with file size,
//if not equal, known as file corrupted and return error.
if (pDFile->info.size != toffset) {
terrno = TSDB_CODE_TDB_FILE_CORRUPTED;
return -1;
}
if (offset) {
*offset = toffset;
......
......@@ -5,9 +5,9 @@ set -e
pgrep taosd || taosd >> /dev/null 2>&1 &
pgrep taosadapter || taosadapter >> /dev/null 2>&1 &
cd ../../docs-examples/R
cd ../../docs/examples/R
jar_path=`find ../../../debug/build -name taos-jdbcdriver-*-dist.jar`
jar_path=`find ../../../../debug/build -name taos-jdbcdriver-*-dist.jar`
echo jar_path=$jar_path
R -f connect_native.r --args $jar_path
# R -f connect_rest.r --args $jar_path # bug 14704
......
......@@ -5,7 +5,7 @@ set -e
taosd >> /dev/null 2>&1 &
taosadapter >> /dev/null 2>&1 &
cd ../../docs-examples/c
cd ../../docs/examples/c
# 1
gcc connect_example.c -o connect_example -ltaos
......
......@@ -4,7 +4,7 @@ set -e
pgrep taosd || taosd >> /dev/null 2>&1 &
pgrep taosadapter || taosadapter >> /dev/null 2>&1 &
cd ../../docs-examples/csharp
cd ../../docs/examples/csharp
dotnet run --project connect.csproj
......
......@@ -5,7 +5,7 @@ set -e
taosd >> /dev/null 2>&1 &
taosadapter >> /dev/null 2>&1 &
cd ../../docs-examples/go
cd ../../docs/examples/go
go mod tidy
......
......@@ -4,6 +4,6 @@ set -e
taosd >> /dev/null 2>&1 &
taosadapter >> /dev/null 2>&1 &
cd ../../docs-examples/java
cd ../../docs/examples/java
mvn test
\ No newline at end of file
......@@ -5,7 +5,7 @@ set -e
pgrep taosd || taosd >> /dev/null 2>&1 &
pgrep taosadapter || taosadapter >> /dev/null 2>&1 &
cd ../../docs-examples/node
cd ../../docs/examples/node
npm install
cd restexample;
......
......@@ -5,7 +5,7 @@ set -e
taosd >> /dev/null 2>&1 &
taosadapter >> /dev/null 2>&1 &
cd ../../docs-examples/python
cd ../../docs/examples/python
# 1
taos -s "create database if not exists log"
......
......@@ -5,7 +5,7 @@ set -e
pgrep taosd || taosd >> /dev/null 2>&1 &
pgrep taosadapter || taosadapter >> /dev/null 2>&1 &
cd ../../docs-examples/rust
cd ../../docs/examples/rust
cargo run -p nativeexample --example connect
cargo run -p restexample --example connect
......
......@@ -95,7 +95,7 @@ docker run \
-v $REPDIR/packaging/cfg/taos.cfg:/etc/taos/taos.cfg:ro \
-v $REPDIR/packaging:$CONTAINER_TESTDIR/packaging:ro \
-v $REPDIR/README.md:$CONTAINER_TESTDIR/README.md:ro \
-v $REPDIR/docs-examples:$CONTAINER_TESTDIR/docs-examples \
-v $REPDIR/docs:$CONTAINER_TESTDIR/docs \
-v $REPDIR/src/connector/python/taos:/usr/local/lib/python3.8/site-packages/taos:ro \
-e LD_LIBRARY_PATH=/home/debug/build/lib:/home/debug/build/lib64 \
--rm --ulimit core=-1 taos_test:v1.0 $CONTAINER_TESTDIR/tests/parallel_test/run_case.sh -d "$exec_dir" -c "$cmd" $timeout_param
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册