提交 5f635bed 编写于 作者: wmmhello's avatar wmmhello

Merge branch 'develop' into feature/TD-6129

...@@ -38,7 +38,8 @@ def pre_test(){ ...@@ -38,7 +38,8 @@ def pre_test(){
sudo rmtaos || echo "taosd has not installed" sudo rmtaos || echo "taosd has not installed"
''' '''
sh ''' sh '''
killall -9 taosd ||echo "no taosd running" kill -9 $(pidof taosd) ||echo "no taosd running"
kill -9 $(pidof taosadapter) ||echo "no taosadapter running"
killall -9 gdb || echo "no gdb running" killall -9 gdb || echo "no gdb running"
killall -9 python3.8 || echo "no python program running" killall -9 python3.8 || echo "no python program running"
cd ${WKC} cd ${WKC}
...@@ -104,7 +105,7 @@ def pre_test(){ ...@@ -104,7 +105,7 @@ def pre_test(){
git clean -dfx git clean -dfx
mkdir debug mkdir debug
cd debug cd debug
cmake .. > /dev/null cmake .. -DBUILD_HTTP=false > /dev/null
make > /dev/null make > /dev/null
make install > /dev/null make install > /dev/null
cd ${WKC}/tests cd ${WKC}/tests
...@@ -178,7 +179,7 @@ def pre_test_noinstall(){ ...@@ -178,7 +179,7 @@ def pre_test_noinstall(){
git clean -dfx git clean -dfx
mkdir debug mkdir debug
cd debug cd debug
cmake .. > /dev/null cmake .. -DBUILD_HTTP=false > /dev/null
make make
''' '''
return 1 return 1
......
...@@ -100,7 +100,7 @@ sudo dnf install -y maven ...@@ -100,7 +100,7 @@ sudo dnf install -y maven
#### Install build dependencies for taos-tools #### Install build dependencies for taos-tools
To build the [taos-tools](https://github.com/taosdata/taos-tools) on CentOS, the following packages need to be installed. To build the [taos-tools](https://github.com/taosdata/taos-tools) on CentOS, the following packages need to be installed.
```bash ```bash
sudo yum install libz-devel xz-devel snappy-devel jansson-devel pkgconfig libatomic sudo yum install zlib-devel xz-devel snappy-devel jansson-devel pkgconfig libatomic
``` ```
Note: Since snappy lacks pkg-config support (refer to [link](https://github.com/google/snappy/pull/86)), it lead a cmake prompt libsnappy not found. But snappy will works well. Note: Since snappy lacks pkg-config support (refer to [link](https://github.com/google/snappy/pull/86)), it lead a cmake prompt libsnappy not found. But snappy will works well.
...@@ -142,15 +142,15 @@ mkdir debug && cd debug ...@@ -142,15 +142,15 @@ mkdir debug && cd debug
cmake .. && cmake --build . cmake .. && cmake --build .
``` ```
Note TDengine 2.3.x.0 and later use a component named 'taosadapter' to play http daemon role by default instead of the http daemon embedded in the early version of TDengine. The taosadapter is programmed by go language. If you pull TDengine source code to the latest from an existing codebase, please execute 'git submodule update --init --recursive' to pull taosadapter source code. Please install go language 1.14 or above for compiling taosadapter. If you meet difficulties regarding 'go mod', especially you are from China, you can use a proxy to solve the problem. Note TDengine 2.3.x.0 and later use a component named 'taosAdapter' to play http daemon role by default instead of the http daemon embedded in the early version of TDengine. The taosAdapter is programmed by go language. If you pull TDengine source code to the latest from an existing codebase, please execute 'git submodule update --init --recursive' to pull taosAdapter source code. Please install go language 1.14 or above for compiling taosAdapter. If you meet difficulties regarding 'go mod', especially you are from China, you can use a proxy to solve the problem.
``` ```
go env -w GO111MODULE=on go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct go env -w GOPROXY=https://goproxy.cn,direct
``` ```
Or you can use the following command to choose to embed old httpd too. The embedded http daemon still be built from TDengine source code by default. Or you can use the following command to choose to build taosAdapter.
``` ```
cmake .. -DBUILD_HTTP=true cmake .. -DBUILD_HTTP=false
``` ```
You can use Jemalloc as memory allocator instead of glibc: You can use Jemalloc as memory allocator instead of glibc:
......
...@@ -113,7 +113,7 @@ TDengine is a highly efficient platform to store, query, and analyze time-series ...@@ -113,7 +113,7 @@ TDengine is a highly efficient platform to store, query, and analyze time-series
- [System Connection and Task Query Management](/administrator#status): show the system connections, queries, streaming calculation and others - [System Connection and Task Query Management](/administrator#status): show the system connections, queries, streaming calculation and others
- [System Monitor](/administrator#monitoring): monitor TDengine cluster with log database and TDinsight. - [System Monitor](/administrator#monitoring): monitor TDengine cluster with log database and TDinsight.
- [File Directory Structure](/administrator#directories): directories where TDengine data files and configuration files located - [File Directory Structure](/administrator#directories): directories where TDengine data files and configuration files located
- [Parameter Limitss and Reserved Keywords](/administrator#keywords): TDengine’s list of parameter limits and reserved keywords - [Parameter Limits and Reserved Keywords](/administrator#keywords): TDengine’s list of parameter limits and reserved keywords
## Performance: TDengine vs Others ## Performance: TDengine vs Others
......
Since TDengine was open sourced in July 2019, it has gained a lot of popularity among time-series database developers with its innovative data modeling design, simple installation mehtod, easy programming interface, and powerful data insertion and query performance. The insertion and querying performance is often astonishing to users who are new to TDengine. In order to help users to experience the high performance and functions of TDengine in the shortest time, we developed an application called taosdemo for insertion and querying performance testing of TDengine. Then user can easily simulate the scenario of a large number of devices generating a very large amount of data. User can easily maniplate the number of columns, data types, disorder ratio, and number of concurrent threads with taosdemo customized parameters. Since TDengine was open sourced in July 2019, it has gained a lot of popularity among time-series database developers with its innovative data modeling design, simple installation method, easy programming interface, and powerful data insertion and query performance. The insertion and querying performance is often astonishing to users who are new to TDengine. In order to help users to experience the high performance and functions of TDengine in the shortest time, we developed an application called taosdemo for insertion and querying performance testing of TDengine. Then user can easily simulate the scenario of a large number of devices generating a very large amount of data. User can easily manipulate the number of columns, data types, disorder ratio, and number of concurrent threads with taosdemo customized parameters.
Running taosdemo is very simple. Just download the TDengine installation package (https://www.taosdata.com/cn/all-downloads/) or compiling the TDengine code yourself (https://github.com/taosdata/TDengine). It can be found and run in the installation directory or in the compiled results directory. Running taosdemo is very simple. Just download the TDengine installation package (https://www.taosdata.com/cn/all-downloads/) or compiling the TDengine code yourself (https://github.com/taosdata/TDengine). It can be found and run in the installation directory or in the compiled results directory.
...@@ -221,7 +221,7 @@ To reach TDengine performance limits, data insertion can be executed by using mu ...@@ -221,7 +221,7 @@ To reach TDengine performance limits, data insertion can be executed by using mu
``` ```
-t, --tables=NUMBER The number of tables. Default is 10000. -t, --tables=NUMBER The number of tables. Default is 10000.
-n, --records=NUMBER The number of records per table. Default is 10000. -n, --records=NUMBER The number of records per table. Default is 10000.
-M, --random The value of records generated are totally random. The default is to simulate power equipment senario. -M, --random The value of records generated are totally random. The default is to simulate power equipment scenario.
``` ```
As mentioned earlier, taosdemo creates 10,000 tables by default, and each table writes 10,000 records. taosdemo can set the number of tables and the number of records in each table by -t and -n. The data generated by default without parameters are simulated real scenarios, and the simulated data are current and voltage phase values with certain jitter, which can more realistically show TDengine's efficient data compression ability. If you need to simulate the generation of completely random data, you can pass the -M parameter. As mentioned earlier, taosdemo creates 10,000 tables by default, and each table writes 10,000 records. taosdemo can set the number of tables and the number of records in each table by -t and -n. The data generated by default without parameters are simulated real scenarios, and the simulated data are current and voltage phase values with certain jitter, which can more realistically show TDengine's efficient data compression ability. If you need to simulate the generation of completely random data, you can pass the -M parameter.
``` ```
......
...@@ -193,7 +193,7 @@ A complete TDengine system runs on one or more physical nodes. Logically, it inc ...@@ -193,7 +193,7 @@ A complete TDengine system runs on one or more physical nodes. Logically, it inc
**Redirection**: No matter about dnode or TAOSC, the connection to the mnode shall be initiated first, but the mnode is automatically created and maintained by the system, so the user does not know which dnode is running the mnode. TDengine only requires a connection to any working dnode in the system. Because any running dnode maintains the currently running mnode EP List, when receiving a connecting request from the newly started dnode or TAOSC, if it’s not a mnode by self, it will reply to the mnode EP List back. After receiving this list, TAOSC or the newly started dnode will try to establish the connection again. When the mnode EP List changes, each data node quickly obtains the latest list and notifies TAOSC through messaging interaction among nodes. **Redirection**: No matter about dnode or TAOSC, the connection to the mnode shall be initiated first, but the mnode is automatically created and maintained by the system, so the user does not know which dnode is running the mnode. TDengine only requires a connection to any working dnode in the system. Because any running dnode maintains the currently running mnode EP List, when receiving a connecting request from the newly started dnode or TAOSC, if it’s not a mnode by self, it will reply to the mnode EP List back. After receiving this list, TAOSC or the newly started dnode will try to establish the connection again. When the mnode EP List changes, each data node quickly obtains the latest list and notifies TAOSC through messaging interaction among nodes.
### A Typical Data Writinfg Process ### A Typical Data Writing Process
To explain the relationship between vnode, mnode, TAOSC and application and their respective roles, the following is an analysis of a typical data writing process. To explain the relationship between vnode, mnode, TAOSC and application and their respective roles, the following is an analysis of a typical data writing process.
...@@ -244,7 +244,7 @@ The meta data of each table (including schema, tags, etc.) is also stored in vno ...@@ -244,7 +244,7 @@ The meta data of each table (including schema, tags, etc.) is also stored in vno
### Data Partitioning ### Data Partitioning
In addition to vnode sharding, TDengine partitions the time-series data by time range. Each data file contains only one time range of time-series data, and the length of the time range is determined by DB's configuration parameter `“days”`. This method of partitioning by time rang is also convenient to efficiently implement the data retention policy. As long as the data file exceeds the specified number of days (system configuration parameter `“keep”`), it will be automatically deleted. Moreover, different time ranges can be stored in different paths and storage media, so as to facilitate the tiered-storage. Cold/hot data can be stored in different storage meida to reduce the storage cost. In addition to vnode sharding, TDengine partitions the time-series data by time range. Each data file contains only one time range of time-series data, and the length of the time range is determined by DB's configuration parameter `“days”`. This method of partitioning by time rang is also convenient to efficiently implement the data retention policy. As long as the data file exceeds the specified number of days (system configuration parameter `“keep”`), it will be automatically deleted. Moreover, different time ranges can be stored in different paths and storage media, so as to facilitate the tiered-storage. Cold/hot data can be stored in different storage media to reduce the storage cost.
In general, **TDengine splits big data by vnode and time range in two dimensions** to manage the data efficiently with horizontal scalability. In general, **TDengine splits big data by vnode and time range in two dimensions** to manage the data efficiently with horizontal scalability.
......
...@@ -182,7 +182,7 @@ In the output plugins section, add the [[outputs.http]] configuration: ...@@ -182,7 +182,7 @@ In the output plugins section, add the [[outputs.http]] configuration:
In agent section: In agent section:
- hostname: The machine name that distinguishes different collection devices, and it is necessary to ensure its uniqueness - hostname: The machine name that distinguishes different collection devices, and it is necessary to ensure its uniqueness
- metric_batch_size: 100, which is the max number of records per batch wriiten by Telegraf allowed. Increasing the number can reduce the request sending frequency of Telegraf. - metric_batch_size: 100, which is the max number of records per batch written by Telegraf allowed. Increasing the number can reduce the request sending frequency of Telegraf.
For information on how to use Telegraf to collect data and more about using Telegraf, please refer to the official [document](https://docs.influxdata.com/telegraf/v1.11/) of Telegraf. For information on how to use Telegraf to collect data and more about using Telegraf, please refer to the official [document](https://docs.influxdata.com/telegraf/v1.11/) of Telegraf.
......
...@@ -11,7 +11,7 @@ TDengine uses SQL as the query language. Applications can send SQL statements th ...@@ -11,7 +11,7 @@ TDengine uses SQL as the query language. Applications can send SQL statements th
- Time stamp aligned join query (implicit join) operations - Time stamp aligned join query (implicit join) operations
- Multiple aggregation/calculation functions: count, max, min, avg, sum, twa, stddev, leastsquares, top, bottom, first, last, percentile, apercentile, last_row, spread, diff, etc - Multiple aggregation/calculation functions: count, max, min, avg, sum, twa, stddev, leastsquares, top, bottom, first, last, percentile, apercentile, last_row, spread, diff, etc
For example, in TAOS shell, the records with vlotage > 215 are queried from table d1001, sorted in descending order by timestamps, and only two records are outputted. For example, in TAOS shell, the records with voltage > 215 are queried from table d1001, sorted in descending order by timestamps, and only two records are outputted.
```mysql ```mysql
taos> select * from d1001 where voltage > 215 order by ts desc limit 2; taos> select * from d1001 where voltage > 215 order by ts desc limit 2;
......
...@@ -110,10 +110,10 @@ First, use `taos_subscribe` to create a subscription: ...@@ -110,10 +110,10 @@ First, use `taos_subscribe` to create a subscription:
```c ```c
TAOS_SUB* tsub = NULL; TAOS_SUB* tsub = NULL;
if (async) { if (async) {
  // create an asynchronized subscription, the callback function will be called every 1s   // create an asynchronous subscription, the callback function will be called every 1s
  tsub = taos_subscribe(taos, restart, topic, sql, subscribe_callback, &blockFetch, 1000);   tsub = taos_subscribe(taos, restart, topic, sql, subscribe_callback, &blockFetch, 1000);
} else { } else {
  // create an synchronized subscription, need to call 'taos_consume' manually   // create an synchronous subscription, need to call 'taos_consume' manually
  tsub = taos_subscribe(taos, restart, topic, sql, NULL, NULL, 0);   tsub = taos_subscribe(taos, restart, topic, sql, NULL, NULL, 0);
} }
``` ```
...@@ -201,7 +201,7 @@ taos_unsubscribe(tsub, keep); ...@@ -201,7 +201,7 @@ taos_unsubscribe(tsub, keep);
Its second parameter is used to decide whether to keep the progress information of subscription on the client. If this parameter is **false** (zero), the subscription can only be restarted no matter what the `restart` parameter is when `taos_subscribe` is called next time. In addition, progress information is saved in the directory {DataDir}/subscribe/. Each subscription has a file with the same name as its `topic`. Deleting a file will also lead to a new start when the corresponding subscription is created next time. Its second parameter is used to decide whether to keep the progress information of subscription on the client. If this parameter is **false** (zero), the subscription can only be restarted no matter what the `restart` parameter is when `taos_subscribe` is called next time. In addition, progress information is saved in the directory {DataDir}/subscribe/. Each subscription has a file with the same name as its `topic`. Deleting a file will also lead to a new start when the corresponding subscription is created next time.
After introducing the code, let's take a look at the actual running effect. For exmaple: After introducing the code, let's take a look at the actual running effect. For example:
- Sample code has been downloaded locally - Sample code has been downloaded locally
- TDengine has been installed on the same machine - TDengine has been installed on the same machine
......
...@@ -54,33 +54,33 @@ INSERT INTO test.t1 USING test.weather (ts, temperature) TAGS('beijing') VALUES( ...@@ -54,33 +54,33 @@ INSERT INTO test.t1 USING test.weather (ts, temperature) TAGS('beijing') VALUES(
## JDBC driver version and supported TDengine and JDK versions ## JDBC driver version and supported TDengine and JDK versions
| taos-jdbcdriver | TDengine | JDK | | taos-jdbcdriver | TDengine | JDK |
| -------------------- | ----------------- | -------- | | --------------- | ------------------ | ----- |
| 2.0.33 - 2.0.34 | 2.0.3.0 and above | 1.8.x | | 2.0.33 - 2.0.34 | 2.0.3.0 and above | 1.8.x |
| 2.0.31 - 2.0.32 | 2.1.3.0 and above | 1.8.x | | 2.0.31 - 2.0.32 | 2.1.3.0 and above | 1.8.x |
| 2.0.22 - 2.0.30 | 2.0.18.0 - 2.1.2.x | 1.8.x | | 2.0.22 - 2.0.30 | 2.0.18.0 - 2.1.2.x | 1.8.x |
| 2.0.12 - 2.0.21 | 2.0.8.0 - 2.0.17.x | 1.8.x | | 2.0.12 - 2.0.21 | 2.0.8.0 - 2.0.17.x | 1.8.x |
| 2.0.4 - 2.0.11 | 2.0.0.0 - 2.0.7.x | 1.8.x | | 2.0.4 - 2.0.11 | 2.0.0.0 - 2.0.7.x | 1.8.x |
| 1.0.3 | 1.6.1.x and above | 1.8.x | | 1.0.3 | 1.6.1.x and above | 1.8.x |
| 1.0.2 | 1.6.1.x and above | 1.8.x | | 1.0.2 | 1.6.1.x and above | 1.8.x |
| 1.0.1 | 1.6.1.x and above | 1.8.x | | 1.0.1 | 1.6.1.x and above | 1.8.x |
## DataType in TDengine and Java connector ## DataType in TDengine and Java connector
The TDengine supports the following data types and Java data types: The TDengine supports the following data types and Java data types:
| TDengine DataType | JDBCType (driver version < 2.0.24) | JDBCType (driver version >= 2.0.24) | | TDengine DataType | JDBCType (driver version < 2.0.24) | JDBCType (driver version >= 2.0.24) |
| ----------------- | ------------------ | ------------------ | | ----------------- | ---------------------------------- | ----------------------------------- |
| TIMESTAMP | java.lang.Long | java.sql.Timestamp | | TIMESTAMP | java.lang.Long | java.sql.Timestamp |
| INT | java.lang.Integer | java.lang.Integer | | INT | java.lang.Integer | java.lang.Integer |
| BIGINT | java.lang.Long | java.lang.Long | | BIGINT | java.lang.Long | java.lang.Long |
| FLOAT | java.lang.Float | java.lang.Float | | FLOAT | java.lang.Float | java.lang.Float |
| DOUBLE | java.lang.Double | java.lang.Double | | DOUBLE | java.lang.Double | java.lang.Double |
| SMALLINT | java.lang.Short | java.lang.Short | | SMALLINT | java.lang.Short | java.lang.Short |
| TINYINT | java.lang.Byte | java.lang.Byte | | TINYINT | java.lang.Byte | java.lang.Byte |
| BOOL | java.lang.Boolean | java.lang.Boolean | | BOOL | java.lang.Boolean | java.lang.Boolean |
| BINARY | java.lang.String | byte array | | BINARY | java.lang.String | byte array |
| NCHAR | java.lang.String | java.lang.String | | NCHAR | java.lang.String | java.lang.String |
## Install Java connector ## Install Java connector
...@@ -448,7 +448,7 @@ public static void main(String[] args) throws SQLException { ...@@ -448,7 +448,7 @@ public static void main(String[] args) throws SQLException {
config.setMinimumIdle(10); //minimum number of idle connection config.setMinimumIdle(10); //minimum number of idle connection
config.setMaximumPoolSize(10); //maximum number of connection in the pool config.setMaximumPoolSize(10); //maximum number of connection in the pool
config.setConnectionTimeout(30000); //maximum wait milliseconds for get connection from pool config.setConnectionTimeout(30000); //maximum wait milliseconds for get connection from pool
config.setMaxLifetime(0); // maximum life time for each connection config.setMaxLifetime(0); // maximum lifetime for each connection
config.setIdleTimeout(0); // max idle time for recycle idle connection config.setIdleTimeout(0); // max idle time for recycle idle connection
config.setConnectionTestQuery("select server_status()"); //validation query config.setConnectionTestQuery("select server_status()"); //validation query
HikariDataSource ds = new HikariDataSource(config); //create datasource HikariDataSource ds = new HikariDataSource(config); //create datasource
...@@ -456,7 +456,7 @@ public static void main(String[] args) throws SQLException { ...@@ -456,7 +456,7 @@ public static void main(String[] args) throws SQLException {
Statement statement = connection.createStatement(); // get statement Statement statement = connection.createStatement(); // get statement
//query or insert //query or insert
// ... // ...
connection.close(); // put back to conneciton pool connection.close(); // put back to connection pool
} }
``` ```
...@@ -480,7 +480,7 @@ public static void main(String[] args) throws Exception { ...@@ -480,7 +480,7 @@ public static void main(String[] args) throws Exception {
Statement statement = connection.createStatement(); // get statement Statement statement = connection.createStatement(); // get statement
//query or insert //query or insert
// ... // ...
connection.close(); // put back to conneciton pool connection.close(); // put back to connection pool
} }
``` ```
......
...@@ -15,7 +15,7 @@ if you use the default features, it'll depend on: ...@@ -15,7 +15,7 @@ if you use the default features, it'll depend on:
- [TDengine Client](https://www.taosdata.com/cn/getting-started/#%E9%80%9A%E8%BF%87%E5%AE%89%E8%A3%85%E5%8C%85%E5%AE%89%E8%A3%85) library and headers. - [TDengine Client](https://www.taosdata.com/cn/getting-started/#%E9%80%9A%E8%BF%87%E5%AE%89%E8%A3%85%E5%8C%85%E5%AE%89%E8%A3%85) library and headers.
- clang because bindgen will requires the clang AST library. - clang because bindgen will requires the clang AST library.
## Fetures ## Features
In-design features: In-design features:
......
...@@ -884,7 +884,7 @@ dotnet new console ...@@ -884,7 +884,7 @@ dotnet new console
``` cmd ``` cmd
dotnet add package TDengine.Connector dotnet add package TDengine.Connector
``` ```
* inlucde the TDnengineDriver in you application's namespace * include the TDnengineDriver in you application's namespace
```C# ```C#
using TDengineDriver; using TDengineDriver;
``` ```
......
...@@ -228,7 +228,7 @@ Note: In 2.0.15.0 and later versions, STABLE reserved words are supported. That ...@@ -228,7 +228,7 @@ Note: In 2.0.15.0 and later versions, STABLE reserved words are supported. That
```mysql ```mysql
CREATE STABLE [IF NOT EXISTS] stb_name (timestamp_field_name TIMESTAMP, field1_name data_type1 [, field2_name data_type2 ...]) TAGS (tag1_name tag_type1, tag2_name tag_type2 [, tag3_name tag_type3]); CREATE STABLE [IF NOT EXISTS] stb_name (timestamp_field_name TIMESTAMP, field1_name data_type1 [, field2_name data_type2 ...]) TAGS (tag1_name tag_type1, tag2_name tag_type2 [, tag3_name tag_type3]);
``` ```
Similiar to a standard table creation SQL, but you need to specify name and type of TAGS field. Similar to a standard table creation SQL, but you need to specify name and type of TAGS field.
Note: Note:
...@@ -673,7 +673,7 @@ Query OK, 1 row(s) in set (0.001091s) ...@@ -673,7 +673,7 @@ Query OK, 1 row(s) in set (0.001091s)
SELECT * FROM tb1 WHERE ts >= NOW - 1h; SELECT * FROM tb1 WHERE ts >= NOW - 1h;
``` ```
- Look up table tb1 from 2018-06-01 08:00:00. 000 to 2018-06-02 08:00:00. 000, and col3 string is a record ending in'nny ', and the result is in descending order of timestamp: - Look up table tb1 from 2018-06-01 08:00:00. 000 to 2018-06-02 08:00:00. 000, and col3 string is a record ending in 'nny ', and the result is in descending order of timestamp:
```mysql ```mysql
SELECT * FROM tb1 WHERE ts > '2018-06-01 08:00:00.000' AND ts <= '2018-06-02 08:00:00.000' AND col3 LIKE '%nny' ORDER BY ts DESC; SELECT * FROM tb1 WHERE ts > '2018-06-01 08:00:00.000' AND ts <= '2018-06-02 08:00:00.000' AND col3 LIKE '%nny' ORDER BY ts DESC;
...@@ -782,7 +782,7 @@ TDengine supports aggregations over data, they are listed below: ...@@ -782,7 +782,7 @@ TDengine supports aggregations over data, they are listed below:
Function: return the sum of a statistics/STable. Function: return the sum of a statistics/STable.
Return Data Type: long integer INMT64 and Double. Return Data Type: INT64 and Double.
Applicable Fields: All types except timestamp, binary, nchar, bool. Applicable Fields: All types except timestamp, binary, nchar, bool.
...@@ -1196,7 +1196,7 @@ SELECT function_list FROM stb_name ...@@ -1196,7 +1196,7 @@ SELECT function_list FROM stb_name
- FILL statement specifies a filling mode when data missed in a certain interval. Applicable filling modes include the following: - FILL statement specifies a filling mode when data missed in a certain interval. Applicable filling modes include the following:
1. Do not fill: NONE (default filingl mode). 1. Do not fill: NONE (default filing mode).
2. VALUE filling: Fixed value filling, where the filled value needs to be specified. For example: fill (VALUE, 1.23). 2. VALUE filling: Fixed value filling, where the filled value needs to be specified. For example: fill (VALUE, 1.23).
3. NULL filling: Fill the data with NULL. For example: fill (NULL). 3. NULL filling: Fill the data with NULL. For example: fill (NULL).
4. PREV filling: Filling data with the previous non-NULL value. For example: fill (PREV). 4. PREV filling: Filling data with the previous non-NULL value. For example: fill (PREV).
......
...@@ -28,7 +28,7 @@ The overall system architecture of a typical DevOps application scenario is show ...@@ -28,7 +28,7 @@ The overall system architecture of a typical DevOps application scenario is show
In this application scenario, there are Agent tools deployed in the application environment to collect machine metrics, network metrics, and application metrics, data collectors to aggregate information collected by agents, systems for data persistence storage and management, and tools for monitoring data visualization (e.g., Grafana, etc.). In this application scenario, there are Agent tools deployed in the application environment to collect machine metrics, network metrics, and application metrics, data collectors to aggregate information collected by agents, systems for data persistence storage and management, and tools for monitoring data visualization (e.g., Grafana, etc.).
Among them, Agents deployed in application nodes are responsible for providing operational metrics from different sources to collectd/Statsd, and collectd/StatsD is responsible for pushing the aggregated data to the OpenTSDB cluster system and then visualizing the data using the visualization kanban board Grafana. Among them, Agents deployed in application nodes are responsible for providing operational metrics from different sources to collectd/Statsd, and collectd/StatsD is responsible for pushing the aggregated data to the OpenTSDB cluster system and then visualizing the data using the visualization board of Grafana.
### 2. Migration Service ### 2. Migration Service
...@@ -127,11 +127,11 @@ On the one hand, TDengine requires a strict schema definition for its incoming d ...@@ -127,11 +127,11 @@ On the one hand, TDengine requires a strict schema definition for its incoming d
Now let's assume a DevOps scenario where we use collectd to collect base metrics of devices, including memory, swap, disk, etc. The schema in OpenTSDB is as follows: Now let's assume a DevOps scenario where we use collectd to collect base metrics of devices, including memory, swap, disk, etc. The schema in OpenTSDB is as follows:
| No. | metric | value | type | tag1 | tag2 | tag3 | tag4 | tag5 | | No. | metric | value | type | tag1 | tag2 | tag3 | tag4 | tag5 |
| ---- | -------------- | ------ | ------ | ---- | ----------- | -------------------- | --------- | ------ | | --- | ------ | ----- | ------ | ---- | ----------- | -------------------- | --------- | ------ |
| 1 | memory | value | double | host | memory_type | memory_type_instance | source | | | 1 | memory | value | double | host | memory_type | memory_type_instance | source | |
| 2 | swap | value | double | host | swap_type | swap_type_instance | source | | | 2 | swap | value | double | host | swap_type | swap_type_instance | source | |
| 3 | disk | value | double | host | disk_point | disk_instance | disk_type | source | | 3 | disk | value | double | host | disk_point | disk_instance | disk_type | source |
......
...@@ -188,9 +188,6 @@ function update() { ...@@ -188,9 +188,6 @@ function update() {
install_log install_log
install_header install_header
install_lib install_lib
if [ "$pagMode" != "lite" ]; then
install_connector
fi
install_examples install_examples
install_bin install_bin
install_config install_config
...@@ -215,9 +212,6 @@ function install() { ...@@ -215,9 +212,6 @@ function install() {
install_log install_log
install_header install_header
install_lib install_lib
if [ "$pagMode" != "lite" ]; then
install_connector
fi
install_examples install_examples
install_bin install_bin
install_config install_config
......
...@@ -189,9 +189,6 @@ function update() { ...@@ -189,9 +189,6 @@ function update() {
install_log install_log
install_header install_header
install_lib install_lib
if [ "$pagMode" != "lite" ]; then
install_connector
fi
install_examples install_examples
install_bin install_bin
install_config install_config
...@@ -216,9 +213,6 @@ function install() { ...@@ -216,9 +213,6 @@ function install() {
install_log install_log
install_header install_header
install_lib install_lib
if [ "$pagMode" != "lite" ]; then
install_connector
fi
install_examples install_examples
install_bin install_bin
install_config install_config
......
...@@ -247,9 +247,6 @@ function update_PowerDB() { ...@@ -247,9 +247,6 @@ function update_PowerDB() {
install_log install_log
install_header install_header
install_lib install_lib
if [ "$pagMode" != "lite" ]; then
install_connector
fi
install_examples install_examples
install_bin install_bin
install_config install_config
...@@ -275,9 +272,6 @@ function install_PowerDB() { ...@@ -275,9 +272,6 @@ function install_PowerDB() {
install_header install_header
install_lib install_lib
install_jemalloc install_jemalloc
if [ "$pagMode" != "lite" ]; then
install_connector
fi
install_examples install_examples
install_bin install_bin
install_config install_config
......
...@@ -189,9 +189,6 @@ function update_prodb() { ...@@ -189,9 +189,6 @@ function update_prodb() {
install_log install_log
install_header install_header
install_lib install_lib
if [ "$pagMode" != "lite" ]; then
install_connector
fi
install_examples install_examples
install_bin install_bin
install_config install_config
...@@ -216,9 +213,6 @@ function install_prodb() { ...@@ -216,9 +213,6 @@ function install_prodb() {
install_log install_log
install_header install_header
install_lib install_lib
if [ "$pagMode" != "lite" ]; then
install_connector
fi
install_examples install_examples
install_bin install_bin
install_config install_config
......
...@@ -193,9 +193,6 @@ function update_tq() { ...@@ -193,9 +193,6 @@ function update_tq() {
install_log install_log
install_header install_header
install_lib install_lib
if [ "$pagMode" != "lite" ]; then
install_connector
fi
install_examples install_examples
install_bin install_bin
install_config install_config
...@@ -220,9 +217,6 @@ function install_tq() { ...@@ -220,9 +217,6 @@ function install_tq() {
install_log install_log
install_header install_header
install_lib install_lib
if [ "$pagMode" != "lite" ]; then
install_connector
fi
install_examples install_examples
install_bin install_bin
install_config install_config
......
...@@ -69,10 +69,10 @@ if [ "$osType" != "Darwin" ]; then ...@@ -69,10 +69,10 @@ if [ "$osType" != "Darwin" ]; then
if [ "$pagMode" == "lite" ]; then if [ "$pagMode" == "lite" ]; then
strip ${build_dir}/bin/taos strip ${build_dir}/bin/taos
cp ${build_dir}/bin/taos ${install_dir}/bin/jh_taos cp ${build_dir}/bin/taos ${install_dir}/bin/jh_taos
cp ${script_dir}/remove_jh.sh ${install_dir}/bin cp ${script_dir}/remove_client_jh.sh ${install_dir}/bin
else else
cp ${build_dir}/bin/taos ${install_dir}/bin/jh_taos cp ${build_dir}/bin/taos ${install_dir}/bin/jh_taos
cp ${script_dir}/remove_jh.sh ${install_dir}/bin cp ${script_dir}/remove_client_jh.sh ${install_dir}/bin
cp ${build_dir}/bin/taosdemo ${install_dir}/bin/jhdemo cp ${build_dir}/bin/taosdemo ${install_dir}/bin/jhdemo
cp ${build_dir}/bin/taosdump ${install_dir}/bin/jh_taosdump cp ${build_dir}/bin/taosdump ${install_dir}/bin/jh_taosdump
cp ${script_dir}/set_core.sh ${install_dir}/bin cp ${script_dir}/set_core.sh ${install_dir}/bin
......
...@@ -69,10 +69,10 @@ if [ "$osType" != "Darwin" ]; then ...@@ -69,10 +69,10 @@ if [ "$osType" != "Darwin" ]; then
if [ "$pagMode" == "lite" ]; then if [ "$pagMode" == "lite" ]; then
strip ${build_dir}/bin/taos strip ${build_dir}/bin/taos
cp ${build_dir}/bin/taos ${install_dir}/bin/khclient cp ${build_dir}/bin/taos ${install_dir}/bin/khclient
cp ${script_dir}/remove_kh.sh ${install_dir}/bin cp ${script_dir}/remove_client_kh.sh ${install_dir}/bin
else else
cp ${build_dir}/bin/taos ${install_dir}/bin/khclient cp ${build_dir}/bin/taos ${install_dir}/bin/khclient
cp ${script_dir}/remove_kh.sh ${install_dir}/bin cp ${script_dir}/remove_client_kh.sh ${install_dir}/bin
cp ${build_dir}/bin/taosdemo ${install_dir}/bin/khdemo cp ${build_dir}/bin/taosdemo ${install_dir}/bin/khdemo
cp ${build_dir}/bin/taosdump ${install_dir}/bin/khdump cp ${build_dir}/bin/taosdump ${install_dir}/bin/khdump
cp ${script_dir}/set_core.sh ${install_dir}/bin cp ${script_dir}/set_core.sh ${install_dir}/bin
......
...@@ -109,10 +109,10 @@ if [ "$osType" != "Darwin" ]; then ...@@ -109,10 +109,10 @@ if [ "$osType" != "Darwin" ]; then
if [ "$pagMode" == "lite" ]; then if [ "$pagMode" == "lite" ]; then
strip ${build_dir}/bin/taos strip ${build_dir}/bin/taos
cp ${build_dir}/bin/taos ${install_dir}/bin/power cp ${build_dir}/bin/taos ${install_dir}/bin/power
cp ${script_dir}/remove_power.sh ${install_dir}/bin cp ${script_dir}/remove_client_power.sh ${install_dir}/bin
else else
cp ${build_dir}/bin/taos ${install_dir}/bin/power cp ${build_dir}/bin/taos ${install_dir}/bin/power
cp ${script_dir}/remove_power.sh ${install_dir}/bin cp ${script_dir}/remove_client_power.sh ${install_dir}/bin
cp ${build_dir}/bin/taosdemo ${install_dir}/bin/powerdemo cp ${build_dir}/bin/taosdemo ${install_dir}/bin/powerdemo
cp ${build_dir}/bin/taosdump ${install_dir}/bin/powerdump cp ${build_dir}/bin/taosdump ${install_dir}/bin/powerdump
cp ${script_dir}/set_core.sh ${install_dir}/bin cp ${script_dir}/set_core.sh ${install_dir}/bin
......
...@@ -69,10 +69,10 @@ if [ "$osType" != "Darwin" ]; then ...@@ -69,10 +69,10 @@ if [ "$osType" != "Darwin" ]; then
if [ "$pagMode" == "lite" ]; then if [ "$pagMode" == "lite" ]; then
strip ${build_dir}/bin/taos strip ${build_dir}/bin/taos
cp ${build_dir}/bin/taos ${install_dir}/bin/prodbc cp ${build_dir}/bin/taos ${install_dir}/bin/prodbc
cp ${script_dir}/remove_pro.sh ${install_dir}/bin cp ${script_dir}/remove_client_pro.sh ${install_dir}/bin
else else
cp ${build_dir}/bin/taos ${install_dir}/bin/prodbc cp ${build_dir}/bin/taos ${install_dir}/bin/prodbc
cp ${script_dir}/remove_pro.sh ${install_dir}/bin cp ${script_dir}/remove_client_pro.sh ${install_dir}/bin
cp ${build_dir}/bin/taosdemo ${install_dir}/bin/prodemo cp ${build_dir}/bin/taosdemo ${install_dir}/bin/prodemo
cp ${build_dir}/bin/taosdump ${install_dir}/bin/prodump cp ${build_dir}/bin/taosdump ${install_dir}/bin/prodump
cp ${script_dir}/set_core.sh ${install_dir}/bin cp ${script_dir}/set_core.sh ${install_dir}/bin
......
...@@ -69,10 +69,10 @@ if [ "$osType" != "Darwin" ]; then ...@@ -69,10 +69,10 @@ if [ "$osType" != "Darwin" ]; then
if [ "$pagMode" == "lite" ]; then if [ "$pagMode" == "lite" ]; then
strip ${build_dir}/bin/taos strip ${build_dir}/bin/taos
cp ${build_dir}/bin/taos ${install_dir}/bin/tq cp ${build_dir}/bin/taos ${install_dir}/bin/tq
cp ${script_dir}/remove_tq.sh ${install_dir}/bin cp ${script_dir}/remove_client_tq.sh ${install_dir}/bin
else else
cp ${build_dir}/bin/taos ${install_dir}/bin/tq cp ${build_dir}/bin/taos ${install_dir}/bin/tq
cp ${script_dir}/remove_tq.sh ${install_dir}/bin cp ${script_dir}/remove_client_tq.sh ${install_dir}/bin
cp ${build_dir}/bin/taosdemo ${install_dir}/bin/tqdemo cp ${build_dir}/bin/taosdemo ${install_dir}/bin/tqdemo
cp ${build_dir}/bin/taosdump ${install_dir}/bin/tqdump cp ${build_dir}/bin/taosdump ${install_dir}/bin/tqdump
cp ${script_dir}/set_core.sh ${install_dir}/bin cp ${script_dir}/set_core.sh ${install_dir}/bin
......
...@@ -636,9 +636,9 @@ static int32_t tscRebuildDDLForNormalTable(SSqlObj *pSql, const char *tableName, ...@@ -636,9 +636,9 @@ static int32_t tscRebuildDDLForNormalTable(SSqlObj *pSql, const char *tableName,
if (type == TSDB_DATA_TYPE_NCHAR) { if (type == TSDB_DATA_TYPE_NCHAR) {
bytes = bytes/TSDB_NCHAR_SIZE; bytes = bytes/TSDB_NCHAR_SIZE;
} }
snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s %s(%d),", pSchema[i].name, tDataTypes[pSchema[i].type].name, bytes); snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "`%s` %s(%d),", pSchema[i].name, tDataTypes[pSchema[i].type].name, bytes);
} else { } else {
snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s %s,", pSchema[i].name, tDataTypes[pSchema[i].type].name); snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "`%s` %s,", pSchema[i].name, tDataTypes[pSchema[i].type].name);
} }
} }
sprintf(result + strlen(result) - 1, "%s", ")"); sprintf(result + strlen(result) - 1, "%s", ")");
...@@ -663,9 +663,9 @@ static int32_t tscRebuildDDLForSuperTable(SSqlObj *pSql, const char *tableName, ...@@ -663,9 +663,9 @@ static int32_t tscRebuildDDLForSuperTable(SSqlObj *pSql, const char *tableName,
if (type == TSDB_DATA_TYPE_NCHAR) { if (type == TSDB_DATA_TYPE_NCHAR) {
bytes = bytes/TSDB_NCHAR_SIZE; bytes = bytes/TSDB_NCHAR_SIZE;
} }
snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result),"%s %s(%d),", pSchema[i].name,tDataTypes[pSchema[i].type].name, bytes); snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result),"`%s` %s(%d),", pSchema[i].name,tDataTypes[pSchema[i].type].name, bytes);
} else { } else {
snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s %s,", pSchema[i].name, tDataTypes[type].name); snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "`%s` %s,", pSchema[i].name, tDataTypes[type].name);
} }
} }
snprintf(result + strlen(result) - 1, TSDB_MAX_BINARY_LEN - strlen(result), "%s %s", ")", "TAGS ("); snprintf(result + strlen(result) - 1, TSDB_MAX_BINARY_LEN - strlen(result), "%s %s", ")", "TAGS (");
...@@ -677,9 +677,9 @@ static int32_t tscRebuildDDLForSuperTable(SSqlObj *pSql, const char *tableName, ...@@ -677,9 +677,9 @@ static int32_t tscRebuildDDLForSuperTable(SSqlObj *pSql, const char *tableName,
if (type == TSDB_DATA_TYPE_NCHAR) { if (type == TSDB_DATA_TYPE_NCHAR) {
bytes = bytes/TSDB_NCHAR_SIZE; bytes = bytes/TSDB_NCHAR_SIZE;
} }
snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s %s(%d),", pSchema[i].name,tDataTypes[pSchema[i].type].name, bytes); snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "`%s` %s(%d),", pSchema[i].name,tDataTypes[pSchema[i].type].name, bytes);
} else { } else {
snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s %s,", pSchema[i].name, tDataTypes[type].name); snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "`%s` %s,", pSchema[i].name, tDataTypes[type].name);
} }
} }
sprintf(result + strlen(result) - 1, "%s", ")"); sprintf(result + strlen(result) - 1, "%s", ")");
......
...@@ -125,8 +125,9 @@ static int32_t parseTelnetTimeStamp(TAOS_SML_KV **pTS, int *num_kvs, const char ...@@ -125,8 +125,9 @@ static int32_t parseTelnetTimeStamp(TAOS_SML_KV **pTS, int *num_kvs, const char
} }
tfree(value); tfree(value);
(*pTS)->key = tcalloc(sizeof(key), 1); (*pTS)->key = tcalloc(sizeof(key) + TS_ESCAPE_CHAR_SIZE, 1);
memcpy((*pTS)->key, key, sizeof(key)); memcpy((*pTS)->key, key, sizeof(key));
addEscapeCharToString((*pTS)->key, (int32_t)strlen(key));
*num_kvs += 1; *num_kvs += 1;
*index = cur + 1; *index = cur + 1;
......
...@@ -82,14 +82,33 @@ int32_t converToStr(char *str, int type, void *buf, int32_t bufSize, int32_t *le ...@@ -82,14 +82,33 @@ int32_t converToStr(char *str, int type, void *buf, int32_t bufSize, int32_t *le
break; break;
case TSDB_DATA_TYPE_FLOAT: case TSDB_DATA_TYPE_FLOAT:
n = sprintf(str, "%e", GET_FLOAT_VAL(buf)); n = sprintf(str, "%.*e", DECIMAL_DIG, GET_FLOAT_VAL(buf));
break; break;
case TSDB_DATA_TYPE_DOUBLE: case TSDB_DATA_TYPE_DOUBLE:
n = sprintf(str, "%e", GET_DOUBLE_VAL(buf)); n = sprintf(str, "%.*e", DECIMAL_DIG, GET_DOUBLE_VAL(buf));
break; break;
case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_BINARY:
if (bufSize < 0) {
tscError("invalid buf size");
return TSDB_CODE_TSC_INVALID_VALUE;
}
int32_t escapeSize = 0;
*str++ = '\'';
++escapeSize;
char* data = buf;
for (int32_t i = 0; i < bufSize; ++i) {
if (data[i] == '\'' || data[i] == '"') {
*str++ = '\\';
++escapeSize;
}
*str++ = data[i];
}
*str = '\'';
++escapeSize;
n = bufSize + escapeSize;
break;
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
case TSDB_DATA_TYPE_JSON: case TSDB_DATA_TYPE_JSON:
if (bufSize < 0) { if (bufSize < 0) {
...@@ -97,9 +116,9 @@ int32_t converToStr(char *str, int type, void *buf, int32_t bufSize, int32_t *le ...@@ -97,9 +116,9 @@ int32_t converToStr(char *str, int type, void *buf, int32_t bufSize, int32_t *le
return TSDB_CODE_TSC_INVALID_VALUE; return TSDB_CODE_TSC_INVALID_VALUE;
} }
*str = '"'; *str = '\'';
memcpy(str + 1, buf, bufSize); memcpy(str + 1, buf, bufSize);
*(str + bufSize + 1) = '"'; *(str + bufSize + 1) = '\'';
n = bufSize + 2; n = bufSize + 2;
break; break;
......
...@@ -1332,7 +1332,7 @@ static void doInitGlobalConfig(void) { ...@@ -1332,7 +1332,7 @@ static void doInitGlobalConfig(void) {
cfg.option = "httpDbNameMandatory"; cfg.option = "httpDbNameMandatory";
cfg.ptr = &tsHttpDbNameMandatory; cfg.ptr = &tsHttpDbNameMandatory;
cfg.valType = TAOS_CFG_VTYPE_INT8; cfg.valType = TAOS_CFG_VTYPE_INT8;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
cfg.minValue = 0; cfg.minValue = 0;
cfg.maxValue = 1; cfg.maxValue = 1;
cfg.ptrLength = 0; cfg.ptrLength = 0;
......

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30114.105
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A1FB5B66-E32F-4789-9BE9-042E5BD21087}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TDengineDriver", "src\TDengineDriver\TDengineDriver.csproj", "{5BED7402-0A65-4ED9-A491-C56BFB518045}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{CB8E6458-31E1-4351-B704-1B918E998654}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XUnitTest", "src\test\XUnitTest\XUnitTest.csproj", "{64C0A478-2591-4459-9F8F-A70F37976A41}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cases", "src\test\Cases\Cases.csproj", "{19A69D26-66BF-4227-97BE-9B087BC76B2F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5BED7402-0A65-4ED9-A491-C56BFB518045}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5BED7402-0A65-4ED9-A491-C56BFB518045}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5BED7402-0A65-4ED9-A491-C56BFB518045}.Debug|x64.ActiveCfg = Debug|Any CPU
{5BED7402-0A65-4ED9-A491-C56BFB518045}.Debug|x64.Build.0 = Debug|Any CPU
{5BED7402-0A65-4ED9-A491-C56BFB518045}.Debug|x86.ActiveCfg = Debug|Any CPU
{5BED7402-0A65-4ED9-A491-C56BFB518045}.Debug|x86.Build.0 = Debug|Any CPU
{5BED7402-0A65-4ED9-A491-C56BFB518045}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5BED7402-0A65-4ED9-A491-C56BFB518045}.Release|Any CPU.Build.0 = Release|Any CPU
{5BED7402-0A65-4ED9-A491-C56BFB518045}.Release|x64.ActiveCfg = Release|Any CPU
{5BED7402-0A65-4ED9-A491-C56BFB518045}.Release|x64.Build.0 = Release|Any CPU
{5BED7402-0A65-4ED9-A491-C56BFB518045}.Release|x86.ActiveCfg = Release|Any CPU
{5BED7402-0A65-4ED9-A491-C56BFB518045}.Release|x86.Build.0 = Release|Any CPU
{64C0A478-2591-4459-9F8F-A70F37976A41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{64C0A478-2591-4459-9F8F-A70F37976A41}.Debug|Any CPU.Build.0 = Debug|Any CPU
{64C0A478-2591-4459-9F8F-A70F37976A41}.Debug|x64.ActiveCfg = Debug|Any CPU
{64C0A478-2591-4459-9F8F-A70F37976A41}.Debug|x64.Build.0 = Debug|Any CPU
{64C0A478-2591-4459-9F8F-A70F37976A41}.Debug|x86.ActiveCfg = Debug|Any CPU
{64C0A478-2591-4459-9F8F-A70F37976A41}.Debug|x86.Build.0 = Debug|Any CPU
{64C0A478-2591-4459-9F8F-A70F37976A41}.Release|Any CPU.ActiveCfg = Release|Any CPU
{64C0A478-2591-4459-9F8F-A70F37976A41}.Release|Any CPU.Build.0 = Release|Any CPU
{64C0A478-2591-4459-9F8F-A70F37976A41}.Release|x64.ActiveCfg = Release|Any CPU
{64C0A478-2591-4459-9F8F-A70F37976A41}.Release|x64.Build.0 = Release|Any CPU
{64C0A478-2591-4459-9F8F-A70F37976A41}.Release|x86.ActiveCfg = Release|Any CPU
{64C0A478-2591-4459-9F8F-A70F37976A41}.Release|x86.Build.0 = Release|Any CPU
{19A69D26-66BF-4227-97BE-9B087BC76B2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19A69D26-66BF-4227-97BE-9B087BC76B2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19A69D26-66BF-4227-97BE-9B087BC76B2F}.Debug|x64.ActiveCfg = Debug|Any CPU
{19A69D26-66BF-4227-97BE-9B087BC76B2F}.Debug|x64.Build.0 = Debug|Any CPU
{19A69D26-66BF-4227-97BE-9B087BC76B2F}.Debug|x86.ActiveCfg = Debug|Any CPU
{19A69D26-66BF-4227-97BE-9B087BC76B2F}.Debug|x86.Build.0 = Debug|Any CPU
{19A69D26-66BF-4227-97BE-9B087BC76B2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{19A69D26-66BF-4227-97BE-9B087BC76B2F}.Release|Any CPU.Build.0 = Release|Any CPU
{19A69D26-66BF-4227-97BE-9B087BC76B2F}.Release|x64.ActiveCfg = Release|Any CPU
{19A69D26-66BF-4227-97BE-9B087BC76B2F}.Release|x64.Build.0 = Release|Any CPU
{19A69D26-66BF-4227-97BE-9B087BC76B2F}.Release|x86.ActiveCfg = Release|Any CPU
{19A69D26-66BF-4227-97BE-9B087BC76B2F}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{5BED7402-0A65-4ED9-A491-C56BFB518045} = {A1FB5B66-E32F-4789-9BE9-042E5BD21087}
{CB8E6458-31E1-4351-B704-1B918E998654} = {A1FB5B66-E32F-4789-9BE9-042E5BD21087}
{64C0A478-2591-4459-9F8F-A70F37976A41} = {CB8E6458-31E1-4351-B704-1B918E998654}
{19A69D26-66BF-4227-97BE-9B087BC76B2F} = {CB8E6458-31E1-4351-B704-1B918E998654}
EndGlobalSection
EndGlobal
...@@ -47,6 +47,14 @@ namespace TDengineDriver ...@@ -47,6 +47,14 @@ namespace TDengineDriver
TDDB_OPTION_SHELL_ACTIVITY_TIMER = 4 TDDB_OPTION_SHELL_ACTIVITY_TIMER = 4
} }
enum TaosField
{
STRUCT_SIZE = 68,
NAME_LENGTH = 65,
TYPE_OFFSET = 65,
BYTES_OFFSET = 66,
}
public class TDengineMeta public class TDengineMeta
{ {
public string name; public string name;
...@@ -90,6 +98,51 @@ namespace TDengineDriver ...@@ -90,6 +98,51 @@ namespace TDengineDriver
} }
} }
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct TAOS_BIND
{
// column type
public int buffer_type;
// one column value
public IntPtr buffer;
// unused
public Int32 buffer_length;
// actual value length in buffer
public IntPtr length;
// indicates the column value is null or not
public IntPtr is_null;
// unused
public int is_unsigned;
// unused
public IntPtr error;
public Int64 u;
public uint allocated;
}
[StructLayout(LayoutKind.Sequential)]
public struct TAOS_MULTI_BIND
{
// column type
public int buffer_type;
// array, one or more lines column value
public IntPtr buffer;
//length of element in TAOS_MULTI_BIND.buffer (for binary and nchar it is the longest element's length)
public ulong buffer_length;
//array, actual data length for each value
public IntPtr length;
//array, indicates each column value is null or not
public IntPtr is_null;
// line number, or the values number in buffer
public int num;
}
public class TDengine public class TDengine
{ {
public const int TSDB_CODE_SUCCESS = 0; public const int TSDB_CODE_SUCCESS = 0;
...@@ -130,7 +183,7 @@ namespace TDengineDriver ...@@ -130,7 +183,7 @@ namespace TDengineDriver
static extern private IntPtr taos_fetch_fields(IntPtr res); static extern private IntPtr taos_fetch_fields(IntPtr res);
static public List<TDengineMeta> FetchFields(IntPtr res) static public List<TDengineMeta> FetchFields(IntPtr res)
{ {
const int fieldSize = 68; // const int fieldSize = 68;
List<TDengineMeta> metas = new List<TDengineMeta>(); List<TDengineMeta> metas = new List<TDengineMeta>();
if (res == IntPtr.Zero) if (res == IntPtr.Zero)
...@@ -143,12 +196,11 @@ namespace TDengineDriver ...@@ -143,12 +196,11 @@ namespace TDengineDriver
for (int i = 0; i < fieldCount; ++i) for (int i = 0; i < fieldCount; ++i)
{ {
int offset = i * fieldSize; int offset = i * (int)TaosField.STRUCT_SIZE;
TDengineMeta meta = new TDengineMeta(); TDengineMeta meta = new TDengineMeta();
meta.name = Marshal.PtrToStringAnsi(fieldsPtr + offset); meta.name = Marshal.PtrToStringAnsi(fieldsPtr + offset);
meta.type = Marshal.ReadByte(fieldsPtr + offset + 65); meta.type = Marshal.ReadByte(fieldsPtr + offset + (int)TaosField.TYPE_OFFSET);
meta.size = Marshal.ReadInt16(fieldsPtr + offset + 66); meta.size = Marshal.ReadInt16(fieldsPtr + offset + (int)TaosField.BYTES_OFFSET);
metas.Add(meta); metas.Add(meta);
} }
...@@ -163,12 +215,185 @@ namespace TDengineDriver ...@@ -163,12 +215,185 @@ namespace TDengineDriver
[DllImport("taos", EntryPoint = "taos_close", CallingConvention = CallingConvention.Cdecl)] [DllImport("taos", EntryPoint = "taos_close", CallingConvention = CallingConvention.Cdecl)]
static extern public int Close(IntPtr taos); static extern public int Close(IntPtr taos);
//get precision in restultset
//get precision of restultset
[DllImport("taos", EntryPoint = "taos_result_precision", CallingConvention = CallingConvention.Cdecl)] [DllImport("taos", EntryPoint = "taos_result_precision", CallingConvention = CallingConvention.Cdecl)]
static extern public int ResultPrecision(IntPtr taos); static extern public int ResultPrecision(IntPtr taos);
//schemaless API
[DllImport("taos",SetLastError = true, EntryPoint = "taos_schemaless_insert", CallingConvention = CallingConvention.Cdecl)]
static extern public IntPtr SchemalessInsert(IntPtr taos, string[] lines, int numLines, int protocol, int precision); //stmt APIs:
/// <summary>
/// init a TAOS_STMT object for later use.
/// </summary>
/// <param name="taos">a valid taos connection</param>
/// <returns>
/// Not NULL returned for success, NULL for failure. And it should be freed with taos_stmt_close.
/// </returns>
[DllImport("taos", EntryPoint = "taos_stmt_init", CallingConvention = CallingConvention.Cdecl)]
static extern public IntPtr StmtInit(IntPtr taos);
/// <summary>
/// prepare a sql statement,'sql' should be a valid INSERT/SELECT statement.
/// </summary>
/// <param name="stmt">could be the value returned by 'StmtInit', that may be a valid object or NULL.</param>
/// <param name="sql">sql string,used to bind parameters with</param>
/// <param name="length">no used</param>
/// <returns>0 for success, non-zero for failure.</returns>
[DllImport("taos", EntryPoint = "taos_stmt_prepare", CallingConvention = CallingConvention.Cdecl)]
static extern public int StmtPrepare(IntPtr stmt, string sql);
/// <summary>
/// For INSERT only. Used to bind table name as a parmeter for the input stmt object.
/// </summary>
/// <param name="stmt">could be the value returned by 'StmtInit', that may be a valid object or NULL.</param>
/// <param name="name">table name you want to bind</param>
/// <returns>0 for success, non-zero for failure.</returns>
[DllImport("taos", EntryPoint = "taos_stmt_set_tbname", CallingConvention = CallingConvention.Cdecl)]
static extern public int StmtSetTbname(IntPtr stmt, string name);
/// <summary>
/// For INSERT only.
/// Set a table name for binding table name as parameter. Only used for binding all tables
/// in one stable, user application must call 'loadTableInfo' API to load all table
/// meta before calling this API. If the table meta is not cached locally, it will return error.
/// </summary>
/// <param name="stmt">could be the value returned by 'StmtInit', that may be a valid object or NULL.</param>
/// <param name="name">table name which is belong to an stable</param>
/// <returns>0 for success, non-zero for failure.</returns>
[DllImport("taos", EntryPoint = "taos_stmt_set_sub_tbname", CallingConvention = CallingConvention.Cdecl)]
static extern public int StmtSetSubTbname(IntPtr stmt, string name);
/// <summary>
/// For INSERT only.
/// set a table name for binding table name as parameter and tag values for all tag parameters.
/// </summary>
/// <param name="stmt">could be the value returned by 'StmtInit', that may be a valid object or NULL.</param>
/// <param name="name">use to set table name</param>
/// <param name="tags">
/// is an array contains all tag values,each item in the array represents a tag column's value.
/// the item number and sequence should keep consistence with that in stable tag definition.
/// </param>
/// <returns>0 for success, non-zero for failure.</returns>
[DllImport("taos", EntryPoint = "taos_stmt_set_tbname_tags", CallingConvention = CallingConvention.Cdecl)]
static extern public int StmtSetTbnameTags(IntPtr stmt, string name, TAOS_BIND[] tags);
/// <summary>
/// For both INSERT and SELECT.
/// bind a whole line data.
/// The usage of structure TAOS_BIND is the same with MYSQL_BIND in MySQL.
/// </summary>
/// <param name="stmt">could be the value returned by 'StmtInit', that may be a valid object or NULL.</param>
/// <param name="bind">
/// points to an array contains the whole line data.
/// the item number and sequence should keep consistence with columns in sql statement.
/// </param>
/// <returns>0 for success, non-zero for failure.</returns>
[DllImport("taos", EntryPoint = "taos_stmt_bind_param", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
static extern public int StmtBindParam(IntPtr stmt, TAOS_BIND[] bind);
/// <summary>
/// bind a single column's data, INTERNAL used and for INSERT only.
/// </summary>
/// <param name="stmt">could be the value returned by 'StmtInit', that may be a valid object or NULL.</param>
/// <param name="bind">points to a column's data which could be the one or more lines. </param>
/// <param name="colIdx">the column's index in prepared sql statement, it starts from 0.</param>
/// <returns>0 for success, non-zero for failure.</returns>
[DllImport("taos", EntryPoint = "taos_stmt_bind_single_param_batch", CallingConvention = CallingConvention.Cdecl)]
static extern public int StmtBindSingleParamBatch(IntPtr stmt, ref TAOS_MULTI_BIND bind, int colIdx);
/// <summary>
/// for INSERT only
/// bind one or multiple lines data. The parameter 'bind'
/// </summary>
/// <param name="stmt">could be the value returned by 'StmtInit', that may be a valid object or NULL.</param>
/// <param name="bind">
/// points to an array contains one or more lines data.Each item in array represents a column's value(s),
/// the item number and sequence should keep consistence with columns in sql statement.
/// </param>
/// <returns>0 for success, non-zero for failure.</returns>
[DllImport("taos", EntryPoint = "taos_stmt_bind_param_batch", CallingConvention = CallingConvention.Cdecl)]
static extern public int StmtBindParamBatch(IntPtr stmt, [In, Out] TAOS_MULTI_BIND[] bind);
/// <summary>
/// For INSERT only.
/// add all current bound parameters to batch process. Must be called after each call to
/// StmtBindParam/StmtBindSingleParamBatch, or all columns binds for one or more lines
/// with StmtBindSingleParamBatch. User application can call any bind parameter
/// API again to bind more data lines after calling to this API.
/// </summary>
/// <param name="stmt">could be the value returned by 'StmtInit', that may be a valid object or NULL.</param>
/// <returns>0 for success, non-zero for failure.</returns>
[DllImport("taos", EntryPoint = "taos_stmt_add_batch", CallingConvention = CallingConvention.Cdecl)]
static extern public int StmtAddBatch(IntPtr stmt);
/// <summary>
/// actually execute the INSERT/SELECT sql statement.
/// User application can continue to bind new data after calling to this API.
/// </summary>
/// <param name="stmt">could be the value returned by 'StmtInit', that may be a valid object or NULL.</param>
/// <returns></returns>
[DllImport("taos", EntryPoint = "taos_stmt_execute", CallingConvention = CallingConvention.Cdecl)]
static extern public int StmtExecute(IntPtr stmt);
/// <summary>
/// For SELECT only,getting the query result. User application should free it with API 'FreeResult' at the end.
/// </summary>
/// <param name="stmt">could be the value returned by 'StmtInit', that may be a valid object or NULL.</param>
/// <returns>Not NULL for success, NULL for failure.</returns>
[DllImport("taos", EntryPoint = "taos_stmt_use_result", CallingConvention = CallingConvention.Cdecl)]
static extern public IntPtr StmtUseResult(IntPtr stmt);
/// <summary>
/// close STMT object and free resources.
/// </summary>
/// <param name="stmt">could be the value returned by 'StmtInit', that may be a valid object or NULL.</param>
/// <returns>0 for success, non-zero for failure.</returns>
[DllImport("taos", EntryPoint = "taos_stmt_close", CallingConvention = CallingConvention.Cdecl)]
static extern public int StmtClose(IntPtr stmt);
[DllImport("taos", EntryPoint = "taos_load_table_info", CallingConvention = CallingConvention.Cdecl)]
/// <summary>
/// user application must call this API to load all tables meta,
/// </summary>
/// <param name="taos">taos connection</param>
/// <param name="tableList">tablelist</param>
/// <returns></returns>
static extern private int LoadTableInfoDll(IntPtr taos, string tableList);
/// <summary>
/// user application call this API to load all tables meta,this method call the native
/// method LoadTableInfoDll.
/// this method must be called before StmtSetSubTbname(IntPtr stmt, string name);
/// </summary>
/// <param name="taos">taos connection</param>
/// <param name="tableList">tables need to load meta info are form in an array</param>
/// <returns></returns>
static public int LoadTableInfo(IntPtr taos, string[] tableList)
{
string listStr = string.Join(",", tableList);
return LoadTableInfoDll(taos, listStr);
}
/// <summary>
/// get detail error message when got failure for any stmt API call. If not failure, the result
/// returned in this API is unknown.
/// </summary>
/// <param name="stmt">could be the value returned by 'StmtInit', that may be a valid object or NULL.</param>
/// <returns>piont the error message</returns>
[DllImport("taos", EntryPoint = "taos_stmt_errstr", CallingConvention = CallingConvention.Cdecl)]
static extern private IntPtr StmtErrPtr(IntPtr stmt);
/// <summary>
/// get detail error message when got failure for any stmt API call. If not failure, the result
/// returned in this API is unknown.
/// </summary>
/// <param name="stmt">could be the value returned by 'StmtInit', that may be a valid object or NULL.</param>
/// <returns>error string</returns>
static public string StmtErrorStr(IntPtr stmt)
{
IntPtr stmtErrPrt = StmtErrPtr(stmt);
return Marshal.PtrToStringAnsi(stmtErrPrt);
}
} }
} }
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
</Project>
using System;
using System.Runtime.InteropServices;
namespace TDengineDriver
{
/// <summary>
/// this class used to get an instance of struct of TAO_BIND or TAOS_MULTI_BIND
/// And the instance is corresponding with TDengine data type. For example, calling
/// "bindBinary" will return a TAOS_BIND object that is corresponding with TDengine's
/// binary type.
/// </summary>
public class TaosBind
{
public static TAOS_BIND BindBool(bool val)
{
TAOS_BIND bind = new TAOS_BIND();
byte[] boolByteArr = BitConverter.GetBytes(val);
int boolByteArrSize = Marshal.SizeOf(boolByteArr[0]) * boolByteArr.Length;
IntPtr bo = Marshal.AllocHGlobal(1);
Marshal.Copy(boolByteArr, 0, bo, boolByteArr.Length);
int length = sizeof(Boolean);
IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_BOOL;
bind.buffer = bo;
bind.buffer_length = length;
bind.length = lengPtr;
bind.is_null = IntPtr.Zero;
return bind;
}
public static TAOS_BIND BindTinyInt(sbyte val)
{
TAOS_BIND bind = new TAOS_BIND();
byte[] tinyIntByteArr = BitConverter.GetBytes(val);
int tinyIntByteArrSize = Marshal.SizeOf(tinyIntByteArr[0]) * tinyIntByteArr.Length;
IntPtr uManageTinyInt = Marshal.AllocHGlobal(tinyIntByteArrSize);
Marshal.Copy(tinyIntByteArr, 0, uManageTinyInt, tinyIntByteArr.Length);
int length = sizeof(sbyte);
IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_TINYINT;
bind.buffer = uManageTinyInt;
bind.buffer_length = length;
bind.length = lengPtr;
bind.is_null = IntPtr.Zero;
return bind;
}
public static TAOS_BIND BindSmallInt(short val)
{
TAOS_BIND bind = new TAOS_BIND();
IntPtr uManageSmallInt = Marshal.AllocHGlobal(sizeof(short));
Marshal.WriteInt16(uManageSmallInt, val);
int length = sizeof(short);
IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_SMALLINT;
bind.buffer = uManageSmallInt;
bind.buffer_length = length;
bind.length = lengPtr;
bind.is_null = IntPtr.Zero;
return bind;
}
public static TAOS_BIND BindInt(int val)
{
TAOS_BIND bind = new TAOS_BIND();
IntPtr uManageInt = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(uManageInt, val);
int length = sizeof(int);
IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_INT;
bind.buffer = uManageInt;
bind.buffer_length = length;
bind.length = lengPtr;
bind.is_null = IntPtr.Zero;
return bind;
}
public static TAOS_BIND BindBigInt(long val)
{
TAOS_BIND bind = new TAOS_BIND();
IntPtr uManageBigInt = Marshal.AllocHGlobal(sizeof(long));
Marshal.WriteInt64(uManageBigInt, val);
int length = sizeof(long);
IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_BIGINT;
bind.buffer = uManageBigInt;
bind.buffer_length = length;
bind.length = lengPtr;
bind.is_null = IntPtr.Zero;
return bind;
}
public static TAOS_BIND BindUTinyInt(byte val)
{
TAOS_BIND bind = new TAOS_BIND();
IntPtr uManageTinyInt = Marshal.AllocHGlobal(sizeof(byte));
Marshal.WriteByte(uManageTinyInt, val);
int length = sizeof(byte);
IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_UTINYINT;
bind.buffer = uManageTinyInt;
bind.buffer_length = length;
bind.length = lengPtr;
bind.is_null = IntPtr.Zero;
return bind;
}
public static TAOS_BIND BindUSmallInt(UInt16 val)
{
TAOS_BIND bind = new TAOS_BIND();
byte[] uSmallIntByteArr = BitConverter.GetBytes(val);
int usmallSize = Marshal.SizeOf(uSmallIntByteArr[0]) * uSmallIntByteArr.Length;
IntPtr uManageUnsignSmallInt = Marshal.AllocHGlobal(usmallSize);
Marshal.Copy(uSmallIntByteArr, 0, uManageUnsignSmallInt, uSmallIntByteArr.Length);
int length = sizeof(UInt16);
IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_USMALLINT;
bind.buffer = uManageUnsignSmallInt;
bind.buffer_length = length;
bind.length = lengPtr;
bind.is_null = IntPtr.Zero;
return bind;
}
public static TAOS_BIND BindUInt(uint val)
{
TAOS_BIND bind = new TAOS_BIND();
byte[] uManageIntByteArr = BitConverter.GetBytes(val);
int usmallSize = Marshal.SizeOf(uManageIntByteArr[0]) * uManageIntByteArr.Length;
IntPtr uManageInt = Marshal.AllocHGlobal(usmallSize);
Marshal.Copy(uManageIntByteArr, 0, uManageInt, uManageIntByteArr.Length);
int length = sizeof(uint);
IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_UINT;
bind.buffer = uManageInt;
bind.buffer_length = length;
bind.length = lengPtr;
bind.is_null = IntPtr.Zero;
return bind;
}
public static TAOS_BIND BindUBigInt(ulong val)
{
TAOS_BIND bind = new TAOS_BIND();
byte[] uManageBigIntByteArr = BitConverter.GetBytes(val);
int usmallSize = Marshal.SizeOf(uManageBigIntByteArr[0]) * uManageBigIntByteArr.Length;
IntPtr uManageBigInt = Marshal.AllocHGlobal(usmallSize);
Marshal.Copy(uManageBigIntByteArr, 0, uManageBigInt, uManageBigIntByteArr.Length);
int length = sizeof(ulong);
IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_UBIGINT;
bind.buffer = uManageBigInt;
bind.buffer_length = length;
bind.length = lengPtr;
bind.is_null = IntPtr.Zero;
return bind;
}
public static TAOS_BIND BindFloat(float val)
{
TAOS_BIND bind = new TAOS_BIND();
byte[] floatByteArr = BitConverter.GetBytes(val);
int floatByteArrSize = Marshal.SizeOf(floatByteArr[0]) * floatByteArr.Length;
IntPtr uManageFloat = Marshal.AllocHGlobal(floatByteArrSize);
Marshal.Copy(floatByteArr, 0, uManageFloat, floatByteArr.Length);
int length = sizeof(float);
IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_FLOAT;
bind.buffer = uManageFloat;
bind.buffer_length = length;
bind.length = lengPtr;
bind.is_null = IntPtr.Zero;
return bind;
}
public static TAOS_BIND BindDouble(Double val)
{
TAOS_BIND bind = new TAOS_BIND();
byte[] doubleByteArr = BitConverter.GetBytes(val);
int doubleByteArrSize = Marshal.SizeOf(doubleByteArr[0]) * doubleByteArr.Length;
IntPtr uManageDouble = Marshal.AllocHGlobal(doubleByteArrSize);
Marshal.Copy(doubleByteArr, 0, uManageDouble, doubleByteArr.Length);
int length = sizeof(Double);
IntPtr lengPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lengPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_DOUBLE;
bind.buffer = uManageDouble;
bind.buffer_length = length;
bind.length = lengPtr;
bind.is_null = IntPtr.Zero;
return bind;
}
public static TAOS_BIND BindBinary(String val)
{
TAOS_BIND bind = new TAOS_BIND();
IntPtr umanageBinary = Marshal.StringToHGlobalAnsi(val);
int leng = val.Length;
IntPtr lenPtr = Marshal.AllocHGlobal(sizeof(ulong));
Marshal.WriteInt64(lenPtr, leng);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_BINARY;
bind.buffer = umanageBinary;
bind.buffer_length = leng;
bind.length = lenPtr;
bind.is_null = IntPtr.Zero;
return bind;
}
public static TAOS_BIND BindNchar(String val)
{
TAOS_BIND bind = new TAOS_BIND();
IntPtr umanageNchar = (IntPtr)Marshal.StringToHGlobalAnsi(val);
int leng = val.Length;
IntPtr lenPtr = Marshal.AllocHGlobal(sizeof(ulong));
Marshal.WriteInt64(lenPtr, leng);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_NCHAR;
bind.buffer = umanageNchar;
bind.buffer_length = leng;
bind.length = lenPtr;
bind.is_null = IntPtr.Zero;
return bind;
}
public static TAOS_BIND BindNil()
{
TAOS_BIND bind = new TAOS_BIND();
int isNull = 1;//IntPtr.Size;
IntPtr lenPtr = Marshal.AllocHGlobal(sizeof(int));
Marshal.WriteInt32(lenPtr, isNull);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_NULL;
bind.is_null = lenPtr;
return bind;
}
public static TAOS_BIND BindTimestamp(long ts)
{
TAOS_BIND bind = new TAOS_BIND();
IntPtr uManageTs = Marshal.AllocHGlobal(sizeof(long));
Marshal.WriteInt64(uManageTs, ts);
int length = sizeof(long);
IntPtr lengPtr = Marshal.AllocHGlobal(4);
Marshal.WriteInt32(lengPtr, length);
bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP;
bind.buffer = uManageTs;
bind.buffer_length = length;
bind.length = lengPtr;
bind.is_null = IntPtr.Zero;
return bind;
}
public static void FreeTaosBind(TAOS_BIND[] binds)
{
foreach (TAOS_BIND bind in binds)
{
Marshal.FreeHGlobal(bind.buffer);
Marshal.FreeHGlobal(bind.length);
if (bind.is_null != IntPtr.Zero)
{
// Console.WriteLine(bind.is_null);
Marshal.FreeHGlobal(bind.is_null);
}
}
}
}
}
\ No newline at end of file
此差异已折叠。
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\..\TDengineDriver\TDengineDriver.csproj" />
</ItemGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
</Project>
using System;
using Test.UtilsTools;
using TDengineDriver;
namespace Test.UtilsTools.DataSource
{
public class DataSource
{
public static long[] tsArr = new long[5] { 1637064040000, 1637064041000, 1637064042000, 1637064043000, 1637064044000 };
public static bool?[] boolArr = new bool?[5] { true, false, null, true, true };
public static sbyte?[] tinyIntArr = new sbyte?[5] { -127, 0, null, 8, 127 };
public static short?[] shortArr = new short?[5] { short.MinValue + 1, -200, null, 100, short.MaxValue };
public static int?[] intArr = new int?[5] { -200, -100, null, 0, 300 };
public static long?[] longArr = new long?[5] { long.MinValue + 1, -2000, null, 1000, long.MaxValue };
public static float?[] floatArr = new float?[5] { float.MinValue + 1, -12.1F, null, 0F, float.MaxValue };
public static double?[] doubleArr = new double?[5] { double.MinValue + 1, -19.112D, null, 0D, double.MaxValue };
public static byte?[] uTinyIntArr = new byte?[5] { byte.MinValue, 12, null, 89, byte.MaxValue - 1 };
public static ushort?[] uShortArr = new ushort?[5] { ushort.MinValue, 200, null, 400, ushort.MaxValue - 1 };
public static uint?[] uIntArr = new uint?[5] { uint.MinValue, 100, null, 2, uint.MaxValue - 1 };
public static ulong?[] uLongArr = new ulong?[5] { ulong.MinValue, 2000, null, 1000, long.MaxValue - 1 };
public static string[] binaryArr = new string[5] { "1234567890~!@#$%^&*()_+=-`[]{}:,./<>?", String.Empty, null, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890~!@#$%^&*()_+=-`[]{}:,./<>?" };
public static string[] ncharArr = new string[5] { "1234567890~!@#$%^&*()_+=-`[]{}:,./<>?", null, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890~!@#$%^&*()_+=-`[]{}:,./<>?", string.Empty };
public static TAOS_BIND[] getTags()
{
TAOS_BIND[] binds = new TAOS_BIND[13];
binds[0] = TaosBind.BindBool(true);
binds[1] = TaosBind.BindTinyInt(-2);
binds[2] = TaosBind.BindSmallInt(short.MaxValue);
binds[3] = TaosBind.BindInt(int.MaxValue);
binds[4] = TaosBind.BindBigInt(Int64.MaxValue);
binds[5] = TaosBind.BindUTinyInt(byte.MaxValue - 1);
binds[6] = TaosBind.BindUSmallInt(UInt16.MaxValue - 1);
binds[7] = TaosBind.BindUInt(uint.MinValue + 1);
binds[8] = TaosBind.BindUBigInt(UInt64.MinValue + 1);
binds[9] = TaosBind.BindFloat(11.11F);
binds[10] = TaosBind.BindDouble(22.22D);
binds[11] = TaosBind.BindBinary("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKZXCVBNM`1234567890-=+_)(*&^%$#@!~[];,./<>?:{}");
binds[12] = TaosBind.BindNchar("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKZXCVBNM`1234567890-=+_)(*&^%$#@!~[];,./<>?:{}");
return binds;
}
public static TAOS_BIND[] getNtableRow()
{
TAOS_BIND[] binds = new TAOS_BIND[15];
binds[0] = TaosBind.BindTimestamp(1637064040000);
binds[1] = TaosBind.BindTinyInt(-2);
binds[2] = TaosBind.BindSmallInt(short.MaxValue);
binds[3] = TaosBind.BindInt(int.MaxValue);
binds[4] = TaosBind.BindBigInt(Int64.MaxValue);
binds[5] = TaosBind.BindUTinyInt(byte.MaxValue - 1);
binds[6] = TaosBind.BindUSmallInt(UInt16.MaxValue - 1);
binds[7] = TaosBind.BindUInt(uint.MinValue + 1);
binds[8] = TaosBind.BindUBigInt(UInt64.MinValue + 1);
binds[9] = TaosBind.BindFloat(11.11F);
binds[10] = TaosBind.BindDouble(22.22D);
binds[11] = TaosBind.BindBinary("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKZXCVBNM`1234567890-=+_)(*&^%$#@!~[];,./<>?:{}");
binds[12] = TaosBind.BindNchar("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKZXCVBNM`1234567890-=+_)(*&^%$#@!~[];,./<>?:{}");
binds[13] = TaosBind.BindBool(true);
binds[14] = TaosBind.BindNil();
return binds;
}
public static TAOS_MULTI_BIND[] GetMultiBindArr()
{
TAOS_MULTI_BIND[] mBinds = new TAOS_MULTI_BIND[14];
mBinds[0] = TaosMultiBind.MultiBindTimestamp(tsArr);
mBinds[1] = TaosMultiBind.MultiBindBool(boolArr);
mBinds[2] = TaosMultiBind.MultiBindTinyInt(tinyIntArr);
mBinds[3] = TaosMultiBind.MultiBindSmallInt(shortArr);
mBinds[4] = TaosMultiBind.MultiBindInt(intArr);
mBinds[5] = TaosMultiBind.MultiBindBigint(longArr);
mBinds[6] = TaosMultiBind.MultiBindFloat(floatArr);
mBinds[7] = TaosMultiBind.MultiBindDouble(doubleArr);
mBinds[8] = TaosMultiBind.MultiBindUTinyInt(uTinyIntArr);
mBinds[9] = TaosMultiBind.MultiBindUSmallInt(uShortArr);
mBinds[10] = TaosMultiBind.MultiBindUInt(uIntArr);
mBinds[11] = TaosMultiBind.MultiBindUBigInt(uLongArr);
mBinds[12] = TaosMultiBind.MultiBindBinary(binaryArr);
mBinds[13] = TaosMultiBind.MultiBindNchar(ncharArr);
return mBinds;
}
public static TAOS_BIND[] GetQueryCondition()
{
TAOS_BIND[] queryCondition = new TAOS_BIND[2];
queryCondition[0] = TaosBind.BindTinyInt(0);
queryCondition[1] = TaosBind.BindInt(1000);
return queryCondition;
}
public static void FreeTaosBind(TAOS_BIND[] binds)
{
TaosBind.FreeTaosBind(binds);
}
public static void FreeTaosMBind(TAOS_MULTI_BIND[] mbinds)
{
TaosMultiBind.FreeTaosBind(mbinds);
}
}
}
\ No newline at end of file
using System;
using Test.UtilsTools;
using Cases;
namespace Cases.EntryPoint
{
class Program
{
static void Main(string[] args)
{
IntPtr conn = IntPtr.Zero;
IntPtr stmt = IntPtr.Zero;
IntPtr res = IntPtr.Zero;
conn = UtilsTools.TDConnection("127.0.0.1", "root", "taosdata", "", 0);
UtilsTools.ExecuteQuery(conn, "drop database if exists csharp");
UtilsTools.ExecuteQuery(conn, "create database if not exists csharp keep 3650");
UtilsTools.ExecuteQuery(conn, "use csharp");
Console.WriteLine("====================StableColumnByColumn===================");
StableColumnByColumn columnByColumn = new StableColumnByColumn();
columnByColumn.Test(conn, "stablecolumnbycolumn");
Console.WriteLine("====================StmtStableQuery===================");
StmtStableQuery stmtStableQuery = new StmtStableQuery();
stmtStableQuery.Test(conn, "stablecolumnbycolumn");
Console.WriteLine("====================StableMutipleLine===================");
StableMutipleLine mutipleLine = new StableMutipleLine();
mutipleLine.Test(conn, "stablemutipleline");
//================================================================================
Console.WriteLine("====================NtableSingleLine===================");
NtableSingleLine ntableSingleLine = new NtableSingleLine();
ntableSingleLine.Test(conn, "stablesingleline");
Console.WriteLine("====================NtableMutipleLine===================");
NtableMutipleLine ntableMutipleLine = new NtableMutipleLine();
ntableMutipleLine.Test(conn, "ntablemutipleline");
Console.WriteLine("====================StmtNtableQuery===================");
StmtNtableQuery stmtNtableQuery = new StmtNtableQuery();
stmtNtableQuery.Test(conn, "ntablemutipleline");
Console.WriteLine("====================NtableColumnByColumn===================");
NtableColumnByColumn ntableColumnByColumn = new NtableColumnByColumn();
ntableColumnByColumn.Test(conn, "ntablecolumnbycolumn");
Console.WriteLine("====================fetchfeilds===================");
FetchFields fetchFields = new FetchFields();
fetchFields.Test(conn, "fetchfeilds");
UtilsTools.ExecuteQuery(conn, "drop database if exists csharp");
UtilsTools.CloseConnection(conn);
UtilsTools.ExitProgram();
}
}
}
using System;
using Test.UtilsTools;
using TDengineDriver;
using Test.UtilsTools.DataSource;
namespace Cases
{
public class NtableSingleLine
{
public void Test(IntPtr conn, string tableName)
{
String createTb = "create table " + tableName + "(ts timestamp,tt tinyint,si smallint,ii int,bi bigint,tu tinyint unsigned,su smallint unsigned,iu int unsigned,bu bigint unsigned,ff float ,dd double ,bb binary(200),nc nchar(200),bo bool,nullVal int);";
String insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
TAOS_BIND[] valuesRow = DataSource.getNtableRow();
UtilsTools.ExecuteQuery(conn, createTb);
IntPtr stmt = StmtUtilTools.StmtInit(conn);
StmtUtilTools.StmtPrepare(stmt, insertSql);
StmtUtilTools.SetTableName(stmt, tableName);
StmtUtilTools.BindParam(stmt, valuesRow);
StmtUtilTools.AddBatch(stmt);
StmtUtilTools.StmtExecute(stmt);
StmtUtilTools.StmtClose(stmt);
DataSource.FreeTaosBind(valuesRow);
}
}
public class NtableMutipleLine
{
TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindArr();
public void Test(IntPtr conn, string tableName)
{
String createTb = "create table " + tableName + " (ts timestamp ,b bool,v1 tinyint,v2 smallint,v4 int,v8 bigint,f4 float,f8 double,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,bin binary(200),blob nchar(200));";
String insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
UtilsTools.ExecuteQuery(conn, createTb);
String[] loadList = { tableName };
IntPtr stmt = StmtUtilTools.StmtInit(conn);
StmtUtilTools.loadTableInfo(conn, loadList);
StmtUtilTools.StmtPrepare(stmt, insertSql);
StmtUtilTools.SetTableName(stmt, tableName);
StmtUtilTools.BindParamBatch(stmt, mbind);
StmtUtilTools.AddBatch(stmt);
StmtUtilTools.StmtExecute(stmt);
StmtUtilTools.StmtClose(stmt);
DataSource.FreeTaosMBind(mbind);
}
}
public class NtableColumnByColumn
{
DataSource data = new DataSource();
TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindArr();
public void Test(IntPtr conn, string tableName)
{
String createTb = "create table " + tableName + " (ts timestamp ,b bool,v1 tinyint,v2 smallint,v4 int,v8 bigint,f4 float,f8 double,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,bin binary(200),blob nchar(200));";
String insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
UtilsTools.ExecuteQuery(conn, createTb);
IntPtr stmt = StmtUtilTools.StmtInit(conn);
StmtUtilTools.StmtPrepare(stmt, insertSql);
StmtUtilTools.SetTableName(stmt, tableName);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[0], 0);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[1], 1);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[2], 2);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[3], 3);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[4], 4);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[5], 5);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[6], 6);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[7], 7);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[8], 8);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[9], 9);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[10], 10);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[11], 11);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[12], 12);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[13], 13);
StmtUtilTools.AddBatch(stmt);
StmtUtilTools.StmtExecute(stmt);
StmtUtilTools.StmtClose(stmt);
DataSource.FreeTaosMBind(mbind);
}
}
}
\ No newline at end of file
using System;
using Test.UtilsTools;
using TDengineDriver;
using Test.UtilsTools.DataSource;
namespace Cases
{
public class StmtStableQuery
{
public void Test(IntPtr conn, string tableName)
{
string selectSql = "SELECT * FROM " + tableName + " WHERE v1 > ? AND v4 < ?";
TAOS_BIND[] queryCondition = DataSource.GetQueryCondition();
IntPtr stmt = StmtUtilTools.StmtInit(conn);
StmtUtilTools.StmtPrepare(stmt, selectSql);
StmtUtilTools.BindParam(stmt, queryCondition);
StmtUtilTools.StmtExecute(stmt);
IntPtr res = StmtUtilTools.StmtUseResult(stmt);
UtilsTools.DisplayRes(res);
StmtUtilTools.StmtClose(stmt);
DataSource.FreeTaosBind(queryCondition);
}
}
public class StmtNtableQuery
{
public void Test(IntPtr conn, string tableName)
{
string selectSql = "SELECT * FROM " + tableName + " WHERE v1 > ? AND v4 < ?";
TAOS_BIND[] queryCondition = DataSource.GetQueryCondition();
IntPtr stmt = StmtUtilTools.StmtInit(conn);
StmtUtilTools.StmtPrepare(stmt, selectSql);
StmtUtilTools.BindParam(stmt, queryCondition);
StmtUtilTools.StmtExecute(stmt);
IntPtr res = StmtUtilTools.StmtUseResult(stmt);
UtilsTools.DisplayRes(res);
StmtUtilTools.StmtClose(stmt);
DataSource.FreeTaosBind(queryCondition);
}
}
}
\ No newline at end of file
using System;
using Test.UtilsTools;
using TDengineDriver;
using Test.UtilsTools.DataSource;
namespace Cases
{
public class StableMutipleLine
{
TAOS_BIND[] tags = DataSource.getTags();
TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindArr();
public void Test(IntPtr conn, string tableName)
{
String createTb = "create stable " + tableName + " (ts timestamp ,b bool,v1 tinyint,v2 smallint,v4 int,v8 bigint,f4 float,f8 double,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,bin binary(200),blob nchar(200))tags(bo bool,tt tinyint,si smallint,ii int,bi bigint,tu tinyint unsigned,su smallint unsigned,iu int unsigned,bu bigint unsigned,ff float ,dd double ,bb binary(200),nc nchar(200));";
String insertSql = "insert into ? using " + tableName + " tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
UtilsTools.ExecuteQuery(conn, createTb);
String[] loadList = { tableName };
IntPtr stmt = StmtUtilTools.StmtInit(conn);
StmtUtilTools.loadTableInfo(conn, loadList);
StmtUtilTools.StmtPrepare(stmt, insertSql);
StmtUtilTools.SetTableNameTags(stmt, tableName + "_t1", tags);
StmtUtilTools.BindParamBatch(stmt, mbind);
StmtUtilTools.AddBatch(stmt);
StmtUtilTools.StmtExecute(stmt);
StmtUtilTools.StmtClose(stmt);
DataSource.FreeTaosBind(tags);
DataSource.FreeTaosMBind(mbind);
}
}
public class StableColumnByColumn
{
DataSource data = new DataSource();
TAOS_BIND[] tags = DataSource.getTags();
TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindArr();
public void Test(IntPtr conn, string tableName)
{
String createTb = "create stable " + tableName + " (ts timestamp ,b bool,v1 tinyint,v2 smallint,v4 int,v8 bigint,f4 float,f8 double,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,bin binary(200),blob nchar(200))tags(bo bool,tt tinyint,si smallint,ii int,bi bigint,tu tinyint unsigned,su smallint unsigned,iu int unsigned,bu bigint unsigned,ff float ,dd double ,bb binary(200),nc nchar(200));";
String insertSql = "insert into ? using " + tableName + " tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
UtilsTools.ExecuteQuery(conn, createTb);
IntPtr stmt = StmtUtilTools.StmtInit(conn);
StmtUtilTools.StmtPrepare(stmt, insertSql);
StmtUtilTools.SetTableNameTags(stmt, tableName + "_t1", tags);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[0], 0);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[1], 1);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[2], 2);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[3], 3);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[4], 4);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[5], 5);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[6], 6);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[7], 7);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[8], 8);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[9], 9);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[10], 10);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[11], 11);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[12], 12);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[13], 13);
StmtUtilTools.AddBatch(stmt);
StmtUtilTools.StmtExecute(stmt);
StmtUtilTools.StmtClose(stmt);
DataSource.FreeTaosBind(tags);
DataSource.FreeTaosMBind(mbind);
}
}
}
\ No newline at end of file
using System;
using TDengineDriver;
using System.Runtime.InteropServices;
namespace Test.UtilsTools
{
public class StmtUtilTools
{
public static IntPtr StmtInit(IntPtr conn)
{
IntPtr stmt = TDengine.StmtInit(conn);
if (stmt == IntPtr.Zero)
{
Console.WriteLine("Init stmt failed");
UtilsTools.CloseConnection(conn);
UtilsTools.ExitProgram();
}
else
{
Console.WriteLine("Init stmt success");
}
return stmt;
}
public static void StmtPrepare(IntPtr stmt, string sql)
{
int res = TDengine.StmtPrepare(stmt, sql);
if (res == 0)
{
Console.WriteLine("stmt prepare success");
}
else
{
Console.WriteLine("stmt prepare failed " + TDengine.StmtErrorStr(stmt));
StmtClose(stmt);
}
}
public static void SetTableName(IntPtr stmt, String tableName)
{
int res = TDengine.StmtSetTbname(stmt, tableName);
if (res == 0)
{
Console.WriteLine("set_tbname success");
}
else
{
Console.Write("set_tbname failed, " + TDengine.StmtErrorStr(stmt));
StmtClose(stmt);
}
}
public static void SetTableNameTags(IntPtr stmt, String tableName, TAOS_BIND[] tags)
{
int res = TDengine.StmtSetTbnameTags(stmt, tableName, tags);
if (res == 0)
{
Console.WriteLine("set tbname && tags success");
}
else
{
Console.Write("set tbname && tags failed, " + TDengine.StmtErrorStr(stmt));
StmtClose(stmt);
}
}
public static void SetSubTableName(IntPtr stmt, string name)
{
int res = TDengine.StmtSetSubTbname(stmt, name);
if (res == 0)
{
Console.WriteLine("set subtable name success");
}
else
{
Console.Write("set subtable name failed, " + TDengine.StmtErrorStr(stmt));
StmtClose(stmt);
}
}
public static void BindParam(IntPtr stmt, TAOS_BIND[] binds)
{
int res = TDengine.StmtBindParam(stmt, binds);
if (res == 0)
{
Console.WriteLine("bind para success");
}
else
{
Console.Write("bind para failed, " + TDengine.StmtErrorStr(stmt));
StmtClose(stmt);
}
}
public static void BindSingleParamBatch(IntPtr stmt, TAOS_MULTI_BIND bind, int index)
{
int res = TDengine.StmtBindSingleParamBatch(stmt, ref bind, index);
if (res == 0)
{
Console.WriteLine("single bind batch success");
}
else
{
Console.Write("single bind batch failed: " + TDengine.StmtErrorStr(stmt));
StmtClose(stmt);
}
}
public static void BindParamBatch(IntPtr stmt, TAOS_MULTI_BIND[] bind)
{
int res = TDengine.StmtBindParamBatch(stmt, bind);
if (res == 0)
{
Console.WriteLine("bind parameter batch success");
}
else
{
Console.WriteLine("bind parameter batch failed, " + TDengine.StmtErrorStr(stmt));
StmtClose(stmt);
}
}
public static void AddBatch(IntPtr stmt)
{
int res = TDengine.StmtAddBatch(stmt);
if (res == 0)
{
Console.WriteLine("stmt add batch success");
}
else
{
Console.Write("stmt add batch failed,reason: " + TDengine.StmtErrorStr(stmt));
StmtClose(stmt);
}
}
public static void StmtExecute(IntPtr stmt)
{
int res = TDengine.StmtExecute(stmt);
if (res == 0)
{
Console.WriteLine("Execute stmt success");
}
else
{
Console.Write("Execute stmt failed,reason: " + TDengine.StmtErrorStr(stmt));
StmtClose(stmt);
}
}
public static void StmtClose(IntPtr stmt)
{
int res = TDengine.StmtClose(stmt);
if (res == 0)
{
Console.WriteLine("close stmt success");
}
else
{
Console.WriteLine("close stmt failed, " + TDengine.StmtErrorStr(stmt));
StmtClose(stmt);
}
}
public static IntPtr StmtUseResult(IntPtr stmt)
{
IntPtr res = TDengine.StmtUseResult(stmt);
if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
{
if (res != IntPtr.Zero)
{
Console.Write("reason: " + TDengine.Error(res));
}
Console.WriteLine("");
StmtClose(stmt);
}
else
{
Console.WriteLine("StmtUseResult success");
}
return res;
}
public static void loadTableInfo(IntPtr conn, string[] arr)
{
if (TDengine.LoadTableInfo(conn, arr) == 0)
{
Console.WriteLine("load table info success");
}
else
{
Console.WriteLine("load table info failed");
}
}
}
}
\ No newline at end of file
using System;
using Test.UtilsTools;
using TDengineDriver;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace Cases
{
public class FetchFields
{
public void Test(IntPtr conn, string tableName)
{
IntPtr res = IntPtr.Zero;
String createTb = "create stable " + tableName + " (ts timestamp ,b bool,v1 tinyint,v2 smallint,v4 int,v8 bigint,f4 float,f8 double,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,bin binary(200),blob nchar(200))tags(id int);";
String insertSql = "insert into " + tableName + "_t1 using " + tableName + " tags(1) values(1637064040000,true,1,2,3,4,5,6,7,8,9,10,'XI','XII')";
String selectSql = "select * from " + tableName;
String dropSql = "drop table " + tableName;
UtilsTools.ExecuteQuery(conn, createTb);
UtilsTools.ExecuteQuery(conn, insertSql);
res = UtilsTools.ExecuteQuery(conn, selectSql);
UtilsTools.ExecuteQuery(conn, dropSql);
List<TDengineMeta> metas = new List<TDengineMeta>();
metas = TDengine.FetchFields(res);
if (metas.Capacity == 0)
{
Console.WriteLine("empty result");
}
else
{
foreach(TDengineMeta meta in metas){
Console.WriteLine("col_name:{0},col_type_code:{1},col_type:{2}({3})",meta.name,meta.type,meta.TypeName(),meta.size);
}
}
}
}
}
\ No newline at end of file
using System;
using TDengineDriver;
using System.Runtime.InteropServices;
using System.Text;
using System.Collections.Generic;
namespace Test.UtilsTools
{
public class UtilsTools
{
static string configDir = "C:/TDengine/cfg";
public static IntPtr TDConnection(string ip, string user, string password, string db, short port)
{
TDengine.Options((int)TDengineInitOption.TDDB_OPTION_CONFIGDIR, configDir);
TDengine.Options((int)TDengineInitOption.TDDB_OPTION_SHELL_ACTIVITY_TIMER, "60");
TDengine.Init();
return TDengine.Connect(ip, user, password, db, port);
}
public static IntPtr ExecuteQuery(IntPtr conn, String sql)
{
IntPtr res = TDengine.Query(conn, sql);
if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
{
Console.Write(sql.ToString() + " failure, ");
if (res != IntPtr.Zero)
{
Console.Write("reason: " + TDengine.Error(res));
}
Console.WriteLine("");
ExitProgram();
}
else
{
Console.WriteLine(sql.ToString() + " success");
}
return res;
}
public static void DisplayRes(IntPtr res)
{
long queryRows = 0;
if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
{
if (res != IntPtr.Zero)
{
Console.Write("reason: " + TDengine.Error(res));
}
Console.WriteLine("");
ExitProgram();
}
int fieldCount = TDengine.FieldCount(res);
List<TDengineMeta> metas = TDengine.FetchFields(res);
for (int j = 0; j < metas.Count; j++)
{
TDengineMeta meta = (TDengineMeta)metas[j];
}
IntPtr rowdata;
StringBuilder builder = new StringBuilder();
while ((rowdata = TDengine.FetchRows(res)) != IntPtr.Zero)
{
queryRows++;
for (int fields = 0; fields < fieldCount; ++fields)
{
TDengineMeta meta = metas[fields];
int offset = IntPtr.Size * fields;
IntPtr data = Marshal.ReadIntPtr(rowdata, offset);
builder.Append("---");
if (data == IntPtr.Zero)
{
builder.Append("NULL");
continue;
}
switch ((TDengineDataType)meta.type)
{
case TDengineDataType.TSDB_DATA_TYPE_BOOL:
bool v1 = Marshal.ReadByte(data) == 0 ? false : true;
builder.Append(v1);
break;
case TDengineDataType.TSDB_DATA_TYPE_TINYINT:
byte v2 = Marshal.ReadByte(data);
builder.Append(v2);
break;
case TDengineDataType.TSDB_DATA_TYPE_SMALLINT:
short v3 = Marshal.ReadInt16(data);
builder.Append(v3);
break;
case TDengineDataType.TSDB_DATA_TYPE_INT:
int v4 = Marshal.ReadInt32(data);
builder.Append(v4);
break;
case TDengineDataType.TSDB_DATA_TYPE_BIGINT:
long v5 = Marshal.ReadInt64(data);
builder.Append(v5);
break;
case TDengineDataType.TSDB_DATA_TYPE_FLOAT:
float v6 = (float)Marshal.PtrToStructure(data, typeof(float));
builder.Append(v6);
break;
case TDengineDataType.TSDB_DATA_TYPE_DOUBLE:
double v7 = (double)Marshal.PtrToStructure(data, typeof(double));
builder.Append(v7);
break;
case TDengineDataType.TSDB_DATA_TYPE_BINARY:
string v8 = Marshal.PtrToStringAnsi(data);
builder.Append(v8);
break;
case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP:
long v9 = Marshal.ReadInt64(data);
builder.Append(v9);
break;
case TDengineDataType.TSDB_DATA_TYPE_NCHAR:
string v10 = Marshal.PtrToStringAnsi(data);
builder.Append(v10);
break;
}
}
builder.Append("---");
if (queryRows <= 10)
{
Console.WriteLine(builder.ToString());
}
builder.Clear();
}
if (TDengine.ErrorNo(res) != 0)
{
Console.Write("Query is not complete, Error {0:G}", TDengine.ErrorNo(res), TDengine.Error(res));
}
TDengine.FreeResult(res); Console.WriteLine("");
}
public static void CloseConnection(IntPtr conn)
{
if (conn != IntPtr.Zero)
{
if (TDengine.Close(conn) == 0)
{
Console.WriteLine("close connection sucess");
}
else
{
Console.WriteLine("close Connection failed");
}
}
}
public static List<TDengineMeta> getField(IntPtr res)
{
List<TDengineMeta> metas = TDengine.FetchFields(res);
return metas;
}
public static void ExitProgram()
{
TDengine.Cleanup();
System.Environment.Exit(0);
}
}
}
\ No newline at end of file
using System;
using Xunit;
using TDengineDriver;
namespace TDengineDriver.Test
{
public class TestTDengineMeta
{
[Fact]
public void TestTypeNameBool()
{
string typeName = "BOOL";
TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta();
meta.type = 1;
string metaTypeName = meta.TypeName();
Assert.Equal(metaTypeName, typeName);
}
[Fact]
public void TestTypeNameTINYINT()
{
string typeName = "TINYINT";
TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta();
meta.type = 2;
string metaTypeName = meta.TypeName();
Assert.Equal(metaTypeName, typeName);
}
[Fact]
public void TestTypeNameSMALLINT()
{
string typeName = "SMALLINT";
TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta();
meta.type = 3;
string metaTypeName = meta.TypeName();
Assert.Equal(metaTypeName, typeName);
}
[Fact]
public void TestTypeNameINT()
{
string typeName = "INT";
TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta();
meta.type = 4;
string metaTypeName = meta.TypeName();
Assert.Equal(metaTypeName, typeName);
}
[Fact]
public void TestTypeNameBIGINT()
{
string typeName = "BIGINT";
TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta();
meta.type = 5;
string metaTypeName = meta.TypeName();
Assert.Equal(metaTypeName, typeName);
}
[Fact]
public void TestTypeNameUTINYINT()
{
string typeName = "TINYINT UNSIGNED";
TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta();
meta.type = 11;
string metaTypeName = meta.TypeName();
Assert.Equal(metaTypeName, typeName);
}
[Fact]
public void TestTypeNameUSMALLINT()
{
string typeName = "SMALLINT UNSIGNED";
TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta();
meta.type = 12;
string metaTypeName = meta.TypeName();
Assert.Equal(metaTypeName, typeName);
}
[Fact]
public void TestTypeNameUINT()
{
string typeName = "INT UNSIGNED";
TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta();
meta.type = 13;
string metaTypeName = meta.TypeName();
Assert.Equal(metaTypeName, typeName);
}
[Fact]
public void TestTypeNameUBIGINT()
{
string typeName = "BIGINT UNSIGNED";
TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta();
meta.type = 14;
string metaTypeName = meta.TypeName();
Assert.Equal(metaTypeName, typeName);
}
[Fact]
public void TestTypeNameFLOAT()
{
string typeName = "FLOAT";
TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta();
meta.type = 6;
string metaTypeName = meta.TypeName();
Assert.Equal(metaTypeName, typeName);
}
[Fact]
public void TestTypeNameDOUBLE()
{
string typeName = "DOUBLE";
TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta();
meta.type = 7;
string metaTypeName = meta.TypeName();
Assert.Equal(metaTypeName, typeName);
}
[Fact]
public void TestTypeNameSTRING()
{
string typeName = "STRING";
TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta();
meta.type = 8;
string metaTypeName = meta.TypeName();
Assert.Equal(metaTypeName, typeName);
}
[Fact]
public void TestTypeNameTIMESTAMP()
{
string typeName = "TIMESTAMP";
TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta();
meta.type = 9;
string metaTypeName = meta.TypeName();
Assert.Equal(metaTypeName, typeName);
}
[Fact]
public void TestTypeNameNCHAR()
{
string typeName = "NCHAR";
TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta();
meta.type = 10;
string metaTypeName = meta.TypeName();
Assert.Equal(metaTypeName, typeName);
}
[Fact]
public void TestTypeNameUndefined()
{
string typeName = "undefine";
TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta();
string metaTypeName = meta.TypeName();
Assert.Equal(metaTypeName, typeName);
}
}
}
此差异已折叠。
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\TDengineDriver\TDengineDriver.csproj" />
</ItemGroup>
</Project>
...@@ -36,6 +36,7 @@ typedef struct { ...@@ -36,6 +36,7 @@ typedef struct {
int totalThreads; int totalThreads;
void * taos; void * taos;
char * db; char * db;
int code;
} ShellThreadObj; } ShellThreadObj;
static int32_t shellUseDb(TAOS *con, char *db) { static int32_t shellUseDb(TAOS *con, char *db) {
...@@ -112,10 +113,10 @@ static void *shellCheckThreadFp(void *arg) { ...@@ -112,10 +113,10 @@ static void *shellCheckThreadFp(void *arg) {
int32_t end = (pThread->threadIndex + 1) * interval; int32_t end = (pThread->threadIndex + 1) * interval;
if (start >= tbNum) return NULL; if (start >= tbNum) return NULL;
if (end > tbNum) end = tbNum + 1; if (end > tbNum) end = tbNum;
char file[32] = {0}; char file[32] = {0};
snprintf(file, 32, "tb%d.txt", pThread->threadIndex); snprintf(file, 32, "tb%d.sql", pThread->threadIndex);
FILE *fp = fopen(file, "w"); FILE *fp = fopen(file, "w");
if (!fp) { if (!fp) {
...@@ -123,16 +124,19 @@ static void *shellCheckThreadFp(void *arg) { ...@@ -123,16 +124,19 @@ static void *shellCheckThreadFp(void *arg) {
return NULL; return NULL;
} }
ASSERT(pThread->code != 0);
char sql[SHELL_SQL_LEN]; char sql[SHELL_SQL_LEN];
for (int32_t t = start; t < end; ++t) { for (int32_t t = start; t < end; ++t) {
char *tbname = tbNames[t]; char *tbname = tbNames[t];
if (tbname == NULL) break; if (tbname == NULL) break;
snprintf(sql, SHELL_SQL_LEN, "select * from %s limit 1", tbname); snprintf(sql, SHELL_SQL_LEN, "select last_row(_c0) from %s;", tbname);
TAOS_RES *pSql = taos_query(pThread->taos, sql); TAOS_RES *pSql = taos_query(pThread->taos, sql);
int32_t code = taos_errno(pSql); int32_t code = taos_errno(pSql);
if (code != 0) { // -k: -1 means check all errors, while other non-zero values means check specific errors.
if ((code == pThread->code) || ((pThread->code == -1) && (code != 0))) {
int32_t len = snprintf(sql, SHELL_SQL_LEN, "drop table %s.%s;\n", pThread->db, tbname); int32_t len = snprintf(sql, SHELL_SQL_LEN, "drop table %s.%s;\n", pThread->db, tbname);
fwrite(sql, 1, len, fp); fwrite(sql, 1, len, fp);
atomic_add_fetch_32(&errorNum, 1); atomic_add_fetch_32(&errorNum, 1);
...@@ -161,6 +165,7 @@ static void shellRunCheckThreads(TAOS *con, SShellArguments *_args) { ...@@ -161,6 +165,7 @@ static void shellRunCheckThreads(TAOS *con, SShellArguments *_args) {
pThread->totalThreads = _args->threadNum; pThread->totalThreads = _args->threadNum;
pThread->taos = con; pThread->taos = con;
pThread->db = _args->database; pThread->db = _args->database;
pThread->code = _args->check;
pthread_attr_init(&thattr); pthread_attr_init(&thattr);
pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE); pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE);
......
Subproject commit 369ae00784a3259b5f2234c25d4458aca32e961a Subproject commit 78519c0c90a261b6a559c6bbe7f3d3b5a7b630b4
...@@ -3092,7 +3092,7 @@ static int32_t mnodeProcessMultiTableMetaMsg(SMnodeMsg *pMsg) { ...@@ -3092,7 +3092,7 @@ static int32_t mnodeProcessMultiTableMetaMsg(SMnodeMsg *pMsg) {
// add the user-defined-function information // add the user-defined-function information
for(int32_t i = 0; i < pInfo->numOfUdfs; ++i, ++t) { for(int32_t i = 0; i < pInfo->numOfUdfs; ++i, ++t) {
char buf[TSDB_FUNC_NAME_LEN] = {0}; char buf[TSDB_FUNC_NAME_LEN] = {0};
strcpy(buf, nameList[t]); tstrncpy(buf, nameList[t], TSDB_FUNC_NAME_LEN);
SFuncObj* pFuncObj = mnodeGetFunc(buf); SFuncObj* pFuncObj = mnodeGetFunc(buf);
if (pFuncObj == NULL) { if (pFuncObj == NULL) {
......
...@@ -379,9 +379,9 @@ bool taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes) { ...@@ -379,9 +379,9 @@ bool taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes) {
"%s %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 "%s %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64
" %" PRId64, " %" PRId64,
nouse0, &o_rbytes, &rpackets, &nouse1, &nouse2, &nouse3, &nouse4, &nouse5, &nouse6, &o_tbytes, &tpackets); nouse0, &o_rbytes, &rpackets, &nouse1, &nouse2, &nouse3, &nouse4, &nouse5, &nouse6, &o_tbytes, &tpackets);
if (rbytes) *rbytes = o_rbytes; if (rbytes) *rbytes += o_rbytes;
if (tbytes) *tbytes = o_tbytes; if (tbytes) *tbytes += o_tbytes;
if (bytes) *bytes += (o_rbytes + o_tbytes); if (bytes) *bytes += (o_rbytes + o_tbytes);
} }
tfree(line); tfree(line);
......
Subproject commit 88346a2e4e2e9282d2ec8b8c5264ca1ec23698a1 Subproject commit f108f5240918d0eec90debd1ff469c98ff0f25ac
...@@ -148,7 +148,7 @@ if(exprInfo->base.numOfParams > 0){ \ ...@@ -148,7 +148,7 @@ if(exprInfo->base.numOfParams > 0){ \
uint64_t queryHandleId = 0; uint64_t queryHandleId = 0;
int32_t getMaximumIdleDurationSec() { int32_t getMaximumIdleDurationSec() {
return tsShellActivityTimer * 2; return tsShellActivityTimer * 10;
} }
int64_t genQueryId(void) { int64_t genQueryId(void) {
int64_t uid = 0; int64_t uid = 0;
......
...@@ -279,6 +279,7 @@ bool qTableQuery(qinfo_t qinfo, uint64_t *qId) { ...@@ -279,6 +279,7 @@ bool qTableQuery(qinfo_t qinfo, uint64_t *qId) {
if (isQueryKilled(pQInfo)) { if (isQueryKilled(pQInfo)) {
qDebug("QInfo:0x%"PRIx64" it is already killed, abort", pQInfo->qId); qDebug("QInfo:0x%"PRIx64" it is already killed, abort", pQInfo->qId);
pQInfo->runtimeEnv.outputBuf = NULL;
return doBuildResCheck(pQInfo); return doBuildResCheck(pQInfo);
} }
......
...@@ -20,9 +20,9 @@ from util.sql import * ...@@ -20,9 +20,9 @@ from util.sql import *
class TDTestCase: class TDTestCase:
def caseDescription(self): def caseDescription(self):
''' '''
insert 倒序插入 case1: insert 倒序插入
语法解析错误同时meta请求也发出去了导致callback中处理逻辑失效 case2: 语法解析错误同时meta请求也发出去了导致callback中处理逻辑失效
insert语句在values之间加入多个逗号 case3: [TD-XXXX]insert语句在values之间加入多个逗号
''' '''
return return
......
此差异已折叠。
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="TDengine.Connector" Version="1.0.2" />
</ItemGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
</Project>
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#define MAX_THREAD_LINE_BATCHES 1024 bool verbose = false;
void printThreadId(pthread_t id, char* buf) void printThreadId(pthread_t id, char* buf)
{ {
...@@ -30,11 +31,10 @@ typedef struct { ...@@ -30,11 +31,10 @@ typedef struct {
typedef struct { typedef struct {
TAOS* taos; TAOS* taos;
int protocol;
int numBatches; int numBatches;
SThreadLinesBatch batches[MAX_THREAD_LINE_BATCHES]; SThreadLinesBatch *batches;
int64_t costTime; int64_t costTime;
int tsPrecision;
int lineProtocol;
} SThreadInsertArgs; } SThreadInsertArgs;
static void* insertLines(void* args) { static void* insertLines(void* args) {
...@@ -43,27 +43,33 @@ static void* insertLines(void* args) { ...@@ -43,27 +43,33 @@ static void* insertLines(void* args) {
printThreadId(pthread_self(), tidBuf); printThreadId(pthread_self(), tidBuf);
for (int i = 0; i < insertArgs->numBatches; ++i) { for (int i = 0; i < insertArgs->numBatches; ++i) {
SThreadLinesBatch* batch = insertArgs->batches + i; SThreadLinesBatch* batch = insertArgs->batches + i;
printf("%s, thread: 0x%s\n", "begin taos_insert_lines", tidBuf); if (verbose) printf("%s, thread: 0x%s\n", "begin taos_insert_lines", tidBuf);
int64_t begin = getTimeInUs(); int64_t begin = getTimeInUs();
TAOS_RES *res = taos_schemaless_insert(insertArgs->taos, batch->lines, batch->numLines, insertArgs->lineProtocol, insertArgs->tsPrecision); //int32_t code = taos_insert_lines(insertArgs->taos, batch->lines, batch->numLines);
TAOS_RES * res = taos_schemaless_insert(insertArgs->taos, batch->lines, batch->numLines, insertArgs->protocol, TSDB_SML_TIMESTAMP_MILLI_SECONDS);
int32_t code = taos_errno(res); int32_t code = taos_errno(res);
int64_t end = getTimeInUs(); int64_t end = getTimeInUs();
insertArgs->costTime += end - begin; insertArgs->costTime += end - begin;
printf("code: %d, %s. affected lines:%d time used:%"PRId64", thread: 0x%s\n", code, taos_errstr(res), taos_affected_rows(res), end - begin, tidBuf); if (verbose) printf("code: %d, %s. time used:%"PRId64", thread: 0x%s\n", code, tstrerror(code), end - begin, tidBuf);
taos_free_result(res);
} }
return NULL; return NULL;
} }
int32_t getTelenetTemplate(char* lineTemplate, int templateLen) {
char* sample = "sta%d %lld 44.3 t0=False t1=127i8 t2=32 t3=%di32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7=\"hpxzrdiw\" t8=\"ncharTagValue\" t9=127i8";
snprintf(lineTemplate, templateLen, "%s", sample);
return 0;
}
int32_t getLineTemplate(char* lineTemplate, int templateLen, int numFields) { int32_t getLineTemplate(char* lineTemplate, int templateLen, int numFields) {
if (numFields <= 4) { if (numFields <= 4) {
char* sample = "sta%d,t3=%di32 c3=2147483647i32,c4=9223372036854775807i64,c9=11.12345f32,c10=22.123456789f64 %lldms"; char* sample = "sta%d,t3=%di32 c3=2147483647i32,c4=9223372036854775807i64,c9=11.12345f32,c10=22.123456789f64 %lld";
snprintf(lineTemplate, templateLen, "%s", sample); snprintf(lineTemplate, templateLen, "%s", sample);
return 0; return 0;
} }
if (numFields <= 13) { if (numFields <= 13) {
char* sample = "sta%d,t0=true,t1=127i8,t2=32767i16,t3=%di32,t4=9223372036854775807i64,t9=11.12345f32,t10=22.123456789f64,t11=\"binaryTagValue\",t12=L\"ncharTagValue\" c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=254u8,c6=32770u16,c7=2147483699u32,c8=9223372036854775899u64,c9=11.12345f32,c10=22.123456789f64,c11=\"binaryValue\",c12=L\"ncharValue\" %lldms"; char* sample = "sta%d,t0=true,t1=127i8,t2=32767i16,t3=%di32,t4=9223372036854775807i64,t9=11.12345f32,t10=22.123456789f64,t11=\"binaryTagValue\",t12=L\"ncharTagValue\" c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=254u8,c6=32770u16,c7=2147483699u32,c8=9223372036854775899u64,c9=11.12345f32,c10=22.123456789f64,c11=\"binaryValue\",c12=L\"ncharValue\" %lld";
snprintf(lineTemplate, templateLen, "%s", sample); snprintf(lineTemplate, templateLen, "%s", sample);
return 0; return 0;
} }
...@@ -84,14 +90,24 @@ int32_t getLineTemplate(char* lineTemplate, int templateLen, int numFields) { ...@@ -84,14 +90,24 @@ int32_t getLineTemplate(char* lineTemplate, int templateLen, int numFields) {
for (int i = offset[1]+1; i < offset[2]; ++i) { for (int i = offset[1]+1; i < offset[2]; ++i) {
snprintf(lineTemplate+strlen(lineTemplate), templateLen-strlen(lineTemplate), "c%d=\"%d\",", i, i); snprintf(lineTemplate+strlen(lineTemplate), templateLen-strlen(lineTemplate), "c%d=\"%d\",", i, i);
} }
char* lineFormatTs = " %lldms"; char* lineFormatTs = " %lld";
snprintf(lineTemplate+strlen(lineTemplate)-1, templateLen-strlen(lineTemplate)+1, "%s", lineFormatTs); snprintf(lineTemplate+strlen(lineTemplate)-1, templateLen-strlen(lineTemplate)+1, "%s", lineFormatTs);
return 0; return 0;
} }
int32_t generateLine(char* line, int lineLen, char* lineTemplate, int protocol, int superTable, int childTable, int64_t ts) {
if (protocol == TSDB_SML_LINE_PROTOCOL) {
snprintf(line, lineLen, lineTemplate, superTable, childTable, ts);
} else if (protocol == TSDB_SML_TELNET_PROTOCOL) {
snprintf(line, lineLen, lineTemplate, superTable, ts, childTable);
}
return TSDB_CODE_SUCCESS;
}
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
int numThreads = 8; int numThreads = 8;
int maxBatchesPerThread = 1024;
int numSuperTables = 1; int numSuperTables = 1;
int numChildTables = 256; int numChildTables = 256;
...@@ -99,11 +115,11 @@ int main(int argc, char* argv[]) { ...@@ -99,11 +115,11 @@ int main(int argc, char* argv[]) {
int numFields = 13; int numFields = 13;
int maxLinesPerBatch = 16384; int maxLinesPerBatch = 16384;
int tsPrecision = TSDB_SML_TIMESTAMP_NOT_CONFIGURED;
int lineProtocol = TSDB_SML_UNKNOWN_PROTOCOL; int protocol = TSDB_SML_TELNET_PROTOCOL;
int opt; int opt;
while ((opt = getopt(argc, argv, "s:c:r:f:t:m:p:P:h")) != -1) { while ((opt = getopt(argc, argv, "s:c:r:f:t:b:p:hv")) != -1) {
switch (opt) { switch (opt) {
case 's': case 's':
numSuperTables = atoi(optarg); numSuperTables = atoi(optarg);
...@@ -120,28 +136,35 @@ int main(int argc, char* argv[]) { ...@@ -120,28 +136,35 @@ int main(int argc, char* argv[]) {
case 't': case 't':
numThreads = atoi(optarg); numThreads = atoi(optarg);
break; break;
case 'm': case 'b':
maxLinesPerBatch = atoi(optarg); maxLinesPerBatch = atoi(optarg);
break; break;
case 'p': case 'v':
tsPrecision = atoi(optarg); verbose = true;
break; break;
case 'P': case 'p':
lineProtocol = atoi(optarg); if (optarg[0] == 't') {
protocol = TSDB_SML_TELNET_PROTOCOL;
} else if (optarg[0] == 'l') {
protocol = TSDB_SML_LINE_PROTOCOL;
} else if (optarg[0] == 'j') {
protocol = TSDB_SML_JSON_PROTOCOL;
}
break; break;
case 'h': case 'h':
fprintf(stderr, "Usage: %s -s supertable -c childtable -r rows -f fields -t threads -m maxlines_per_batch\n", fprintf(stderr, "Usage: %s -s supertable -c childtable -r rows -f fields -t threads -b maxlines_per_batch -p [t|l|j] -v\n",
argv[0]); argv[0]);
exit(0); exit(0);
default: /* '?' */ default: /* '?' */
fprintf(stderr, "Usage: %s -s supertable -c childtable -r rows -f fields -t threads -m maxlines_per_batch\n", fprintf(stderr, "Usage: %s -s supertable -c childtable -r rows -f fields -t threads -b maxlines_per_batch -p [t|l|j] -v\n",
argv[0]); argv[0]);
exit(-1); exit(-1);
} }
} }
TAOS_RES* result; TAOS_RES* result;
const char* host = "127.0.0.1"; //const char* host = "127.0.0.1";
const char* host = NULL;
const char* user = "root"; const char* user = "root";
const char* passwd = "taosdata"; const char* passwd = "taosdata";
...@@ -152,10 +175,7 @@ int main(int argc, char* argv[]) { ...@@ -152,10 +175,7 @@ int main(int argc, char* argv[]) {
exit(1); exit(1);
} }
if (numThreads * MAX_THREAD_LINE_BATCHES* maxLinesPerBatch < numSuperTables*numChildTables*numRowsPerChildTable) { maxBatchesPerThread = (numSuperTables*numChildTables*numRowsPerChildTable)/(numThreads * maxLinesPerBatch) + 1;
printf("too many rows to be handle by threads with %d batches", MAX_THREAD_LINE_BATCHES);
exit(2);
}
char* info = taos_get_server_info(taos); char* info = taos_get_server_info(taos);
printf("server info: %s\n", info); printf("server info: %s\n", info);
...@@ -171,28 +191,33 @@ int main(int argc, char* argv[]) { ...@@ -171,28 +191,33 @@ int main(int argc, char* argv[]) {
(void)taos_select_db(taos, "db"); (void)taos_select_db(taos, "db");
time_t ct = time(0); time_t ct = time(0);
int64_t ts = ct * 1000; int64_t ts = ct * 1000 ;
char* lineTemplate = calloc(65536, sizeof(char)); char* lineTemplate = calloc(65536, sizeof(char));
getLineTemplate(lineTemplate, 65535, numFields); if (protocol == TSDB_SML_LINE_PROTOCOL) {
getLineTemplate(lineTemplate, 65535, numFields);
} else if (protocol == TSDB_SML_TELNET_PROTOCOL ) {
getTelenetTemplate(lineTemplate, 65535);
}
printf("setup supertables..."); printf("setup supertables...");
{ {
char** linesStb = calloc(numSuperTables, sizeof(char*)); char** linesStb = calloc(numSuperTables, sizeof(char*));
for (int i = 0; i < numSuperTables; i++) { for (int i = 0; i < numSuperTables; i++) {
char* lineStb = calloc(strlen(lineTemplate)+128, 1); char* lineStb = calloc(strlen(lineTemplate)+128, 1);
snprintf(lineStb, strlen(lineTemplate)+128, lineTemplate, i, generateLine(lineStb, strlen(lineTemplate)+128, lineTemplate, protocol, i,
numSuperTables * numChildTables, numSuperTables * numChildTables,
ts + numSuperTables * numChildTables * numRowsPerChildTable); ts + numSuperTables * numChildTables * numRowsPerChildTable);
linesStb[i] = lineStb; linesStb[i] = lineStb;
} }
SThreadInsertArgs args = {0}; SThreadInsertArgs args = {0};
args.protocol = protocol;
args.batches = calloc(maxBatchesPerThread, sizeof(maxBatchesPerThread));
args.taos = taos; args.taos = taos;
args.batches[0].lines = linesStb; args.batches[0].lines = linesStb;
args.batches[0].numLines = numSuperTables; args.batches[0].numLines = numSuperTables;
args.tsPrecision = tsPrecision;
args.lineProtocol = lineProtocol;
insertLines(&args); insertLines(&args);
free(args.batches);
for (int i = 0; i < numSuperTables; ++i) { for (int i = 0; i < numSuperTables; ++i) {
free(linesStb[i]); free(linesStb[i]);
} }
...@@ -203,8 +228,10 @@ int main(int argc, char* argv[]) { ...@@ -203,8 +228,10 @@ int main(int argc, char* argv[]) {
pthread_t* tids = calloc(numThreads, sizeof(pthread_t)); pthread_t* tids = calloc(numThreads, sizeof(pthread_t));
SThreadInsertArgs* argsThread = calloc(numThreads, sizeof(SThreadInsertArgs)); SThreadInsertArgs* argsThread = calloc(numThreads, sizeof(SThreadInsertArgs));
for (int i = 0; i < numThreads; ++i) { for (int i = 0; i < numThreads; ++i) {
argsThread[i].batches = calloc(maxBatchesPerThread, sizeof(SThreadLinesBatch));
argsThread[i].taos = taos; argsThread[i].taos = taos;
argsThread[i].numBatches = 0; argsThread[i].numBatches = 0;
argsThread[i].protocol = protocol;
} }
int64_t totalLines = numSuperTables * numChildTables * numRowsPerChildTable; int64_t totalLines = numSuperTables * numChildTables * numRowsPerChildTable;
...@@ -229,7 +256,7 @@ int main(int argc, char* argv[]) { ...@@ -229,7 +256,7 @@ int main(int argc, char* argv[]) {
int stIdx = i; int stIdx = i;
int ctIdx = numSuperTables*numChildTables + j; int ctIdx = numSuperTables*numChildTables + j;
char* line = calloc(strlen(lineTemplate)+128, 1); char* line = calloc(strlen(lineTemplate)+128, 1);
snprintf(line, strlen(lineTemplate)+128, lineTemplate, stIdx, ctIdx, ts + l); generateLine(line, strlen(lineTemplate)+128, lineTemplate, protocol, stIdx, ctIdx, ts + l);
int batchNo = l / maxLinesPerBatch; int batchNo = l / maxLinesPerBatch;
int lineNo = l % maxLinesPerBatch; int lineNo = l % maxLinesPerBatch;
allBatches[batchNo][lineNo] = line; allBatches[batchNo][lineNo] = line;
...@@ -262,6 +289,9 @@ int main(int argc, char* argv[]) { ...@@ -262,6 +289,9 @@ int main(int argc, char* argv[]) {
} }
free(allBatches); free(allBatches);
for (int i = 0; i < numThreads; i++) {
free(argsThread[i].batches);
}
free(argsThread); free(argsThread);
free(tids); free(tids);
......
...@@ -45,13 +45,13 @@ python3 ./test.py -f table/tablename-boundary.py ...@@ -45,13 +45,13 @@ python3 ./test.py -f table/tablename-boundary.py
python3 ./test.py -f table/max_table_length.py python3 ./test.py -f table/max_table_length.py
python3 ./test.py -f table/alter_column.py python3 ./test.py -f table/alter_column.py
python3 ./test.py -f table/boundary.py python3 ./test.py -f table/boundary.py
python3 ./test.py -f table/create.py #python3 ./test.py -f table/create.py
python3 ./test.py -f table/del_stable.py python3 ./test.py -f table/del_stable.py
python3 ./test.py -f table/create_db_from_normal_db.py python3 ./test.py -f table/create_db_from_normal_db.py
#stable #stable
python3 ./test.py -f stable/insert.py python3 ./test.py -f stable/insert.py
#python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJsonStmt.py python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJsonStmt.py
# tag # tag
python3 ./test.py -f tag_lite/filter.py python3 ./test.py -f tag_lite/filter.py
...@@ -166,13 +166,13 @@ python3 ./test.py -f update/merge_commit_data.py ...@@ -166,13 +166,13 @@ python3 ./test.py -f update/merge_commit_data.py
python3 test.py -f tools/taosdumpTest.py python3 test.py -f tools/taosdumpTest.py
python3 test.py -f tools/taosdumpTest2.py python3 test.py -f tools/taosdumpTest2.py
#python3 test.py -f tools/taosdemoTest.py python3 test.py -f tools/taosdemoTest.py
#python3 test.py -f tools/taosdemoTestWithoutMetric.py python3 test.py -f tools/taosdemoTestWithoutMetric.py
#python3 test.py -f tools/taosdemoTestWithJson.py python3 test.py -f tools/taosdemoTestWithJson.py
#python3 test.py -f tools/taosdemoTestLimitOffset.py python3 test.py -f tools/taosdemoTestLimitOffset.py
#python3 test.py -f tools/taosdemoTestTblAlt.py python3 test.py -f tools/taosdemoTestTblAlt.py
#python3 test.py -f tools/taosdemoTestSampleData.py python3 test.py -f tools/taosdemoTestSampleData.py
#python3 test.py -f tools/taosdemoTestInterlace.py python3 test.py -f tools/taosdemoTestInterlace.py
# python3 test.py -f tools/taosdemoTestQuery.py # python3 test.py -f tools/taosdemoTestQuery.py
# restful test for python # restful test for python
...@@ -180,10 +180,10 @@ python3 test.py -f tools/taosdumpTest2.py ...@@ -180,10 +180,10 @@ python3 test.py -f tools/taosdumpTest2.py
# python3 test.py -f restful/restful_bind_db2.py # python3 test.py -f restful/restful_bind_db2.py
# nano support # nano support
# python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoInsert.py python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoInsert.py
#python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuery.py python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuery.py
#python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanosubscribe.py python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanosubscribe.py
#python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestInsertTime_step.py python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestInsertTime_step.py
python3 test.py -f tools/taosdumpTestNanoSupport.py python3 test.py -f tools/taosdumpTestNanoSupport.py
# #
...@@ -220,9 +220,9 @@ python3 ./test.py -f perfbenchmark/bug3433.py ...@@ -220,9 +220,9 @@ python3 ./test.py -f perfbenchmark/bug3433.py
#python3 ./test.py -f perfbenchmark/taosdemoInsert.py #python3 ./test.py -f perfbenchmark/taosdemoInsert.py
#taosdemo #taosdemo
#python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJson.py python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJson.py
#python3 test.py -f tools/taosdemoAllTest/taosdemoTestQueryWithJson.py python3 test.py -f tools/taosdemoAllTest/taosdemoTestQueryWithJson.py
#python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertAllType.py python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertAllType.py
#query #query
python3 test.py -f query/distinctOneColTb.py python3 test.py -f query/distinctOneColTb.py
...@@ -395,9 +395,9 @@ python3 ./test.py -f insert/insert_locking.py ...@@ -395,9 +395,9 @@ python3 ./test.py -f insert/insert_locking.py
python3 ./test.py -f alter/alter_debugFlag.py python3 ./test.py -f alter/alter_debugFlag.py
python3 ./test.py -f query/queryBetweenAnd.py python3 ./test.py -f query/queryBetweenAnd.py
python3 ./test.py -f tag_lite/alter_tag.py python3 ./test.py -f tag_lite/alter_tag.py
#python3 test.py -f tools/taosdemoAllTest/TD-4985/query-limit-offset.py python3 test.py -f tools/taosdemoAllTest/TD-4985/query-limit-offset.py
#python3 test.py -f tools/taosdemoAllTest/TD-5213/insert4096columns_not_use_taosdemo.py python3 test.py -f tools/taosdemoAllTest/TD-5213/insert4096columns_not_use_taosdemo.py
#python3 test.py -f tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py python3 test.py -f tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py
#python3 test.py -f tools/taosdemoAllTest/TD-10539/create_taosdemo.py #python3 test.py -f tools/taosdemoAllTest/TD-10539/create_taosdemo.py
python3 ./test.py -f tag_lite/drop_auto_create.py python3 ./test.py -f tag_lite/drop_auto_create.py
python3 test.py -f insert/insert_before_use_db.py python3 test.py -f insert/insert_before_use_db.py
...@@ -421,10 +421,11 @@ python3 ./test.py -f insert/verifyMemToDiskCrash.py ...@@ -421,10 +421,11 @@ python3 ./test.py -f insert/verifyMemToDiskCrash.py
python3 ./test.py -f query/queryRegex.py python3 ./test.py -f query/queryRegex.py
#python3 ./test.py -f tools/taosdemoTestdatatype.py python3 ./test.py -f tools/taosdemoTestdatatype.py
#python3 ./test.py -f insert/schemalessInsert.py #python3 ./test.py -f insert/schemalessInsert.py
#python3 ./test.py -f insert/openTsdbTelnetLinesInsert.py
#python3 ./test.py -f insert/openTsdbJsonInsert.py #python3 ./test.py -f insert/openTsdbJsonInsert.py
python3 ./test.py -f insert/openTsdbTelnetLinesInsert.py
python3 ./test.py -f functions/variable_httpDbNameMandatory.py
#======================p4-end=============== #======================p4-end===============
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -332,6 +332,14 @@ class TDSql: ...@@ -332,6 +332,14 @@ class TDSql:
args = (caller.filename, caller.lineno, self.sql, elm, expect_elm) args = (caller.filename, caller.lineno, self.sql, elm, expect_elm)
tdLog.exit("%s(%d) failed: sql:%s, elm:%s == expect_elm:%s" % args) tdLog.exit("%s(%d) failed: sql:%s, elm:%s == expect_elm:%s" % args)
def checkIn(self, sub, res):
if sub in res:
tdLog.info("sql:%s, sub:%s in result:%s" % (self.sql, sub, res))
else:
caller = inspect.getframeinfo(inspect.stack()[1][0])
args = (caller.filename, caller.lineno, self.sql, sub, res)
tdLog.exit("%s(%d) failed: sql:%s, sub:%s not in result:%s" % args)
def taosdStatus(self, state): def taosdStatus(self, state):
tdLog.sleep(5) tdLog.sleep(5)
pstate = 0 pstate = 0
......
...@@ -203,5 +203,35 @@ if $data24 != NULL then ...@@ -203,5 +203,35 @@ if $data24 != NULL then
return -1 return -1
endi endi
print ======================= test show create table/stable
sql create stable stb3 (ts timestamp, c0 int) tags (`123` int, `123 456` int, `123.abc` int)
sql create table ctb3 using stb3 (`123`, `123 456`, `123.abc`) tags (1, 1, 1)
sql show create table stb3;
if $rows != 1 then
return -1
endi
if $data00 != @stb3@ then
return -1
endi
if $data01 != @create table `stb3` (`ts` TIMESTAMP,`c0` INT) TAGS (`123` INT,`123 456` INT,`123.abc` INT)@ then
return -1
endi
sql show create table ctb3;
if $rows != 1 then
return -1
endi
if $data00 != @ctb3@ then
return -1
endi
if $data01 != @CREATE TABLE `ctb3` USING `stb3` TAGS (1,1,1)@ then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s stop -x SIGINT
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册