diff --git a/CMakeLists.txt b/CMakeLists.txt index b78b896908..0c7e31bfbb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,6 @@ add_subdirectory(tests) add_subdirectory(examples/c) # docs -add_subdirectory(docs) +add_subdirectory(docs/doxgen) # tests (TODO) diff --git a/docs-cn/07-develop/01-connect/_connect_c.mdx b/docs-cn/07-develop/01-connect/_connect_c.mdx deleted file mode 100644 index 9cd8669561..0000000000 --- a/docs-cn/07-develop/01-connect/_connect_c.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```c title="原生连接" -{{#include docs-examples/c/connect_example.c}} -``` diff --git a/docs-cn/07-develop/01-connect/_connect_node.mdx b/docs-cn/07-develop/01-connect/_connect_node.mdx deleted file mode 100644 index 199a6e3faa..0000000000 --- a/docs-cn/07-develop/01-connect/_connect_node.mdx +++ /dev/null @@ -1,7 +0,0 @@ -```js title="原生连接" -{{#include docs-examples/node/nativeexample/connect.js}} -``` - -```js title="REST 连接" -{{#include docs-examples/node/restexample/connect.js}} -``` diff --git a/docs-cn/07-develop/01-connect/_connect_php.mdx b/docs-cn/07-develop/01-connect/_connect_php.mdx deleted file mode 100644 index 2431df2a72..0000000000 --- a/docs-cn/07-develop/01-connect/_connect_php.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```php title="原生连接" -{{#include docs-examples/php/connect.php}} -``` diff --git a/docs-cn/07-develop/01-connect/_connect_python.mdx b/docs-cn/07-develop/01-connect/_connect_python.mdx deleted file mode 100644 index c0043c752e..0000000000 --- a/docs-cn/07-develop/01-connect/_connect_python.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```python title="原生连接" -{{#include docs-examples/python/connect_example.py}} -``` diff --git a/docs-cn/07-develop/01-connect/_connect_r.mdx b/docs-cn/07-develop/01-connect/_connect_r.mdx deleted file mode 100644 index 8aab6121a6..0000000000 --- a/docs-cn/07-develop/01-connect/_connect_r.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```r title="原生连接" -{{#include docs-examples/R/connect_native.r:demo}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_c_line.mdx b/docs-cn/07-develop/03-insert-data/_c_line.mdx deleted file mode 100644 index 5ef2e9af77..0000000000 --- a/docs-cn/07-develop/03-insert-data/_c_line.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```c -{{#include docs-examples/c/line_example.c:main}} -``` \ No newline at end of file diff --git a/docs-cn/07-develop/03-insert-data/_c_opts_json.mdx b/docs-cn/07-develop/03-insert-data/_c_opts_json.mdx deleted file mode 100644 index 22ad2e0122..0000000000 --- a/docs-cn/07-develop/03-insert-data/_c_opts_json.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```c -{{#include docs-examples/c/json_protocol_example.c:main}} -``` \ No newline at end of file diff --git a/docs-cn/07-develop/03-insert-data/_c_opts_telnet.mdx b/docs-cn/07-develop/03-insert-data/_c_opts_telnet.mdx deleted file mode 100644 index 508d7bc98a..0000000000 --- a/docs-cn/07-develop/03-insert-data/_c_opts_telnet.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```c -{{#include docs-examples/c/telnet_line_example.c:main}} -``` \ No newline at end of file diff --git a/docs-cn/07-develop/03-insert-data/_c_sql.mdx b/docs-cn/07-develop/03-insert-data/_c_sql.mdx deleted file mode 100644 index f4153fd2c4..0000000000 --- a/docs-cn/07-develop/03-insert-data/_c_sql.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```c -{{#include docs-examples/c/insert_example.c}} -``` \ No newline at end of file diff --git a/docs-cn/07-develop/03-insert-data/_c_stmt.mdx b/docs-cn/07-develop/03-insert-data/_c_stmt.mdx deleted file mode 100644 index 01ac067519..0000000000 --- a/docs-cn/07-develop/03-insert-data/_c_stmt.mdx +++ /dev/null @@ -1,6 +0,0 @@ -```c title=一次绑定一行 -{{#include docs-examples/c/stmt_example.c}} -``` -```c title=一次绑定多行 72:117 -{{#include docs-examples/c/multi_bind_example.c}} -``` \ No newline at end of file diff --git a/docs-cn/07-develop/03-insert-data/_cs_line.mdx b/docs-cn/07-develop/03-insert-data/_cs_line.mdx deleted file mode 100644 index 9c275ee3d7..0000000000 --- a/docs-cn/07-develop/03-insert-data/_cs_line.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```csharp -{{#include docs-examples/csharp/InfluxDBLineExample.cs}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_cs_opts_json.mdx b/docs-cn/07-develop/03-insert-data/_cs_opts_json.mdx deleted file mode 100644 index 3d538b8506..0000000000 --- a/docs-cn/07-develop/03-insert-data/_cs_opts_json.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```csharp -{{#include docs-examples/csharp/OptsJsonExample.cs}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_cs_opts_telnet.mdx b/docs-cn/07-develop/03-insert-data/_cs_opts_telnet.mdx deleted file mode 100644 index c53bf3d723..0000000000 --- a/docs-cn/07-develop/03-insert-data/_cs_opts_telnet.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```csharp -{{#include docs-examples/csharp/OptsTelnetExample.cs}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_cs_sql.mdx b/docs-cn/07-develop/03-insert-data/_cs_sql.mdx deleted file mode 100644 index c7688bfbe7..0000000000 --- a/docs-cn/07-develop/03-insert-data/_cs_sql.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```csharp -{{#include docs-examples/csharp/SQLInsertExample.cs}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_cs_stmt.mdx b/docs-cn/07-develop/03-insert-data/_cs_stmt.mdx deleted file mode 100644 index 97c3b910ff..0000000000 --- a/docs-cn/07-develop/03-insert-data/_cs_stmt.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```csharp -{{#include docs-examples/csharp/StmtInsertExample.cs}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_go_line.mdx b/docs-cn/07-develop/03-insert-data/_go_line.mdx deleted file mode 100644 index cd225945b7..0000000000 --- a/docs-cn/07-develop/03-insert-data/_go_line.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```go -{{#include docs-examples/go/insert/line/main.go}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_go_opts_json.mdx b/docs-cn/07-develop/03-insert-data/_go_opts_json.mdx deleted file mode 100644 index 0c0d3e5b63..0000000000 --- a/docs-cn/07-develop/03-insert-data/_go_opts_json.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```go -{{#include docs-examples/go/insert/json/main.go}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_go_opts_telnet.mdx b/docs-cn/07-develop/03-insert-data/_go_opts_telnet.mdx deleted file mode 100644 index d5ca40cc14..0000000000 --- a/docs-cn/07-develop/03-insert-data/_go_opts_telnet.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```go -{{#include docs-examples/go/insert/telnet/main.go}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_go_sql.mdx b/docs-cn/07-develop/03-insert-data/_go_sql.mdx deleted file mode 100644 index 613a65add1..0000000000 --- a/docs-cn/07-develop/03-insert-data/_go_sql.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```go -{{#include docs-examples/go/insert/sql/main.go}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_java_line.mdx b/docs-cn/07-develop/03-insert-data/_java_line.mdx deleted file mode 100644 index 2e59a5d470..0000000000 --- a/docs-cn/07-develop/03-insert-data/_java_line.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```java -{{#include docs-examples/java/src/main/java/com/taos/example/LineProtocolExample.java}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_java_opts_json.mdx b/docs-cn/07-develop/03-insert-data/_java_opts_json.mdx deleted file mode 100644 index 826a1a07d9..0000000000 --- a/docs-cn/07-develop/03-insert-data/_java_opts_json.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```java -{{#include docs-examples/java/src/main/java/com/taos/example/JSONProtocolExample.java}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_java_opts_telnet.mdx b/docs-cn/07-develop/03-insert-data/_java_opts_telnet.mdx deleted file mode 100644 index 954dcc1a48..0000000000 --- a/docs-cn/07-develop/03-insert-data/_java_opts_telnet.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```java -{{#include docs-examples/java/src/main/java/com/taos/example/TelnetLineProtocolExample.java}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_java_sql.mdx b/docs-cn/07-develop/03-insert-data/_java_sql.mdx deleted file mode 100644 index a863378def..0000000000 --- a/docs-cn/07-develop/03-insert-data/_java_sql.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```java -{{#include docs-examples/java/src/main/java/com/taos/example/RestInsertExample.java:insert}} -``` \ No newline at end of file diff --git a/docs-cn/07-develop/03-insert-data/_java_stmt.mdx b/docs-cn/07-develop/03-insert-data/_java_stmt.mdx deleted file mode 100644 index 54443e535f..0000000000 --- a/docs-cn/07-develop/03-insert-data/_java_stmt.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```java -{{#include docs-examples/java/src/main/java/com/taos/example/StmtInsertExample.java}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_js_line.mdx b/docs-cn/07-develop/03-insert-data/_js_line.mdx deleted file mode 100644 index 172c9bc17b..0000000000 --- a/docs-cn/07-develop/03-insert-data/_js_line.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```js -{{#include docs-examples/node/nativeexample/influxdb_line_example.js}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_js_opts_json.mdx b/docs-cn/07-develop/03-insert-data/_js_opts_json.mdx deleted file mode 100644 index 20ac9ec91e..0000000000 --- a/docs-cn/07-develop/03-insert-data/_js_opts_json.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```js -{{#include docs-examples/node/nativeexample/opentsdb_json_example.js}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_js_opts_telnet.mdx b/docs-cn/07-develop/03-insert-data/_js_opts_telnet.mdx deleted file mode 100644 index c3c8c40bd6..0000000000 --- a/docs-cn/07-develop/03-insert-data/_js_opts_telnet.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```js -{{#include docs-examples/node/nativeexample/opentsdb_telnet_example.js}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_js_sql.mdx b/docs-cn/07-develop/03-insert-data/_js_sql.mdx deleted file mode 100644 index f5e17c7689..0000000000 --- a/docs-cn/07-develop/03-insert-data/_js_sql.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```js -{{#include docs-examples/node/nativeexample/insert_example.js}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_php_sql.mdx b/docs-cn/07-develop/03-insert-data/_php_sql.mdx deleted file mode 100644 index 42d6a54847..0000000000 --- a/docs-cn/07-develop/03-insert-data/_php_sql.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```php -{{#include docs-examples/php/insert.php}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_php_stmt.mdx b/docs-cn/07-develop/03-insert-data/_php_stmt.mdx deleted file mode 100644 index c1ba4ed3b1..0000000000 --- a/docs-cn/07-develop/03-insert-data/_php_stmt.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```php -{{#include docs-examples/php/insert_stmt.php}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_py_line.mdx b/docs-cn/07-develop/03-insert-data/_py_line.mdx deleted file mode 100644 index d3bb1ebb34..0000000000 --- a/docs-cn/07-develop/03-insert-data/_py_line.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```py -{{#include docs-examples/python/line_protocol_example.py}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_py_opts_json.mdx b/docs-cn/07-develop/03-insert-data/_py_opts_json.mdx deleted file mode 100644 index cfbfe13ccf..0000000000 --- a/docs-cn/07-develop/03-insert-data/_py_opts_json.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```py -{{#include docs-examples/python/json_protocol_example.py}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_py_opts_telnet.mdx b/docs-cn/07-develop/03-insert-data/_py_opts_telnet.mdx deleted file mode 100644 index 14bc65a7a3..0000000000 --- a/docs-cn/07-develop/03-insert-data/_py_opts_telnet.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```py -{{#include docs-examples/python/telnet_line_protocol_example.py}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_py_sql.mdx b/docs-cn/07-develop/03-insert-data/_py_sql.mdx deleted file mode 100644 index c0e15b8ec1..0000000000 --- a/docs-cn/07-develop/03-insert-data/_py_sql.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```py -{{#include docs-examples/python/native_insert_example.py}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_rust_line.mdx b/docs-cn/07-develop/03-insert-data/_rust_line.mdx deleted file mode 100644 index 696ddb7b85..0000000000 --- a/docs-cn/07-develop/03-insert-data/_rust_line.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```rust -{{#include docs-examples/rust/schemalessexample/examples/influxdb_line_example.rs}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_rust_opts_json.mdx b/docs-cn/07-develop/03-insert-data/_rust_opts_json.mdx deleted file mode 100644 index 97d9052dac..0000000000 --- a/docs-cn/07-develop/03-insert-data/_rust_opts_json.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```rust -{{#include docs-examples/rust/schemalessexample/examples/opentsdb_json_example.rs}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_rust_opts_telnet.mdx b/docs-cn/07-develop/03-insert-data/_rust_opts_telnet.mdx deleted file mode 100644 index 14021f43d8..0000000000 --- a/docs-cn/07-develop/03-insert-data/_rust_opts_telnet.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```rust -{{#include docs-examples/rust/schemalessexample/examples/opentsdb_telnet_example.rs}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_rust_sql.mdx b/docs-cn/07-develop/03-insert-data/_rust_sql.mdx deleted file mode 100644 index 8e8013e4ad..0000000000 --- a/docs-cn/07-develop/03-insert-data/_rust_sql.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```rust -{{#include docs-examples/rust/restexample/examples/insert_example.rs}} -``` diff --git a/docs-cn/07-develop/03-insert-data/_rust_stmt.mdx b/docs-cn/07-develop/03-insert-data/_rust_stmt.mdx deleted file mode 100644 index 590a7a0e71..0000000000 --- a/docs-cn/07-develop/03-insert-data/_rust_stmt.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```rust -{{#include docs-examples/rust/nativeexample/examples/stmt_example.rs}} -``` diff --git a/docs-cn/07-develop/04-query-data/_c.mdx b/docs-cn/07-develop/04-query-data/_c.mdx deleted file mode 100644 index 76c9067e2f..0000000000 --- a/docs-cn/07-develop/04-query-data/_c.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```c -{{#include docs-examples/c/query_example.c}} -``` \ No newline at end of file diff --git a/docs-cn/07-develop/04-query-data/_c_async.mdx b/docs-cn/07-develop/04-query-data/_c_async.mdx deleted file mode 100644 index 09f3d3b3ff..0000000000 --- a/docs-cn/07-develop/04-query-data/_c_async.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```c -{{#include docs-examples/c/async_query_example.c:demo}} -``` \ No newline at end of file diff --git a/docs-cn/07-develop/04-query-data/_cs.mdx b/docs-cn/07-develop/04-query-data/_cs.mdx deleted file mode 100644 index 2ab52feb56..0000000000 --- a/docs-cn/07-develop/04-query-data/_cs.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```csharp -{{#include docs-examples/csharp/QueryExample.cs}} -``` diff --git a/docs-cn/07-develop/04-query-data/_cs_async.mdx b/docs-cn/07-develop/04-query-data/_cs_async.mdx deleted file mode 100644 index f868994b30..0000000000 --- a/docs-cn/07-develop/04-query-data/_cs_async.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```csharp -{{#include docs-examples/csharp/AsyncQueryExample.cs}} -``` diff --git a/docs-cn/07-develop/04-query-data/_go.mdx b/docs-cn/07-develop/04-query-data/_go.mdx deleted file mode 100644 index 417c12315c..0000000000 --- a/docs-cn/07-develop/04-query-data/_go.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```go -{{#include docs-examples/go/query/sync/main.go}} -``` diff --git a/docs-cn/07-develop/04-query-data/_go_async.mdx b/docs-cn/07-develop/04-query-data/_go_async.mdx deleted file mode 100644 index 72fff411b9..0000000000 --- a/docs-cn/07-develop/04-query-data/_go_async.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```go -{{#include docs-examples/go/query/async/main.go}} -``` diff --git a/docs-cn/07-develop/04-query-data/_java.mdx b/docs-cn/07-develop/04-query-data/_java.mdx deleted file mode 100644 index 519b926614..0000000000 --- a/docs-cn/07-develop/04-query-data/_java.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```java -{{#include docs-examples/java/src/main/java/com/taos/example/RestQueryExample.java}} -``` diff --git a/docs-cn/07-develop/04-query-data/_js.mdx b/docs-cn/07-develop/04-query-data/_js.mdx deleted file mode 100644 index c5e4c4f3fc..0000000000 --- a/docs-cn/07-develop/04-query-data/_js.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```js -{{#include docs-examples/node/nativeexample/query_example.js}} -``` diff --git a/docs-cn/07-develop/04-query-data/_js_async.mdx b/docs-cn/07-develop/04-query-data/_js_async.mdx deleted file mode 100644 index c65d54ed12..0000000000 --- a/docs-cn/07-develop/04-query-data/_js_async.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```js -{{#include docs-examples/node/nativeexample/async_query_example.js}} -``` diff --git a/docs-cn/07-develop/04-query-data/_php.mdx b/docs-cn/07-develop/04-query-data/_php.mdx deleted file mode 100644 index 6264bd99f5..0000000000 --- a/docs-cn/07-develop/04-query-data/_php.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```go -{{#include docs-examples/php/query.php}} -``` diff --git a/docs-cn/07-develop/04-query-data/_rust.mdx b/docs-cn/07-develop/04-query-data/_rust.mdx deleted file mode 100644 index 742d70fd02..0000000000 --- a/docs-cn/07-develop/04-query-data/_rust.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```rust -{{#include docs-examples/rust/restexample/examples/query_example.rs}} -``` diff --git a/docs-cn/07-develop/_sub_c.mdx b/docs-cn/07-develop/_sub_c.mdx deleted file mode 100644 index 95fef0042d..0000000000 --- a/docs-cn/07-develop/_sub_c.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```c -{{#include docs-examples/c/subscribe_demo.c}} -``` \ No newline at end of file diff --git a/docs-cn/07-develop/_sub_cs.mdx b/docs-cn/07-develop/_sub_cs.mdx deleted file mode 100644 index 80934aa4d0..0000000000 --- a/docs-cn/07-develop/_sub_cs.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```csharp -{{#include docs-examples/csharp/SubscribeDemo.cs}} -``` \ No newline at end of file diff --git a/docs-cn/07-develop/_sub_go.mdx b/docs-cn/07-develop/_sub_go.mdx deleted file mode 100644 index cd908fc12c..0000000000 --- a/docs-cn/07-develop/_sub_go.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```go -{{#include docs-examples/go/sub/main.go}} -``` \ No newline at end of file diff --git a/docs-cn/07-develop/_sub_node.mdx b/docs-cn/07-develop/_sub_node.mdx deleted file mode 100644 index c93ad627ce..0000000000 --- a/docs-cn/07-develop/_sub_node.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```js -{{#include docs-examples/node/nativeexample/subscribe_demo.js}} -``` \ No newline at end of file diff --git a/docs-cn/07-develop/_sub_python.mdx b/docs-cn/07-develop/_sub_python.mdx deleted file mode 100644 index b817deeba6..0000000000 --- a/docs-cn/07-develop/_sub_python.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```py -{{#include docs-examples/python/subscribe_demo.py}} -``` \ No newline at end of file diff --git a/docs-cn/07-develop/_sub_rust.mdx b/docs-cn/07-develop/_sub_rust.mdx deleted file mode 100644 index 4750cf7a3b..0000000000 --- a/docs-cn/07-develop/_sub_rust.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```rs -{{#include docs-examples/rust/nativeexample/examples/subscribe_demo.rs}} -``` \ No newline at end of file diff --git a/docs-en/07-develop/01-connect/_connect_c.mdx b/docs-en/07-develop/01-connect/_connect_c.mdx deleted file mode 100644 index 174bf45c4e..0000000000 --- a/docs-en/07-develop/01-connect/_connect_c.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```c title="Native Connection" -{{#include docs-examples/c/connect_example.c}} -``` diff --git a/docs-en/07-develop/01-connect/_connect_node.mdx b/docs-en/07-develop/01-connect/_connect_node.mdx deleted file mode 100644 index 489b0386e9..0000000000 --- a/docs-en/07-develop/01-connect/_connect_node.mdx +++ /dev/null @@ -1,7 +0,0 @@ -```js title="Native Connection" -{{#include docs-examples/node/nativeexample/connect.js}} -``` - -```js title="REST Connection" -{{#include docs-examples/node/restexample/connect.js}} -``` diff --git a/docs-en/07-develop/01-connect/_connect_python.mdx b/docs-en/07-develop/01-connect/_connect_python.mdx deleted file mode 100644 index 44b7586fad..0000000000 --- a/docs-en/07-develop/01-connect/_connect_python.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```python title="Native Connection" -{{#include docs-examples/python/connect_example.py}} -``` diff --git a/docs-en/07-develop/01-connect/_connect_r.mdx b/docs-en/07-develop/01-connect/_connect_r.mdx deleted file mode 100644 index 09c3d71ac3..0000000000 --- a/docs-en/07-develop/01-connect/_connect_r.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```r title="Native Connection" -{{#include docs-examples/R/connect_native.r:demo}} -``` diff --git a/docs-en/07-develop/03-insert-data/_c_line.mdx b/docs-en/07-develop/03-insert-data/_c_line.mdx deleted file mode 100644 index 5ef2e9af77..0000000000 --- a/docs-en/07-develop/03-insert-data/_c_line.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```c -{{#include docs-examples/c/line_example.c:main}} -``` \ No newline at end of file diff --git a/docs-en/07-develop/03-insert-data/_c_opts_json.mdx b/docs-en/07-develop/03-insert-data/_c_opts_json.mdx deleted file mode 100644 index 22ad2e0122..0000000000 --- a/docs-en/07-develop/03-insert-data/_c_opts_json.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```c -{{#include docs-examples/c/json_protocol_example.c:main}} -``` \ No newline at end of file diff --git a/docs-en/07-develop/03-insert-data/_c_opts_telnet.mdx b/docs-en/07-develop/03-insert-data/_c_opts_telnet.mdx deleted file mode 100644 index 508d7bc98a..0000000000 --- a/docs-en/07-develop/03-insert-data/_c_opts_telnet.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```c -{{#include docs-examples/c/telnet_line_example.c:main}} -``` \ No newline at end of file diff --git a/docs-en/07-develop/03-insert-data/_c_sql.mdx b/docs-en/07-develop/03-insert-data/_c_sql.mdx deleted file mode 100644 index f4153fd2c4..0000000000 --- a/docs-en/07-develop/03-insert-data/_c_sql.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```c -{{#include docs-examples/c/insert_example.c}} -``` \ No newline at end of file diff --git a/docs-en/07-develop/03-insert-data/_c_stmt.mdx b/docs-en/07-develop/03-insert-data/_c_stmt.mdx deleted file mode 100644 index 7f5ef23a84..0000000000 --- a/docs-en/07-develop/03-insert-data/_c_stmt.mdx +++ /dev/null @@ -1,6 +0,0 @@ -```c title=Single Row Binding -{{#include docs-examples/c/stmt_example.c}} -``` -```c title=Multiple Row Binding 72:117 -{{#include docs-examples/c/multi_bind_example.c}} -``` \ No newline at end of file diff --git a/docs-en/07-develop/03-insert-data/_cs_line.mdx b/docs-en/07-develop/03-insert-data/_cs_line.mdx deleted file mode 100644 index 9c275ee3d7..0000000000 --- a/docs-en/07-develop/03-insert-data/_cs_line.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```csharp -{{#include docs-examples/csharp/InfluxDBLineExample.cs}} -``` diff --git a/docs-en/07-develop/03-insert-data/_cs_opts_json.mdx b/docs-en/07-develop/03-insert-data/_cs_opts_json.mdx deleted file mode 100644 index 3d538b8506..0000000000 --- a/docs-en/07-develop/03-insert-data/_cs_opts_json.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```csharp -{{#include docs-examples/csharp/OptsJsonExample.cs}} -``` diff --git a/docs-en/07-develop/03-insert-data/_cs_opts_telnet.mdx b/docs-en/07-develop/03-insert-data/_cs_opts_telnet.mdx deleted file mode 100644 index c53bf3d723..0000000000 --- a/docs-en/07-develop/03-insert-data/_cs_opts_telnet.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```csharp -{{#include docs-examples/csharp/OptsTelnetExample.cs}} -``` diff --git a/docs-en/07-develop/03-insert-data/_cs_sql.mdx b/docs-en/07-develop/03-insert-data/_cs_sql.mdx deleted file mode 100644 index c7688bfbe7..0000000000 --- a/docs-en/07-develop/03-insert-data/_cs_sql.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```csharp -{{#include docs-examples/csharp/SQLInsertExample.cs}} -``` diff --git a/docs-en/07-develop/03-insert-data/_cs_stmt.mdx b/docs-en/07-develop/03-insert-data/_cs_stmt.mdx deleted file mode 100644 index 97c3b910ff..0000000000 --- a/docs-en/07-develop/03-insert-data/_cs_stmt.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```csharp -{{#include docs-examples/csharp/StmtInsertExample.cs}} -``` diff --git a/docs-en/07-develop/03-insert-data/_go_line.mdx b/docs-en/07-develop/03-insert-data/_go_line.mdx deleted file mode 100644 index cd225945b7..0000000000 --- a/docs-en/07-develop/03-insert-data/_go_line.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```go -{{#include docs-examples/go/insert/line/main.go}} -``` diff --git a/docs-en/07-develop/03-insert-data/_go_opts_json.mdx b/docs-en/07-develop/03-insert-data/_go_opts_json.mdx deleted file mode 100644 index 0c0d3e5b63..0000000000 --- a/docs-en/07-develop/03-insert-data/_go_opts_json.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```go -{{#include docs-examples/go/insert/json/main.go}} -``` diff --git a/docs-en/07-develop/03-insert-data/_go_opts_telnet.mdx b/docs-en/07-develop/03-insert-data/_go_opts_telnet.mdx deleted file mode 100644 index d5ca40cc14..0000000000 --- a/docs-en/07-develop/03-insert-data/_go_opts_telnet.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```go -{{#include docs-examples/go/insert/telnet/main.go}} -``` diff --git a/docs-en/07-develop/03-insert-data/_go_sql.mdx b/docs-en/07-develop/03-insert-data/_go_sql.mdx deleted file mode 100644 index 613a65add1..0000000000 --- a/docs-en/07-develop/03-insert-data/_go_sql.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```go -{{#include docs-examples/go/insert/sql/main.go}} -``` diff --git a/docs-en/07-develop/03-insert-data/_java_line.mdx b/docs-en/07-develop/03-insert-data/_java_line.mdx deleted file mode 100644 index 2e59a5d470..0000000000 --- a/docs-en/07-develop/03-insert-data/_java_line.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```java -{{#include docs-examples/java/src/main/java/com/taos/example/LineProtocolExample.java}} -``` diff --git a/docs-en/07-develop/03-insert-data/_java_opts_json.mdx b/docs-en/07-develop/03-insert-data/_java_opts_json.mdx deleted file mode 100644 index 826a1a07d9..0000000000 --- a/docs-en/07-develop/03-insert-data/_java_opts_json.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```java -{{#include docs-examples/java/src/main/java/com/taos/example/JSONProtocolExample.java}} -``` diff --git a/docs-en/07-develop/03-insert-data/_java_opts_telnet.mdx b/docs-en/07-develop/03-insert-data/_java_opts_telnet.mdx deleted file mode 100644 index 954dcc1a48..0000000000 --- a/docs-en/07-develop/03-insert-data/_java_opts_telnet.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```java -{{#include docs-examples/java/src/main/java/com/taos/example/TelnetLineProtocolExample.java}} -``` diff --git a/docs-en/07-develop/03-insert-data/_java_sql.mdx b/docs-en/07-develop/03-insert-data/_java_sql.mdx deleted file mode 100644 index a863378def..0000000000 --- a/docs-en/07-develop/03-insert-data/_java_sql.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```java -{{#include docs-examples/java/src/main/java/com/taos/example/RestInsertExample.java:insert}} -``` \ No newline at end of file diff --git a/docs-en/07-develop/03-insert-data/_java_stmt.mdx b/docs-en/07-develop/03-insert-data/_java_stmt.mdx deleted file mode 100644 index 54443e535f..0000000000 --- a/docs-en/07-develop/03-insert-data/_java_stmt.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```java -{{#include docs-examples/java/src/main/java/com/taos/example/StmtInsertExample.java}} -``` diff --git a/docs-en/07-develop/03-insert-data/_js_line.mdx b/docs-en/07-develop/03-insert-data/_js_line.mdx deleted file mode 100644 index 172c9bc17b..0000000000 --- a/docs-en/07-develop/03-insert-data/_js_line.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```js -{{#include docs-examples/node/nativeexample/influxdb_line_example.js}} -``` diff --git a/docs-en/07-develop/03-insert-data/_js_opts_json.mdx b/docs-en/07-develop/03-insert-data/_js_opts_json.mdx deleted file mode 100644 index 20ac9ec91e..0000000000 --- a/docs-en/07-develop/03-insert-data/_js_opts_json.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```js -{{#include docs-examples/node/nativeexample/opentsdb_json_example.js}} -``` diff --git a/docs-en/07-develop/03-insert-data/_js_opts_telnet.mdx b/docs-en/07-develop/03-insert-data/_js_opts_telnet.mdx deleted file mode 100644 index c3c8c40bd6..0000000000 --- a/docs-en/07-develop/03-insert-data/_js_opts_telnet.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```js -{{#include docs-examples/node/nativeexample/opentsdb_telnet_example.js}} -``` diff --git a/docs-en/07-develop/03-insert-data/_js_sql.mdx b/docs-en/07-develop/03-insert-data/_js_sql.mdx deleted file mode 100644 index f5e17c7689..0000000000 --- a/docs-en/07-develop/03-insert-data/_js_sql.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```js -{{#include docs-examples/node/nativeexample/insert_example.js}} -``` diff --git a/docs-en/07-develop/03-insert-data/_py_line.mdx b/docs-en/07-develop/03-insert-data/_py_line.mdx deleted file mode 100644 index d3bb1ebb34..0000000000 --- a/docs-en/07-develop/03-insert-data/_py_line.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```py -{{#include docs-examples/python/line_protocol_example.py}} -``` diff --git a/docs-en/07-develop/03-insert-data/_py_opts_json.mdx b/docs-en/07-develop/03-insert-data/_py_opts_json.mdx deleted file mode 100644 index cfbfe13ccf..0000000000 --- a/docs-en/07-develop/03-insert-data/_py_opts_json.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```py -{{#include docs-examples/python/json_protocol_example.py}} -``` diff --git a/docs-en/07-develop/03-insert-data/_py_opts_telnet.mdx b/docs-en/07-develop/03-insert-data/_py_opts_telnet.mdx deleted file mode 100644 index 14bc65a7a3..0000000000 --- a/docs-en/07-develop/03-insert-data/_py_opts_telnet.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```py -{{#include docs-examples/python/telnet_line_protocol_example.py}} -``` diff --git a/docs-en/07-develop/03-insert-data/_py_sql.mdx b/docs-en/07-develop/03-insert-data/_py_sql.mdx deleted file mode 100644 index c0e15b8ec1..0000000000 --- a/docs-en/07-develop/03-insert-data/_py_sql.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```py -{{#include docs-examples/python/native_insert_example.py}} -``` diff --git a/docs-en/07-develop/03-insert-data/_rust_line.mdx b/docs-en/07-develop/03-insert-data/_rust_line.mdx deleted file mode 100644 index 696ddb7b85..0000000000 --- a/docs-en/07-develop/03-insert-data/_rust_line.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```rust -{{#include docs-examples/rust/schemalessexample/examples/influxdb_line_example.rs}} -``` diff --git a/docs-en/07-develop/03-insert-data/_rust_opts_json.mdx b/docs-en/07-develop/03-insert-data/_rust_opts_json.mdx deleted file mode 100644 index 97d9052dac..0000000000 --- a/docs-en/07-develop/03-insert-data/_rust_opts_json.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```rust -{{#include docs-examples/rust/schemalessexample/examples/opentsdb_json_example.rs}} -``` diff --git a/docs-en/07-develop/03-insert-data/_rust_opts_telnet.mdx b/docs-en/07-develop/03-insert-data/_rust_opts_telnet.mdx deleted file mode 100644 index 14021f43d8..0000000000 --- a/docs-en/07-develop/03-insert-data/_rust_opts_telnet.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```rust -{{#include docs-examples/rust/schemalessexample/examples/opentsdb_telnet_example.rs}} -``` diff --git a/docs-en/07-develop/03-insert-data/_rust_sql.mdx b/docs-en/07-develop/03-insert-data/_rust_sql.mdx deleted file mode 100644 index 8e8013e4ad..0000000000 --- a/docs-en/07-develop/03-insert-data/_rust_sql.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```rust -{{#include docs-examples/rust/restexample/examples/insert_example.rs}} -``` diff --git a/docs-en/07-develop/03-insert-data/_rust_stmt.mdx b/docs-en/07-develop/03-insert-data/_rust_stmt.mdx deleted file mode 100644 index 590a7a0e71..0000000000 --- a/docs-en/07-develop/03-insert-data/_rust_stmt.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```rust -{{#include docs-examples/rust/nativeexample/examples/stmt_example.rs}} -``` diff --git a/docs-en/07-develop/04-query-data/_c.mdx b/docs-en/07-develop/04-query-data/_c.mdx deleted file mode 100644 index 76c9067e2f..0000000000 --- a/docs-en/07-develop/04-query-data/_c.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```c -{{#include docs-examples/c/query_example.c}} -``` \ No newline at end of file diff --git a/docs-en/07-develop/04-query-data/_c_async.mdx b/docs-en/07-develop/04-query-data/_c_async.mdx deleted file mode 100644 index 09f3d3b3ff..0000000000 --- a/docs-en/07-develop/04-query-data/_c_async.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```c -{{#include docs-examples/c/async_query_example.c:demo}} -``` \ No newline at end of file diff --git a/docs-en/07-develop/04-query-data/_cs.mdx b/docs-en/07-develop/04-query-data/_cs.mdx deleted file mode 100644 index 2ab52feb56..0000000000 --- a/docs-en/07-develop/04-query-data/_cs.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```csharp -{{#include docs-examples/csharp/QueryExample.cs}} -``` diff --git a/docs-en/07-develop/04-query-data/_cs_async.mdx b/docs-en/07-develop/04-query-data/_cs_async.mdx deleted file mode 100644 index f868994b30..0000000000 --- a/docs-en/07-develop/04-query-data/_cs_async.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```csharp -{{#include docs-examples/csharp/AsyncQueryExample.cs}} -``` diff --git a/docs-en/07-develop/04-query-data/_go.mdx b/docs-en/07-develop/04-query-data/_go.mdx deleted file mode 100644 index 417c12315c..0000000000 --- a/docs-en/07-develop/04-query-data/_go.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```go -{{#include docs-examples/go/query/sync/main.go}} -``` diff --git a/docs-en/07-develop/04-query-data/_go_async.mdx b/docs-en/07-develop/04-query-data/_go_async.mdx deleted file mode 100644 index 72fff411b9..0000000000 --- a/docs-en/07-develop/04-query-data/_go_async.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```go -{{#include docs-examples/go/query/async/main.go}} -``` diff --git a/docs-en/07-develop/04-query-data/_java.mdx b/docs-en/07-develop/04-query-data/_java.mdx deleted file mode 100644 index 519b926614..0000000000 --- a/docs-en/07-develop/04-query-data/_java.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```java -{{#include docs-examples/java/src/main/java/com/taos/example/RestQueryExample.java}} -``` diff --git a/docs-en/07-develop/04-query-data/_js.mdx b/docs-en/07-develop/04-query-data/_js.mdx deleted file mode 100644 index c5e4c4f3fc..0000000000 --- a/docs-en/07-develop/04-query-data/_js.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```js -{{#include docs-examples/node/nativeexample/query_example.js}} -``` diff --git a/docs-en/07-develop/04-query-data/_js_async.mdx b/docs-en/07-develop/04-query-data/_js_async.mdx deleted file mode 100644 index c65d54ed12..0000000000 --- a/docs-en/07-develop/04-query-data/_js_async.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```js -{{#include docs-examples/node/nativeexample/async_query_example.js}} -``` diff --git a/docs-en/07-develop/04-query-data/_rust.mdx b/docs-en/07-develop/04-query-data/_rust.mdx deleted file mode 100644 index 742d70fd02..0000000000 --- a/docs-en/07-develop/04-query-data/_rust.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```rust -{{#include docs-examples/rust/restexample/examples/query_example.rs}} -``` diff --git a/docs-en/07-develop/_sub_c.mdx b/docs-en/07-develop/_sub_c.mdx deleted file mode 100644 index 95fef0042d..0000000000 --- a/docs-en/07-develop/_sub_c.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```c -{{#include docs-examples/c/subscribe_demo.c}} -``` \ No newline at end of file diff --git a/docs-en/07-develop/_sub_cs.mdx b/docs-en/07-develop/_sub_cs.mdx deleted file mode 100644 index 80934aa4d0..0000000000 --- a/docs-en/07-develop/_sub_cs.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```csharp -{{#include docs-examples/csharp/SubscribeDemo.cs}} -``` \ No newline at end of file diff --git a/docs-en/07-develop/_sub_go.mdx b/docs-en/07-develop/_sub_go.mdx deleted file mode 100644 index cd908fc12c..0000000000 --- a/docs-en/07-develop/_sub_go.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```go -{{#include docs-examples/go/sub/main.go}} -``` \ No newline at end of file diff --git a/docs-en/07-develop/_sub_node.mdx b/docs-en/07-develop/_sub_node.mdx deleted file mode 100644 index c93ad627ce..0000000000 --- a/docs-en/07-develop/_sub_node.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```js -{{#include docs-examples/node/nativeexample/subscribe_demo.js}} -``` \ No newline at end of file diff --git a/docs-en/07-develop/_sub_python.mdx b/docs-en/07-develop/_sub_python.mdx deleted file mode 100644 index b817deeba6..0000000000 --- a/docs-en/07-develop/_sub_python.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```py -{{#include docs-examples/python/subscribe_demo.py}} -``` \ No newline at end of file diff --git a/docs-en/07-develop/_sub_rust.mdx b/docs-en/07-develop/_sub_rust.mdx deleted file mode 100644 index 4750cf7a3b..0000000000 --- a/docs-en/07-develop/_sub_rust.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```rs -{{#include docs-examples/rust/nativeexample/examples/subscribe_demo.rs}} -``` \ No newline at end of file diff --git a/docs-en/12-taos-sql/12-keywords.md b/docs-en/12-taos-sql/12-keywords.md deleted file mode 100644 index ed0c96b4e4..0000000000 --- a/docs-en/12-taos-sql/12-keywords.md +++ /dev/null @@ -1,90 +0,0 @@ ---- -title: Keywords ---- - -There are about 200 keywords reserved by TDengine, they can't be used as the name of database, STable or table with either upper case, lower case or mixed case. - -**Keywords List** - -| | | | | | -| ----------- | ---------- | --------- | ---------- | ------------ | -| ABORT | CREATE | IGNORE | NULL | STAR | -| ACCOUNT | CTIME | IMMEDIATE | OF | STATE | -| ACCOUNTS | DATABASE | IMPORT | OFFSET | STATEMENT | -| ADD | DATABASES | IN | OR | STATE_WINDOW | -| AFTER | DAYS | INITIALLY | ORDER | STORAGE | -| ALL | DBS | INSERT | PARTITIONS | STREAM | -| ALTER | DEFERRED | INSTEAD | PASS | STREAMS | -| AND | DELIMITERS | INT | PLUS | STRING | -| AS | DESC | INTEGER | PPS | SYNCDB | -| ASC | DESCRIBE | INTERVAL | PRECISION | TABLE | -| ATTACH | DETACH | INTO | PREV | TABLES | -| BEFORE | DISTINCT | IS | PRIVILEGE | TAG | -| BEGIN | DIVIDE | ISNULL | QTIME | TAGS | -| BETWEEN | DNODE | JOIN | QUERIES | TBNAME | -| BIGINT | DNODES | KEEP | QUERY | TIMES | -| BINARY | DOT | KEY | QUORUM | TIMESTAMP | -| BITAND | DOUBLE | KILL | RAISE | TINYINT | -| BITNOT | DROP | LE | REM | TOPIC | -| BITOR | EACH | LIKE | REPLACE | TOPICS | -| BLOCKS | END | LIMIT | REPLICA | TRIGGER | -| BOOL | EQ | LINEAR | RESET | TSERIES | -| BY | EXISTS | LOCAL | RESTRICT | UMINUS | -| CACHE | EXPLAIN | LP | ROW | UNION | -| CACHELAST | FAIL | LSHIFT | RP | UNSIGNED | -| CASCADE | FILE | LT | RSHIFT | UPDATE | -| CHANGE | FILL | MATCH | SCORES | UPLUS | -| CLUSTER | FLOAT | MAXROWS | SELECT | USE | -| COLON | FOR | MINROWS | SEMI | USER | -| COLUMN | FROM | MINUS | SESSION | USERS | -| COMMA | FSYNC | MNODES | SET | USING | -| COMP | GE | MODIFY | SHOW | VALUES | -| COMPACT | GLOB | MODULES | SLASH | VARIABLE | -| CONCAT | GRANTS | NCHAR | SLIDING | VARIABLES | -| CONFLICT | GROUP | NE | SLIMIT | VGROUPS | -| CONNECTION | GT | NONE | SMALLINT | VIEW | -| CONNECTIONS | HAVING | NOT | SOFFSET | VNODES | -| CONNS | ID | NOTNULL | STable | WAL | -| COPY | IF | NOW | STableS | WHERE | -| _C0 | _QSTART | _QSTOP | _QDURATION | _WSTART | -| _WSTOP | _WDURATION | _ROWTS | - -## Explanations -### TBNAME -`TBNAME` can be considered as a special tag, which represents the name of the subtable, in a STable. - -Get the table name and tag values of all subtables in a STable. -```mysql -SELECT TBNAME, location FROM meters; -``` - -Count the number of subtables in a STable. -```mysql -SELECT COUNT(TBNAME) FROM meters; -``` - -Only filter on TAGS can be used in WHERE clause in the above two query statements. -```mysql -taos> SELECT TBNAME, location FROM meters; - tbname | location | -================================================================== - d1004 | California.SanFrancisco | - d1003 | California.SanFrancisco | - d1002 | California.LosAngeles | - d1001 | California.LosAngeles | -Query OK, 4 row(s) in set (0.000881s) - -taos> SELECT COUNT(tbname) FROM meters WHERE groupId > 2; - count(tbname) | -======================== - 2 | -Query OK, 1 row(s) in set (0.001091s) -``` -### _QSTART/_QSTOP/_QDURATION -The start, stop and duration of a query time window. - -### _WSTART/_WSTOP/_WDURATION -The start, stop and duration of aggegate query by time window, like interval, session window, state window. - -### _c0/_ROWTS -_c0 is equal to _ROWTS, it means the first column of a table or STable. diff --git a/docs-examples/.gitignre b/docs-examples/.gitignre deleted file mode 100644 index 0853156c65..0000000000 --- a/docs-examples/.gitignre +++ /dev/null @@ -1,2 +0,0 @@ -.vscode -*.lock \ No newline at end of file diff --git a/docs/CMakeLists.txt b/docs/doxgen/CMakeLists.txt similarity index 100% rename from docs/CMakeLists.txt rename to docs/doxgen/CMakeLists.txt diff --git a/docs/Doxyfile.in b/docs/doxgen/Doxyfile.in similarity index 100% rename from docs/Doxyfile.in rename to docs/doxgen/Doxyfile.in diff --git a/docs/scratch.md b/docs/doxgen/scratch.md similarity index 100% rename from docs/scratch.md rename to docs/doxgen/scratch.md diff --git a/docs/user_manual/Small_Materialized_Aggrates.md b/docs/doxgen/user_manual/Small_Materialized_Aggrates.md similarity index 100% rename from docs/user_manual/Small_Materialized_Aggrates.md rename to docs/doxgen/user_manual/Small_Materialized_Aggrates.md diff --git a/docs/vnode_write.md b/docs/doxgen/vnode_write.md similarity index 100% rename from docs/vnode_write.md rename to docs/doxgen/vnode_write.md diff --git a/docs-en/01-index.md b/docs/en/01-index.md similarity index 100% rename from docs-en/01-index.md rename to docs/en/01-index.md diff --git a/docs-en/02-intro/_category_.yml b/docs/en/02-intro/_category_.yml similarity index 100% rename from docs-en/02-intro/_category_.yml rename to docs/en/02-intro/_category_.yml diff --git a/docs-cn/eco_system.webp b/docs/en/02-intro/eco_system.webp similarity index 100% rename from docs-cn/eco_system.webp rename to docs/en/02-intro/eco_system.webp diff --git a/docs-en/02-intro/index.md b/docs/en/02-intro/index.md similarity index 100% rename from docs-en/02-intro/index.md rename to docs/en/02-intro/index.md diff --git a/docs-en/04-concept/_category_.yml b/docs/en/04-concept/_category_.yml similarity index 100% rename from docs-en/04-concept/_category_.yml rename to docs/en/04-concept/_category_.yml diff --git a/docs-en/04-concept/index.md b/docs/en/04-concept/index.md similarity index 100% rename from docs-en/04-concept/index.md rename to docs/en/04-concept/index.md diff --git a/docs-en/05-get-started/_apt_get_install.mdx b/docs/en/05-get-started/_apt_get_install.mdx similarity index 100% rename from docs-en/05-get-started/_apt_get_install.mdx rename to docs/en/05-get-started/_apt_get_install.mdx diff --git a/docs-en/05-get-started/_category_.yml b/docs/en/05-get-started/_category_.yml similarity index 100% rename from docs-en/05-get-started/_category_.yml rename to docs/en/05-get-started/_category_.yml diff --git a/docs-en/05-get-started/_pkg_install.mdx b/docs/en/05-get-started/_pkg_install.mdx similarity index 100% rename from docs-en/05-get-started/_pkg_install.mdx rename to docs/en/05-get-started/_pkg_install.mdx diff --git a/docs-en/05-get-started/index.md b/docs/en/05-get-started/index.md similarity index 100% rename from docs-en/05-get-started/index.md rename to docs/en/05-get-started/index.md diff --git a/docs-en/07-develop/01-connect/_category_.yml b/docs/en/07-develop/01-connect/_category_.yml similarity index 100% rename from docs-en/07-develop/01-connect/_category_.yml rename to docs/en/07-develop/01-connect/_category_.yml diff --git a/docs/en/07-develop/01-connect/_connect_c.mdx b/docs/en/07-develop/01-connect/_connect_c.mdx new file mode 100644 index 0000000000..4d13d80e08 --- /dev/null +++ b/docs/en/07-develop/01-connect/_connect_c.mdx @@ -0,0 +1,3 @@ +```c title="Native Connection" +{{#include docs/examples/c/connect_example.c}} +``` diff --git a/docs-en/07-develop/01-connect/_connect_cs.mdx b/docs/en/07-develop/01-connect/_connect_cs.mdx similarity index 67% rename from docs-en/07-develop/01-connect/_connect_cs.mdx rename to docs/en/07-develop/01-connect/_connect_cs.mdx index 52ea2d4371..f8d8e519fd 100644 --- a/docs-en/07-develop/01-connect/_connect_cs.mdx +++ b/docs/en/07-develop/01-connect/_connect_cs.mdx @@ -1,5 +1,5 @@ ```csharp title="Native Connection" -{{#include docs-examples/csharp/ConnectExample.cs}} +{{#include docs/examples/csharp/ConnectExample.cs}} ``` :::info diff --git a/docs-en/07-develop/01-connect/_connect_go.mdx b/docs/en/07-develop/01-connect/_connect_go.mdx similarity index 69% rename from docs-en/07-develop/01-connect/_connect_go.mdx rename to docs/en/07-develop/01-connect/_connect_go.mdx index 1dd5d67e35..6f742ea0bc 100644 --- a/docs-en/07-develop/01-connect/_connect_go.mdx +++ b/docs/en/07-develop/01-connect/_connect_go.mdx @@ -1,11 +1,11 @@ #### Unified Database Access Interface ```go title="Native Connection" -{{#include docs-examples/go/connect/cgoexample/main.go}} +{{#include docs/examples/go/connect/cgoexample/main.go}} ``` ```go title="REST Connection" -{{#include docs-examples/go/connect/restexample/main.go}} +{{#include docs/examples/go/connect/restexample/main.go}} ``` #### Advanced Features @@ -13,5 +13,5 @@ The af package of driver-go can also be used to establish connection, with this way some advanced features of TDengine, like parameter binding and subscription, can be used. ```go title="Establish native connection using af package" -{{#include docs-examples/go/connect/afconn/main.go}} +{{#include docs/examples/go/connect/afconn/main.go}} ``` diff --git a/docs-en/07-develop/01-connect/_connect_java.mdx b/docs/en/07-develop/01-connect/_connect_java.mdx similarity index 68% rename from docs-en/07-develop/01-connect/_connect_java.mdx rename to docs/en/07-develop/01-connect/_connect_java.mdx index 1c3e9326bf..880d2aa3e4 100644 --- a/docs-en/07-develop/01-connect/_connect_java.mdx +++ b/docs/en/07-develop/01-connect/_connect_java.mdx @@ -1,15 +1,15 @@ ```java title="Native Connection" -{{#include docs-examples/java/src/main/java/com/taos/example/JNIConnectExample.java}} +{{#include docs/examples/java/src/main/java/com/taos/example/JNIConnectExample.java}} ``` ```java title="REST Connection" -{{#include docs-examples/java/src/main/java/com/taos/example/RESTConnectExample.java:main}} +{{#include docs/examples/java/src/main/java/com/taos/example/RESTConnectExample.java:main}} ``` When using REST connection, the feature of bulk pulling can be enabled if the size of resulting data set is huge. ```java title="Enable Bulk Pulling" {4} -{{#include docs-examples/java/src/main/java/com/taos/example/WSConnectExample.java:main}} +{{#include docs/examples/java/src/main/java/com/taos/example/WSConnectExample.java:main}} ``` More configuration about connection,please refer to [Java Connector](/reference/connector/java) diff --git a/docs/en/07-develop/01-connect/_connect_node.mdx b/docs/en/07-develop/01-connect/_connect_node.mdx new file mode 100644 index 0000000000..943677b36b --- /dev/null +++ b/docs/en/07-develop/01-connect/_connect_node.mdx @@ -0,0 +1,7 @@ +```js title="Native Connection" +{{#include docs/examples/node/nativeexample/connect.js}} +``` + +```js title="REST Connection" +{{#include docs/examples/node/restexample/connect.js}} +``` diff --git a/docs/en/07-develop/01-connect/_connect_python.mdx b/docs/en/07-develop/01-connect/_connect_python.mdx new file mode 100644 index 0000000000..60b454d52f --- /dev/null +++ b/docs/en/07-develop/01-connect/_connect_python.mdx @@ -0,0 +1,3 @@ +```python title="Native Connection" +{{#include docs/examples/python/connect_example.py}} +``` diff --git a/docs/en/07-develop/01-connect/_connect_r.mdx b/docs/en/07-develop/01-connect/_connect_r.mdx new file mode 100644 index 0000000000..e2d7f631d2 --- /dev/null +++ b/docs/en/07-develop/01-connect/_connect_r.mdx @@ -0,0 +1,3 @@ +```r title="Native Connection" +{{#include docs/examples/R/connect_native.r:demo}} +``` diff --git a/docs-en/07-develop/01-connect/_connect_rust.mdx b/docs/en/07-develop/01-connect/_connect_rust.mdx similarity index 78% rename from docs-en/07-develop/01-connect/_connect_rust.mdx rename to docs/en/07-develop/01-connect/_connect_rust.mdx index aa19f58de6..80ac1f4ff4 100644 --- a/docs-en/07-develop/01-connect/_connect_rust.mdx +++ b/docs/en/07-develop/01-connect/_connect_rust.mdx @@ -1,5 +1,5 @@ ```rust title="Native Connection/REST Connection" -{{#include docs-examples/rust/nativeexample/examples/connect.rs}} +{{#include docs/examples/rust/nativeexample/examples/connect.rs}} ``` :::note diff --git a/docs-en/07-develop/01-connect/index.md b/docs/en/07-develop/01-connect/index.md similarity index 100% rename from docs-en/07-develop/01-connect/index.md rename to docs/en/07-develop/01-connect/index.md diff --git a/docs-en/07-develop/02-model/_category_.yml b/docs/en/07-develop/02-model/_category_.yml similarity index 100% rename from docs-en/07-develop/02-model/_category_.yml rename to docs/en/07-develop/02-model/_category_.yml diff --git a/docs-en/07-develop/02-model/index.mdx b/docs/en/07-develop/02-model/index.mdx similarity index 100% rename from docs-en/07-develop/02-model/index.mdx rename to docs/en/07-develop/02-model/index.mdx diff --git a/docs-en/07-develop/03-insert-data/01-sql-writing.mdx b/docs/en/07-develop/03-insert-data/01-sql-writing.mdx similarity index 100% rename from docs-en/07-develop/03-insert-data/01-sql-writing.mdx rename to docs/en/07-develop/03-insert-data/01-sql-writing.mdx diff --git a/docs-en/07-develop/03-insert-data/02-influxdb-line.mdx b/docs/en/07-develop/03-insert-data/02-influxdb-line.mdx similarity index 100% rename from docs-en/07-develop/03-insert-data/02-influxdb-line.mdx rename to docs/en/07-develop/03-insert-data/02-influxdb-line.mdx diff --git a/docs-en/07-develop/03-insert-data/03-opentsdb-telnet.mdx b/docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx similarity index 100% rename from docs-en/07-develop/03-insert-data/03-opentsdb-telnet.mdx rename to docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx diff --git a/docs-en/07-develop/03-insert-data/04-opentsdb-json.mdx b/docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx similarity index 100% rename from docs-en/07-develop/03-insert-data/04-opentsdb-json.mdx rename to docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx diff --git a/docs/en/07-develop/03-insert-data/_c_line.mdx b/docs/en/07-develop/03-insert-data/_c_line.mdx new file mode 100644 index 0000000000..7f2f0d5dd8 --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_c_line.mdx @@ -0,0 +1,3 @@ +```c +{{#include docs/examples/c/line_example.c:main}} +``` \ No newline at end of file diff --git a/docs/en/07-develop/03-insert-data/_c_opts_json.mdx b/docs/en/07-develop/03-insert-data/_c_opts_json.mdx new file mode 100644 index 0000000000..34b1d8ab3c --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_c_opts_json.mdx @@ -0,0 +1,3 @@ +```c +{{#include docs/examples/c/json_protocol_example.c:main}} +``` \ No newline at end of file diff --git a/docs/en/07-develop/03-insert-data/_c_opts_telnet.mdx b/docs/en/07-develop/03-insert-data/_c_opts_telnet.mdx new file mode 100644 index 0000000000..6bda068d12 --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_c_opts_telnet.mdx @@ -0,0 +1,3 @@ +```c +{{#include docs/examples/c/telnet_line_example.c:main}} +``` \ No newline at end of file diff --git a/docs/en/07-develop/03-insert-data/_c_sql.mdx b/docs/en/07-develop/03-insert-data/_c_sql.mdx new file mode 100644 index 0000000000..4e55c3387e --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_c_sql.mdx @@ -0,0 +1,3 @@ +```c +{{#include docs/examples/c/insert_example.c}} +``` \ No newline at end of file diff --git a/docs/en/07-develop/03-insert-data/_c_stmt.mdx b/docs/en/07-develop/03-insert-data/_c_stmt.mdx new file mode 100644 index 0000000000..4b609efe5e --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_c_stmt.mdx @@ -0,0 +1,6 @@ +```c title=Single Row Binding +{{#include docs/examples/c/stmt_example.c}} +``` +```c title=Multiple Row Binding 72:117 +{{#include docs/examples/c/multi_bind_example.c}} +``` \ No newline at end of file diff --git a/docs-en/07-develop/03-insert-data/_category_.yml b/docs/en/07-develop/03-insert-data/_category_.yml similarity index 100% rename from docs-en/07-develop/03-insert-data/_category_.yml rename to docs/en/07-develop/03-insert-data/_category_.yml diff --git a/docs/en/07-develop/03-insert-data/_cs_line.mdx b/docs/en/07-develop/03-insert-data/_cs_line.mdx new file mode 100644 index 0000000000..71f46c62be --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_cs_line.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs/examples/csharp/InfluxDBLineExample.cs}} +``` diff --git a/docs/en/07-develop/03-insert-data/_cs_opts_json.mdx b/docs/en/07-develop/03-insert-data/_cs_opts_json.mdx new file mode 100644 index 0000000000..8d80d042c9 --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_cs_opts_json.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs/examples/csharp/OptsJsonExample.cs}} +``` diff --git a/docs/en/07-develop/03-insert-data/_cs_opts_telnet.mdx b/docs/en/07-develop/03-insert-data/_cs_opts_telnet.mdx new file mode 100644 index 0000000000..cff32abf1f --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_cs_opts_telnet.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs/examples/csharp/OptsTelnetExample.cs}} +``` diff --git a/docs/en/07-develop/03-insert-data/_cs_sql.mdx b/docs/en/07-develop/03-insert-data/_cs_sql.mdx new file mode 100644 index 0000000000..1dc7bb3d13 --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_cs_sql.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs/examples/csharp/SQLInsertExample.cs}} +``` diff --git a/docs/en/07-develop/03-insert-data/_cs_stmt.mdx b/docs/en/07-develop/03-insert-data/_cs_stmt.mdx new file mode 100644 index 0000000000..229c874ab9 --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_cs_stmt.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs/examples/csharp/StmtInsertExample.cs}} +``` diff --git a/docs/en/07-develop/03-insert-data/_go_line.mdx b/docs/en/07-develop/03-insert-data/_go_line.mdx new file mode 100644 index 0000000000..df2afc0e87 --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_go_line.mdx @@ -0,0 +1,3 @@ +```go +{{#include docs/examples/go/insert/line/main.go}} +``` diff --git a/docs/en/07-develop/03-insert-data/_go_opts_json.mdx b/docs/en/07-develop/03-insert-data/_go_opts_json.mdx new file mode 100644 index 0000000000..362ce43051 --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_go_opts_json.mdx @@ -0,0 +1,3 @@ +```go +{{#include docs/examples/go/insert/json/main.go}} +``` diff --git a/docs/en/07-develop/03-insert-data/_go_opts_telnet.mdx b/docs/en/07-develop/03-insert-data/_go_opts_telnet.mdx new file mode 100644 index 0000000000..518ea4c816 --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_go_opts_telnet.mdx @@ -0,0 +1,3 @@ +```go +{{#include docs/examples/go/insert/telnet/main.go}} +``` diff --git a/docs/en/07-develop/03-insert-data/_go_sql.mdx b/docs/en/07-develop/03-insert-data/_go_sql.mdx new file mode 100644 index 0000000000..02f4d4e2ba --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_go_sql.mdx @@ -0,0 +1,3 @@ +```go +{{#include docs/examples/go/insert/sql/main.go}} +``` diff --git a/docs-en/07-develop/03-insert-data/_go_stmt.mdx b/docs/en/07-develop/03-insert-data/_go_stmt.mdx similarity index 76% rename from docs-en/07-develop/03-insert-data/_go_stmt.mdx rename to docs/en/07-develop/03-insert-data/_go_stmt.mdx index c32bc21fb9..ab519c9a80 100644 --- a/docs-en/07-develop/03-insert-data/_go_stmt.mdx +++ b/docs/en/07-develop/03-insert-data/_go_stmt.mdx @@ -1,5 +1,5 @@ ```go -{{#include docs-examples/go/insert/stmt/main.go}} +{{#include docs/examples/go/insert/stmt/main.go}} ``` :::tip diff --git a/docs/en/07-develop/03-insert-data/_java_line.mdx b/docs/en/07-develop/03-insert-data/_java_line.mdx new file mode 100644 index 0000000000..17f759d30f --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_java_line.mdx @@ -0,0 +1,3 @@ +```java +{{#include docs/examples/java/src/main/java/com/taos/example/LineProtocolExample.java}} +``` diff --git a/docs/en/07-develop/03-insert-data/_java_opts_json.mdx b/docs/en/07-develop/03-insert-data/_java_opts_json.mdx new file mode 100644 index 0000000000..1fc0adc202 --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_java_opts_json.mdx @@ -0,0 +1,3 @@ +```java +{{#include docs/examples/java/src/main/java/com/taos/example/JSONProtocolExample.java}} +``` diff --git a/docs/en/07-develop/03-insert-data/_java_opts_telnet.mdx b/docs/en/07-develop/03-insert-data/_java_opts_telnet.mdx new file mode 100644 index 0000000000..b68f54b4e8 --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_java_opts_telnet.mdx @@ -0,0 +1,3 @@ +```java +{{#include docs/examples/java/src/main/java/com/taos/example/TelnetLineProtocolExample.java}} +``` diff --git a/docs/en/07-develop/03-insert-data/_java_sql.mdx b/docs/en/07-develop/03-insert-data/_java_sql.mdx new file mode 100644 index 0000000000..636c7e00eb --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_java_sql.mdx @@ -0,0 +1,3 @@ +```java +{{#include docs/examples/java/src/main/java/com/taos/example/RestInsertExample.java:insert}} +``` \ No newline at end of file diff --git a/docs/en/07-develop/03-insert-data/_java_stmt.mdx b/docs/en/07-develop/03-insert-data/_java_stmt.mdx new file mode 100644 index 0000000000..2f6a337690 --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_java_stmt.mdx @@ -0,0 +1,3 @@ +```java +{{#include docs/examples/java/src/main/java/com/taos/example/StmtInsertExample.java}} +``` diff --git a/docs/en/07-develop/03-insert-data/_js_line.mdx b/docs/en/07-develop/03-insert-data/_js_line.mdx new file mode 100644 index 0000000000..cc138a76bd --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_js_line.mdx @@ -0,0 +1,3 @@ +```js +{{#include docs/examples/node/nativeexample/influxdb_line_example.js}} +``` diff --git a/docs/en/07-develop/03-insert-data/_js_opts_json.mdx b/docs/en/07-develop/03-insert-data/_js_opts_json.mdx new file mode 100644 index 0000000000..cb3c275ce8 --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_js_opts_json.mdx @@ -0,0 +1,3 @@ +```js +{{#include docs/examples/node/nativeexample/opentsdb_json_example.js}} +``` diff --git a/docs/en/07-develop/03-insert-data/_js_opts_telnet.mdx b/docs/en/07-develop/03-insert-data/_js_opts_telnet.mdx new file mode 100644 index 0000000000..db96742f31 --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_js_opts_telnet.mdx @@ -0,0 +1,3 @@ +```js +{{#include docs/examples/node/nativeexample/opentsdb_telnet_example.js}} +``` diff --git a/docs/en/07-develop/03-insert-data/_js_sql.mdx b/docs/en/07-develop/03-insert-data/_js_sql.mdx new file mode 100644 index 0000000000..a9a12f5d2c --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_js_sql.mdx @@ -0,0 +1,3 @@ +```js +{{#include docs/examples/node/nativeexample/insert_example.js}} +``` diff --git a/docs-en/07-develop/03-insert-data/_js_stmt.mdx b/docs/en/07-develop/03-insert-data/_js_stmt.mdx similarity index 70% rename from docs-en/07-develop/03-insert-data/_js_stmt.mdx rename to docs/en/07-develop/03-insert-data/_js_stmt.mdx index 964d7ddc11..8df1065c4a 100644 --- a/docs-en/07-develop/03-insert-data/_js_stmt.mdx +++ b/docs/en/07-develop/03-insert-data/_js_stmt.mdx @@ -1,9 +1,9 @@ ```js title=Single Row Binding -{{#include docs-examples/node/nativeexample/param_bind_example.js}} +{{#include docs/examples/node/nativeexample/param_bind_example.js}} ``` ```js title=Multiple Row Binding -{{#include docs-examples/node/nativeexample/multi_bind_example.js:insertData}} +{{#include docs/examples/node/nativeexample/multi_bind_example.js:insertData}} ``` :::info diff --git a/docs/en/07-develop/03-insert-data/_py_line.mdx b/docs/en/07-develop/03-insert-data/_py_line.mdx new file mode 100644 index 0000000000..85f7e32e66 --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_py_line.mdx @@ -0,0 +1,3 @@ +```py +{{#include docs/examples/python/line_protocol_example.py}} +``` diff --git a/docs/en/07-develop/03-insert-data/_py_opts_json.mdx b/docs/en/07-develop/03-insert-data/_py_opts_json.mdx new file mode 100644 index 0000000000..195c7090c0 --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_py_opts_json.mdx @@ -0,0 +1,3 @@ +```py +{{#include docs/examples/python/json_protocol_example.py}} +``` diff --git a/docs/en/07-develop/03-insert-data/_py_opts_telnet.mdx b/docs/en/07-develop/03-insert-data/_py_opts_telnet.mdx new file mode 100644 index 0000000000..3bae1ea57b --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_py_opts_telnet.mdx @@ -0,0 +1,3 @@ +```py +{{#include docs/examples/python/telnet_line_protocol_example.py}} +``` diff --git a/docs/en/07-develop/03-insert-data/_py_sql.mdx b/docs/en/07-develop/03-insert-data/_py_sql.mdx new file mode 100644 index 0000000000..1557e3994b --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_py_sql.mdx @@ -0,0 +1,3 @@ +```py +{{#include docs/examples/python/native_insert_example.py}} +``` diff --git a/docs-en/07-develop/03-insert-data/_py_stmt.mdx b/docs/en/07-develop/03-insert-data/_py_stmt.mdx similarity index 70% rename from docs-en/07-develop/03-insert-data/_py_stmt.mdx rename to docs/en/07-develop/03-insert-data/_py_stmt.mdx index 16d98f5432..4f7636bfb8 100644 --- a/docs-en/07-develop/03-insert-data/_py_stmt.mdx +++ b/docs/en/07-develop/03-insert-data/_py_stmt.mdx @@ -1,9 +1,9 @@ ```py title=Single Row Binding -{{#include docs-examples/python/bind_param_example.py}} +{{#include docs/examples/python/bind_param_example.py}} ``` ```py title=Multiple Row Binding -{{#include docs-examples/python/multi_bind_example.py:bind_batch}} +{{#include docs/examples/python/multi_bind_example.py:bind_batch}} ``` :::info diff --git a/docs/en/07-develop/03-insert-data/_rust_line.mdx b/docs/en/07-develop/03-insert-data/_rust_line.mdx new file mode 100644 index 0000000000..dbb35d76bc --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_rust_line.mdx @@ -0,0 +1,3 @@ +```rust +{{#include docs/examples/rust/schemalessexample/examples/influxdb_line_example.rs}} +``` diff --git a/docs/en/07-develop/03-insert-data/_rust_opts_json.mdx b/docs/en/07-develop/03-insert-data/_rust_opts_json.mdx new file mode 100644 index 0000000000..cc2055510b --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_rust_opts_json.mdx @@ -0,0 +1,3 @@ +```rust +{{#include docs/examples/rust/schemalessexample/examples/opentsdb_json_example.rs}} +``` diff --git a/docs/en/07-develop/03-insert-data/_rust_opts_telnet.mdx b/docs/en/07-develop/03-insert-data/_rust_opts_telnet.mdx new file mode 100644 index 0000000000..109c0c5d01 --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_rust_opts_telnet.mdx @@ -0,0 +1,3 @@ +```rust +{{#include docs/examples/rust/schemalessexample/examples/opentsdb_telnet_example.rs}} +``` diff --git a/docs/en/07-develop/03-insert-data/_rust_sql.mdx b/docs/en/07-develop/03-insert-data/_rust_sql.mdx new file mode 100644 index 0000000000..fb59a48265 --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_rust_sql.mdx @@ -0,0 +1,3 @@ +```rust +{{#include docs/examples/rust/restexample/examples/insert_example.rs}} +``` diff --git a/docs/en/07-develop/03-insert-data/_rust_stmt.mdx b/docs/en/07-develop/03-insert-data/_rust_stmt.mdx new file mode 100644 index 0000000000..a889b56745 --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_rust_stmt.mdx @@ -0,0 +1,3 @@ +```rust +{{#include docs/examples/rust/nativeexample/examples/stmt_example.rs}} +``` diff --git a/docs-en/07-develop/03-insert-data/index.md b/docs/en/07-develop/03-insert-data/index.md similarity index 100% rename from docs-en/07-develop/03-insert-data/index.md rename to docs/en/07-develop/03-insert-data/index.md diff --git a/docs/en/07-develop/04-query-data/_c.mdx b/docs/en/07-develop/04-query-data/_c.mdx new file mode 100644 index 0000000000..c51557ef29 --- /dev/null +++ b/docs/en/07-develop/04-query-data/_c.mdx @@ -0,0 +1,3 @@ +```c +{{#include docs/examples/c/query_example.c}} +``` \ No newline at end of file diff --git a/docs/en/07-develop/04-query-data/_c_async.mdx b/docs/en/07-develop/04-query-data/_c_async.mdx new file mode 100644 index 0000000000..641a53e82d --- /dev/null +++ b/docs/en/07-develop/04-query-data/_c_async.mdx @@ -0,0 +1,3 @@ +```c +{{#include docs/examples/c/async_query_example.c:demo}} +``` \ No newline at end of file diff --git a/docs-en/07-develop/04-query-data/_category_.yml b/docs/en/07-develop/04-query-data/_category_.yml similarity index 100% rename from docs-en/07-develop/04-query-data/_category_.yml rename to docs/en/07-develop/04-query-data/_category_.yml diff --git a/docs/en/07-develop/04-query-data/_cs.mdx b/docs/en/07-develop/04-query-data/_cs.mdx new file mode 100644 index 0000000000..4bb582ecbf --- /dev/null +++ b/docs/en/07-develop/04-query-data/_cs.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs/examples/csharp/QueryExample.cs}} +``` diff --git a/docs/en/07-develop/04-query-data/_cs_async.mdx b/docs/en/07-develop/04-query-data/_cs_async.mdx new file mode 100644 index 0000000000..3ecf635fd3 --- /dev/null +++ b/docs/en/07-develop/04-query-data/_cs_async.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs/examples/csharp/AsyncQueryExample.cs}} +``` diff --git a/docs/en/07-develop/04-query-data/_go.mdx b/docs/en/07-develop/04-query-data/_go.mdx new file mode 100644 index 0000000000..b43894a1eb --- /dev/null +++ b/docs/en/07-develop/04-query-data/_go.mdx @@ -0,0 +1,3 @@ +```go +{{#include docs/examples/go/query/sync/main.go}} +``` diff --git a/docs/en/07-develop/04-query-data/_go_async.mdx b/docs/en/07-develop/04-query-data/_go_async.mdx new file mode 100644 index 0000000000..3fbc6f5b6d --- /dev/null +++ b/docs/en/07-develop/04-query-data/_go_async.mdx @@ -0,0 +1,3 @@ +```go +{{#include docs/examples/go/query/async/main.go}} +``` diff --git a/docs/en/07-develop/04-query-data/_java.mdx b/docs/en/07-develop/04-query-data/_java.mdx new file mode 100644 index 0000000000..74de32658c --- /dev/null +++ b/docs/en/07-develop/04-query-data/_java.mdx @@ -0,0 +1,3 @@ +```java +{{#include docs/examples/java/src/main/java/com/taos/example/RestQueryExample.java}} +``` diff --git a/docs/en/07-develop/04-query-data/_js.mdx b/docs/en/07-develop/04-query-data/_js.mdx new file mode 100644 index 0000000000..5883d378e7 --- /dev/null +++ b/docs/en/07-develop/04-query-data/_js.mdx @@ -0,0 +1,3 @@ +```js +{{#include docs/examples/node/nativeexample/query_example.js}} +``` diff --git a/docs/en/07-develop/04-query-data/_js_async.mdx b/docs/en/07-develop/04-query-data/_js_async.mdx new file mode 100644 index 0000000000..4b0f54a034 --- /dev/null +++ b/docs/en/07-develop/04-query-data/_js_async.mdx @@ -0,0 +1,3 @@ +```js +{{#include docs/examples/node/nativeexample/async_query_example.js}} +``` diff --git a/docs-en/07-develop/04-query-data/_py.mdx b/docs/en/07-develop/04-query-data/_py.mdx similarity index 54% rename from docs-en/07-develop/04-query-data/_py.mdx rename to docs/en/07-develop/04-query-data/_py.mdx index aeae42a15e..8ebeca450b 100644 --- a/docs-en/07-develop/04-query-data/_py.mdx +++ b/docs/en/07-develop/04-query-data/_py.mdx @@ -1,11 +1,11 @@ Result set is iterated row by row. ```py -{{#include docs-examples/python/query_example.py:iter}} +{{#include docs/examples/python/query_example.py:iter}} ``` Result set is retrieved as a whole, each row is converted to a dict and returned. ```py -{{#include docs-examples/python/query_example.py:fetch_all}} +{{#include docs/examples/python/query_example.py:fetch_all}} ``` \ No newline at end of file diff --git a/docs-en/07-develop/04-query-data/_py_async.mdx b/docs/en/07-develop/04-query-data/_py_async.mdx similarity index 58% rename from docs-en/07-develop/04-query-data/_py_async.mdx rename to docs/en/07-develop/04-query-data/_py_async.mdx index ed6880ae64..393a5b1733 100644 --- a/docs-en/07-develop/04-query-data/_py_async.mdx +++ b/docs/en/07-develop/04-query-data/_py_async.mdx @@ -1,5 +1,5 @@ ```py -{{#include docs-examples/python/async_query_example.py}} +{{#include docs/examples/python/async_query_example.py}} ``` :::note diff --git a/docs/en/07-develop/04-query-data/_rust.mdx b/docs/en/07-develop/04-query-data/_rust.mdx new file mode 100644 index 0000000000..cab1b403fb --- /dev/null +++ b/docs/en/07-develop/04-query-data/_rust.mdx @@ -0,0 +1,3 @@ +```rust +{{#include docs/examples/rust/restexample/examples/query_example.rs}} +``` diff --git a/docs-en/07-develop/04-query-data/index.mdx b/docs/en/07-develop/04-query-data/index.mdx similarity index 100% rename from docs-en/07-develop/04-query-data/index.mdx rename to docs/en/07-develop/04-query-data/index.mdx diff --git a/docs-en/07-develop/06-continuous-query.mdx b/docs/en/07-develop/06-continuous-query.mdx similarity index 100% rename from docs-en/07-develop/06-continuous-query.mdx rename to docs/en/07-develop/06-continuous-query.mdx diff --git a/docs-en/07-develop/07-subscribe.mdx b/docs/en/07-develop/07-subscribe.mdx similarity index 100% rename from docs-en/07-develop/07-subscribe.mdx rename to docs/en/07-develop/07-subscribe.mdx diff --git a/docs-en/07-develop/08-cache.md b/docs/en/07-develop/08-cache.md similarity index 100% rename from docs-en/07-develop/08-cache.md rename to docs/en/07-develop/08-cache.md diff --git a/docs-en/07-develop/09-udf.md b/docs/en/07-develop/09-udf.md similarity index 100% rename from docs-en/07-develop/09-udf.md rename to docs/en/07-develop/09-udf.md diff --git a/docs-en/07-develop/_category_.yml b/docs/en/07-develop/_category_.yml similarity index 100% rename from docs-en/07-develop/_category_.yml rename to docs/en/07-develop/_category_.yml diff --git a/docs/en/07-develop/_sub_c.mdx b/docs/en/07-develop/_sub_c.mdx new file mode 100644 index 0000000000..da492a0269 --- /dev/null +++ b/docs/en/07-develop/_sub_c.mdx @@ -0,0 +1,3 @@ +```c +{{#include docs/examples/c/subscribe_demo.c}} +``` \ No newline at end of file diff --git a/docs/en/07-develop/_sub_cs.mdx b/docs/en/07-develop/_sub_cs.mdx new file mode 100644 index 0000000000..a435ea0273 --- /dev/null +++ b/docs/en/07-develop/_sub_cs.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs/examples/csharp/SubscribeDemo.cs}} +``` \ No newline at end of file diff --git a/docs/en/07-develop/_sub_go.mdx b/docs/en/07-develop/_sub_go.mdx new file mode 100644 index 0000000000..34b2aefd92 --- /dev/null +++ b/docs/en/07-develop/_sub_go.mdx @@ -0,0 +1,3 @@ +```go +{{#include docs/examples/go/sub/main.go}} +``` \ No newline at end of file diff --git a/docs-en/07-develop/_sub_java.mdx b/docs/en/07-develop/_sub_java.mdx similarity index 71% rename from docs-en/07-develop/_sub_java.mdx rename to docs/en/07-develop/_sub_java.mdx index e65bc576eb..ab77f61348 100644 --- a/docs-en/07-develop/_sub_java.mdx +++ b/docs/en/07-develop/_sub_java.mdx @@ -1,5 +1,5 @@ ```java -{{#include docs-examples/java/src/main/java/com/taos/example/SubscribeDemo.java}} +{{#include docs/examples/java/src/main/java/com/taos/example/SubscribeDemo.java}} ``` :::note For now Java connector doesn't provide asynchronous subscription, but `TimerTask` can be used to achieve similar purpose. diff --git a/docs/en/07-develop/_sub_node.mdx b/docs/en/07-develop/_sub_node.mdx new file mode 100644 index 0000000000..3eeff0922a --- /dev/null +++ b/docs/en/07-develop/_sub_node.mdx @@ -0,0 +1,3 @@ +```js +{{#include docs/examples/node/nativeexample/subscribe_demo.js}} +``` \ No newline at end of file diff --git a/docs/en/07-develop/_sub_python.mdx b/docs/en/07-develop/_sub_python.mdx new file mode 100644 index 0000000000..490b76fca6 --- /dev/null +++ b/docs/en/07-develop/_sub_python.mdx @@ -0,0 +1,3 @@ +```py +{{#include docs/examples/python/subscribe_demo.py}} +``` \ No newline at end of file diff --git a/docs/en/07-develop/_sub_rust.mdx b/docs/en/07-develop/_sub_rust.mdx new file mode 100644 index 0000000000..afb8d79daa --- /dev/null +++ b/docs/en/07-develop/_sub_rust.mdx @@ -0,0 +1,3 @@ +```rs +{{#include docs/examples/rust/nativeexample/examples/subscribe_demo.rs}} +``` \ No newline at end of file diff --git a/docs-en/07-develop/index.md b/docs/en/07-develop/index.md similarity index 100% rename from docs-en/07-develop/index.md rename to docs/en/07-develop/index.md diff --git a/docs-en/10-cluster/01-deploy.md b/docs/en/10-cluster/01-deploy.md similarity index 100% rename from docs-en/10-cluster/01-deploy.md rename to docs/en/10-cluster/01-deploy.md diff --git a/docs-en/10-cluster/02-cluster-mgmt.md b/docs/en/10-cluster/02-cluster-mgmt.md similarity index 100% rename from docs-en/10-cluster/02-cluster-mgmt.md rename to docs/en/10-cluster/02-cluster-mgmt.md diff --git a/docs-en/10-cluster/03-ha-and-lb.md b/docs/en/10-cluster/03-ha-and-lb.md similarity index 100% rename from docs-en/10-cluster/03-ha-and-lb.md rename to docs/en/10-cluster/03-ha-and-lb.md diff --git a/docs-en/10-cluster/_category_.yml b/docs/en/10-cluster/_category_.yml similarity index 100% rename from docs-en/10-cluster/_category_.yml rename to docs/en/10-cluster/_category_.yml diff --git a/docs-en/10-cluster/index.md b/docs/en/10-cluster/index.md similarity index 100% rename from docs-en/10-cluster/index.md rename to docs/en/10-cluster/index.md diff --git a/docs-en/12-taos-sql/01-data-type.md b/docs/en/12-taos-sql/01-data-type.md similarity index 100% rename from docs-en/12-taos-sql/01-data-type.md rename to docs/en/12-taos-sql/01-data-type.md diff --git a/docs-en/12-taos-sql/02-database.md b/docs/en/12-taos-sql/02-database.md similarity index 100% rename from docs-en/12-taos-sql/02-database.md rename to docs/en/12-taos-sql/02-database.md diff --git a/docs-en/12-taos-sql/03-table.md b/docs/en/12-taos-sql/03-table.md similarity index 100% rename from docs-en/12-taos-sql/03-table.md rename to docs/en/12-taos-sql/03-table.md diff --git a/docs-en/12-taos-sql/04-stable.md b/docs/en/12-taos-sql/04-stable.md similarity index 100% rename from docs-en/12-taos-sql/04-stable.md rename to docs/en/12-taos-sql/04-stable.md diff --git a/docs-en/12-taos-sql/05-insert.md b/docs/en/12-taos-sql/05-insert.md similarity index 100% rename from docs-en/12-taos-sql/05-insert.md rename to docs/en/12-taos-sql/05-insert.md diff --git a/docs-en/12-taos-sql/06-select.md b/docs/en/12-taos-sql/06-select.md similarity index 100% rename from docs-en/12-taos-sql/06-select.md rename to docs/en/12-taos-sql/06-select.md diff --git a/docs-en/07-develop/05-delete-data.mdx b/docs/en/12-taos-sql/08-delete-data.mdx similarity index 100% rename from docs-en/07-develop/05-delete-data.mdx rename to docs/en/12-taos-sql/08-delete-data.mdx diff --git a/docs-en/12-taos-sql/07-function.md b/docs/en/12-taos-sql/10-function.md similarity index 100% rename from docs-en/12-taos-sql/07-function.md rename to docs/en/12-taos-sql/10-function.md diff --git a/docs-en/12-taos-sql/08-interval.md b/docs/en/12-taos-sql/12-interval.md similarity index 100% rename from docs-en/12-taos-sql/08-interval.md rename to docs/en/12-taos-sql/12-interval.md diff --git a/docs-en/12-taos-sql/13-operators.md b/docs/en/12-taos-sql/13-operators.md similarity index 100% rename from docs-en/12-taos-sql/13-operators.md rename to docs/en/12-taos-sql/13-operators.md diff --git a/docs-en/12-taos-sql/09-limit.md b/docs/en/12-taos-sql/14-limit.md similarity index 100% rename from docs-en/12-taos-sql/09-limit.md rename to docs/en/12-taos-sql/14-limit.md diff --git a/docs-en/12-taos-sql/10-json.md b/docs/en/12-taos-sql/16-json.md similarity index 100% rename from docs-en/12-taos-sql/10-json.md rename to docs/en/12-taos-sql/16-json.md diff --git a/docs-en/12-taos-sql/11-escape.md b/docs/en/12-taos-sql/18-escape.md similarity index 100% rename from docs-en/12-taos-sql/11-escape.md rename to docs/en/12-taos-sql/18-escape.md diff --git a/docs/en/12-taos-sql/20-keywords.md b/docs/en/12-taos-sql/20-keywords.md new file mode 100644 index 0000000000..6d40deb5a6 --- /dev/null +++ b/docs/en/12-taos-sql/20-keywords.md @@ -0,0 +1,315 @@ +--- +title: Keywords +--- + +There are about 200 keywords reserved by TDengine, they can't be used as the name of database, STable or table with either upper case, lower case or mixed case. + +## Keywords List + +### A + +- ABORT +- ACCOUNT +- ACCOUNTS +- ADD +- AFTER +- ALL +- ALTER +- AND +- AS +- ASC +- ATTACH + +### B + +- BEFORE +- BEGIN +- BETWEEN +- BIGINT +- BINARY +- BITAND +- BITNOT +- BITOR +- BLOCKS +- BOOL +- BY + +### C + +- CACHE +- CACHELAST +- CASCADE +- CHANGE +- CLUSTER +- COLON +- COLUMN +- COMMA +- COMP +- COMPACT +- CONCAT +- CONFLICT +- CONNECTION +- CONNECTIONS +- CONNS +- COPY +- CREATE +- CTIME + +### D + +- DATABASE +- DATABASES +- DAYS +- DBS +- DEFERRED +- DELETE +- DELIMITERS +- DESC +- DESCRIBE +- DETACH +- DISTINCT +- DIVIDE +- DNODE +- DNODES +- DOT +- DOUBLE +- DROP + +### E + +- END +- EQ +- EXISTS +- EXPLAIN + +### F + +- FAIL +- FILE +- FILL +- FLOAT +- FOR +- FROM +- FSYNC + +### G + +- GE +- GLOB +- GRANTS +- GROUP +- GT + +### H + +- HAVING + +### I + +- ID +- IF +- IGNORE +- IMMEDIA +- IMPORT +- IN +- INITIAL +- INSERT +- INSTEAD +- INT +- INTEGER +- INTERVA +- INTO +- IS +- ISNULL + +### J + +- JOIN + +### K + +- KEEP +- KEY +- KILL + +### L + +- LE +- LIKE +- LIMIT +- LINEAR +- LOCAL +- LP +- LSHIFT +- LT + +### M + +- MATCH +- MAXROWS +- MINROWS +- MINUS +- MNODES +- MODIFY +- MODULES + +### N + +- NE +- NONE +- NOT +- NOTNULL +- NOW +- NULL + +### O + +- OF +- OFFSET +- OR +- ORDER + +### P + +- PARTITION +- PASS +- PLUS +- PPS +- PRECISION +- PREV +- PRIVILEGE + +### Q + +- QTIME +- QUERIE +- QUERY +- QUORUM + +### R + +- RAISE +- REM +- REPLACE +- REPLICA +- RESET +- RESTRIC +- ROW +- RP +- RSHIFT + +### S + +- SCORES +- SELECT +- SEMI +- SESSION +- SET +- SHOW +- SLASH +- SLIDING +- SLIMIT +- SMALLIN +- SOFFSET +- STable +- STableS +- STAR +- STATE +- STATEMEN +- STATE_WI +- STORAGE +- STREAM +- STREAMS +- STRING +- SYNCDB + +### T + +- TABLE +- TABLES +- TAG +- TAGS +- TBNAME +- TIMES +- TIMESTAMP +- TINYINT +- TOPIC +- TOPICS +- TRIGGER +- TSERIES + +### U + +- UMINUS +- UNION +- UNSIGNED +- UPDATE +- UPLUS +- USE +- USER +- USERS +- USING + +### V + +- VALUES +- VARIABLE +- VARIABLES +- VGROUPS +- VIEW +- VNODES + +### W + +- WAL +- WHERE + +### _ + +- _C0 +- _QSTART +- _QSTOP +- _QDURATION +- _WSTART +- _WSTOP +- _WDURATION + +## Explanations +### TBNAME +`TBNAME` can be considered as a special tag, which represents the name of the subtable, in a STable. + +Get the table name and tag values of all subtables in a STable. +```mysql +SELECT TBNAME, location FROM meters; +``` + +Count the number of subtables in a STable. +```mysql +SELECT COUNT(TBNAME) FROM meters; +``` + +Only filter on TAGS can be used in WHERE clause in the above two query statements. +```mysql +taos> SELECT TBNAME, location FROM meters; + tbname | location | +================================================================== + d1004 | California.SanFrancisco | + d1003 | California.SanFrancisco | + d1002 | California.LosAngeles | + d1001 | California.LosAngeles | +Query OK, 4 row(s) in set (0.000881s) + +taos> SELECT COUNT(tbname) FROM meters WHERE groupId > 2; + count(tbname) | +======================== + 2 | +Query OK, 1 row(s) in set (0.001091s) +``` +### _QSTART/_QSTOP/_QDURATION +The start, stop and duration of a query time window. + +### _WSTART/_WSTOP/_WDURATION +The start, stop and duration of aggegate query by time window, like interval, session window, state window. + +### _c0/_ROWTS +_c0 is equal to _ROWTS, it means the first column of a table or STable. diff --git a/docs-en/12-taos-sql/_category_.yml b/docs/en/12-taos-sql/_category_.yml similarity index 100% rename from docs-en/12-taos-sql/_category_.yml rename to docs/en/12-taos-sql/_category_.yml diff --git a/docs-en/12-taos-sql/index.md b/docs/en/12-taos-sql/index.md similarity index 100% rename from docs-en/12-taos-sql/index.md rename to docs/en/12-taos-sql/index.md diff --git a/docs-cn/12-taos-sql/timewindow-1.webp b/docs/en/12-taos-sql/timewindow-1.webp similarity index 100% rename from docs-cn/12-taos-sql/timewindow-1.webp rename to docs/en/12-taos-sql/timewindow-1.webp diff --git a/docs-cn/12-taos-sql/timewindow-2.webp b/docs/en/12-taos-sql/timewindow-2.webp similarity index 100% rename from docs-cn/12-taos-sql/timewindow-2.webp rename to docs/en/12-taos-sql/timewindow-2.webp diff --git a/docs-cn/12-taos-sql/timewindow-3.webp b/docs/en/12-taos-sql/timewindow-3.webp similarity index 100% rename from docs-cn/12-taos-sql/timewindow-3.webp rename to docs/en/12-taos-sql/timewindow-3.webp diff --git a/docs-en/13-operation/01-pkg-install.md b/docs/en/13-operation/01-pkg-install.md similarity index 100% rename from docs-en/13-operation/01-pkg-install.md rename to docs/en/13-operation/01-pkg-install.md diff --git a/docs-en/13-operation/02-planning.mdx b/docs/en/13-operation/02-planning.mdx similarity index 100% rename from docs-en/13-operation/02-planning.mdx rename to docs/en/13-operation/02-planning.mdx diff --git a/docs-en/13-operation/03-tolerance.md b/docs/en/13-operation/03-tolerance.md similarity index 100% rename from docs-en/13-operation/03-tolerance.md rename to docs/en/13-operation/03-tolerance.md diff --git a/docs-en/13-operation/06-admin.md b/docs/en/13-operation/06-admin.md similarity index 100% rename from docs-en/13-operation/06-admin.md rename to docs/en/13-operation/06-admin.md diff --git a/docs-en/13-operation/07-import.md b/docs/en/13-operation/07-import.md similarity index 100% rename from docs-en/13-operation/07-import.md rename to docs/en/13-operation/07-import.md diff --git a/docs-en/13-operation/08-export.md b/docs/en/13-operation/08-export.md similarity index 100% rename from docs-en/13-operation/08-export.md rename to docs/en/13-operation/08-export.md diff --git a/docs-en/13-operation/09-status.md b/docs/en/13-operation/09-status.md similarity index 100% rename from docs-en/13-operation/09-status.md rename to docs/en/13-operation/09-status.md diff --git a/docs-en/13-operation/10-monitor.md b/docs/en/13-operation/10-monitor.md similarity index 100% rename from docs-en/13-operation/10-monitor.md rename to docs/en/13-operation/10-monitor.md diff --git a/docs-en/13-operation/17-diagnose.md b/docs/en/13-operation/17-diagnose.md similarity index 100% rename from docs-en/13-operation/17-diagnose.md rename to docs/en/13-operation/17-diagnose.md diff --git a/docs-en/13-operation/_category_.yml b/docs/en/13-operation/_category_.yml similarity index 100% rename from docs-en/13-operation/_category_.yml rename to docs/en/13-operation/_category_.yml diff --git a/docs-en/13-operation/index.md b/docs/en/13-operation/index.md similarity index 100% rename from docs-en/13-operation/index.md rename to docs/en/13-operation/index.md diff --git a/docs-en/14-reference/02-rest-api/02-rest-api.mdx b/docs/en/14-reference/02-rest-api/02-rest-api.mdx similarity index 100% rename from docs-en/14-reference/02-rest-api/02-rest-api.mdx rename to docs/en/14-reference/02-rest-api/02-rest-api.mdx diff --git a/docs-cn/14-reference/02-rest-api/_category_.yml b/docs/en/14-reference/02-rest-api/_category_.yml similarity index 100% rename from docs-cn/14-reference/02-rest-api/_category_.yml rename to docs/en/14-reference/02-rest-api/_category_.yml diff --git a/docs-en/14-reference/03-connector/03-connector.mdx b/docs/en/14-reference/03-connector/03-connector.mdx similarity index 100% rename from docs-en/14-reference/03-connector/03-connector.mdx rename to docs/en/14-reference/03-connector/03-connector.mdx diff --git a/docs-en/14-reference/03-connector/_category_.yml b/docs/en/14-reference/03-connector/_category_.yml similarity index 100% rename from docs-en/14-reference/03-connector/_category_.yml rename to docs/en/14-reference/03-connector/_category_.yml diff --git a/docs-en/14-reference/03-connector/_linux_install.mdx b/docs/en/14-reference/03-connector/_linux_install.mdx similarity index 100% rename from docs-en/14-reference/03-connector/_linux_install.mdx rename to docs/en/14-reference/03-connector/_linux_install.mdx diff --git a/docs-en/14-reference/03-connector/_preparation.mdx b/docs/en/14-reference/03-connector/_preparation.mdx similarity index 100% rename from docs-en/14-reference/03-connector/_preparation.mdx rename to docs/en/14-reference/03-connector/_preparation.mdx diff --git a/docs-en/14-reference/03-connector/_verify_linux.mdx b/docs/en/14-reference/03-connector/_verify_linux.mdx similarity index 100% rename from docs-en/14-reference/03-connector/_verify_linux.mdx rename to docs/en/14-reference/03-connector/_verify_linux.mdx diff --git a/docs-en/14-reference/03-connector/_verify_windows.mdx b/docs/en/14-reference/03-connector/_verify_windows.mdx similarity index 100% rename from docs-en/14-reference/03-connector/_verify_windows.mdx rename to docs/en/14-reference/03-connector/_verify_windows.mdx diff --git a/docs-en/14-reference/03-connector/_windows_install.mdx b/docs/en/14-reference/03-connector/_windows_install.mdx similarity index 100% rename from docs-en/14-reference/03-connector/_windows_install.mdx rename to docs/en/14-reference/03-connector/_windows_install.mdx diff --git a/docs-cn/14-reference/03-connector/connector.webp b/docs/en/14-reference/03-connector/connector.webp similarity index 100% rename from docs-cn/14-reference/03-connector/connector.webp rename to docs/en/14-reference/03-connector/connector.webp diff --git a/docs-en/14-reference/03-connector/cpp.mdx b/docs/en/14-reference/03-connector/cpp.mdx similarity index 100% rename from docs-en/14-reference/03-connector/cpp.mdx rename to docs/en/14-reference/03-connector/cpp.mdx diff --git a/docs-en/14-reference/03-connector/csharp.mdx b/docs/en/14-reference/03-connector/csharp.mdx similarity index 100% rename from docs-en/14-reference/03-connector/csharp.mdx rename to docs/en/14-reference/03-connector/csharp.mdx diff --git a/docs-en/14-reference/03-connector/go.mdx b/docs/en/14-reference/03-connector/go.mdx similarity index 100% rename from docs-en/14-reference/03-connector/go.mdx rename to docs/en/14-reference/03-connector/go.mdx diff --git a/docs-en/14-reference/03-connector/java.mdx b/docs/en/14-reference/03-connector/java.mdx similarity index 100% rename from docs-en/14-reference/03-connector/java.mdx rename to docs/en/14-reference/03-connector/java.mdx diff --git a/docs-en/14-reference/03-connector/node.mdx b/docs/en/14-reference/03-connector/node.mdx similarity index 100% rename from docs-en/14-reference/03-connector/node.mdx rename to docs/en/14-reference/03-connector/node.mdx diff --git a/docs-en/14-reference/03-connector/php.mdx b/docs/en/14-reference/03-connector/php.mdx similarity index 95% rename from docs-en/14-reference/03-connector/php.mdx rename to docs/en/14-reference/03-connector/php.mdx index 839a5c8c3c..69dcce91e8 100644 --- a/docs-en/14-reference/03-connector/php.mdx +++ b/docs/en/14-reference/03-connector/php.mdx @@ -91,7 +91,7 @@ In this section a few sample programs which use TDengine PHP connector to access Establish Connection ```c -{{#include docs-examples/php/connect.php}} +{{#include docs/examples/php/connect.php}} ``` @@ -102,7 +102,7 @@ In this section a few sample programs which use TDengine PHP connector to access Insert Data ```c -{{#include docs-examples/php/insert.php}} +{{#include docs/examples/php/insert.php}} ``` @@ -113,7 +113,7 @@ In this section a few sample programs which use TDengine PHP connector to access Synchronous Query ```c -{{#include docs-examples/php/query.php}} +{{#include docs/examples/php/query.php}} ``` @@ -124,7 +124,7 @@ In this section a few sample programs which use TDengine PHP connector to access Parameter Binding ```c -{{#include docs-examples/php/insert_stmt.php}} +{{#include docs/examples/php/insert_stmt.php}} ``` diff --git a/docs-en/14-reference/03-connector/python.mdx b/docs/en/14-reference/03-connector/python.mdx similarity index 95% rename from docs-en/14-reference/03-connector/python.mdx rename to docs/en/14-reference/03-connector/python.mdx index 58b94f13ae..04eb2e57d4 100644 --- a/docs-en/14-reference/03-connector/python.mdx +++ b/docs/en/14-reference/03-connector/python.mdx @@ -169,7 +169,7 @@ The following example code assumes that TDengine is installed locally and that t ```python -{{#include docs-examples/python/connect_native_reference.py}} +{{#include docs/examples/python/connect_native_reference.py}} ``` All arguments of the `connect()` function are optional keyword arguments. The following are the connection parameters specified. @@ -194,7 +194,7 @@ The `connect()` function returns a `taos.TaosConnection` instance. In client-sid ```python -{{#include docs-examples/python/connect_rest_examples.py:connect}} +{{#include docs/examples/python/connect_rest_examples.py:connect}} ``` All arguments to the `connect()` function are optional keyword arguments. The following are the connection parameters specified. @@ -219,11 +219,11 @@ All arguments to the `connect()` function are optional keyword arguments. The fo The `TaosConnection` class contains both an implementation of the PEP249 Connection interface (e.g., the `cursor()` method and the `close()` method) and many extensions (e.g., the `execute()`, `query()`, `schemaless_insert()`, and `subscribe()` methods). ```python title="execute method" -{{#include docs-examples/python/connection_usage_native_reference.py:insert}} +{{#include docs/examples/python/connection_usage_native_reference.py:insert}} ``` ```python title="query method" -{{#include docs-examples/python/connection_usage_native_reference.py:query}} +{{#include docs/examples/python/connection_usage_native_reference.py:query}} ``` :::tip @@ -235,14 +235,14 @@ The queried results can only be fetched once. For example, only one of `fetch_al In the above example of using the `TaosConnection` class, we have shown two ways to get the result of a query: `fetch_all()` and `fetch_all_into_dict()`. In addition, `TaosResult` also provides methods to iterate through the result set by rows (`rows_iter`) or by data blocks (`blocks_iter`). Using these two methods will be more efficient in scenarios where the query has a large amount of data. ```python title="blocks_iter method" -{{#include docs-examples/python/result_set_examples.py}} +{{#include docs/examples/python/result_set_examples.py}} ``` ##### Use of the TaosCursor class The `TaosConnection` class and the `TaosResult` class already implement all the functionality of the native interface. If you are familiar with the interfaces in the PEP249 specification, you can also use the methods provided by the `TaosCursor` class. ```python title="Use of TaosCursor" -{{#include docs-examples/python/cursor_usage_native_reference.py}} +{{#include docs/examples/python/cursor_usage_native_reference.py}} ``` :::note @@ -258,7 +258,7 @@ The TaosCursor class uses native connections for write and query operations. In The ``TaosRestCursor`` class is an implementation of the PEP249 Cursor interface. ```python title="Use of TaosRestCursor" -{{#include docs-examples/python/connect_rest_examples.py:basic}} +{{#include docs/examples/python/connect_rest_examples.py:basic}} ``` - `cursor.execute` : Used to execute arbitrary SQL statements. - `cursor.rowcount` : For write operations, returns the number of successful rows written. For query operations, returns the number of rows in the result set. @@ -269,7 +269,7 @@ The ``TaosRestCursor`` class is an implementation of the PEP249 Cursor interface The `RestClient` class is a direct wrapper for the [REST API](/reference/rest-api). It contains only a `sql()` method for executing arbitrary SQL statements and returning the result. ```python title="Use of RestClient" -{{#include docs-examples/python/rest_client_example.py}} +{{#include docs/examples/python/rest_client_example.py}} ``` For a more detailed description of the `sql()` method, please refer to [RestClient](https://docs.taosdata.com/api/taospy/taosrest/restclient.html). @@ -283,14 +283,14 @@ For a more detailed description of the `sql()` method, please refer to [RestClie ```python -{{#include docs-examples/python/conn_native_pandas.py}} +{{#include docs/examples/python/conn_native_pandas.py}} ``` ```python -{{#include docs-examples/python/conn_rest_pandas.py}} +{{#include docs/examples/python/conn_rest_pandas.py}} ``` @@ -314,7 +314,7 @@ For a more detailed description of the `sql()` method, please refer to [RestClie All errors from database operations are thrown directly as exceptions and the error message from the database is passed up the exception stack. The application is responsible for exception handling. For example: ```python -{{#include docs-examples/python/handle_exception.py}} +{{#include docs/examples/python/handle_exception.py}} ``` ### About nanoseconds diff --git a/docs-en/14-reference/03-connector/rust.mdx b/docs/en/14-reference/03-connector/rust.mdx similarity index 100% rename from docs-en/14-reference/03-connector/rust.mdx rename to docs/en/14-reference/03-connector/rust.mdx diff --git a/docs-en/14-reference/03-connector/tdengine-jdbc-connector.webp b/docs/en/14-reference/03-connector/tdengine-jdbc-connector.webp similarity index 100% rename from docs-en/14-reference/03-connector/tdengine-jdbc-connector.webp rename to docs/en/14-reference/03-connector/tdengine-jdbc-connector.webp diff --git a/docs-en/14-reference/04-taosadapter.md b/docs/en/14-reference/04-taosadapter.md similarity index 100% rename from docs-en/14-reference/04-taosadapter.md rename to docs/en/14-reference/04-taosadapter.md diff --git a/docs-en/14-reference/05-taosbenchmark.md b/docs/en/14-reference/05-taosbenchmark.md similarity index 100% rename from docs-en/14-reference/05-taosbenchmark.md rename to docs/en/14-reference/05-taosbenchmark.md diff --git a/docs-en/14-reference/06-taosdump.md b/docs/en/14-reference/06-taosdump.md similarity index 100% rename from docs-en/14-reference/06-taosdump.md rename to docs/en/14-reference/06-taosdump.md diff --git a/docs-cn/14-reference/07-tdinsight/assets/15146-tdengine-monitor-dashboard.json b/docs/en/14-reference/07-tdinsight/assets/15146-tdengine-monitor-dashboard.json similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/15146-tdengine-monitor-dashboard.json rename to docs/en/14-reference/07-tdinsight/assets/15146-tdengine-monitor-dashboard.json diff --git a/docs-cn/14-reference/07-tdinsight/assets/15155-tdengine-alert-demo.json b/docs/en/14-reference/07-tdinsight/assets/15155-tdengine-alert-demo.json similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/15155-tdengine-alert-demo.json rename to docs/en/14-reference/07-tdinsight/assets/15155-tdengine-alert-demo.json diff --git a/docs-cn/14-reference/07-tdinsight/assets/TDinsight-1-cluster-status.webp b/docs/en/14-reference/07-tdinsight/assets/TDinsight-1-cluster-status.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/TDinsight-1-cluster-status.webp rename to docs/en/14-reference/07-tdinsight/assets/TDinsight-1-cluster-status.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/TDinsight-2-dnodes.webp b/docs/en/14-reference/07-tdinsight/assets/TDinsight-2-dnodes.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/TDinsight-2-dnodes.webp rename to docs/en/14-reference/07-tdinsight/assets/TDinsight-2-dnodes.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/TDinsight-3-mnodes.webp b/docs/en/14-reference/07-tdinsight/assets/TDinsight-3-mnodes.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/TDinsight-3-mnodes.webp rename to docs/en/14-reference/07-tdinsight/assets/TDinsight-3-mnodes.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/TDinsight-4-requests.webp b/docs/en/14-reference/07-tdinsight/assets/TDinsight-4-requests.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/TDinsight-4-requests.webp rename to docs/en/14-reference/07-tdinsight/assets/TDinsight-4-requests.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/TDinsight-5-database.webp b/docs/en/14-reference/07-tdinsight/assets/TDinsight-5-database.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/TDinsight-5-database.webp rename to docs/en/14-reference/07-tdinsight/assets/TDinsight-5-database.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/TDinsight-6-dnode-usage.webp b/docs/en/14-reference/07-tdinsight/assets/TDinsight-6-dnode-usage.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/TDinsight-6-dnode-usage.webp rename to docs/en/14-reference/07-tdinsight/assets/TDinsight-6-dnode-usage.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/TDinsight-7-login-history.webp b/docs/en/14-reference/07-tdinsight/assets/TDinsight-7-login-history.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/TDinsight-7-login-history.webp rename to docs/en/14-reference/07-tdinsight/assets/TDinsight-7-login-history.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp b/docs/en/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp rename to docs/en/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/TDinsight-full.webp b/docs/en/14-reference/07-tdinsight/assets/TDinsight-full.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/TDinsight-full.webp rename to docs/en/14-reference/07-tdinsight/assets/TDinsight-full.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/alert-manager-status.webp b/docs/en/14-reference/07-tdinsight/assets/alert-manager-status.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/alert-manager-status.webp rename to docs/en/14-reference/07-tdinsight/assets/alert-manager-status.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/alert-notification-channel.webp b/docs/en/14-reference/07-tdinsight/assets/alert-notification-channel.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/alert-notification-channel.webp rename to docs/en/14-reference/07-tdinsight/assets/alert-notification-channel.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/alert-query-demo.webp b/docs/en/14-reference/07-tdinsight/assets/alert-query-demo.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/alert-query-demo.webp rename to docs/en/14-reference/07-tdinsight/assets/alert-query-demo.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/alert-rule-condition-notifications.webp b/docs/en/14-reference/07-tdinsight/assets/alert-rule-condition-notifications.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/alert-rule-condition-notifications.webp rename to docs/en/14-reference/07-tdinsight/assets/alert-rule-condition-notifications.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/alert-rule-test.webp b/docs/en/14-reference/07-tdinsight/assets/alert-rule-test.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/alert-rule-test.webp rename to docs/en/14-reference/07-tdinsight/assets/alert-rule-test.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/howto-add-datasource-button.webp b/docs/en/14-reference/07-tdinsight/assets/howto-add-datasource-button.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/howto-add-datasource-button.webp rename to docs/en/14-reference/07-tdinsight/assets/howto-add-datasource-button.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/howto-add-datasource-tdengine.webp b/docs/en/14-reference/07-tdinsight/assets/howto-add-datasource-tdengine.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/howto-add-datasource-tdengine.webp rename to docs/en/14-reference/07-tdinsight/assets/howto-add-datasource-tdengine.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/howto-add-datasource-test.webp b/docs/en/14-reference/07-tdinsight/assets/howto-add-datasource-test.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/howto-add-datasource-test.webp rename to docs/en/14-reference/07-tdinsight/assets/howto-add-datasource-test.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/howto-add-datasource.webp b/docs/en/14-reference/07-tdinsight/assets/howto-add-datasource.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/howto-add-datasource.webp rename to docs/en/14-reference/07-tdinsight/assets/howto-add-datasource.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/howto-dashboard-display.webp b/docs/en/14-reference/07-tdinsight/assets/howto-dashboard-display.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/howto-dashboard-display.webp rename to docs/en/14-reference/07-tdinsight/assets/howto-dashboard-display.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/howto-dashboard-import-options.webp b/docs/en/14-reference/07-tdinsight/assets/howto-dashboard-import-options.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/howto-dashboard-import-options.webp rename to docs/en/14-reference/07-tdinsight/assets/howto-dashboard-import-options.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/howto-import-dashboard.webp b/docs/en/14-reference/07-tdinsight/assets/howto-import-dashboard.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/howto-import-dashboard.webp rename to docs/en/14-reference/07-tdinsight/assets/howto-import-dashboard.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/import-dashboard-15167.webp b/docs/en/14-reference/07-tdinsight/assets/import-dashboard-15167.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/import-dashboard-15167.webp rename to docs/en/14-reference/07-tdinsight/assets/import-dashboard-15167.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/import-dashboard-for-tdengine.webp b/docs/en/14-reference/07-tdinsight/assets/import-dashboard-for-tdengine.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/import-dashboard-for-tdengine.webp rename to docs/en/14-reference/07-tdinsight/assets/import-dashboard-for-tdengine.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/import-via-grafana-dot-com.webp b/docs/en/14-reference/07-tdinsight/assets/import-via-grafana-dot-com.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/import-via-grafana-dot-com.webp rename to docs/en/14-reference/07-tdinsight/assets/import-via-grafana-dot-com.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/import_dashboard.webp b/docs/en/14-reference/07-tdinsight/assets/import_dashboard.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/import_dashboard.webp rename to docs/en/14-reference/07-tdinsight/assets/import_dashboard.webp diff --git a/docs-cn/14-reference/07-tdinsight/assets/tdengine-grafana-7.x.json b/docs/en/14-reference/07-tdinsight/assets/tdengine-grafana-7.x.json similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/tdengine-grafana-7.x.json rename to docs/en/14-reference/07-tdinsight/assets/tdengine-grafana-7.x.json diff --git a/docs-cn/14-reference/07-tdinsight/assets/tdengine-grafana.json b/docs/en/14-reference/07-tdinsight/assets/tdengine-grafana.json similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/tdengine-grafana.json rename to docs/en/14-reference/07-tdinsight/assets/tdengine-grafana.json diff --git a/docs-cn/14-reference/07-tdinsight/assets/tdengine_dashboard.webp b/docs/en/14-reference/07-tdinsight/assets/tdengine_dashboard.webp similarity index 100% rename from docs-cn/14-reference/07-tdinsight/assets/tdengine_dashboard.webp rename to docs/en/14-reference/07-tdinsight/assets/tdengine_dashboard.webp diff --git a/docs-en/14-reference/07-tdinsight/index.md b/docs/en/14-reference/07-tdinsight/index.md similarity index 100% rename from docs-en/14-reference/07-tdinsight/index.md rename to docs/en/14-reference/07-tdinsight/index.md diff --git a/docs-en/14-reference/08-taos-shell.md b/docs/en/14-reference/08-taos-shell.md similarity index 100% rename from docs-en/14-reference/08-taos-shell.md rename to docs/en/14-reference/08-taos-shell.md diff --git a/docs-en/14-reference/09-support-platform/_category_.yml b/docs/en/14-reference/09-support-platform/_category_.yml similarity index 100% rename from docs-en/14-reference/09-support-platform/_category_.yml rename to docs/en/14-reference/09-support-platform/_category_.yml diff --git a/docs-en/14-reference/09-support-platform/index.md b/docs/en/14-reference/09-support-platform/index.md similarity index 100% rename from docs-en/14-reference/09-support-platform/index.md rename to docs/en/14-reference/09-support-platform/index.md diff --git a/docs-en/14-reference/11-docker/_category_.yml b/docs/en/14-reference/11-docker/_category_.yml similarity index 100% rename from docs-en/14-reference/11-docker/_category_.yml rename to docs/en/14-reference/11-docker/_category_.yml diff --git a/docs-en/14-reference/11-docker/index.md b/docs/en/14-reference/11-docker/index.md similarity index 100% rename from docs-en/14-reference/11-docker/index.md rename to docs/en/14-reference/11-docker/index.md diff --git a/docs-en/14-reference/12-config/_category_.yml b/docs/en/14-reference/12-config/_category_.yml similarity index 100% rename from docs-en/14-reference/12-config/_category_.yml rename to docs/en/14-reference/12-config/_category_.yml diff --git a/docs-en/14-reference/12-config/index.md b/docs/en/14-reference/12-config/index.md similarity index 100% rename from docs-en/14-reference/12-config/index.md rename to docs/en/14-reference/12-config/index.md diff --git a/docs-en/14-reference/12-directory.md b/docs/en/14-reference/12-directory.md similarity index 100% rename from docs-en/14-reference/12-directory.md rename to docs/en/14-reference/12-directory.md diff --git a/docs-en/14-reference/13-schemaless/13-schemaless.md b/docs/en/14-reference/13-schemaless/13-schemaless.md similarity index 100% rename from docs-en/14-reference/13-schemaless/13-schemaless.md rename to docs/en/14-reference/13-schemaless/13-schemaless.md diff --git a/docs-en/14-reference/13-schemaless/_category_.yml b/docs/en/14-reference/13-schemaless/_category_.yml similarity index 100% rename from docs-en/14-reference/13-schemaless/_category_.yml rename to docs/en/14-reference/13-schemaless/_category_.yml diff --git a/docs-en/14-reference/_category_.yml b/docs/en/14-reference/_category_.yml similarity index 100% rename from docs-en/14-reference/_category_.yml rename to docs/en/14-reference/_category_.yml diff --git a/docs-en/14-reference/_collectd.mdx b/docs/en/14-reference/_collectd.mdx similarity index 100% rename from docs-en/14-reference/_collectd.mdx rename to docs/en/14-reference/_collectd.mdx diff --git a/docs-en/14-reference/_icinga2.mdx b/docs/en/14-reference/_icinga2.mdx similarity index 100% rename from docs-en/14-reference/_icinga2.mdx rename to docs/en/14-reference/_icinga2.mdx diff --git a/docs-en/14-reference/_prometheus.mdx b/docs/en/14-reference/_prometheus.mdx similarity index 100% rename from docs-en/14-reference/_prometheus.mdx rename to docs/en/14-reference/_prometheus.mdx diff --git a/docs-en/14-reference/_statsd.mdx b/docs/en/14-reference/_statsd.mdx similarity index 100% rename from docs-en/14-reference/_statsd.mdx rename to docs/en/14-reference/_statsd.mdx diff --git a/docs-en/14-reference/_tcollector.mdx b/docs/en/14-reference/_tcollector.mdx similarity index 100% rename from docs-en/14-reference/_tcollector.mdx rename to docs/en/14-reference/_tcollector.mdx diff --git a/docs-en/14-reference/_telegraf.mdx b/docs/en/14-reference/_telegraf.mdx similarity index 100% rename from docs-en/14-reference/_telegraf.mdx rename to docs/en/14-reference/_telegraf.mdx diff --git a/docs-en/14-reference/index.md b/docs/en/14-reference/index.md similarity index 100% rename from docs-en/14-reference/index.md rename to docs/en/14-reference/index.md diff --git a/docs-cn/14-reference/taosAdapter-architecture.webp b/docs/en/14-reference/taosAdapter-architecture.webp similarity index 100% rename from docs-cn/14-reference/taosAdapter-architecture.webp rename to docs/en/14-reference/taosAdapter-architecture.webp diff --git a/docs-en/20-third-party/01-grafana.mdx b/docs/en/20-third-party/01-grafana.mdx similarity index 100% rename from docs-en/20-third-party/01-grafana.mdx rename to docs/en/20-third-party/01-grafana.mdx diff --git a/docs-en/20-third-party/02-prometheus.md b/docs/en/20-third-party/02-prometheus.md similarity index 100% rename from docs-en/20-third-party/02-prometheus.md rename to docs/en/20-third-party/02-prometheus.md diff --git a/docs-en/20-third-party/03-telegraf.md b/docs/en/20-third-party/03-telegraf.md similarity index 100% rename from docs-en/20-third-party/03-telegraf.md rename to docs/en/20-third-party/03-telegraf.md diff --git a/docs-en/20-third-party/05-collectd.md b/docs/en/20-third-party/05-collectd.md similarity index 100% rename from docs-en/20-third-party/05-collectd.md rename to docs/en/20-third-party/05-collectd.md diff --git a/docs-en/20-third-party/06-statsd.md b/docs/en/20-third-party/06-statsd.md similarity index 100% rename from docs-en/20-third-party/06-statsd.md rename to docs/en/20-third-party/06-statsd.md diff --git a/docs-en/20-third-party/07-icinga2.md b/docs/en/20-third-party/07-icinga2.md similarity index 100% rename from docs-en/20-third-party/07-icinga2.md rename to docs/en/20-third-party/07-icinga2.md diff --git a/docs-en/20-third-party/08-tcollector.md b/docs/en/20-third-party/08-tcollector.md similarity index 100% rename from docs-en/20-third-party/08-tcollector.md rename to docs/en/20-third-party/08-tcollector.md diff --git a/docs-en/20-third-party/09-emq-broker.md b/docs/en/20-third-party/09-emq-broker.md similarity index 99% rename from docs-en/20-third-party/09-emq-broker.md rename to docs/en/20-third-party/09-emq-broker.md index 7c6b83cf99..8dfa09e6c7 100644 --- a/docs-en/20-third-party/09-emq-broker.md +++ b/docs/en/20-third-party/09-emq-broker.md @@ -108,7 +108,7 @@ Finally, click the "Create" button at bottom left corner saving the rule. ## Compose program to mock data ```javascript -{{#include docs-examples/other/mock.js}} +{{#include docs/examples/other/mock.js}} ``` Note: `CLIENT_NUM` in the code can be set to a smaller value at the beginning of the test to avoid hardware performance be not capable to handle a more significant number of concurrent clients. diff --git a/docs-en/20-third-party/10-hive-mq-broker.md b/docs/en/20-third-party/10-hive-mq-broker.md similarity index 100% rename from docs-en/20-third-party/10-hive-mq-broker.md rename to docs/en/20-third-party/10-hive-mq-broker.md diff --git a/docs-en/20-third-party/11-kafka.md b/docs/en/20-third-party/11-kafka.md similarity index 100% rename from docs-en/20-third-party/11-kafka.md rename to docs/en/20-third-party/11-kafka.md diff --git a/docs-en/20-third-party/_category_.yml b/docs/en/20-third-party/_category_.yml similarity index 100% rename from docs-en/20-third-party/_category_.yml rename to docs/en/20-third-party/_category_.yml diff --git a/docs-en/20-third-party/_deploytaosadapter.mdx b/docs/en/20-third-party/_deploytaosadapter.mdx similarity index 100% rename from docs-en/20-third-party/_deploytaosadapter.mdx rename to docs/en/20-third-party/_deploytaosadapter.mdx diff --git a/docs-cn/20-third-party/emqx/add-action-handler.webp b/docs/en/20-third-party/emqx/add-action-handler.webp similarity index 100% rename from docs-cn/20-third-party/emqx/add-action-handler.webp rename to docs/en/20-third-party/emqx/add-action-handler.webp diff --git a/docs-cn/20-third-party/emqx/check-result-in-taos.webp b/docs/en/20-third-party/emqx/check-result-in-taos.webp similarity index 100% rename from docs-cn/20-third-party/emqx/check-result-in-taos.webp rename to docs/en/20-third-party/emqx/check-result-in-taos.webp diff --git a/docs-cn/20-third-party/emqx/check-rule-matched.webp b/docs/en/20-third-party/emqx/check-rule-matched.webp similarity index 100% rename from docs-cn/20-third-party/emqx/check-rule-matched.webp rename to docs/en/20-third-party/emqx/check-rule-matched.webp diff --git a/docs-cn/20-third-party/emqx/client-num.webp b/docs/en/20-third-party/emqx/client-num.webp similarity index 100% rename from docs-cn/20-third-party/emqx/client-num.webp rename to docs/en/20-third-party/emqx/client-num.webp diff --git a/docs-cn/20-third-party/emqx/create-resource.webp b/docs/en/20-third-party/emqx/create-resource.webp similarity index 100% rename from docs-cn/20-third-party/emqx/create-resource.webp rename to docs/en/20-third-party/emqx/create-resource.webp diff --git a/docs-cn/20-third-party/emqx/create-rule.webp b/docs/en/20-third-party/emqx/create-rule.webp similarity index 100% rename from docs-cn/20-third-party/emqx/create-rule.webp rename to docs/en/20-third-party/emqx/create-rule.webp diff --git a/docs-cn/20-third-party/emqx/edit-action.webp b/docs/en/20-third-party/emqx/edit-action.webp similarity index 100% rename from docs-cn/20-third-party/emqx/edit-action.webp rename to docs/en/20-third-party/emqx/edit-action.webp diff --git a/docs-cn/20-third-party/emqx/edit-resource.webp b/docs/en/20-third-party/emqx/edit-resource.webp similarity index 100% rename from docs-cn/20-third-party/emqx/edit-resource.webp rename to docs/en/20-third-party/emqx/edit-resource.webp diff --git a/docs-cn/20-third-party/emqx/login-dashboard.webp b/docs/en/20-third-party/emqx/login-dashboard.webp similarity index 100% rename from docs-cn/20-third-party/emqx/login-dashboard.webp rename to docs/en/20-third-party/emqx/login-dashboard.webp diff --git a/docs-cn/20-third-party/emqx/rule-engine.webp b/docs/en/20-third-party/emqx/rule-engine.webp similarity index 100% rename from docs-cn/20-third-party/emqx/rule-engine.webp rename to docs/en/20-third-party/emqx/rule-engine.webp diff --git a/docs-cn/20-third-party/emqx/rule-header-key-value.webp b/docs/en/20-third-party/emqx/rule-header-key-value.webp similarity index 100% rename from docs-cn/20-third-party/emqx/rule-header-key-value.webp rename to docs/en/20-third-party/emqx/rule-header-key-value.webp diff --git a/docs-cn/20-third-party/emqx/run-mock.webp b/docs/en/20-third-party/emqx/run-mock.webp similarity index 100% rename from docs-cn/20-third-party/emqx/run-mock.webp rename to docs/en/20-third-party/emqx/run-mock.webp diff --git a/docs-cn/20-third-party/add_datasource1.webp b/docs/en/20-third-party/grafana/add_datasource1.webp similarity index 100% rename from docs-cn/20-third-party/add_datasource1.webp rename to docs/en/20-third-party/grafana/add_datasource1.webp diff --git a/docs-cn/20-third-party/add_datasource2.webp b/docs/en/20-third-party/grafana/add_datasource2.webp similarity index 100% rename from docs-cn/20-third-party/add_datasource2.webp rename to docs/en/20-third-party/grafana/add_datasource2.webp diff --git a/docs-cn/20-third-party/add_datasource3.webp b/docs/en/20-third-party/grafana/add_datasource3.webp similarity index 100% rename from docs-cn/20-third-party/add_datasource3.webp rename to docs/en/20-third-party/grafana/add_datasource3.webp diff --git a/docs-cn/20-third-party/add_datasource4.webp b/docs/en/20-third-party/grafana/add_datasource4.webp similarity index 100% rename from docs-cn/20-third-party/add_datasource4.webp rename to docs/en/20-third-party/grafana/add_datasource4.webp diff --git a/docs-cn/20-third-party/create_dashboard1.webp b/docs/en/20-third-party/grafana/create_dashboard1.webp similarity index 100% rename from docs-cn/20-third-party/create_dashboard1.webp rename to docs/en/20-third-party/grafana/create_dashboard1.webp diff --git a/docs-cn/20-third-party/create_dashboard2.webp b/docs/en/20-third-party/grafana/create_dashboard2.webp similarity index 100% rename from docs-cn/20-third-party/create_dashboard2.webp rename to docs/en/20-third-party/grafana/create_dashboard2.webp diff --git a/docs-en/20-third-party/index.md b/docs/en/20-third-party/index.md similarity index 100% rename from docs-en/20-third-party/index.md rename to docs/en/20-third-party/index.md diff --git a/docs-cn/20-third-party/kafka/Kafka_Connect.webp b/docs/en/20-third-party/kafka/Kafka_Connect.webp similarity index 100% rename from docs-cn/20-third-party/kafka/Kafka_Connect.webp rename to docs/en/20-third-party/kafka/Kafka_Connect.webp diff --git a/docs-cn/20-third-party/kafka/confluentPlatform.webp b/docs/en/20-third-party/kafka/confluentPlatform.webp similarity index 100% rename from docs-cn/20-third-party/kafka/confluentPlatform.webp rename to docs/en/20-third-party/kafka/confluentPlatform.webp diff --git a/docs-cn/20-third-party/kafka/streaming-integration-with-kafka-connect.webp b/docs/en/20-third-party/kafka/streaming-integration-with-kafka-connect.webp similarity index 100% rename from docs-cn/20-third-party/kafka/streaming-integration-with-kafka-connect.webp rename to docs/en/20-third-party/kafka/streaming-integration-with-kafka-connect.webp diff --git a/docs-en/21-tdinternal/01-arch.md b/docs/en/21-tdinternal/01-arch.md similarity index 100% rename from docs-en/21-tdinternal/01-arch.md rename to docs/en/21-tdinternal/01-arch.md diff --git a/docs-en/21-tdinternal/_category_.yml b/docs/en/21-tdinternal/_category_.yml similarity index 100% rename from docs-en/21-tdinternal/_category_.yml rename to docs/en/21-tdinternal/_category_.yml diff --git a/docs-cn/21-tdinternal/dnode.webp b/docs/en/21-tdinternal/dnode.webp similarity index 100% rename from docs-cn/21-tdinternal/dnode.webp rename to docs/en/21-tdinternal/dnode.webp diff --git a/docs-en/21-tdinternal/index.md b/docs/en/21-tdinternal/index.md similarity index 100% rename from docs-en/21-tdinternal/index.md rename to docs/en/21-tdinternal/index.md diff --git a/docs-cn/21-tdinternal/message.webp b/docs/en/21-tdinternal/message.webp similarity index 100% rename from docs-cn/21-tdinternal/message.webp rename to docs/en/21-tdinternal/message.webp diff --git a/docs-cn/21-tdinternal/modules.webp b/docs/en/21-tdinternal/modules.webp similarity index 100% rename from docs-cn/21-tdinternal/modules.webp rename to docs/en/21-tdinternal/modules.webp diff --git a/docs-cn/21-tdinternal/multi_tables.webp b/docs/en/21-tdinternal/multi_tables.webp similarity index 100% rename from docs-cn/21-tdinternal/multi_tables.webp rename to docs/en/21-tdinternal/multi_tables.webp diff --git a/docs-cn/21-tdinternal/replica-forward.webp b/docs/en/21-tdinternal/replica-forward.webp similarity index 100% rename from docs-cn/21-tdinternal/replica-forward.webp rename to docs/en/21-tdinternal/replica-forward.webp diff --git a/docs-cn/21-tdinternal/replica-master.webp b/docs/en/21-tdinternal/replica-master.webp similarity index 100% rename from docs-cn/21-tdinternal/replica-master.webp rename to docs/en/21-tdinternal/replica-master.webp diff --git a/docs-cn/21-tdinternal/replica-restore.webp b/docs/en/21-tdinternal/replica-restore.webp similarity index 100% rename from docs-cn/21-tdinternal/replica-restore.webp rename to docs/en/21-tdinternal/replica-restore.webp diff --git a/docs-cn/21-tdinternal/structure.webp b/docs/en/21-tdinternal/structure.webp similarity index 100% rename from docs-cn/21-tdinternal/structure.webp rename to docs/en/21-tdinternal/structure.webp diff --git a/docs-cn/21-tdinternal/vnode.webp b/docs/en/21-tdinternal/vnode.webp similarity index 100% rename from docs-cn/21-tdinternal/vnode.webp rename to docs/en/21-tdinternal/vnode.webp diff --git a/docs-cn/21-tdinternal/write_master.webp b/docs/en/21-tdinternal/write_master.webp similarity index 100% rename from docs-cn/21-tdinternal/write_master.webp rename to docs/en/21-tdinternal/write_master.webp diff --git a/docs-cn/21-tdinternal/write_slave.webp b/docs/en/21-tdinternal/write_slave.webp similarity index 100% rename from docs-cn/21-tdinternal/write_slave.webp rename to docs/en/21-tdinternal/write_slave.webp diff --git a/docs-en/25-application/01-telegraf.md b/docs/en/25-application/01-telegraf.md similarity index 100% rename from docs-en/25-application/01-telegraf.md rename to docs/en/25-application/01-telegraf.md diff --git a/docs-en/25-application/02-collectd.md b/docs/en/25-application/02-collectd.md similarity index 100% rename from docs-en/25-application/02-collectd.md rename to docs/en/25-application/02-collectd.md diff --git a/docs-en/25-application/03-immigrate.md b/docs/en/25-application/03-immigrate.md similarity index 100% rename from docs-en/25-application/03-immigrate.md rename to docs/en/25-application/03-immigrate.md diff --git a/docs-cn/25-application/IT-DevOps-Solutions-Collectd-StatsD.webp b/docs/en/25-application/IT-DevOps-Solutions-Collectd-StatsD.webp similarity index 100% rename from docs-cn/25-application/IT-DevOps-Solutions-Collectd-StatsD.webp rename to docs/en/25-application/IT-DevOps-Solutions-Collectd-StatsD.webp diff --git a/docs-cn/25-application/IT-DevOps-Solutions-Immigrate-OpenTSDB-Arch.webp b/docs/en/25-application/IT-DevOps-Solutions-Immigrate-OpenTSDB-Arch.webp similarity index 100% rename from docs-cn/25-application/IT-DevOps-Solutions-Immigrate-OpenTSDB-Arch.webp rename to docs/en/25-application/IT-DevOps-Solutions-Immigrate-OpenTSDB-Arch.webp diff --git a/docs-cn/25-application/IT-DevOps-Solutions-Immigrate-OpenTSDB-Dashboard.webp b/docs/en/25-application/IT-DevOps-Solutions-Immigrate-OpenTSDB-Dashboard.webp similarity index 100% rename from docs-cn/25-application/IT-DevOps-Solutions-Immigrate-OpenTSDB-Dashboard.webp rename to docs/en/25-application/IT-DevOps-Solutions-Immigrate-OpenTSDB-Dashboard.webp diff --git a/docs-cn/25-application/IT-DevOps-Solutions-Immigrate-TDengine-Arch.webp b/docs/en/25-application/IT-DevOps-Solutions-Immigrate-TDengine-Arch.webp similarity index 100% rename from docs-cn/25-application/IT-DevOps-Solutions-Immigrate-TDengine-Arch.webp rename to docs/en/25-application/IT-DevOps-Solutions-Immigrate-TDengine-Arch.webp diff --git a/docs-cn/25-application/IT-DevOps-Solutions-Telegraf.webp b/docs/en/25-application/IT-DevOps-Solutions-Telegraf.webp similarity index 100% rename from docs-cn/25-application/IT-DevOps-Solutions-Telegraf.webp rename to docs/en/25-application/IT-DevOps-Solutions-Telegraf.webp diff --git a/docs-cn/25-application/IT-DevOps-Solutions-collectd-dashboard.webp b/docs/en/25-application/IT-DevOps-Solutions-collectd-dashboard.webp similarity index 100% rename from docs-cn/25-application/IT-DevOps-Solutions-collectd-dashboard.webp rename to docs/en/25-application/IT-DevOps-Solutions-collectd-dashboard.webp diff --git a/docs-cn/25-application/IT-DevOps-Solutions-statsd-dashboard.webp b/docs/en/25-application/IT-DevOps-Solutions-statsd-dashboard.webp similarity index 100% rename from docs-cn/25-application/IT-DevOps-Solutions-statsd-dashboard.webp rename to docs/en/25-application/IT-DevOps-Solutions-statsd-dashboard.webp diff --git a/docs-cn/25-application/IT-DevOps-Solutions-telegraf-dashboard.webp b/docs/en/25-application/IT-DevOps-Solutions-telegraf-dashboard.webp similarity index 100% rename from docs-cn/25-application/IT-DevOps-Solutions-telegraf-dashboard.webp rename to docs/en/25-application/IT-DevOps-Solutions-telegraf-dashboard.webp diff --git a/docs-en/25-application/_category_.yml b/docs/en/25-application/_category_.yml similarity index 100% rename from docs-en/25-application/_category_.yml rename to docs/en/25-application/_category_.yml diff --git a/docs-en/25-application/index.md b/docs/en/25-application/index.md similarity index 100% rename from docs-en/25-application/index.md rename to docs/en/25-application/index.md diff --git a/docs-en/27-train-faq/01-faq.md b/docs/en/27-train-faq/01-faq.md similarity index 100% rename from docs-en/27-train-faq/01-faq.md rename to docs/en/27-train-faq/01-faq.md diff --git a/docs-en/27-train-faq/03-docker.md b/docs/en/27-train-faq/03-docker.md similarity index 100% rename from docs-en/27-train-faq/03-docker.md rename to docs/en/27-train-faq/03-docker.md diff --git a/docs-en/27-train-faq/_category_.yml b/docs/en/27-train-faq/_category_.yml similarity index 100% rename from docs-en/27-train-faq/_category_.yml rename to docs/en/27-train-faq/_category_.yml diff --git a/docs-en/27-train-faq/index.md b/docs/en/27-train-faq/index.md similarity index 100% rename from docs-en/27-train-faq/index.md rename to docs/en/27-train-faq/index.md diff --git a/docs-examples/.gitignore b/docs/examples/.gitignore similarity index 100% rename from docs-examples/.gitignore rename to docs/examples/.gitignore diff --git a/docs-examples/R/connect_native.r b/docs/examples/R/connect_native.r similarity index 100% rename from docs-examples/R/connect_native.r rename to docs/examples/R/connect_native.r diff --git a/docs-examples/R/connect_rest.r b/docs/examples/R/connect_rest.r similarity index 100% rename from docs-examples/R/connect_rest.r rename to docs/examples/R/connect_rest.r diff --git a/docs-examples/c/.gitignore b/docs/examples/c/.gitignore similarity index 100% rename from docs-examples/c/.gitignore rename to docs/examples/c/.gitignore diff --git a/docs-examples/c/async_query_example.c b/docs/examples/c/async_query_example.c similarity index 100% rename from docs-examples/c/async_query_example.c rename to docs/examples/c/async_query_example.c diff --git a/docs-examples/c/connect_example.c b/docs/examples/c/connect_example.c similarity index 100% rename from docs-examples/c/connect_example.c rename to docs/examples/c/connect_example.c diff --git a/docs-examples/c/error_handle_example.c b/docs/examples/c/error_handle_example.c similarity index 100% rename from docs-examples/c/error_handle_example.c rename to docs/examples/c/error_handle_example.c diff --git a/docs-examples/c/insert_example.c b/docs/examples/c/insert_example.c similarity index 100% rename from docs-examples/c/insert_example.c rename to docs/examples/c/insert_example.c diff --git a/docs-examples/c/json_protocol_example.c b/docs/examples/c/json_protocol_example.c similarity index 100% rename from docs-examples/c/json_protocol_example.c rename to docs/examples/c/json_protocol_example.c diff --git a/docs-examples/c/line_example.c b/docs/examples/c/line_example.c similarity index 100% rename from docs-examples/c/line_example.c rename to docs/examples/c/line_example.c diff --git a/docs-examples/c/multi_bind_example.c b/docs/examples/c/multi_bind_example.c similarity index 100% rename from docs-examples/c/multi_bind_example.c rename to docs/examples/c/multi_bind_example.c diff --git a/docs-examples/c/query_example.c b/docs/examples/c/query_example.c similarity index 100% rename from docs-examples/c/query_example.c rename to docs/examples/c/query_example.c diff --git a/docs-examples/c/stmt_example.c b/docs/examples/c/stmt_example.c similarity index 100% rename from docs-examples/c/stmt_example.c rename to docs/examples/c/stmt_example.c diff --git a/docs-examples/c/subscribe_demo.c b/docs/examples/c/subscribe_demo.c similarity index 100% rename from docs-examples/c/subscribe_demo.c rename to docs/examples/c/subscribe_demo.c diff --git a/docs-examples/c/telnet_line_example.c b/docs/examples/c/telnet_line_example.c similarity index 100% rename from docs-examples/c/telnet_line_example.c rename to docs/examples/c/telnet_line_example.c diff --git a/docs-examples/csharp/.gitignore b/docs/examples/csharp/.gitignore similarity index 100% rename from docs-examples/csharp/.gitignore rename to docs/examples/csharp/.gitignore diff --git a/docs-examples/csharp/AsyncQueryExample.cs b/docs/examples/csharp/AsyncQueryExample.cs similarity index 100% rename from docs-examples/csharp/AsyncQueryExample.cs rename to docs/examples/csharp/AsyncQueryExample.cs diff --git a/docs-examples/csharp/ConnectExample.cs b/docs/examples/csharp/ConnectExample.cs similarity index 100% rename from docs-examples/csharp/ConnectExample.cs rename to docs/examples/csharp/ConnectExample.cs diff --git a/docs-examples/csharp/InfluxDBLineExample.cs b/docs/examples/csharp/InfluxDBLineExample.cs similarity index 100% rename from docs-examples/csharp/InfluxDBLineExample.cs rename to docs/examples/csharp/InfluxDBLineExample.cs diff --git a/docs-examples/csharp/OptsJsonExample.cs b/docs/examples/csharp/OptsJsonExample.cs similarity index 100% rename from docs-examples/csharp/OptsJsonExample.cs rename to docs/examples/csharp/OptsJsonExample.cs diff --git a/docs-examples/csharp/OptsTelnetExample.cs b/docs/examples/csharp/OptsTelnetExample.cs similarity index 100% rename from docs-examples/csharp/OptsTelnetExample.cs rename to docs/examples/csharp/OptsTelnetExample.cs diff --git a/docs-examples/csharp/QueryExample.cs b/docs/examples/csharp/QueryExample.cs similarity index 100% rename from docs-examples/csharp/QueryExample.cs rename to docs/examples/csharp/QueryExample.cs diff --git a/docs-examples/csharp/SQLInsertExample.cs b/docs/examples/csharp/SQLInsertExample.cs similarity index 100% rename from docs-examples/csharp/SQLInsertExample.cs rename to docs/examples/csharp/SQLInsertExample.cs diff --git a/docs-examples/csharp/StmtInsertExample.cs b/docs/examples/csharp/StmtInsertExample.cs similarity index 100% rename from docs-examples/csharp/StmtInsertExample.cs rename to docs/examples/csharp/StmtInsertExample.cs diff --git a/docs-examples/csharp/SubscribeDemo.cs b/docs/examples/csharp/SubscribeDemo.cs similarity index 100% rename from docs-examples/csharp/SubscribeDemo.cs rename to docs/examples/csharp/SubscribeDemo.cs diff --git a/docs-examples/csharp/asyncquery.csproj b/docs/examples/csharp/asyncquery.csproj similarity index 100% rename from docs-examples/csharp/asyncquery.csproj rename to docs/examples/csharp/asyncquery.csproj diff --git a/docs-examples/csharp/connect.csproj b/docs/examples/csharp/connect.csproj similarity index 100% rename from docs-examples/csharp/connect.csproj rename to docs/examples/csharp/connect.csproj diff --git a/docs-examples/csharp/influxdbline.csproj b/docs/examples/csharp/influxdbline.csproj similarity index 100% rename from docs-examples/csharp/influxdbline.csproj rename to docs/examples/csharp/influxdbline.csproj diff --git a/docs-examples/csharp/optsjson.csproj b/docs/examples/csharp/optsjson.csproj similarity index 100% rename from docs-examples/csharp/optsjson.csproj rename to docs/examples/csharp/optsjson.csproj diff --git a/docs-examples/csharp/optstelnet.csproj b/docs/examples/csharp/optstelnet.csproj similarity index 100% rename from docs-examples/csharp/optstelnet.csproj rename to docs/examples/csharp/optstelnet.csproj diff --git a/docs-examples/csharp/query.csproj b/docs/examples/csharp/query.csproj similarity index 100% rename from docs-examples/csharp/query.csproj rename to docs/examples/csharp/query.csproj diff --git a/docs-examples/csharp/sqlinsert.csproj b/docs/examples/csharp/sqlinsert.csproj similarity index 100% rename from docs-examples/csharp/sqlinsert.csproj rename to docs/examples/csharp/sqlinsert.csproj diff --git a/docs-examples/csharp/stmtinsert.csproj b/docs/examples/csharp/stmtinsert.csproj similarity index 100% rename from docs-examples/csharp/stmtinsert.csproj rename to docs/examples/csharp/stmtinsert.csproj diff --git a/docs-examples/csharp/subscribe.csproj b/docs/examples/csharp/subscribe.csproj similarity index 100% rename from docs-examples/csharp/subscribe.csproj rename to docs/examples/csharp/subscribe.csproj diff --git a/docs-examples/go/.gitignore b/docs/examples/go/.gitignore similarity index 100% rename from docs-examples/go/.gitignore rename to docs/examples/go/.gitignore diff --git a/docs-examples/go/connect/afconn/main.go b/docs/examples/go/connect/afconn/main.go similarity index 100% rename from docs-examples/go/connect/afconn/main.go rename to docs/examples/go/connect/afconn/main.go diff --git a/docs-examples/go/connect/cgoexample/main.go b/docs/examples/go/connect/cgoexample/main.go similarity index 100% rename from docs-examples/go/connect/cgoexample/main.go rename to docs/examples/go/connect/cgoexample/main.go diff --git a/docs-examples/go/connect/restexample/main.go b/docs/examples/go/connect/restexample/main.go similarity index 100% rename from docs-examples/go/connect/restexample/main.go rename to docs/examples/go/connect/restexample/main.go diff --git a/docs-examples/go/connect/wrapper/main.go b/docs/examples/go/connect/wrapper/main.go similarity index 100% rename from docs-examples/go/connect/wrapper/main.go rename to docs/examples/go/connect/wrapper/main.go diff --git a/docs-examples/go/go.mod b/docs/examples/go/go.mod similarity index 100% rename from docs-examples/go/go.mod rename to docs/examples/go/go.mod diff --git a/docs-examples/go/insert/json/main.go b/docs/examples/go/insert/json/main.go similarity index 100% rename from docs-examples/go/insert/json/main.go rename to docs/examples/go/insert/json/main.go diff --git a/docs-examples/go/insert/line/main.go b/docs/examples/go/insert/line/main.go similarity index 100% rename from docs-examples/go/insert/line/main.go rename to docs/examples/go/insert/line/main.go diff --git a/docs-examples/go/insert/sql/main.go b/docs/examples/go/insert/sql/main.go similarity index 100% rename from docs-examples/go/insert/sql/main.go rename to docs/examples/go/insert/sql/main.go diff --git a/docs-examples/go/insert/stmt/main.go b/docs/examples/go/insert/stmt/main.go similarity index 100% rename from docs-examples/go/insert/stmt/main.go rename to docs/examples/go/insert/stmt/main.go diff --git a/docs-examples/go/insert/telnet/main.go b/docs/examples/go/insert/telnet/main.go similarity index 100% rename from docs-examples/go/insert/telnet/main.go rename to docs/examples/go/insert/telnet/main.go diff --git a/docs-examples/go/query/async/main.go b/docs/examples/go/query/async/main.go similarity index 100% rename from docs-examples/go/query/async/main.go rename to docs/examples/go/query/async/main.go diff --git a/docs-examples/go/query/sync/main.go b/docs/examples/go/query/sync/main.go similarity index 100% rename from docs-examples/go/query/sync/main.go rename to docs/examples/go/query/sync/main.go diff --git a/docs-examples/go/rest/opentsdbjson/main.go b/docs/examples/go/rest/opentsdbjson/main.go similarity index 100% rename from docs-examples/go/rest/opentsdbjson/main.go rename to docs/examples/go/rest/opentsdbjson/main.go diff --git a/docs-examples/go/sub/main.go b/docs/examples/go/sub/main.go similarity index 100% rename from docs-examples/go/sub/main.go rename to docs/examples/go/sub/main.go diff --git a/docs-examples/java/.gitignore b/docs/examples/java/.gitignore similarity index 100% rename from docs-examples/java/.gitignore rename to docs/examples/java/.gitignore diff --git a/docs-examples/java/pom.xml b/docs/examples/java/pom.xml similarity index 100% rename from docs-examples/java/pom.xml rename to docs/examples/java/pom.xml diff --git a/docs-examples/java/src/main/java/com/taos/example/JNIConnectExample.java b/docs/examples/java/src/main/java/com/taos/example/JNIConnectExample.java similarity index 100% rename from docs-examples/java/src/main/java/com/taos/example/JNIConnectExample.java rename to docs/examples/java/src/main/java/com/taos/example/JNIConnectExample.java diff --git a/docs-examples/java/src/main/java/com/taos/example/JSONProtocolExample.java b/docs/examples/java/src/main/java/com/taos/example/JSONProtocolExample.java similarity index 100% rename from docs-examples/java/src/main/java/com/taos/example/JSONProtocolExample.java rename to docs/examples/java/src/main/java/com/taos/example/JSONProtocolExample.java diff --git a/docs-examples/java/src/main/java/com/taos/example/LineProtocolExample.java b/docs/examples/java/src/main/java/com/taos/example/LineProtocolExample.java similarity index 100% rename from docs-examples/java/src/main/java/com/taos/example/LineProtocolExample.java rename to docs/examples/java/src/main/java/com/taos/example/LineProtocolExample.java diff --git a/docs-examples/java/src/main/java/com/taos/example/RESTConnectExample.java b/docs/examples/java/src/main/java/com/taos/example/RESTConnectExample.java similarity index 100% rename from docs-examples/java/src/main/java/com/taos/example/RESTConnectExample.java rename to docs/examples/java/src/main/java/com/taos/example/RESTConnectExample.java diff --git a/docs-examples/java/src/main/java/com/taos/example/RestInsertExample.java b/docs/examples/java/src/main/java/com/taos/example/RestInsertExample.java similarity index 100% rename from docs-examples/java/src/main/java/com/taos/example/RestInsertExample.java rename to docs/examples/java/src/main/java/com/taos/example/RestInsertExample.java diff --git a/docs-examples/java/src/main/java/com/taos/example/RestQueryExample.java b/docs/examples/java/src/main/java/com/taos/example/RestQueryExample.java similarity index 100% rename from docs-examples/java/src/main/java/com/taos/example/RestQueryExample.java rename to docs/examples/java/src/main/java/com/taos/example/RestQueryExample.java diff --git a/docs-examples/java/src/main/java/com/taos/example/StmtInsertExample.java b/docs/examples/java/src/main/java/com/taos/example/StmtInsertExample.java similarity index 100% rename from docs-examples/java/src/main/java/com/taos/example/StmtInsertExample.java rename to docs/examples/java/src/main/java/com/taos/example/StmtInsertExample.java diff --git a/docs-examples/java/src/main/java/com/taos/example/SubscribeDemo.java b/docs/examples/java/src/main/java/com/taos/example/SubscribeDemo.java similarity index 100% rename from docs-examples/java/src/main/java/com/taos/example/SubscribeDemo.java rename to docs/examples/java/src/main/java/com/taos/example/SubscribeDemo.java diff --git a/docs-examples/java/src/main/java/com/taos/example/TelnetLineProtocolExample.java b/docs/examples/java/src/main/java/com/taos/example/TelnetLineProtocolExample.java similarity index 100% rename from docs-examples/java/src/main/java/com/taos/example/TelnetLineProtocolExample.java rename to docs/examples/java/src/main/java/com/taos/example/TelnetLineProtocolExample.java diff --git a/docs-examples/java/src/main/java/com/taos/example/WSConnectExample.java b/docs/examples/java/src/main/java/com/taos/example/WSConnectExample.java similarity index 100% rename from docs-examples/java/src/main/java/com/taos/example/WSConnectExample.java rename to docs/examples/java/src/main/java/com/taos/example/WSConnectExample.java diff --git a/docs-examples/java/src/test/java/com/taos/test/TestAll.java b/docs/examples/java/src/test/java/com/taos/test/TestAll.java similarity index 100% rename from docs-examples/java/src/test/java/com/taos/test/TestAll.java rename to docs/examples/java/src/test/java/com/taos/test/TestAll.java diff --git a/docs-examples/node/.gitignore b/docs/examples/node/.gitignore similarity index 100% rename from docs-examples/node/.gitignore rename to docs/examples/node/.gitignore diff --git a/docs-examples/node/nativeexample/async_query_example.js b/docs/examples/node/nativeexample/async_query_example.js similarity index 100% rename from docs-examples/node/nativeexample/async_query_example.js rename to docs/examples/node/nativeexample/async_query_example.js diff --git a/docs-examples/node/nativeexample/connect.js b/docs/examples/node/nativeexample/connect.js similarity index 100% rename from docs-examples/node/nativeexample/connect.js rename to docs/examples/node/nativeexample/connect.js diff --git a/docs-examples/node/nativeexample/influxdb_line_example.js b/docs/examples/node/nativeexample/influxdb_line_example.js similarity index 100% rename from docs-examples/node/nativeexample/influxdb_line_example.js rename to docs/examples/node/nativeexample/influxdb_line_example.js diff --git a/docs-examples/node/nativeexample/insert_example.js b/docs/examples/node/nativeexample/insert_example.js similarity index 100% rename from docs-examples/node/nativeexample/insert_example.js rename to docs/examples/node/nativeexample/insert_example.js diff --git a/docs-examples/node/nativeexample/multi_bind_example.js b/docs/examples/node/nativeexample/multi_bind_example.js similarity index 100% rename from docs-examples/node/nativeexample/multi_bind_example.js rename to docs/examples/node/nativeexample/multi_bind_example.js diff --git a/docs-examples/node/nativeexample/opentsdb_json_example.js b/docs/examples/node/nativeexample/opentsdb_json_example.js similarity index 100% rename from docs-examples/node/nativeexample/opentsdb_json_example.js rename to docs/examples/node/nativeexample/opentsdb_json_example.js diff --git a/docs-examples/node/nativeexample/opentsdb_telnet_example.js b/docs/examples/node/nativeexample/opentsdb_telnet_example.js similarity index 100% rename from docs-examples/node/nativeexample/opentsdb_telnet_example.js rename to docs/examples/node/nativeexample/opentsdb_telnet_example.js diff --git a/docs-examples/node/nativeexample/param_bind_example.js b/docs/examples/node/nativeexample/param_bind_example.js similarity index 100% rename from docs-examples/node/nativeexample/param_bind_example.js rename to docs/examples/node/nativeexample/param_bind_example.js diff --git a/docs-examples/node/nativeexample/query_example.js b/docs/examples/node/nativeexample/query_example.js similarity index 100% rename from docs-examples/node/nativeexample/query_example.js rename to docs/examples/node/nativeexample/query_example.js diff --git a/docs-examples/node/nativeexample/subscribe_demo.js b/docs/examples/node/nativeexample/subscribe_demo.js similarity index 100% rename from docs-examples/node/nativeexample/subscribe_demo.js rename to docs/examples/node/nativeexample/subscribe_demo.js diff --git a/docs-examples/node/package.json b/docs/examples/node/package.json similarity index 100% rename from docs-examples/node/package.json rename to docs/examples/node/package.json diff --git a/docs-examples/node/restexample/connect.js b/docs/examples/node/restexample/connect.js similarity index 100% rename from docs-examples/node/restexample/connect.js rename to docs/examples/node/restexample/connect.js diff --git a/docs-examples/other/mock.js b/docs/examples/other/mock.js similarity index 100% rename from docs-examples/other/mock.js rename to docs/examples/other/mock.js diff --git a/docs-examples/php/connect.php b/docs/examples/php/connect.php similarity index 100% rename from docs-examples/php/connect.php rename to docs/examples/php/connect.php diff --git a/docs-examples/php/insert.php b/docs/examples/php/insert.php similarity index 100% rename from docs-examples/php/insert.php rename to docs/examples/php/insert.php diff --git a/docs-examples/php/insert_stmt.php b/docs/examples/php/insert_stmt.php similarity index 100% rename from docs-examples/php/insert_stmt.php rename to docs/examples/php/insert_stmt.php diff --git a/docs-examples/php/query.php b/docs/examples/php/query.php similarity index 100% rename from docs-examples/php/query.php rename to docs/examples/php/query.php diff --git a/docs-examples/python/.gitignore b/docs/examples/python/.gitignore similarity index 100% rename from docs-examples/python/.gitignore rename to docs/examples/python/.gitignore diff --git a/docs-examples/python/.gitkeep b/docs/examples/python/.gitkeep similarity index 100% rename from docs-examples/python/.gitkeep rename to docs/examples/python/.gitkeep diff --git a/docs-examples/python/async_query_example.py b/docs/examples/python/async_query_example.py similarity index 100% rename from docs-examples/python/async_query_example.py rename to docs/examples/python/async_query_example.py diff --git a/docs-examples/python/bind_param_example.py b/docs/examples/python/bind_param_example.py similarity index 100% rename from docs-examples/python/bind_param_example.py rename to docs/examples/python/bind_param_example.py diff --git a/docs-examples/python/conn_native_pandas.py b/docs/examples/python/conn_native_pandas.py similarity index 100% rename from docs-examples/python/conn_native_pandas.py rename to docs/examples/python/conn_native_pandas.py diff --git a/docs-examples/python/conn_rest_pandas.py b/docs/examples/python/conn_rest_pandas.py similarity index 100% rename from docs-examples/python/conn_rest_pandas.py rename to docs/examples/python/conn_rest_pandas.py diff --git a/docs-examples/python/connect_example.py b/docs/examples/python/connect_example.py similarity index 100% rename from docs-examples/python/connect_example.py rename to docs/examples/python/connect_example.py diff --git a/docs-examples/python/connect_native_reference.py b/docs/examples/python/connect_native_reference.py similarity index 100% rename from docs-examples/python/connect_native_reference.py rename to docs/examples/python/connect_native_reference.py diff --git a/docs-examples/python/connect_rest_examples.py b/docs/examples/python/connect_rest_examples.py similarity index 100% rename from docs-examples/python/connect_rest_examples.py rename to docs/examples/python/connect_rest_examples.py diff --git a/docs-examples/python/connection_usage_native_reference.py b/docs/examples/python/connection_usage_native_reference.py similarity index 100% rename from docs-examples/python/connection_usage_native_reference.py rename to docs/examples/python/connection_usage_native_reference.py diff --git a/docs-examples/python/cursor_usage_native_reference.py b/docs/examples/python/cursor_usage_native_reference.py similarity index 100% rename from docs-examples/python/cursor_usage_native_reference.py rename to docs/examples/python/cursor_usage_native_reference.py diff --git a/docs-examples/python/handle_exception.py b/docs/examples/python/handle_exception.py similarity index 100% rename from docs-examples/python/handle_exception.py rename to docs/examples/python/handle_exception.py diff --git a/docs-examples/python/json_protocol_example.py b/docs/examples/python/json_protocol_example.py similarity index 100% rename from docs-examples/python/json_protocol_example.py rename to docs/examples/python/json_protocol_example.py diff --git a/docs-examples/python/line_protocol_example.py b/docs/examples/python/line_protocol_example.py similarity index 100% rename from docs-examples/python/line_protocol_example.py rename to docs/examples/python/line_protocol_example.py diff --git a/docs-examples/python/multi_bind_example.py b/docs/examples/python/multi_bind_example.py similarity index 100% rename from docs-examples/python/multi_bind_example.py rename to docs/examples/python/multi_bind_example.py diff --git a/docs-examples/python/native_insert_example.py b/docs/examples/python/native_insert_example.py similarity index 100% rename from docs-examples/python/native_insert_example.py rename to docs/examples/python/native_insert_example.py diff --git a/docs-examples/python/query_example.py b/docs/examples/python/query_example.py similarity index 100% rename from docs-examples/python/query_example.py rename to docs/examples/python/query_example.py diff --git a/docs-examples/python/rest_client_example.py b/docs/examples/python/rest_client_example.py similarity index 100% rename from docs-examples/python/rest_client_example.py rename to docs/examples/python/rest_client_example.py diff --git a/docs-examples/python/result_set_examples.py b/docs/examples/python/result_set_examples.py similarity index 100% rename from docs-examples/python/result_set_examples.py rename to docs/examples/python/result_set_examples.py diff --git a/docs-examples/python/subscribe_demo.py b/docs/examples/python/subscribe_demo.py similarity index 100% rename from docs-examples/python/subscribe_demo.py rename to docs/examples/python/subscribe_demo.py diff --git a/docs-examples/python/telnet_line_protocol_example.py b/docs/examples/python/telnet_line_protocol_example.py similarity index 100% rename from docs-examples/python/telnet_line_protocol_example.py rename to docs/examples/python/telnet_line_protocol_example.py diff --git a/docs-examples/rust/Cargo.toml b/docs/examples/rust/Cargo.toml similarity index 100% rename from docs-examples/rust/Cargo.toml rename to docs/examples/rust/Cargo.toml diff --git a/docs-examples/rust/nativeexample/Cargo.toml b/docs/examples/rust/nativeexample/Cargo.toml similarity index 100% rename from docs-examples/rust/nativeexample/Cargo.toml rename to docs/examples/rust/nativeexample/Cargo.toml diff --git a/docs-examples/rust/nativeexample/examples/connect.rs b/docs/examples/rust/nativeexample/examples/connect.rs similarity index 100% rename from docs-examples/rust/nativeexample/examples/connect.rs rename to docs/examples/rust/nativeexample/examples/connect.rs diff --git a/docs-examples/rust/nativeexample/examples/stmt_example.rs b/docs/examples/rust/nativeexample/examples/stmt_example.rs similarity index 100% rename from docs-examples/rust/nativeexample/examples/stmt_example.rs rename to docs/examples/rust/nativeexample/examples/stmt_example.rs diff --git a/docs-examples/rust/nativeexample/examples/subscribe_demo.rs b/docs/examples/rust/nativeexample/examples/subscribe_demo.rs similarity index 100% rename from docs-examples/rust/nativeexample/examples/subscribe_demo.rs rename to docs/examples/rust/nativeexample/examples/subscribe_demo.rs diff --git a/docs-examples/rust/nativeexample/src/main.rs b/docs/examples/rust/nativeexample/src/main.rs similarity index 100% rename from docs-examples/rust/nativeexample/src/main.rs rename to docs/examples/rust/nativeexample/src/main.rs diff --git a/docs-examples/rust/restexample/Cargo.toml b/docs/examples/rust/restexample/Cargo.toml similarity index 100% rename from docs-examples/rust/restexample/Cargo.toml rename to docs/examples/rust/restexample/Cargo.toml diff --git a/docs-examples/rust/restexample/examples/connect.rs b/docs/examples/rust/restexample/examples/connect.rs similarity index 100% rename from docs-examples/rust/restexample/examples/connect.rs rename to docs/examples/rust/restexample/examples/connect.rs diff --git a/docs-examples/rust/restexample/examples/insert_example.rs b/docs/examples/rust/restexample/examples/insert_example.rs similarity index 100% rename from docs-examples/rust/restexample/examples/insert_example.rs rename to docs/examples/rust/restexample/examples/insert_example.rs diff --git a/docs-examples/rust/restexample/examples/query_example.rs b/docs/examples/rust/restexample/examples/query_example.rs similarity index 100% rename from docs-examples/rust/restexample/examples/query_example.rs rename to docs/examples/rust/restexample/examples/query_example.rs diff --git a/docs-examples/rust/restexample/src/main.rs b/docs/examples/rust/restexample/src/main.rs similarity index 100% rename from docs-examples/rust/restexample/src/main.rs rename to docs/examples/rust/restexample/src/main.rs diff --git a/docs-examples/rust/schemalessexample/Cargo.toml b/docs/examples/rust/schemalessexample/Cargo.toml similarity index 100% rename from docs-examples/rust/schemalessexample/Cargo.toml rename to docs/examples/rust/schemalessexample/Cargo.toml diff --git a/docs-examples/rust/schemalessexample/examples/influxdb_line_example.rs b/docs/examples/rust/schemalessexample/examples/influxdb_line_example.rs similarity index 100% rename from docs-examples/rust/schemalessexample/examples/influxdb_line_example.rs rename to docs/examples/rust/schemalessexample/examples/influxdb_line_example.rs diff --git a/docs-examples/rust/schemalessexample/examples/opentsdb_json_example.rs b/docs/examples/rust/schemalessexample/examples/opentsdb_json_example.rs similarity index 100% rename from docs-examples/rust/schemalessexample/examples/opentsdb_json_example.rs rename to docs/examples/rust/schemalessexample/examples/opentsdb_json_example.rs diff --git a/docs-examples/rust/schemalessexample/examples/opentsdb_telnet_example.rs b/docs/examples/rust/schemalessexample/examples/opentsdb_telnet_example.rs similarity index 100% rename from docs-examples/rust/schemalessexample/examples/opentsdb_telnet_example.rs rename to docs/examples/rust/schemalessexample/examples/opentsdb_telnet_example.rs diff --git a/docs-examples/rust/schemalessexample/src/main.rs b/docs/examples/rust/schemalessexample/src/main.rs similarity index 100% rename from docs-examples/rust/schemalessexample/src/main.rs rename to docs/examples/rust/schemalessexample/src/main.rs diff --git a/docs-cn/01-index.md b/docs/zh/01-index.md similarity index 100% rename from docs-cn/01-index.md rename to docs/zh/01-index.md diff --git a/docs-cn/02-intro.md b/docs/zh/02-intro.md similarity index 100% rename from docs-cn/02-intro.md rename to docs/zh/02-intro.md diff --git a/docs-cn/04-concept/_category_.yml b/docs/zh/04-concept/_category_.yml similarity index 100% rename from docs-cn/04-concept/_category_.yml rename to docs/zh/04-concept/_category_.yml diff --git a/docs-cn/04-concept/index.md b/docs/zh/04-concept/index.md similarity index 100% rename from docs-cn/04-concept/index.md rename to docs/zh/04-concept/index.md diff --git a/docs-cn/05-get-started/_apt_get_install.mdx b/docs/zh/05-get-started/_apt_get_install.mdx similarity index 100% rename from docs-cn/05-get-started/_apt_get_install.mdx rename to docs/zh/05-get-started/_apt_get_install.mdx diff --git a/docs-cn/05-get-started/_category_.yml b/docs/zh/05-get-started/_category_.yml similarity index 100% rename from docs-cn/05-get-started/_category_.yml rename to docs/zh/05-get-started/_category_.yml diff --git a/docs-cn/05-get-started/_pkg_install.mdx b/docs/zh/05-get-started/_pkg_install.mdx similarity index 100% rename from docs-cn/05-get-started/_pkg_install.mdx rename to docs/zh/05-get-started/_pkg_install.mdx diff --git a/docs-cn/05-get-started/index.md b/docs/zh/05-get-started/index.md similarity index 100% rename from docs-cn/05-get-started/index.md rename to docs/zh/05-get-started/index.md diff --git a/docs-cn/07-develop/01-connect/_category_.yml b/docs/zh/07-develop/01-connect/_category_.yml similarity index 100% rename from docs-cn/07-develop/01-connect/_category_.yml rename to docs/zh/07-develop/01-connect/_category_.yml diff --git a/docs/zh/07-develop/01-connect/_connect_c.mdx b/docs/zh/07-develop/01-connect/_connect_c.mdx new file mode 100644 index 0000000000..1b145538dc --- /dev/null +++ b/docs/zh/07-develop/01-connect/_connect_c.mdx @@ -0,0 +1,3 @@ +```c title="原生连接" +{{#include docs/examples/c/connect_example.c}} +``` diff --git a/docs-cn/07-develop/01-connect/_connect_cs.mdx b/docs/zh/07-develop/01-connect/_connect_cs.mdx similarity index 63% rename from docs-cn/07-develop/01-connect/_connect_cs.mdx rename to docs/zh/07-develop/01-connect/_connect_cs.mdx index 821820e8fe..13b8a5dff2 100644 --- a/docs-cn/07-develop/01-connect/_connect_cs.mdx +++ b/docs/zh/07-develop/01-connect/_connect_cs.mdx @@ -1,5 +1,5 @@ ```csharp title="原生连接" -{{#include docs-examples/csharp/ConnectExample.cs}} +{{#include docs/examples/csharp/ConnectExample.cs}} ``` :::info diff --git a/docs-cn/07-develop/01-connect/_connect_go.mdx b/docs/zh/07-develop/01-connect/_connect_go.mdx similarity index 65% rename from docs-cn/07-develop/01-connect/_connect_go.mdx rename to docs/zh/07-develop/01-connect/_connect_go.mdx index 478768caaa..d69720496d 100644 --- a/docs-cn/07-develop/01-connect/_connect_go.mdx +++ b/docs/zh/07-develop/01-connect/_connect_go.mdx @@ -1,11 +1,11 @@ #### 使用数据库访问统一接口 ```go title="原生连接" -{{#include docs-examples/go/connect/cgoexample/main.go}} +{{#include docs/examples/go/connect/cgoexample/main.go}} ``` ```go title="REST 连接" -{{#include docs-examples/go/connect/restexample/main.go}} +{{#include docs/examples/go/connect/restexample/main.go}} ``` #### 使用高级封装 @@ -13,5 +13,5 @@ 也可以使用 driver-go 的 af 包建立连接。这个模块封装了 TDengine 的高级功能, 如:参数绑定、订阅等。 ```go title="使用 af 包建立原生连接" -{{#include docs-examples/go/connect/afconn/main.go}} +{{#include docs/examples/go/connect/afconn/main.go}} ``` diff --git a/docs-cn/07-develop/01-connect/_connect_java.mdx b/docs/zh/07-develop/01-connect/_connect_java.mdx similarity index 65% rename from docs-cn/07-develop/01-connect/_connect_java.mdx rename to docs/zh/07-develop/01-connect/_connect_java.mdx index 635f39ceb2..f5b8ea1cc2 100644 --- a/docs-cn/07-develop/01-connect/_connect_java.mdx +++ b/docs/zh/07-develop/01-connect/_connect_java.mdx @@ -1,15 +1,15 @@ ```java title="原生连接" -{{#include docs-examples/java/src/main/java/com/taos/example/JNIConnectExample.java}} +{{#include docs/examples/java/src/main/java/com/taos/example/JNIConnectExample.java}} ``` ```java title="REST 连接" -{{#include docs-examples/java/src/main/java/com/taos/example/RESTConnectExample.java:main}} +{{#include docs/examples/java/src/main/java/com/taos/example/RESTConnectExample.java:main}} ``` 使用 REST 连接时,如果查询数据量比较大,还可开启批量拉取功能。 ```java title="开启批量拉取功能" {4} -{{#include docs-examples/java/src/main/java/com/taos/example/WSConnectExample.java:main}} +{{#include docs/examples/java/src/main/java/com/taos/example/WSConnectExample.java:main}} ``` 更多连接参数配置,参考[Java 连接器](/reference/connector/java) diff --git a/docs/zh/07-develop/01-connect/_connect_node.mdx b/docs/zh/07-develop/01-connect/_connect_node.mdx new file mode 100644 index 0000000000..3a856d4022 --- /dev/null +++ b/docs/zh/07-develop/01-connect/_connect_node.mdx @@ -0,0 +1,7 @@ +```js title="原生连接" +{{#include docs/examples/node/nativeexample/connect.js}} +``` + +```js title="REST 连接" +{{#include docs/examples/node/restexample/connect.js}} +``` diff --git a/docs/zh/07-develop/01-connect/_connect_php.mdx b/docs/zh/07-develop/01-connect/_connect_php.mdx new file mode 100644 index 0000000000..dbad72bc19 --- /dev/null +++ b/docs/zh/07-develop/01-connect/_connect_php.mdx @@ -0,0 +1,3 @@ +```php title="原生连接" +{{#include docs/examples/php/connect.php}} +``` diff --git a/docs/zh/07-develop/01-connect/_connect_python.mdx b/docs/zh/07-develop/01-connect/_connect_python.mdx new file mode 100644 index 0000000000..b331f4648c --- /dev/null +++ b/docs/zh/07-develop/01-connect/_connect_python.mdx @@ -0,0 +1,3 @@ +```python title="原生连接" +{{#include docs/examples/python/connect_example.py}} +``` diff --git a/docs/zh/07-develop/01-connect/_connect_r.mdx b/docs/zh/07-develop/01-connect/_connect_r.mdx new file mode 100644 index 0000000000..ba72dc848c --- /dev/null +++ b/docs/zh/07-develop/01-connect/_connect_r.mdx @@ -0,0 +1,3 @@ +```r title="原生连接" +{{#include docs/examples/R/connect_native.r:demo}} +``` diff --git a/docs-cn/07-develop/01-connect/_connect_rust.mdx b/docs/zh/07-develop/01-connect/_connect_rust.mdx similarity index 78% rename from docs-cn/07-develop/01-connect/_connect_rust.mdx rename to docs/zh/07-develop/01-connect/_connect_rust.mdx index 9e64724c17..25f178a285 100644 --- a/docs-cn/07-develop/01-connect/_connect_rust.mdx +++ b/docs/zh/07-develop/01-connect/_connect_rust.mdx @@ -1,5 +1,5 @@ ```rust title="原生连接/REST 连接" -{{#include docs-examples/rust/nativeexample/examples/connect.rs}} +{{#include docs/examples/rust/nativeexample/examples/connect.rs}} ``` :::note diff --git a/docs-cn/07-develop/01-connect/index.md b/docs/zh/07-develop/01-connect/index.md similarity index 100% rename from docs-cn/07-develop/01-connect/index.md rename to docs/zh/07-develop/01-connect/index.md diff --git a/docs-cn/07-develop/02-model/_category_.yml b/docs/zh/07-develop/02-model/_category_.yml similarity index 100% rename from docs-cn/07-develop/02-model/_category_.yml rename to docs/zh/07-develop/02-model/_category_.yml diff --git a/docs-cn/07-develop/02-model/index.mdx b/docs/zh/07-develop/02-model/index.mdx similarity index 100% rename from docs-cn/07-develop/02-model/index.mdx rename to docs/zh/07-develop/02-model/index.mdx diff --git a/docs-cn/07-develop/03-insert-data/01-sql-writing.mdx b/docs/zh/07-develop/03-insert-data/01-sql-writing.mdx similarity index 100% rename from docs-cn/07-develop/03-insert-data/01-sql-writing.mdx rename to docs/zh/07-develop/03-insert-data/01-sql-writing.mdx diff --git a/docs-cn/07-develop/03-insert-data/02-influxdb-line.mdx b/docs/zh/07-develop/03-insert-data/02-influxdb-line.mdx similarity index 100% rename from docs-cn/07-develop/03-insert-data/02-influxdb-line.mdx rename to docs/zh/07-develop/03-insert-data/02-influxdb-line.mdx diff --git a/docs-cn/07-develop/03-insert-data/03-opentsdb-telnet.mdx b/docs/zh/07-develop/03-insert-data/03-opentsdb-telnet.mdx similarity index 100% rename from docs-cn/07-develop/03-insert-data/03-opentsdb-telnet.mdx rename to docs/zh/07-develop/03-insert-data/03-opentsdb-telnet.mdx diff --git a/docs-cn/07-develop/03-insert-data/04-opentsdb-json.mdx b/docs/zh/07-develop/03-insert-data/04-opentsdb-json.mdx similarity index 100% rename from docs-cn/07-develop/03-insert-data/04-opentsdb-json.mdx rename to docs/zh/07-develop/03-insert-data/04-opentsdb-json.mdx diff --git a/docs/zh/07-develop/03-insert-data/_c_line.mdx b/docs/zh/07-develop/03-insert-data/_c_line.mdx new file mode 100644 index 0000000000..7f2f0d5dd8 --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_c_line.mdx @@ -0,0 +1,3 @@ +```c +{{#include docs/examples/c/line_example.c:main}} +``` \ No newline at end of file diff --git a/docs/zh/07-develop/03-insert-data/_c_opts_json.mdx b/docs/zh/07-develop/03-insert-data/_c_opts_json.mdx new file mode 100644 index 0000000000..34b1d8ab3c --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_c_opts_json.mdx @@ -0,0 +1,3 @@ +```c +{{#include docs/examples/c/json_protocol_example.c:main}} +``` \ No newline at end of file diff --git a/docs/zh/07-develop/03-insert-data/_c_opts_telnet.mdx b/docs/zh/07-develop/03-insert-data/_c_opts_telnet.mdx new file mode 100644 index 0000000000..6bda068d12 --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_c_opts_telnet.mdx @@ -0,0 +1,3 @@ +```c +{{#include docs/examples/c/telnet_line_example.c:main}} +``` \ No newline at end of file diff --git a/docs/zh/07-develop/03-insert-data/_c_sql.mdx b/docs/zh/07-develop/03-insert-data/_c_sql.mdx new file mode 100644 index 0000000000..4e55c3387e --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_c_sql.mdx @@ -0,0 +1,3 @@ +```c +{{#include docs/examples/c/insert_example.c}} +``` \ No newline at end of file diff --git a/docs/zh/07-develop/03-insert-data/_c_stmt.mdx b/docs/zh/07-develop/03-insert-data/_c_stmt.mdx new file mode 100644 index 0000000000..78f2d20dfb --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_c_stmt.mdx @@ -0,0 +1,6 @@ +```c title=一次绑定一行 +{{#include docs/examples/c/stmt_example.c}} +``` +```c title=一次绑定多行 72:117 +{{#include docs/examples/c/multi_bind_example.c}} +``` \ No newline at end of file diff --git a/docs-cn/07-develop/03-insert-data/_category_.yml b/docs/zh/07-develop/03-insert-data/_category_.yml similarity index 100% rename from docs-cn/07-develop/03-insert-data/_category_.yml rename to docs/zh/07-develop/03-insert-data/_category_.yml diff --git a/docs/zh/07-develop/03-insert-data/_cs_line.mdx b/docs/zh/07-develop/03-insert-data/_cs_line.mdx new file mode 100644 index 0000000000..71f46c62be --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_cs_line.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs/examples/csharp/InfluxDBLineExample.cs}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_cs_opts_json.mdx b/docs/zh/07-develop/03-insert-data/_cs_opts_json.mdx new file mode 100644 index 0000000000..8d80d042c9 --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_cs_opts_json.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs/examples/csharp/OptsJsonExample.cs}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_cs_opts_telnet.mdx b/docs/zh/07-develop/03-insert-data/_cs_opts_telnet.mdx new file mode 100644 index 0000000000..cff32abf1f --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_cs_opts_telnet.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs/examples/csharp/OptsTelnetExample.cs}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_cs_sql.mdx b/docs/zh/07-develop/03-insert-data/_cs_sql.mdx new file mode 100644 index 0000000000..1dc7bb3d13 --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_cs_sql.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs/examples/csharp/SQLInsertExample.cs}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_cs_stmt.mdx b/docs/zh/07-develop/03-insert-data/_cs_stmt.mdx new file mode 100644 index 0000000000..229c874ab9 --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_cs_stmt.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs/examples/csharp/StmtInsertExample.cs}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_go_line.mdx b/docs/zh/07-develop/03-insert-data/_go_line.mdx new file mode 100644 index 0000000000..df2afc0e87 --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_go_line.mdx @@ -0,0 +1,3 @@ +```go +{{#include docs/examples/go/insert/line/main.go}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_go_opts_json.mdx b/docs/zh/07-develop/03-insert-data/_go_opts_json.mdx new file mode 100644 index 0000000000..362ce43051 --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_go_opts_json.mdx @@ -0,0 +1,3 @@ +```go +{{#include docs/examples/go/insert/json/main.go}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_go_opts_telnet.mdx b/docs/zh/07-develop/03-insert-data/_go_opts_telnet.mdx new file mode 100644 index 0000000000..518ea4c816 --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_go_opts_telnet.mdx @@ -0,0 +1,3 @@ +```go +{{#include docs/examples/go/insert/telnet/main.go}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_go_sql.mdx b/docs/zh/07-develop/03-insert-data/_go_sql.mdx new file mode 100644 index 0000000000..02f4d4e2ba --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_go_sql.mdx @@ -0,0 +1,3 @@ +```go +{{#include docs/examples/go/insert/sql/main.go}} +``` diff --git a/docs-cn/07-develop/03-insert-data/_go_stmt.mdx b/docs/zh/07-develop/03-insert-data/_go_stmt.mdx similarity index 77% rename from docs-cn/07-develop/03-insert-data/_go_stmt.mdx rename to docs/zh/07-develop/03-insert-data/_go_stmt.mdx index 7bb6792d6d..d65a96549f 100644 --- a/docs-cn/07-develop/03-insert-data/_go_stmt.mdx +++ b/docs/zh/07-develop/03-insert-data/_go_stmt.mdx @@ -1,5 +1,5 @@ ```go -{{#include docs-examples/go/insert/stmt/main.go}} +{{#include docs/examples/go/insert/stmt/main.go}} ``` :::tip diff --git a/docs/zh/07-develop/03-insert-data/_java_line.mdx b/docs/zh/07-develop/03-insert-data/_java_line.mdx new file mode 100644 index 0000000000..17f759d30f --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_java_line.mdx @@ -0,0 +1,3 @@ +```java +{{#include docs/examples/java/src/main/java/com/taos/example/LineProtocolExample.java}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_java_opts_json.mdx b/docs/zh/07-develop/03-insert-data/_java_opts_json.mdx new file mode 100644 index 0000000000..1fc0adc202 --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_java_opts_json.mdx @@ -0,0 +1,3 @@ +```java +{{#include docs/examples/java/src/main/java/com/taos/example/JSONProtocolExample.java}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_java_opts_telnet.mdx b/docs/zh/07-develop/03-insert-data/_java_opts_telnet.mdx new file mode 100644 index 0000000000..b68f54b4e8 --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_java_opts_telnet.mdx @@ -0,0 +1,3 @@ +```java +{{#include docs/examples/java/src/main/java/com/taos/example/TelnetLineProtocolExample.java}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_java_sql.mdx b/docs/zh/07-develop/03-insert-data/_java_sql.mdx new file mode 100644 index 0000000000..636c7e00eb --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_java_sql.mdx @@ -0,0 +1,3 @@ +```java +{{#include docs/examples/java/src/main/java/com/taos/example/RestInsertExample.java:insert}} +``` \ No newline at end of file diff --git a/docs/zh/07-develop/03-insert-data/_java_stmt.mdx b/docs/zh/07-develop/03-insert-data/_java_stmt.mdx new file mode 100644 index 0000000000..2f6a337690 --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_java_stmt.mdx @@ -0,0 +1,3 @@ +```java +{{#include docs/examples/java/src/main/java/com/taos/example/StmtInsertExample.java}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_js_line.mdx b/docs/zh/07-develop/03-insert-data/_js_line.mdx new file mode 100644 index 0000000000..cc138a76bd --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_js_line.mdx @@ -0,0 +1,3 @@ +```js +{{#include docs/examples/node/nativeexample/influxdb_line_example.js}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_js_opts_json.mdx b/docs/zh/07-develop/03-insert-data/_js_opts_json.mdx new file mode 100644 index 0000000000..cb3c275ce8 --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_js_opts_json.mdx @@ -0,0 +1,3 @@ +```js +{{#include docs/examples/node/nativeexample/opentsdb_json_example.js}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_js_opts_telnet.mdx b/docs/zh/07-develop/03-insert-data/_js_opts_telnet.mdx new file mode 100644 index 0000000000..db96742f31 --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_js_opts_telnet.mdx @@ -0,0 +1,3 @@ +```js +{{#include docs/examples/node/nativeexample/opentsdb_telnet_example.js}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_js_sql.mdx b/docs/zh/07-develop/03-insert-data/_js_sql.mdx new file mode 100644 index 0000000000..a9a12f5d2c --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_js_sql.mdx @@ -0,0 +1,3 @@ +```js +{{#include docs/examples/node/nativeexample/insert_example.js}} +``` diff --git a/docs-cn/07-develop/03-insert-data/_js_stmt.mdx b/docs/zh/07-develop/03-insert-data/_js_stmt.mdx similarity index 65% rename from docs-cn/07-develop/03-insert-data/_js_stmt.mdx rename to docs/zh/07-develop/03-insert-data/_js_stmt.mdx index 17a6c9785c..b94ae121c5 100644 --- a/docs-cn/07-develop/03-insert-data/_js_stmt.mdx +++ b/docs/zh/07-develop/03-insert-data/_js_stmt.mdx @@ -1,9 +1,9 @@ ```js title=一次绑定一行 -{{#include docs-examples/node/nativeexample/param_bind_example.js}} +{{#include docs/examples/node/nativeexample/param_bind_example.js}} ``` ```js title=一次绑定多行 -{{#include docs-examples/node/nativeexample/multi_bind_example.js:insertData}} +{{#include docs/examples/node/nativeexample/multi_bind_example.js:insertData}} ``` :::info diff --git a/docs/zh/07-develop/03-insert-data/_php_sql.mdx b/docs/zh/07-develop/03-insert-data/_php_sql.mdx new file mode 100644 index 0000000000..78cd663ec2 --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_php_sql.mdx @@ -0,0 +1,3 @@ +```php +{{#include docs/examples/php/insert.php}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_php_stmt.mdx b/docs/zh/07-develop/03-insert-data/_php_stmt.mdx new file mode 100644 index 0000000000..3bb7b2f8da --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_php_stmt.mdx @@ -0,0 +1,3 @@ +```php +{{#include docs/examples/php/insert_stmt.php}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_py_line.mdx b/docs/zh/07-develop/03-insert-data/_py_line.mdx new file mode 100644 index 0000000000..85f7e32e66 --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_py_line.mdx @@ -0,0 +1,3 @@ +```py +{{#include docs/examples/python/line_protocol_example.py}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_py_opts_json.mdx b/docs/zh/07-develop/03-insert-data/_py_opts_json.mdx new file mode 100644 index 0000000000..195c7090c0 --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_py_opts_json.mdx @@ -0,0 +1,3 @@ +```py +{{#include docs/examples/python/json_protocol_example.py}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_py_opts_telnet.mdx b/docs/zh/07-develop/03-insert-data/_py_opts_telnet.mdx new file mode 100644 index 0000000000..3bae1ea57b --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_py_opts_telnet.mdx @@ -0,0 +1,3 @@ +```py +{{#include docs/examples/python/telnet_line_protocol_example.py}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_py_sql.mdx b/docs/zh/07-develop/03-insert-data/_py_sql.mdx new file mode 100644 index 0000000000..1557e3994b --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_py_sql.mdx @@ -0,0 +1,3 @@ +```py +{{#include docs/examples/python/native_insert_example.py}} +``` diff --git a/docs-cn/07-develop/03-insert-data/_py_stmt.mdx b/docs/zh/07-develop/03-insert-data/_py_stmt.mdx similarity index 65% rename from docs-cn/07-develop/03-insert-data/_py_stmt.mdx rename to docs/zh/07-develop/03-insert-data/_py_stmt.mdx index 8241ea86bc..e244288401 100644 --- a/docs-cn/07-develop/03-insert-data/_py_stmt.mdx +++ b/docs/zh/07-develop/03-insert-data/_py_stmt.mdx @@ -1,9 +1,9 @@ ```py title=一次绑定一行 -{{#include docs-examples/python/bind_param_example.py}} +{{#include docs/examples/python/bind_param_example.py}} ``` ```py title=一次绑定多行 -{{#include docs-examples/python/multi_bind_example.py:bind_batch}} +{{#include docs/examples/python/multi_bind_example.py:bind_batch}} ``` :::info diff --git a/docs/zh/07-develop/03-insert-data/_rust_line.mdx b/docs/zh/07-develop/03-insert-data/_rust_line.mdx new file mode 100644 index 0000000000..dbb35d76bc --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_rust_line.mdx @@ -0,0 +1,3 @@ +```rust +{{#include docs/examples/rust/schemalessexample/examples/influxdb_line_example.rs}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_rust_opts_json.mdx b/docs/zh/07-develop/03-insert-data/_rust_opts_json.mdx new file mode 100644 index 0000000000..cc2055510b --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_rust_opts_json.mdx @@ -0,0 +1,3 @@ +```rust +{{#include docs/examples/rust/schemalessexample/examples/opentsdb_json_example.rs}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_rust_opts_telnet.mdx b/docs/zh/07-develop/03-insert-data/_rust_opts_telnet.mdx new file mode 100644 index 0000000000..109c0c5d01 --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_rust_opts_telnet.mdx @@ -0,0 +1,3 @@ +```rust +{{#include docs/examples/rust/schemalessexample/examples/opentsdb_telnet_example.rs}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_rust_sql.mdx b/docs/zh/07-develop/03-insert-data/_rust_sql.mdx new file mode 100644 index 0000000000..fb59a48265 --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_rust_sql.mdx @@ -0,0 +1,3 @@ +```rust +{{#include docs/examples/rust/restexample/examples/insert_example.rs}} +``` diff --git a/docs/zh/07-develop/03-insert-data/_rust_stmt.mdx b/docs/zh/07-develop/03-insert-data/_rust_stmt.mdx new file mode 100644 index 0000000000..a889b56745 --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_rust_stmt.mdx @@ -0,0 +1,3 @@ +```rust +{{#include docs/examples/rust/nativeexample/examples/stmt_example.rs}} +``` diff --git a/docs-cn/07-develop/03-insert-data/index.md b/docs/zh/07-develop/03-insert-data/index.md similarity index 100% rename from docs-cn/07-develop/03-insert-data/index.md rename to docs/zh/07-develop/03-insert-data/index.md diff --git a/docs/zh/07-develop/04-query-data/_c.mdx b/docs/zh/07-develop/04-query-data/_c.mdx new file mode 100644 index 0000000000..c51557ef29 --- /dev/null +++ b/docs/zh/07-develop/04-query-data/_c.mdx @@ -0,0 +1,3 @@ +```c +{{#include docs/examples/c/query_example.c}} +``` \ No newline at end of file diff --git a/docs/zh/07-develop/04-query-data/_c_async.mdx b/docs/zh/07-develop/04-query-data/_c_async.mdx new file mode 100644 index 0000000000..641a53e82d --- /dev/null +++ b/docs/zh/07-develop/04-query-data/_c_async.mdx @@ -0,0 +1,3 @@ +```c +{{#include docs/examples/c/async_query_example.c:demo}} +``` \ No newline at end of file diff --git a/docs-cn/07-develop/04-query-data/_category_.yml b/docs/zh/07-develop/04-query-data/_category_.yml similarity index 100% rename from docs-cn/07-develop/04-query-data/_category_.yml rename to docs/zh/07-develop/04-query-data/_category_.yml diff --git a/docs/zh/07-develop/04-query-data/_cs.mdx b/docs/zh/07-develop/04-query-data/_cs.mdx new file mode 100644 index 0000000000..4bb582ecbf --- /dev/null +++ b/docs/zh/07-develop/04-query-data/_cs.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs/examples/csharp/QueryExample.cs}} +``` diff --git a/docs/zh/07-develop/04-query-data/_cs_async.mdx b/docs/zh/07-develop/04-query-data/_cs_async.mdx new file mode 100644 index 0000000000..3ecf635fd3 --- /dev/null +++ b/docs/zh/07-develop/04-query-data/_cs_async.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs/examples/csharp/AsyncQueryExample.cs}} +``` diff --git a/docs/zh/07-develop/04-query-data/_go.mdx b/docs/zh/07-develop/04-query-data/_go.mdx new file mode 100644 index 0000000000..b43894a1eb --- /dev/null +++ b/docs/zh/07-develop/04-query-data/_go.mdx @@ -0,0 +1,3 @@ +```go +{{#include docs/examples/go/query/sync/main.go}} +``` diff --git a/docs/zh/07-develop/04-query-data/_go_async.mdx b/docs/zh/07-develop/04-query-data/_go_async.mdx new file mode 100644 index 0000000000..3fbc6f5b6d --- /dev/null +++ b/docs/zh/07-develop/04-query-data/_go_async.mdx @@ -0,0 +1,3 @@ +```go +{{#include docs/examples/go/query/async/main.go}} +``` diff --git a/docs/zh/07-develop/04-query-data/_java.mdx b/docs/zh/07-develop/04-query-data/_java.mdx new file mode 100644 index 0000000000..74de32658c --- /dev/null +++ b/docs/zh/07-develop/04-query-data/_java.mdx @@ -0,0 +1,3 @@ +```java +{{#include docs/examples/java/src/main/java/com/taos/example/RestQueryExample.java}} +``` diff --git a/docs/zh/07-develop/04-query-data/_js.mdx b/docs/zh/07-develop/04-query-data/_js.mdx new file mode 100644 index 0000000000..5883d378e7 --- /dev/null +++ b/docs/zh/07-develop/04-query-data/_js.mdx @@ -0,0 +1,3 @@ +```js +{{#include docs/examples/node/nativeexample/query_example.js}} +``` diff --git a/docs/zh/07-develop/04-query-data/_js_async.mdx b/docs/zh/07-develop/04-query-data/_js_async.mdx new file mode 100644 index 0000000000..4b0f54a034 --- /dev/null +++ b/docs/zh/07-develop/04-query-data/_js_async.mdx @@ -0,0 +1,3 @@ +```js +{{#include docs/examples/node/nativeexample/async_query_example.js}} +``` diff --git a/docs/zh/07-develop/04-query-data/_php.mdx b/docs/zh/07-develop/04-query-data/_php.mdx new file mode 100644 index 0000000000..bcafd1cfbc --- /dev/null +++ b/docs/zh/07-develop/04-query-data/_php.mdx @@ -0,0 +1,3 @@ +```go +{{#include docs/examples/php/query.php}} +``` diff --git a/docs-cn/07-develop/04-query-data/_py.mdx b/docs/zh/07-develop/04-query-data/_py.mdx similarity index 54% rename from docs-cn/07-develop/04-query-data/_py.mdx rename to docs/zh/07-develop/04-query-data/_py.mdx index 6a1bacdd3e..7184c66b8e 100644 --- a/docs-cn/07-develop/04-query-data/_py.mdx +++ b/docs/zh/07-develop/04-query-data/_py.mdx @@ -1,11 +1,11 @@ 通过迭代逐行获取查询结果。 ```py -{{#include docs-examples/python/query_example.py:iter}} +{{#include docs/examples/python/query_example.py:iter}} ``` 一次获取所有查询结果,并把每一行转化为一个字典返回。 ```py -{{#include docs-examples/python/query_example.py:fetch_all}} +{{#include docs/examples/python/query_example.py:fetch_all}} ``` diff --git a/docs-cn/07-develop/04-query-data/_py_async.mdx b/docs/zh/07-develop/04-query-data/_py_async.mdx similarity index 60% rename from docs-cn/07-develop/04-query-data/_py_async.mdx rename to docs/zh/07-develop/04-query-data/_py_async.mdx index 2399a50df6..dd323ef364 100644 --- a/docs-cn/07-develop/04-query-data/_py_async.mdx +++ b/docs/zh/07-develop/04-query-data/_py_async.mdx @@ -1,5 +1,5 @@ ```py -{{#include docs-examples/python/async_query_example.py}} +{{#include docs/examples/python/async_query_example.py}} ``` :::note diff --git a/docs/zh/07-develop/04-query-data/_rust.mdx b/docs/zh/07-develop/04-query-data/_rust.mdx new file mode 100644 index 0000000000..cab1b403fb --- /dev/null +++ b/docs/zh/07-develop/04-query-data/_rust.mdx @@ -0,0 +1,3 @@ +```rust +{{#include docs/examples/rust/restexample/examples/query_example.rs}} +``` diff --git a/docs-cn/07-develop/04-query-data/index.mdx b/docs/zh/07-develop/04-query-data/index.mdx similarity index 100% rename from docs-cn/07-develop/04-query-data/index.mdx rename to docs/zh/07-develop/04-query-data/index.mdx diff --git a/docs-cn/07-develop/06-continuous-query.mdx b/docs/zh/07-develop/06-continuous-query.mdx similarity index 100% rename from docs-cn/07-develop/06-continuous-query.mdx rename to docs/zh/07-develop/06-continuous-query.mdx diff --git a/docs-cn/07-develop/07-subscribe.md b/docs/zh/07-develop/07-subscribe.md similarity index 100% rename from docs-cn/07-develop/07-subscribe.md rename to docs/zh/07-develop/07-subscribe.md diff --git a/docs-cn/07-develop/08-cache.md b/docs/zh/07-develop/08-cache.md similarity index 100% rename from docs-cn/07-develop/08-cache.md rename to docs/zh/07-develop/08-cache.md diff --git a/docs-cn/07-develop/09-udf.md b/docs/zh/07-develop/09-udf.md similarity index 100% rename from docs-cn/07-develop/09-udf.md rename to docs/zh/07-develop/09-udf.md diff --git a/docs-cn/07-develop/_category_.yml b/docs/zh/07-develop/_category_.yml similarity index 100% rename from docs-cn/07-develop/_category_.yml rename to docs/zh/07-develop/_category_.yml diff --git a/docs/zh/07-develop/_sub_c.mdx b/docs/zh/07-develop/_sub_c.mdx new file mode 100644 index 0000000000..da492a0269 --- /dev/null +++ b/docs/zh/07-develop/_sub_c.mdx @@ -0,0 +1,3 @@ +```c +{{#include docs/examples/c/subscribe_demo.c}} +``` \ No newline at end of file diff --git a/docs/zh/07-develop/_sub_cs.mdx b/docs/zh/07-develop/_sub_cs.mdx new file mode 100644 index 0000000000..a435ea0273 --- /dev/null +++ b/docs/zh/07-develop/_sub_cs.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs/examples/csharp/SubscribeDemo.cs}} +``` \ No newline at end of file diff --git a/docs/zh/07-develop/_sub_go.mdx b/docs/zh/07-develop/_sub_go.mdx new file mode 100644 index 0000000000..34b2aefd92 --- /dev/null +++ b/docs/zh/07-develop/_sub_go.mdx @@ -0,0 +1,3 @@ +```go +{{#include docs/examples/go/sub/main.go}} +``` \ No newline at end of file diff --git a/docs-cn/07-develop/_sub_java.mdx b/docs/zh/07-develop/_sub_java.mdx similarity index 72% rename from docs-cn/07-develop/_sub_java.mdx rename to docs/zh/07-develop/_sub_java.mdx index 1ee0cb1a21..52df23f7dd 100644 --- a/docs-cn/07-develop/_sub_java.mdx +++ b/docs/zh/07-develop/_sub_java.mdx @@ -1,5 +1,5 @@ ```java -{{#include docs-examples/java/src/main/java/com/taos/example/SubscribeDemo.java}} +{{#include docs/examples/java/src/main/java/com/taos/example/SubscribeDemo.java}} ``` :::note 目前 Java 接口没有提供异步订阅模式,但用户程序可以通过创建 `TimerTask` 等方式达到同样的效果。 diff --git a/docs/zh/07-develop/_sub_node.mdx b/docs/zh/07-develop/_sub_node.mdx new file mode 100644 index 0000000000..3eeff0922a --- /dev/null +++ b/docs/zh/07-develop/_sub_node.mdx @@ -0,0 +1,3 @@ +```js +{{#include docs/examples/node/nativeexample/subscribe_demo.js}} +``` \ No newline at end of file diff --git a/docs/zh/07-develop/_sub_python.mdx b/docs/zh/07-develop/_sub_python.mdx new file mode 100644 index 0000000000..490b76fca6 --- /dev/null +++ b/docs/zh/07-develop/_sub_python.mdx @@ -0,0 +1,3 @@ +```py +{{#include docs/examples/python/subscribe_demo.py}} +``` \ No newline at end of file diff --git a/docs/zh/07-develop/_sub_rust.mdx b/docs/zh/07-develop/_sub_rust.mdx new file mode 100644 index 0000000000..afb8d79daa --- /dev/null +++ b/docs/zh/07-develop/_sub_rust.mdx @@ -0,0 +1,3 @@ +```rs +{{#include docs/examples/rust/nativeexample/examples/subscribe_demo.rs}} +``` \ No newline at end of file diff --git a/docs-cn/07-develop/index.md b/docs/zh/07-develop/index.md similarity index 100% rename from docs-cn/07-develop/index.md rename to docs/zh/07-develop/index.md diff --git a/docs-cn/10-cluster/01-deploy.md b/docs/zh/10-cluster/01-deploy.md similarity index 100% rename from docs-cn/10-cluster/01-deploy.md rename to docs/zh/10-cluster/01-deploy.md diff --git a/docs-cn/10-cluster/02-cluster-mgmt.md b/docs/zh/10-cluster/02-cluster-mgmt.md similarity index 100% rename from docs-cn/10-cluster/02-cluster-mgmt.md rename to docs/zh/10-cluster/02-cluster-mgmt.md diff --git a/docs-cn/10-cluster/03-ha-and-lb.md b/docs/zh/10-cluster/03-ha-and-lb.md similarity index 100% rename from docs-cn/10-cluster/03-ha-and-lb.md rename to docs/zh/10-cluster/03-ha-and-lb.md diff --git a/docs-cn/10-cluster/_category_.yml b/docs/zh/10-cluster/_category_.yml similarity index 100% rename from docs-cn/10-cluster/_category_.yml rename to docs/zh/10-cluster/_category_.yml diff --git a/docs-cn/10-cluster/index.md b/docs/zh/10-cluster/index.md similarity index 100% rename from docs-cn/10-cluster/index.md rename to docs/zh/10-cluster/index.md diff --git a/docs-cn/12-taos-sql/01-data-type.md b/docs/zh/12-taos-sql/01-data-type.md similarity index 100% rename from docs-cn/12-taos-sql/01-data-type.md rename to docs/zh/12-taos-sql/01-data-type.md diff --git a/docs-cn/12-taos-sql/02-database.md b/docs/zh/12-taos-sql/02-database.md similarity index 100% rename from docs-cn/12-taos-sql/02-database.md rename to docs/zh/12-taos-sql/02-database.md diff --git a/docs-cn/12-taos-sql/03-table.md b/docs/zh/12-taos-sql/03-table.md similarity index 100% rename from docs-cn/12-taos-sql/03-table.md rename to docs/zh/12-taos-sql/03-table.md diff --git a/docs-cn/12-taos-sql/04-stable.md b/docs/zh/12-taos-sql/04-stable.md similarity index 100% rename from docs-cn/12-taos-sql/04-stable.md rename to docs/zh/12-taos-sql/04-stable.md diff --git a/docs-cn/12-taos-sql/05-insert.md b/docs/zh/12-taos-sql/05-insert.md similarity index 100% rename from docs-cn/12-taos-sql/05-insert.md rename to docs/zh/12-taos-sql/05-insert.md diff --git a/docs-cn/12-taos-sql/06-select.md b/docs/zh/12-taos-sql/06-select.md similarity index 100% rename from docs-cn/12-taos-sql/06-select.md rename to docs/zh/12-taos-sql/06-select.md diff --git a/docs-cn/07-develop/05-delete-data.mdx b/docs/zh/12-taos-sql/08-delete-data.mdx similarity index 100% rename from docs-cn/07-develop/05-delete-data.mdx rename to docs/zh/12-taos-sql/08-delete-data.mdx diff --git a/docs-cn/12-taos-sql/07-function.md b/docs/zh/12-taos-sql/10-function.md similarity index 100% rename from docs-cn/12-taos-sql/07-function.md rename to docs/zh/12-taos-sql/10-function.md diff --git a/docs-cn/12-taos-sql/08-interval.md b/docs/zh/12-taos-sql/12-interval.md similarity index 100% rename from docs-cn/12-taos-sql/08-interval.md rename to docs/zh/12-taos-sql/12-interval.md diff --git a/docs-cn/12-taos-sql/13-operators.md b/docs/zh/12-taos-sql/13-operators.md similarity index 100% rename from docs-cn/12-taos-sql/13-operators.md rename to docs/zh/12-taos-sql/13-operators.md diff --git a/docs-cn/12-taos-sql/09-limit.md b/docs/zh/12-taos-sql/14-limit.md similarity index 100% rename from docs-cn/12-taos-sql/09-limit.md rename to docs/zh/12-taos-sql/14-limit.md diff --git a/docs-cn/12-taos-sql/10-json.md b/docs/zh/12-taos-sql/16-json.md similarity index 100% rename from docs-cn/12-taos-sql/10-json.md rename to docs/zh/12-taos-sql/16-json.md diff --git a/docs-cn/12-taos-sql/11-escape.md b/docs/zh/12-taos-sql/18-escape.md similarity index 100% rename from docs-cn/12-taos-sql/11-escape.md rename to docs/zh/12-taos-sql/18-escape.md diff --git a/docs-cn/12-taos-sql/12-keywords.md b/docs/zh/12-taos-sql/20-keywords.md similarity index 60% rename from docs-cn/12-taos-sql/12-keywords.md rename to docs/zh/12-taos-sql/20-keywords.md index 5c68e5da7e..202f223b45 100644 --- a/docs-cn/12-taos-sql/12-keywords.md +++ b/docs/zh/12-taos-sql/20-keywords.md @@ -45,48 +45,274 @@ title: TDengine 参数限制与保留关键字 目前 TDengine 有将近 200 个内部保留关键字,这些关键字无论大小写均不可以用作库名、表名、STable 名、数据列名及标签列名等。这些关键字列表如下: -| 关键字列表 | | | | | -| ----------- | ---------- | --------- | ---------- | ------------ | -| ABORT | CREATE | IGNORE | NULL | STAR | -| ACCOUNT | CTIME | IMMEDIATE | OF | STATE | -| ACCOUNTS | DATABASE | IMPORT | OFFSET | STATEMENT | -| ADD | DATABASES | IN | OR | STATE_WINDOW | -| AFTER | DAYS | INITIALLY | ORDER | STORAGE | -| ALL | DBS | INSERT | PARTITIONS | STREAM | -| ALTER | DEFERRED | INSTEAD | PASS | STREAMS | -| AND | DELIMITERS | INT | PLUS | STRING | -| AS | DESC | INTEGER | PPS | SYNCDB | -| ASC | DESCRIBE | INTERVAL | PRECISION | TABLE | -| ATTACH | DETACH | INTO | PREV | TABLES | -| BEFORE | DISTINCT | IS | PRIVILEGE | TAG | -| BEGIN | DIVIDE | ISNULL | QTIME | TAGS | -| BETWEEN | DNODE | JOIN | QUERIES | TBNAME | -| BIGINT | DNODES | KEEP | QUERY | TIMES | -| BINARY | DOT | KEY | QUORUM | TIMESTAMP | -| BITAND | DOUBLE | KILL | RAISE | TINYINT | -| BITNOT | DROP | LE | REM | TOPIC | -| BITOR | EACH | LIKE | REPLACE | TOPICS | -| BLOCKS | END | LIMIT | REPLICA | TRIGGER | -| BOOL | EQ | LINEAR | RESET | TSERIES | -| BY | EXISTS | LOCAL | RESTRICT | UMINUS | -| CACHE | EXPLAIN | LP | ROW | UNION | -| CACHELAST | FAIL | LSHIFT | RP | UNSIGNED | -| CASCADE | FILE | LT | RSHIFT | UPDATE | -| CHANGE | FILL | MATCH | SCORES | UPLUS | -| CLUSTER | FLOAT | MAXROWS | SELECT | USE | -| COLON | FOR | MINROWS | SEMI | USER | -| COLUMN | FROM | MINUS | SESSION | USERS | -| COMMA | FSYNC | MNODES | SET | USING | -| COMP | GE | MODIFY | SHOW | VALUES | -| COMPACT | GLOB | MODULES | SLASH | VARIABLE | -| CONCAT | GRANTS | NCHAR | SLIDING | VARIABLES | -| CONFLICT | GROUP | NE | SLIMIT | VGROUPS | -| CONNECTION | GT | NONE | SMALLINT | VIEW | -| CONNECTIONS | HAVING | NOT | SOFFSET | VNODES | -| CONNS | ID | NOTNULL | STABLE | WAL | -| COPY | IF | NOW | STABLES | WHERE | -| _C0 | _QSTART | _QSTOP | _QDURATION | _WSTART | -| _WSTOP | _WDURATION | _ROWTS | +### A + +- ABORT +- ACCOUNT +- ACCOUNTS +- ADD +- AFTER +- ALL +- ALTER +- AND +- AS +- ASC +- ATTACH + +### B + +- BEFORE +- BEGIN +- BETWEEN +- BIGINT +- BINARY +- BITAND +- BITNOT +- BITOR +- BLOCKS +- BOOL +- BY + +### C + +- CACHE +- CACHELAST +- CASCADE +- CHANGE +- CLUSTER +- COLON +- COLUMN +- COMMA +- COMP +- COMPACT +- CONCAT +- CONFLICT +- CONNECTION +- CONNECTIONS +- CONNS +- COPY +- CREATE +- CTIME + +### D + +- DATABASE +- DATABASES +- DAYS +- DBS +- DEFERRED +- DELETE +- DELIMITERS +- DESC +- DESCRIBE +- DETACH +- DISTINCT +- DIVIDE +- DNODE +- DNODES +- DOT +- DOUBLE +- DROP + +### E + +- END +- EQ +- EXISTS +- EXPLAIN + +### F + +- FAIL +- FILE +- FILL +- FLOAT +- FOR +- FROM +- FSYNC + +### G + +- GE +- GLOB +- GRANTS +- GROUP +- GT + +### H + +- HAVING + +### I + +- ID +- IF +- IGNORE +- IMMEDIA +- IMPORT +- IN +- INITIAL +- INSERT +- INSTEAD +- INT +- INTEGER +- INTERVA +- INTO +- IS +- ISNULL + +### J + +- JOIN + +### K + +- KEEP +- KEY +- KILL + +### L + +- LE +- LIKE +- LIMIT +- LINEAR +- LOCAL +- LP +- LSHIFT +- LT + +### M + +- MATCH +- MAXROWS +- MINROWS +- MINUS +- MNODES +- MODIFY +- MODULES + +### N + +- NE +- NONE +- NOT +- NOTNULL +- NOW +- NULL + +### O + +- OF +- OFFSET +- OR +- ORDER + +### P + +- PARTITION +- PASS +- PLUS +- PPS +- PRECISION +- PREV +- PRIVILEGE + +### Q + +- QTIME +- QUERIE +- QUERY +- QUORUM + +### R + +- RAISE +- REM +- REPLACE +- REPLICA +- RESET +- RESTRIC +- ROW +- RP +- RSHIFT + +### S + +- SCORES +- SELECT +- SEMI +- SESSION +- SET +- SHOW +- SLASH +- SLIDING +- SLIMIT +- SMALLIN +- SOFFSET +- STable +- STableS +- STAR +- STATE +- STATEMEN +- STATE_WI +- STORAGE +- STREAM +- STREAMS +- STRING +- SYNCDB + +### T + +- TABLE +- TABLES +- TAG +- TAGS +- TBNAME +- TIMES +- TIMESTAMP +- TINYINT +- TOPIC +- TOPICS +- TRIGGER +- TSERIES + +### U + +- UMINUS +- UNION +- UNSIGNED +- UPDATE +- UPLUS +- USE +- USER +- USERS +- USING + +### V + +- VALUES +- VARIABLE +- VARIABLES +- VGROUPS +- VIEW +- VNODES + +### W + +- WAL +- WHERE + +### _ + +- _C0 +- _QSTART +- _QSTOP +- _QDURATION +- _WSTART +- _WSTOP +- _WDURATION + ## 特殊说明 ### TBNAME diff --git a/docs-cn/12-taos-sql/_category_.yml b/docs/zh/12-taos-sql/_category_.yml similarity index 100% rename from docs-cn/12-taos-sql/_category_.yml rename to docs/zh/12-taos-sql/_category_.yml diff --git a/docs-cn/12-taos-sql/index.md b/docs/zh/12-taos-sql/index.md similarity index 100% rename from docs-cn/12-taos-sql/index.md rename to docs/zh/12-taos-sql/index.md diff --git a/docs-en/12-taos-sql/timewindow-1.webp b/docs/zh/12-taos-sql/timewindow-1.webp similarity index 100% rename from docs-en/12-taos-sql/timewindow-1.webp rename to docs/zh/12-taos-sql/timewindow-1.webp diff --git a/docs-en/12-taos-sql/timewindow-2.webp b/docs/zh/12-taos-sql/timewindow-2.webp similarity index 100% rename from docs-en/12-taos-sql/timewindow-2.webp rename to docs/zh/12-taos-sql/timewindow-2.webp diff --git a/docs-en/12-taos-sql/timewindow-3.webp b/docs/zh/12-taos-sql/timewindow-3.webp similarity index 100% rename from docs-en/12-taos-sql/timewindow-3.webp rename to docs/zh/12-taos-sql/timewindow-3.webp diff --git a/docs-cn/13-operation/01-pkg-install.md b/docs/zh/13-operation/01-pkg-install.md similarity index 100% rename from docs-cn/13-operation/01-pkg-install.md rename to docs/zh/13-operation/01-pkg-install.md diff --git a/docs-cn/13-operation/02-planning.mdx b/docs/zh/13-operation/02-planning.mdx similarity index 100% rename from docs-cn/13-operation/02-planning.mdx rename to docs/zh/13-operation/02-planning.mdx diff --git a/docs-cn/13-operation/03-tolerance.md b/docs/zh/13-operation/03-tolerance.md similarity index 100% rename from docs-cn/13-operation/03-tolerance.md rename to docs/zh/13-operation/03-tolerance.md diff --git a/docs-cn/13-operation/06-admin.md b/docs/zh/13-operation/06-admin.md similarity index 100% rename from docs-cn/13-operation/06-admin.md rename to docs/zh/13-operation/06-admin.md diff --git a/docs-cn/13-operation/07-import.md b/docs/zh/13-operation/07-import.md similarity index 100% rename from docs-cn/13-operation/07-import.md rename to docs/zh/13-operation/07-import.md diff --git a/docs-cn/13-operation/08-export.md b/docs/zh/13-operation/08-export.md similarity index 100% rename from docs-cn/13-operation/08-export.md rename to docs/zh/13-operation/08-export.md diff --git a/docs-cn/13-operation/09-status.md b/docs/zh/13-operation/09-status.md similarity index 100% rename from docs-cn/13-operation/09-status.md rename to docs/zh/13-operation/09-status.md diff --git a/docs-cn/13-operation/10-monitor.md b/docs/zh/13-operation/10-monitor.md similarity index 100% rename from docs-cn/13-operation/10-monitor.md rename to docs/zh/13-operation/10-monitor.md diff --git a/docs-cn/13-operation/17-diagnose.md b/docs/zh/13-operation/17-diagnose.md similarity index 100% rename from docs-cn/13-operation/17-diagnose.md rename to docs/zh/13-operation/17-diagnose.md diff --git a/docs-cn/13-operation/_category_.yml b/docs/zh/13-operation/_category_.yml similarity index 100% rename from docs-cn/13-operation/_category_.yml rename to docs/zh/13-operation/_category_.yml diff --git a/docs-cn/13-operation/index.md b/docs/zh/13-operation/index.md similarity index 100% rename from docs-cn/13-operation/index.md rename to docs/zh/13-operation/index.md diff --git a/docs-cn/14-reference/02-rest-api/02-rest-api.mdx b/docs/zh/14-reference/02-rest-api/02-rest-api.mdx similarity index 100% rename from docs-cn/14-reference/02-rest-api/02-rest-api.mdx rename to docs/zh/14-reference/02-rest-api/02-rest-api.mdx diff --git a/docs-en/14-reference/02-rest-api/_category_.yml b/docs/zh/14-reference/02-rest-api/_category_.yml similarity index 100% rename from docs-en/14-reference/02-rest-api/_category_.yml rename to docs/zh/14-reference/02-rest-api/_category_.yml diff --git a/docs-cn/14-reference/03-connector/03-connector.mdx b/docs/zh/14-reference/03-connector/03-connector.mdx similarity index 100% rename from docs-cn/14-reference/03-connector/03-connector.mdx rename to docs/zh/14-reference/03-connector/03-connector.mdx diff --git a/docs-cn/14-reference/03-connector/_category_.yml b/docs/zh/14-reference/03-connector/_category_.yml similarity index 100% rename from docs-cn/14-reference/03-connector/_category_.yml rename to docs/zh/14-reference/03-connector/_category_.yml diff --git a/docs-cn/14-reference/03-connector/_linux_install.mdx b/docs/zh/14-reference/03-connector/_linux_install.mdx similarity index 100% rename from docs-cn/14-reference/03-connector/_linux_install.mdx rename to docs/zh/14-reference/03-connector/_linux_install.mdx diff --git a/docs-cn/14-reference/03-connector/_preparition.mdx b/docs/zh/14-reference/03-connector/_preparition.mdx similarity index 100% rename from docs-cn/14-reference/03-connector/_preparition.mdx rename to docs/zh/14-reference/03-connector/_preparition.mdx diff --git a/docs-cn/14-reference/03-connector/_verify_linux.mdx b/docs/zh/14-reference/03-connector/_verify_linux.mdx similarity index 100% rename from docs-cn/14-reference/03-connector/_verify_linux.mdx rename to docs/zh/14-reference/03-connector/_verify_linux.mdx diff --git a/docs-cn/14-reference/03-connector/_verify_windows.mdx b/docs/zh/14-reference/03-connector/_verify_windows.mdx similarity index 100% rename from docs-cn/14-reference/03-connector/_verify_windows.mdx rename to docs/zh/14-reference/03-connector/_verify_windows.mdx diff --git a/docs-cn/14-reference/03-connector/_windows_install.mdx b/docs/zh/14-reference/03-connector/_windows_install.mdx similarity index 100% rename from docs-cn/14-reference/03-connector/_windows_install.mdx rename to docs/zh/14-reference/03-connector/_windows_install.mdx diff --git a/docs-en/14-reference/03-connector/connector.webp b/docs/zh/14-reference/03-connector/connector.webp similarity index 100% rename from docs-en/14-reference/03-connector/connector.webp rename to docs/zh/14-reference/03-connector/connector.webp diff --git a/docs-cn/14-reference/03-connector/cpp.mdx b/docs/zh/14-reference/03-connector/cpp.mdx similarity index 100% rename from docs-cn/14-reference/03-connector/cpp.mdx rename to docs/zh/14-reference/03-connector/cpp.mdx diff --git a/docs-cn/14-reference/03-connector/csharp.mdx b/docs/zh/14-reference/03-connector/csharp.mdx similarity index 100% rename from docs-cn/14-reference/03-connector/csharp.mdx rename to docs/zh/14-reference/03-connector/csharp.mdx diff --git a/docs-cn/14-reference/03-connector/go.mdx b/docs/zh/14-reference/03-connector/go.mdx similarity index 100% rename from docs-cn/14-reference/03-connector/go.mdx rename to docs/zh/14-reference/03-connector/go.mdx diff --git a/docs-cn/14-reference/03-connector/java.mdx b/docs/zh/14-reference/03-connector/java.mdx similarity index 100% rename from docs-cn/14-reference/03-connector/java.mdx rename to docs/zh/14-reference/03-connector/java.mdx diff --git a/docs-cn/14-reference/03-connector/node.mdx b/docs/zh/14-reference/03-connector/node.mdx similarity index 100% rename from docs-cn/14-reference/03-connector/node.mdx rename to docs/zh/14-reference/03-connector/node.mdx diff --git a/docs-cn/14-reference/03-connector/php.mdx b/docs/zh/14-reference/03-connector/php.mdx similarity index 95% rename from docs-cn/14-reference/03-connector/php.mdx rename to docs/zh/14-reference/03-connector/php.mdx index f150aed4c8..2b7ff2a6fe 100644 --- a/docs-cn/14-reference/03-connector/php.mdx +++ b/docs/zh/14-reference/03-connector/php.mdx @@ -91,7 +91,7 @@ phpize && ./configure --enable-swoole && make -j && make install 建立连接 ```c -{{#include docs-examples/php/connect.php}} +{{#include docs/examples/php/connect.php}} ``` @@ -102,7 +102,7 @@ phpize && ./configure --enable-swoole && make -j && make install 插入数据 ```c -{{#include docs-examples/php/insert.php}} +{{#include docs/examples/php/insert.php}} ``` @@ -113,7 +113,7 @@ phpize && ./configure --enable-swoole && make -j && make install 同步查询 ```c -{{#include docs-examples/php/query.php}} +{{#include docs/examples/php/query.php}} ``` @@ -124,7 +124,7 @@ phpize && ./configure --enable-swoole && make -j && make install 参数绑定 ```c -{{#include docs-examples/php/insert_stmt.php}} +{{#include docs/examples/php/insert_stmt.php}} ``` diff --git a/docs-cn/14-reference/03-connector/python.mdx b/docs/zh/14-reference/03-connector/python.mdx similarity index 95% rename from docs-cn/14-reference/03-connector/python.mdx rename to docs/zh/14-reference/03-connector/python.mdx index 828e0a4abb..a77dc71db7 100644 --- a/docs-cn/14-reference/03-connector/python.mdx +++ b/docs/zh/14-reference/03-connector/python.mdx @@ -169,7 +169,7 @@ curl -u root:taosdata http://:/rest/sql -d "select server_version()" ```python -{{#include docs-examples/python/connect_native_reference.py}} +{{#include docs/examples/python/connect_native_reference.py}} ``` `connect` 函数的所有参数都是可选的关键字参数。下面是连接参数的具体说明: @@ -194,7 +194,7 @@ curl -u root:taosdata http://:/rest/sql -d "select server_version()" ```python -{{#include docs-examples/python/connect_rest_examples.py:connect}} +{{#include docs/examples/python/connect_rest_examples.py:connect}} ``` `connect()` 函数的所有参数都是可选的关键字参数。下面是连接参数的具体说明: @@ -219,11 +219,11 @@ curl -u root:taosdata http://:/rest/sql -d "select server_version()" `TaosConnection` 类既包含对 PEP249 Connection 接口的实现(如:`cursor`方法和 `close` 方法),也包含很多扩展功能(如: `execute`、 `query`、`schemaless_insert` 和 `subscribe` 方法。 ```python title="execute 方法" -{{#include docs-examples/python/connection_usage_native_reference.py:insert}} +{{#include docs/examples/python/connection_usage_native_reference.py:insert}} ``` ```python title="query 方法" -{{#include docs-examples/python/connection_usage_native_reference.py:query}} +{{#include docs/examples/python/connection_usage_native_reference.py:query}} ``` :::tip @@ -235,14 +235,14 @@ curl -u root:taosdata http://:/rest/sql -d "select server_version()" 上面 `TaosConnection` 类的使用示例中,我们已经展示了两种获取查询结果的方法: `fetch_all()` 和 `fetch_all_into_dict()`。除此之外 `TaosResult` 还提供了按行迭代(`rows_iter`)或按数据块迭代(`blocks_iter`)结果集的方法。在查询数据量较大的场景,使用这两个方法会更高效。 ```python title="blocks_iter 方法" -{{#include docs-examples/python/result_set_examples.py}} +{{#include docs/examples/python/result_set_examples.py}} ``` ##### TaosCursor 类的使用 `TaosConnection` 类和 `TaosResult` 类已经实现了原生接口的所有功能。如果你对 PEP249 规范中的接口比较熟悉也可以使用 `TaosCursor` 类提供的方法。 ```python title="TaosCursor 的使用" -{{#include docs-examples/python/cursor_usage_native_reference.py}} +{{#include docs/examples/python/cursor_usage_native_reference.py}} ``` :::note @@ -258,7 +258,7 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线 `TaosRestCursor` 类是对 PEP249 Cursor 接口的实现。 ```python title="TaosRestCursor 的使用" -{{#include docs-examples/python/connect_rest_examples.py:basic}} +{{#include docs/examples/python/connect_rest_examples.py:basic}} ``` - `cursor.execute` : 用来执行任意 SQL 语句。 - `cursor.rowcount`: 对于写入操作返回写入成功记录数。对于查询操作,返回结果集行数。 @@ -269,7 +269,7 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线 `RestClient` 类是对于 [REST API](/reference/rest-api) 的直接封装。它只包含一个 `sql()` 方法用于执行任意 SQL 语句, 并返回执行结果。 ```python title="RestClient 的使用" -{{#include docs-examples/python/rest_client_example.py}} +{{#include docs/examples/python/rest_client_example.py}} ``` 对于 `sql()` 方法更详细的介绍, 请参考 [RestClient](https://docs.taosdata.com/api/taospy/taosrest/restclient.html)。 @@ -285,14 +285,14 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线 ```python -{{#include docs-examples/python/conn_native_pandas.py}} +{{#include docs/examples/python/conn_native_pandas.py}} ``` ```python -{{#include docs-examples/python/conn_rest_pandas.py}} +{{#include docs/examples/python/conn_rest_pandas.py}} ``` @@ -316,7 +316,7 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线 所有数据库操作如果出现异常,都会直接抛出来。由应用程序负责异常处理。比如: ```python -{{#include docs-examples/python/handle_exception.py}} +{{#include docs/examples/python/handle_exception.py}} ``` ### 关于纳秒 (nanosecond) diff --git a/docs-cn/14-reference/03-connector/rust.mdx b/docs/zh/14-reference/03-connector/rust.mdx similarity index 100% rename from docs-cn/14-reference/03-connector/rust.mdx rename to docs/zh/14-reference/03-connector/rust.mdx diff --git a/docs-cn/14-reference/03-connector/tdengine-jdbc-connector.webp b/docs/zh/14-reference/03-connector/tdengine-jdbc-connector.webp similarity index 100% rename from docs-cn/14-reference/03-connector/tdengine-jdbc-connector.webp rename to docs/zh/14-reference/03-connector/tdengine-jdbc-connector.webp diff --git a/docs-cn/14-reference/04-taosadapter.md b/docs/zh/14-reference/04-taosadapter.md similarity index 100% rename from docs-cn/14-reference/04-taosadapter.md rename to docs/zh/14-reference/04-taosadapter.md diff --git a/docs-cn/14-reference/05-taosbenchmark.md b/docs/zh/14-reference/05-taosbenchmark.md similarity index 100% rename from docs-cn/14-reference/05-taosbenchmark.md rename to docs/zh/14-reference/05-taosbenchmark.md diff --git a/docs-cn/14-reference/06-taosdump.md b/docs/zh/14-reference/06-taosdump.md similarity index 100% rename from docs-cn/14-reference/06-taosdump.md rename to docs/zh/14-reference/06-taosdump.md diff --git a/docs-en/14-reference/07-tdinsight/assets/15146-tdengine-monitor-dashboard.json b/docs/zh/14-reference/07-tdinsight/assets/15146-tdengine-monitor-dashboard.json similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/15146-tdengine-monitor-dashboard.json rename to docs/zh/14-reference/07-tdinsight/assets/15146-tdengine-monitor-dashboard.json diff --git a/docs-en/14-reference/07-tdinsight/assets/15155-tdengine-alert-demo.json b/docs/zh/14-reference/07-tdinsight/assets/15155-tdengine-alert-demo.json similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/15155-tdengine-alert-demo.json rename to docs/zh/14-reference/07-tdinsight/assets/15155-tdengine-alert-demo.json diff --git a/docs-en/14-reference/07-tdinsight/assets/TDinsight-1-cluster-status.webp b/docs/zh/14-reference/07-tdinsight/assets/TDinsight-1-cluster-status.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/TDinsight-1-cluster-status.webp rename to docs/zh/14-reference/07-tdinsight/assets/TDinsight-1-cluster-status.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/TDinsight-2-dnodes.webp b/docs/zh/14-reference/07-tdinsight/assets/TDinsight-2-dnodes.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/TDinsight-2-dnodes.webp rename to docs/zh/14-reference/07-tdinsight/assets/TDinsight-2-dnodes.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/TDinsight-3-mnodes.webp b/docs/zh/14-reference/07-tdinsight/assets/TDinsight-3-mnodes.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/TDinsight-3-mnodes.webp rename to docs/zh/14-reference/07-tdinsight/assets/TDinsight-3-mnodes.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/TDinsight-4-requests.webp b/docs/zh/14-reference/07-tdinsight/assets/TDinsight-4-requests.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/TDinsight-4-requests.webp rename to docs/zh/14-reference/07-tdinsight/assets/TDinsight-4-requests.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/TDinsight-5-database.webp b/docs/zh/14-reference/07-tdinsight/assets/TDinsight-5-database.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/TDinsight-5-database.webp rename to docs/zh/14-reference/07-tdinsight/assets/TDinsight-5-database.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/TDinsight-6-dnode-usage.webp b/docs/zh/14-reference/07-tdinsight/assets/TDinsight-6-dnode-usage.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/TDinsight-6-dnode-usage.webp rename to docs/zh/14-reference/07-tdinsight/assets/TDinsight-6-dnode-usage.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/TDinsight-7-login-history.webp b/docs/zh/14-reference/07-tdinsight/assets/TDinsight-7-login-history.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/TDinsight-7-login-history.webp rename to docs/zh/14-reference/07-tdinsight/assets/TDinsight-7-login-history.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp b/docs/zh/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp rename to docs/zh/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/TDinsight-full.webp b/docs/zh/14-reference/07-tdinsight/assets/TDinsight-full.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/TDinsight-full.webp rename to docs/zh/14-reference/07-tdinsight/assets/TDinsight-full.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/alert-manager-status.webp b/docs/zh/14-reference/07-tdinsight/assets/alert-manager-status.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/alert-manager-status.webp rename to docs/zh/14-reference/07-tdinsight/assets/alert-manager-status.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/alert-notification-channel.webp b/docs/zh/14-reference/07-tdinsight/assets/alert-notification-channel.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/alert-notification-channel.webp rename to docs/zh/14-reference/07-tdinsight/assets/alert-notification-channel.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/alert-query-demo.webp b/docs/zh/14-reference/07-tdinsight/assets/alert-query-demo.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/alert-query-demo.webp rename to docs/zh/14-reference/07-tdinsight/assets/alert-query-demo.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/alert-rule-condition-notifications.webp b/docs/zh/14-reference/07-tdinsight/assets/alert-rule-condition-notifications.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/alert-rule-condition-notifications.webp rename to docs/zh/14-reference/07-tdinsight/assets/alert-rule-condition-notifications.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/alert-rule-test.webp b/docs/zh/14-reference/07-tdinsight/assets/alert-rule-test.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/alert-rule-test.webp rename to docs/zh/14-reference/07-tdinsight/assets/alert-rule-test.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/howto-add-datasource-button.webp b/docs/zh/14-reference/07-tdinsight/assets/howto-add-datasource-button.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/howto-add-datasource-button.webp rename to docs/zh/14-reference/07-tdinsight/assets/howto-add-datasource-button.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/howto-add-datasource-tdengine.webp b/docs/zh/14-reference/07-tdinsight/assets/howto-add-datasource-tdengine.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/howto-add-datasource-tdengine.webp rename to docs/zh/14-reference/07-tdinsight/assets/howto-add-datasource-tdengine.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/howto-add-datasource-test.webp b/docs/zh/14-reference/07-tdinsight/assets/howto-add-datasource-test.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/howto-add-datasource-test.webp rename to docs/zh/14-reference/07-tdinsight/assets/howto-add-datasource-test.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/howto-add-datasource.webp b/docs/zh/14-reference/07-tdinsight/assets/howto-add-datasource.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/howto-add-datasource.webp rename to docs/zh/14-reference/07-tdinsight/assets/howto-add-datasource.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/howto-dashboard-display.webp b/docs/zh/14-reference/07-tdinsight/assets/howto-dashboard-display.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/howto-dashboard-display.webp rename to docs/zh/14-reference/07-tdinsight/assets/howto-dashboard-display.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/howto-dashboard-import-options.webp b/docs/zh/14-reference/07-tdinsight/assets/howto-dashboard-import-options.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/howto-dashboard-import-options.webp rename to docs/zh/14-reference/07-tdinsight/assets/howto-dashboard-import-options.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/howto-import-dashboard.webp b/docs/zh/14-reference/07-tdinsight/assets/howto-import-dashboard.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/howto-import-dashboard.webp rename to docs/zh/14-reference/07-tdinsight/assets/howto-import-dashboard.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/import-dashboard-15167.webp b/docs/zh/14-reference/07-tdinsight/assets/import-dashboard-15167.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/import-dashboard-15167.webp rename to docs/zh/14-reference/07-tdinsight/assets/import-dashboard-15167.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/import-dashboard-for-tdengine.webp b/docs/zh/14-reference/07-tdinsight/assets/import-dashboard-for-tdengine.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/import-dashboard-for-tdengine.webp rename to docs/zh/14-reference/07-tdinsight/assets/import-dashboard-for-tdengine.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/import-via-grafana-dot-com.webp b/docs/zh/14-reference/07-tdinsight/assets/import-via-grafana-dot-com.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/import-via-grafana-dot-com.webp rename to docs/zh/14-reference/07-tdinsight/assets/import-via-grafana-dot-com.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/import_dashboard.webp b/docs/zh/14-reference/07-tdinsight/assets/import_dashboard.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/import_dashboard.webp rename to docs/zh/14-reference/07-tdinsight/assets/import_dashboard.webp diff --git a/docs-en/14-reference/07-tdinsight/assets/tdengine-grafana-7.x.json b/docs/zh/14-reference/07-tdinsight/assets/tdengine-grafana-7.x.json similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/tdengine-grafana-7.x.json rename to docs/zh/14-reference/07-tdinsight/assets/tdengine-grafana-7.x.json diff --git a/docs-en/14-reference/07-tdinsight/assets/tdengine-grafana.json b/docs/zh/14-reference/07-tdinsight/assets/tdengine-grafana.json similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/tdengine-grafana.json rename to docs/zh/14-reference/07-tdinsight/assets/tdengine-grafana.json diff --git a/docs-en/14-reference/07-tdinsight/assets/tdengine_dashboard.webp b/docs/zh/14-reference/07-tdinsight/assets/tdengine_dashboard.webp similarity index 100% rename from docs-en/14-reference/07-tdinsight/assets/tdengine_dashboard.webp rename to docs/zh/14-reference/07-tdinsight/assets/tdengine_dashboard.webp diff --git a/docs-cn/14-reference/07-tdinsight/index.md b/docs/zh/14-reference/07-tdinsight/index.md similarity index 100% rename from docs-cn/14-reference/07-tdinsight/index.md rename to docs/zh/14-reference/07-tdinsight/index.md diff --git a/docs-cn/14-reference/08-taos-shell.md b/docs/zh/14-reference/08-taos-shell.md similarity index 100% rename from docs-cn/14-reference/08-taos-shell.md rename to docs/zh/14-reference/08-taos-shell.md diff --git a/docs-cn/14-reference/09-support-platform/_category_.yml b/docs/zh/14-reference/09-support-platform/_category_.yml similarity index 100% rename from docs-cn/14-reference/09-support-platform/_category_.yml rename to docs/zh/14-reference/09-support-platform/_category_.yml diff --git a/docs-cn/14-reference/09-support-platform/index.md b/docs/zh/14-reference/09-support-platform/index.md similarity index 100% rename from docs-cn/14-reference/09-support-platform/index.md rename to docs/zh/14-reference/09-support-platform/index.md diff --git a/docs-cn/14-reference/11-docker/_category_.yml b/docs/zh/14-reference/11-docker/_category_.yml similarity index 100% rename from docs-cn/14-reference/11-docker/_category_.yml rename to docs/zh/14-reference/11-docker/_category_.yml diff --git a/docs-cn/14-reference/11-docker/index.md b/docs/zh/14-reference/11-docker/index.md similarity index 100% rename from docs-cn/14-reference/11-docker/index.md rename to docs/zh/14-reference/11-docker/index.md diff --git a/docs-cn/14-reference/12-config/_category_.yml b/docs/zh/14-reference/12-config/_category_.yml similarity index 100% rename from docs-cn/14-reference/12-config/_category_.yml rename to docs/zh/14-reference/12-config/_category_.yml diff --git a/docs-cn/14-reference/12-config/index.md b/docs/zh/14-reference/12-config/index.md similarity index 100% rename from docs-cn/14-reference/12-config/index.md rename to docs/zh/14-reference/12-config/index.md diff --git a/docs-cn/14-reference/12-directory.md b/docs/zh/14-reference/12-directory.md similarity index 100% rename from docs-cn/14-reference/12-directory.md rename to docs/zh/14-reference/12-directory.md diff --git a/docs-cn/14-reference/13-schemaless/13-schemaless.md b/docs/zh/14-reference/13-schemaless/13-schemaless.md similarity index 100% rename from docs-cn/14-reference/13-schemaless/13-schemaless.md rename to docs/zh/14-reference/13-schemaless/13-schemaless.md diff --git a/docs-cn/14-reference/13-schemaless/_category_.yml b/docs/zh/14-reference/13-schemaless/_category_.yml similarity index 100% rename from docs-cn/14-reference/13-schemaless/_category_.yml rename to docs/zh/14-reference/13-schemaless/_category_.yml diff --git a/docs-cn/14-reference/_category_.yml b/docs/zh/14-reference/_category_.yml similarity index 100% rename from docs-cn/14-reference/_category_.yml rename to docs/zh/14-reference/_category_.yml diff --git a/docs-cn/14-reference/_collectd.mdx b/docs/zh/14-reference/_collectd.mdx similarity index 100% rename from docs-cn/14-reference/_collectd.mdx rename to docs/zh/14-reference/_collectd.mdx diff --git a/docs-cn/14-reference/_icinga2.mdx b/docs/zh/14-reference/_icinga2.mdx similarity index 100% rename from docs-cn/14-reference/_icinga2.mdx rename to docs/zh/14-reference/_icinga2.mdx diff --git a/docs-cn/14-reference/_prometheus.mdx b/docs/zh/14-reference/_prometheus.mdx similarity index 100% rename from docs-cn/14-reference/_prometheus.mdx rename to docs/zh/14-reference/_prometheus.mdx diff --git a/docs-cn/14-reference/_statsd.mdx b/docs/zh/14-reference/_statsd.mdx similarity index 100% rename from docs-cn/14-reference/_statsd.mdx rename to docs/zh/14-reference/_statsd.mdx diff --git a/docs-cn/14-reference/_tcollector.mdx b/docs/zh/14-reference/_tcollector.mdx similarity index 100% rename from docs-cn/14-reference/_tcollector.mdx rename to docs/zh/14-reference/_tcollector.mdx diff --git a/docs-cn/14-reference/_telegraf.mdx b/docs/zh/14-reference/_telegraf.mdx similarity index 100% rename from docs-cn/14-reference/_telegraf.mdx rename to docs/zh/14-reference/_telegraf.mdx diff --git a/docs-cn/14-reference/index.md b/docs/zh/14-reference/index.md similarity index 100% rename from docs-cn/14-reference/index.md rename to docs/zh/14-reference/index.md diff --git a/docs-en/14-reference/taosAdapter-architecture.webp b/docs/zh/14-reference/taosAdapter-architecture.webp similarity index 100% rename from docs-en/14-reference/taosAdapter-architecture.webp rename to docs/zh/14-reference/taosAdapter-architecture.webp diff --git a/docs-cn/20-third-party/01-grafana.mdx b/docs/zh/20-third-party/01-grafana.mdx similarity index 100% rename from docs-cn/20-third-party/01-grafana.mdx rename to docs/zh/20-third-party/01-grafana.mdx diff --git a/docs-cn/20-third-party/02-prometheus.md b/docs/zh/20-third-party/02-prometheus.md similarity index 100% rename from docs-cn/20-third-party/02-prometheus.md rename to docs/zh/20-third-party/02-prometheus.md diff --git a/docs-cn/20-third-party/03-telegraf.md b/docs/zh/20-third-party/03-telegraf.md similarity index 100% rename from docs-cn/20-third-party/03-telegraf.md rename to docs/zh/20-third-party/03-telegraf.md diff --git a/docs-cn/20-third-party/05-collectd.md b/docs/zh/20-third-party/05-collectd.md similarity index 100% rename from docs-cn/20-third-party/05-collectd.md rename to docs/zh/20-third-party/05-collectd.md diff --git a/docs-cn/20-third-party/06-statsd.md b/docs/zh/20-third-party/06-statsd.md similarity index 100% rename from docs-cn/20-third-party/06-statsd.md rename to docs/zh/20-third-party/06-statsd.md diff --git a/docs-cn/20-third-party/07-icinga2.md b/docs/zh/20-third-party/07-icinga2.md similarity index 100% rename from docs-cn/20-third-party/07-icinga2.md rename to docs/zh/20-third-party/07-icinga2.md diff --git a/docs-cn/20-third-party/08-tcollector.md b/docs/zh/20-third-party/08-tcollector.md similarity index 100% rename from docs-cn/20-third-party/08-tcollector.md rename to docs/zh/20-third-party/08-tcollector.md diff --git a/docs-cn/20-third-party/09-emq-broker.md b/docs/zh/20-third-party/09-emq-broker.md similarity index 99% rename from docs-cn/20-third-party/09-emq-broker.md rename to docs/zh/20-third-party/09-emq-broker.md index 2125545f39..84b1027f6b 100644 --- a/docs-cn/20-third-party/09-emq-broker.md +++ b/docs/zh/20-third-party/09-emq-broker.md @@ -116,7 +116,7 @@ INSERT INTO test.sensor_data VALUES( ## 编写模拟测试程序 ```javascript -{{#include docs-examples/other/mock.js}} +{{#include docs/examples/other/mock.js}} ``` 注意:代码中 CLIENT_NUM 在开始测试中可以先设置一个较小的值,避免硬件性能不能完全处理较大并发客户端数量。 diff --git a/docs-cn/20-third-party/10-hive-mq-broker.md b/docs/zh/20-third-party/10-hive-mq-broker.md similarity index 100% rename from docs-cn/20-third-party/10-hive-mq-broker.md rename to docs/zh/20-third-party/10-hive-mq-broker.md diff --git a/docs-cn/20-third-party/11-kafka.md b/docs/zh/20-third-party/11-kafka.md similarity index 100% rename from docs-cn/20-third-party/11-kafka.md rename to docs/zh/20-third-party/11-kafka.md diff --git a/docs-cn/20-third-party/_category_.yml b/docs/zh/20-third-party/_category_.yml similarity index 100% rename from docs-cn/20-third-party/_category_.yml rename to docs/zh/20-third-party/_category_.yml diff --git a/docs-cn/20-third-party/_deploytaosadapter.mdx b/docs/zh/20-third-party/_deploytaosadapter.mdx similarity index 100% rename from docs-cn/20-third-party/_deploytaosadapter.mdx rename to docs/zh/20-third-party/_deploytaosadapter.mdx diff --git a/docs-en/20-third-party/grafana/add_datasource1.webp b/docs/zh/20-third-party/add_datasource1.webp similarity index 100% rename from docs-en/20-third-party/grafana/add_datasource1.webp rename to docs/zh/20-third-party/add_datasource1.webp diff --git a/docs-en/20-third-party/grafana/add_datasource2.webp b/docs/zh/20-third-party/add_datasource2.webp similarity index 100% rename from docs-en/20-third-party/grafana/add_datasource2.webp rename to docs/zh/20-third-party/add_datasource2.webp diff --git a/docs-en/20-third-party/grafana/add_datasource3.webp b/docs/zh/20-third-party/add_datasource3.webp similarity index 100% rename from docs-en/20-third-party/grafana/add_datasource3.webp rename to docs/zh/20-third-party/add_datasource3.webp diff --git a/docs-en/20-third-party/grafana/add_datasource4.webp b/docs/zh/20-third-party/add_datasource4.webp similarity index 100% rename from docs-en/20-third-party/grafana/add_datasource4.webp rename to docs/zh/20-third-party/add_datasource4.webp diff --git a/docs-en/20-third-party/grafana/create_dashboard1.webp b/docs/zh/20-third-party/create_dashboard1.webp similarity index 100% rename from docs-en/20-third-party/grafana/create_dashboard1.webp rename to docs/zh/20-third-party/create_dashboard1.webp diff --git a/docs-en/20-third-party/grafana/create_dashboard2.webp b/docs/zh/20-third-party/create_dashboard2.webp similarity index 100% rename from docs-en/20-third-party/grafana/create_dashboard2.webp rename to docs/zh/20-third-party/create_dashboard2.webp diff --git a/docs-cn/20-third-party/dashboard-15146.webp b/docs/zh/20-third-party/dashboard-15146.webp similarity index 100% rename from docs-cn/20-third-party/dashboard-15146.webp rename to docs/zh/20-third-party/dashboard-15146.webp diff --git a/docs-en/20-third-party/emqx/add-action-handler.webp b/docs/zh/20-third-party/emqx/add-action-handler.webp similarity index 100% rename from docs-en/20-third-party/emqx/add-action-handler.webp rename to docs/zh/20-third-party/emqx/add-action-handler.webp diff --git a/docs-en/20-third-party/emqx/check-result-in-taos.webp b/docs/zh/20-third-party/emqx/check-result-in-taos.webp similarity index 100% rename from docs-en/20-third-party/emqx/check-result-in-taos.webp rename to docs/zh/20-third-party/emqx/check-result-in-taos.webp diff --git a/docs-en/20-third-party/emqx/check-rule-matched.webp b/docs/zh/20-third-party/emqx/check-rule-matched.webp similarity index 100% rename from docs-en/20-third-party/emqx/check-rule-matched.webp rename to docs/zh/20-third-party/emqx/check-rule-matched.webp diff --git a/docs-en/20-third-party/emqx/client-num.webp b/docs/zh/20-third-party/emqx/client-num.webp similarity index 100% rename from docs-en/20-third-party/emqx/client-num.webp rename to docs/zh/20-third-party/emqx/client-num.webp diff --git a/docs-en/20-third-party/emqx/create-resource.webp b/docs/zh/20-third-party/emqx/create-resource.webp similarity index 100% rename from docs-en/20-third-party/emqx/create-resource.webp rename to docs/zh/20-third-party/emqx/create-resource.webp diff --git a/docs-en/20-third-party/emqx/create-rule.webp b/docs/zh/20-third-party/emqx/create-rule.webp similarity index 100% rename from docs-en/20-third-party/emqx/create-rule.webp rename to docs/zh/20-third-party/emqx/create-rule.webp diff --git a/docs-en/20-third-party/emqx/edit-action.webp b/docs/zh/20-third-party/emqx/edit-action.webp similarity index 100% rename from docs-en/20-third-party/emqx/edit-action.webp rename to docs/zh/20-third-party/emqx/edit-action.webp diff --git a/docs-en/20-third-party/emqx/edit-resource.webp b/docs/zh/20-third-party/emqx/edit-resource.webp similarity index 100% rename from docs-en/20-third-party/emqx/edit-resource.webp rename to docs/zh/20-third-party/emqx/edit-resource.webp diff --git a/docs-en/20-third-party/emqx/login-dashboard.webp b/docs/zh/20-third-party/emqx/login-dashboard.webp similarity index 100% rename from docs-en/20-third-party/emqx/login-dashboard.webp rename to docs/zh/20-third-party/emqx/login-dashboard.webp diff --git a/docs-en/20-third-party/emqx/rule-engine.webp b/docs/zh/20-third-party/emqx/rule-engine.webp similarity index 100% rename from docs-en/20-third-party/emqx/rule-engine.webp rename to docs/zh/20-third-party/emqx/rule-engine.webp diff --git a/docs-en/20-third-party/emqx/rule-header-key-value.webp b/docs/zh/20-third-party/emqx/rule-header-key-value.webp similarity index 100% rename from docs-en/20-third-party/emqx/rule-header-key-value.webp rename to docs/zh/20-third-party/emqx/rule-header-key-value.webp diff --git a/docs-en/20-third-party/emqx/run-mock.webp b/docs/zh/20-third-party/emqx/run-mock.webp similarity index 100% rename from docs-en/20-third-party/emqx/run-mock.webp rename to docs/zh/20-third-party/emqx/run-mock.webp diff --git a/docs-cn/20-third-party/import_dashboard1.webp b/docs/zh/20-third-party/import_dashboard1.webp similarity index 100% rename from docs-cn/20-third-party/import_dashboard1.webp rename to docs/zh/20-third-party/import_dashboard1.webp diff --git a/docs-cn/20-third-party/import_dashboard2.webp b/docs/zh/20-third-party/import_dashboard2.webp similarity index 100% rename from docs-cn/20-third-party/import_dashboard2.webp rename to docs/zh/20-third-party/import_dashboard2.webp diff --git a/docs-cn/20-third-party/index.md b/docs/zh/20-third-party/index.md similarity index 100% rename from docs-cn/20-third-party/index.md rename to docs/zh/20-third-party/index.md diff --git a/docs-en/20-third-party/kafka/Kafka_Connect.webp b/docs/zh/20-third-party/kafka/Kafka_Connect.webp similarity index 100% rename from docs-en/20-third-party/kafka/Kafka_Connect.webp rename to docs/zh/20-third-party/kafka/Kafka_Connect.webp diff --git a/docs-en/20-third-party/kafka/confluentPlatform.webp b/docs/zh/20-third-party/kafka/confluentPlatform.webp similarity index 100% rename from docs-en/20-third-party/kafka/confluentPlatform.webp rename to docs/zh/20-third-party/kafka/confluentPlatform.webp diff --git a/docs-en/20-third-party/kafka/streaming-integration-with-kafka-connect.webp b/docs/zh/20-third-party/kafka/streaming-integration-with-kafka-connect.webp similarity index 100% rename from docs-en/20-third-party/kafka/streaming-integration-with-kafka-connect.webp rename to docs/zh/20-third-party/kafka/streaming-integration-with-kafka-connect.webp diff --git a/docs-cn/21-tdinternal/01-arch.md b/docs/zh/21-tdinternal/01-arch.md similarity index 100% rename from docs-cn/21-tdinternal/01-arch.md rename to docs/zh/21-tdinternal/01-arch.md diff --git a/docs-cn/21-tdinternal/_category_.yml b/docs/zh/21-tdinternal/_category_.yml similarity index 100% rename from docs-cn/21-tdinternal/_category_.yml rename to docs/zh/21-tdinternal/_category_.yml diff --git a/docs-en/21-tdinternal/dnode.webp b/docs/zh/21-tdinternal/dnode.webp similarity index 100% rename from docs-en/21-tdinternal/dnode.webp rename to docs/zh/21-tdinternal/dnode.webp diff --git a/docs-cn/21-tdinternal/index.md b/docs/zh/21-tdinternal/index.md similarity index 100% rename from docs-cn/21-tdinternal/index.md rename to docs/zh/21-tdinternal/index.md diff --git a/docs-en/21-tdinternal/message.webp b/docs/zh/21-tdinternal/message.webp similarity index 100% rename from docs-en/21-tdinternal/message.webp rename to docs/zh/21-tdinternal/message.webp diff --git a/docs-en/21-tdinternal/modules.webp b/docs/zh/21-tdinternal/modules.webp similarity index 100% rename from docs-en/21-tdinternal/modules.webp rename to docs/zh/21-tdinternal/modules.webp diff --git a/docs-en/21-tdinternal/multi_tables.webp b/docs/zh/21-tdinternal/multi_tables.webp similarity index 100% rename from docs-en/21-tdinternal/multi_tables.webp rename to docs/zh/21-tdinternal/multi_tables.webp diff --git a/docs-en/21-tdinternal/replica-forward.webp b/docs/zh/21-tdinternal/replica-forward.webp similarity index 100% rename from docs-en/21-tdinternal/replica-forward.webp rename to docs/zh/21-tdinternal/replica-forward.webp diff --git a/docs-en/21-tdinternal/replica-master.webp b/docs/zh/21-tdinternal/replica-master.webp similarity index 100% rename from docs-en/21-tdinternal/replica-master.webp rename to docs/zh/21-tdinternal/replica-master.webp diff --git a/docs-en/21-tdinternal/replica-restore.webp b/docs/zh/21-tdinternal/replica-restore.webp similarity index 100% rename from docs-en/21-tdinternal/replica-restore.webp rename to docs/zh/21-tdinternal/replica-restore.webp diff --git a/docs-en/21-tdinternal/structure.webp b/docs/zh/21-tdinternal/structure.webp similarity index 100% rename from docs-en/21-tdinternal/structure.webp rename to docs/zh/21-tdinternal/structure.webp diff --git a/docs-en/21-tdinternal/vnode.webp b/docs/zh/21-tdinternal/vnode.webp similarity index 100% rename from docs-en/21-tdinternal/vnode.webp rename to docs/zh/21-tdinternal/vnode.webp diff --git a/docs-en/21-tdinternal/write_master.webp b/docs/zh/21-tdinternal/write_master.webp similarity index 100% rename from docs-en/21-tdinternal/write_master.webp rename to docs/zh/21-tdinternal/write_master.webp diff --git a/docs-en/21-tdinternal/write_slave.webp b/docs/zh/21-tdinternal/write_slave.webp similarity index 100% rename from docs-en/21-tdinternal/write_slave.webp rename to docs/zh/21-tdinternal/write_slave.webp diff --git a/docs-cn/25-application/01-telegraf.md b/docs/zh/25-application/01-telegraf.md similarity index 100% rename from docs-cn/25-application/01-telegraf.md rename to docs/zh/25-application/01-telegraf.md diff --git a/docs-cn/25-application/02-collectd.md b/docs/zh/25-application/02-collectd.md similarity index 100% rename from docs-cn/25-application/02-collectd.md rename to docs/zh/25-application/02-collectd.md diff --git a/docs-cn/25-application/03-immigrate.md b/docs/zh/25-application/03-immigrate.md similarity index 100% rename from docs-cn/25-application/03-immigrate.md rename to docs/zh/25-application/03-immigrate.md diff --git a/docs-en/25-application/IT-DevOps-Solutions-Collectd-StatsD.webp b/docs/zh/25-application/IT-DevOps-Solutions-Collectd-StatsD.webp similarity index 100% rename from docs-en/25-application/IT-DevOps-Solutions-Collectd-StatsD.webp rename to docs/zh/25-application/IT-DevOps-Solutions-Collectd-StatsD.webp diff --git a/docs-en/25-application/IT-DevOps-Solutions-Immigrate-OpenTSDB-Arch.webp b/docs/zh/25-application/IT-DevOps-Solutions-Immigrate-OpenTSDB-Arch.webp similarity index 100% rename from docs-en/25-application/IT-DevOps-Solutions-Immigrate-OpenTSDB-Arch.webp rename to docs/zh/25-application/IT-DevOps-Solutions-Immigrate-OpenTSDB-Arch.webp diff --git a/docs-en/25-application/IT-DevOps-Solutions-Immigrate-OpenTSDB-Dashboard.webp b/docs/zh/25-application/IT-DevOps-Solutions-Immigrate-OpenTSDB-Dashboard.webp similarity index 100% rename from docs-en/25-application/IT-DevOps-Solutions-Immigrate-OpenTSDB-Dashboard.webp rename to docs/zh/25-application/IT-DevOps-Solutions-Immigrate-OpenTSDB-Dashboard.webp diff --git a/docs-en/25-application/IT-DevOps-Solutions-Immigrate-TDengine-Arch.webp b/docs/zh/25-application/IT-DevOps-Solutions-Immigrate-TDengine-Arch.webp similarity index 100% rename from docs-en/25-application/IT-DevOps-Solutions-Immigrate-TDengine-Arch.webp rename to docs/zh/25-application/IT-DevOps-Solutions-Immigrate-TDengine-Arch.webp diff --git a/docs-en/25-application/IT-DevOps-Solutions-Telegraf.webp b/docs/zh/25-application/IT-DevOps-Solutions-Telegraf.webp similarity index 100% rename from docs-en/25-application/IT-DevOps-Solutions-Telegraf.webp rename to docs/zh/25-application/IT-DevOps-Solutions-Telegraf.webp diff --git a/docs-en/25-application/IT-DevOps-Solutions-collectd-dashboard.webp b/docs/zh/25-application/IT-DevOps-Solutions-collectd-dashboard.webp similarity index 100% rename from docs-en/25-application/IT-DevOps-Solutions-collectd-dashboard.webp rename to docs/zh/25-application/IT-DevOps-Solutions-collectd-dashboard.webp diff --git a/docs-en/25-application/IT-DevOps-Solutions-statsd-dashboard.webp b/docs/zh/25-application/IT-DevOps-Solutions-statsd-dashboard.webp similarity index 100% rename from docs-en/25-application/IT-DevOps-Solutions-statsd-dashboard.webp rename to docs/zh/25-application/IT-DevOps-Solutions-statsd-dashboard.webp diff --git a/docs-en/25-application/IT-DevOps-Solutions-telegraf-dashboard.webp b/docs/zh/25-application/IT-DevOps-Solutions-telegraf-dashboard.webp similarity index 100% rename from docs-en/25-application/IT-DevOps-Solutions-telegraf-dashboard.webp rename to docs/zh/25-application/IT-DevOps-Solutions-telegraf-dashboard.webp diff --git a/docs-cn/25-application/_category_.yml b/docs/zh/25-application/_category_.yml similarity index 100% rename from docs-cn/25-application/_category_.yml rename to docs/zh/25-application/_category_.yml diff --git a/docs-cn/25-application/index.md b/docs/zh/25-application/index.md similarity index 100% rename from docs-cn/25-application/index.md rename to docs/zh/25-application/index.md diff --git a/docs-cn/27-train-faq/01-faq.md b/docs/zh/27-train-faq/01-faq.md similarity index 100% rename from docs-cn/27-train-faq/01-faq.md rename to docs/zh/27-train-faq/01-faq.md diff --git a/docs-cn/27-train-faq/03-docker.md b/docs/zh/27-train-faq/03-docker.md similarity index 100% rename from docs-cn/27-train-faq/03-docker.md rename to docs/zh/27-train-faq/03-docker.md diff --git a/docs-cn/27-train-faq/_category_.yml b/docs/zh/27-train-faq/_category_.yml similarity index 100% rename from docs-cn/27-train-faq/_category_.yml rename to docs/zh/27-train-faq/_category_.yml diff --git a/docs-cn/27-train-faq/index.md b/docs/zh/27-train-faq/index.md similarity index 100% rename from docs-cn/27-train-faq/index.md rename to docs/zh/27-train-faq/index.md diff --git a/docs-en/02-intro/eco_system.webp b/docs/zh/eco_system.webp similarity index 100% rename from docs-en/02-intro/eco_system.webp rename to docs/zh/eco_system.webp diff --git a/include/common/tdatablock.h b/include/common/tdatablock.h index af46535c94..709462a744 100644 --- a/include/common/tdatablock.h +++ b/include/common/tdatablock.h @@ -234,9 +234,6 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks char* buildCtbNameByGroupId(const char* stbName, uint64_t groupId); -SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pSchema, bool createTb, int64_t suid, - const char* stbFullName, int32_t vgId); - static FORCE_INLINE int32_t blockGetEncodeSize(const SSDataBlock* pBlock) { return blockDataGetSerialMetaSize(pBlock->info.numOfCols) + blockDataGetSize(pBlock); } diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 81123ea3d9..694a3cdbdf 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1296,6 +1296,14 @@ typedef struct { int32_t tSerializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq); int32_t tDeserializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq); +typedef struct { + int32_t dnodeId; + int8_t standby; +} SSetStandbyReq; + +int32_t tSerializeSSetStandbyReq(void* buf, int32_t bufLen, SSetStandbyReq* pReq); +int32_t tDeserializeSSetStandbyReq(void* buf, int32_t bufLen, SSetStandbyReq* pReq); + typedef struct { int32_t connId; int32_t queryId; @@ -1496,9 +1504,9 @@ typedef struct { int32_t code; } STaskDropRsp; -#define STREAM_TRIGGER_AT_ONCE 1 -#define STREAM_TRIGGER_WINDOW_CLOSE 2 -#define STREAM_TRIGGER_MAX_DELAY 3 +#define STREAM_TRIGGER_AT_ONCE 1 +#define STREAM_TRIGGER_WINDOW_CLOSE 2 +#define STREAM_TRIGGER_MAX_DELAY 3 typedef struct { char name[TSDB_TABLE_FNAME_LEN]; @@ -1508,6 +1516,7 @@ typedef struct { char* sql; char* ast; int8_t triggerType; + int64_t maxDelay; int64_t watermark; } SCMCreateStreamReq; @@ -2300,6 +2309,29 @@ int32_t tDecodeSMqOffset(SDecoder* decoder, SMqOffset* pOffset); int32_t tEncodeSMqCMCommitOffsetReq(SEncoder* encoder, const SMqCMCommitOffsetReq* pReq); int32_t tDecodeSMqCMCommitOffsetReq(SDecoder* decoder, SMqCMCommitOffsetReq* pReq); +// tqOffset +enum { + TMQ_OFFSET__SNAPSHOT = 1, + TMQ_OFFSET__LOG, +}; + +typedef struct { + int8_t type; + union { + struct { + int64_t uid; + int64_t ts; + }; + struct { + int64_t version; + }; + }; + char subKey[TSDB_SUBSCRIBE_KEY_LEN]; +} STqOffset; + +int32_t tEncodeSTqOffset(SEncoder* pEncoder, const STqOffset* pOffset); +int32_t tDecodeSTqOffset(SDecoder* pDecoder, STqOffset* pOffset); + typedef struct { char name[TSDB_TABLE_FNAME_LEN]; char stb[TSDB_TABLE_FNAME_LEN]; @@ -2396,6 +2428,7 @@ typedef struct { static FORCE_INLINE void tDestroyTSma(STSma* pSma) { if (pSma) { + taosMemoryFreeClear(pSma->dstTbName); taosMemoryFreeClear(pSma->expr); taosMemoryFreeClear(pSma->tagsFilter); } @@ -2424,7 +2457,7 @@ int32_t tEncodeSVCreateTSmaReq(SEncoder* pCoder, const SVCreateTSmaReq* pReq); int32_t tDecodeSVCreateTSmaReq(SDecoder* pCoder, SVCreateTSmaReq* pReq); int32_t tEncodeTSma(SEncoder* pCoder, const STSma* pSma); -int32_t tDecodeTSma(SDecoder* pCoder, STSma* pSma); +int32_t tDecodeTSma(SDecoder* pCoder, STSma* pSma, bool deepCopy); static int32_t tEncodeTSmaWrapper(SEncoder* pEncoder, const STSmaWrapper* pReq) { if (tEncodeI32(pEncoder, pReq->number) < 0) return -1; @@ -2434,10 +2467,10 @@ static int32_t tEncodeTSmaWrapper(SEncoder* pEncoder, const STSmaWrapper* pReq) return 0; } -static int32_t tDecodeTSmaWrapper(SDecoder* pDecoder, STSmaWrapper* pReq) { +static int32_t tDecodeTSmaWrapper(SDecoder* pDecoder, STSmaWrapper* pReq, bool deepCopy) { if (tDecodeI32(pDecoder, &pReq->number) < 0) return -1; for (int32_t i = 0; i < pReq->number; ++i) { - tDecodeTSma(pDecoder, pReq->tSma + i); + tDecodeTSma(pDecoder, pReq->tSma + i, deepCopy); } return 0; } diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index 743f10bd55..f2ba16ff47 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -140,7 +140,7 @@ enum { TD_DEF_MSG_TYPE(TDMT_MND_MQ_CONSUMER_RECOVER, "consumer-recover", SMqConsumerRecoverMsg, NULL) TD_DEF_MSG_TYPE(TDMT_MND_MQ_DO_REBALANCE, "do-rebalance", SMqDoRebalanceMsg, NULL) TD_DEF_MSG_TYPE(TDMT_MND_MQ_DROP_CGROUP, "drop-cgroup", SMqDropCGroupReq, SMqDropCGroupRsp) - TD_DEF_MSG_TYPE(TDMT_MND_MQ_COMMIT_OFFSET, "commit-offset", SMqCMCommitOffsetReq, SMqCMCommitOffsetRsp) + TD_DEF_MSG_TYPE(TDMT_MND_MQ_COMMIT_OFFSET, "mnode-commit-offset", SMqCMCommitOffsetReq, SMqCMCommitOffsetRsp) TD_DEF_MSG_TYPE(TDMT_MND_MQ_TIMER, "mq-tmr", SMTimerReq, NULL) TD_DEF_MSG_TYPE(TDMT_MND_TELEM_TIMER, "telem-tmr", SMTimerReq, SMTimerReq) TD_DEF_MSG_TYPE(TDMT_MND_TRANS_TIMER, "trans-tmr", NULL, NULL) @@ -176,6 +176,7 @@ enum { TD_DEF_MSG_TYPE(TDMT_VND_DROP_STB, "vnode-drop-stb", SVDropStbReq, NULL) TD_DEF_MSG_TYPE(TDMT_VND_MQ_VG_CHANGE, "vnode-mq-vg-change", SMqRebVgReq, SMqRebVgRsp) TD_DEF_MSG_TYPE(TDMT_VND_MQ_VG_DELETE, "vnode-mq-vg-delete", SMqVDeleteReq, SMqVDeleteRsp) + TD_DEF_MSG_TYPE(TDMT_VND_MQ_COMMIT_OFFSET, "vnode-commit-offset", STqOffset, STqOffset) TD_DEF_MSG_TYPE(TDMT_VND_CANCEL_TASK, "vnode-cancel-task", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_DROP_TASK, "vnode-drop-task", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_CREATE_TOPIC, "vnode-create-topic", NULL, NULL) @@ -237,6 +238,8 @@ enum { TD_DEF_MSG_TYPE(TDMT_SYNC_SNAPSHOT_SEND, "sync-snapshot-send", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SYNC_SNAPSHOT_RSP, "sync-snapshot-rsp", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SYNC_LEADER_TRANSFER, "sync-leader-transfer", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_SYNC_SET_MNODE_STANDBY, "set-mnode-standby", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_SYNC_SET_VNODE_STANDBY, "set-vnode-standby", NULL, NULL) #if defined(TD_MSG_NUMBER_) TDMT_MAX diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 84e0527587..f5495db5ae 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -184,76 +184,77 @@ #define TK_TRIGGER 166 #define TK_AT_ONCE 167 #define TK_WINDOW_CLOSE 168 -#define TK_WATERMARK 169 -#define TK_KILL 170 -#define TK_CONNECTION 171 -#define TK_TRANSACTION 172 -#define TK_BALANCE 173 -#define TK_VGROUP 174 -#define TK_MERGE 175 -#define TK_REDISTRIBUTE 176 -#define TK_SPLIT 177 -#define TK_SYNCDB 178 -#define TK_DELETE 179 -#define TK_NULL 180 -#define TK_NK_QUESTION 181 -#define TK_NK_ARROW 182 -#define TK_ROWTS 183 -#define TK_TBNAME 184 -#define TK_QSTARTTS 185 -#define TK_QENDTS 186 -#define TK_WSTARTTS 187 -#define TK_WENDTS 188 -#define TK_WDURATION 189 -#define TK_CAST 190 -#define TK_NOW 191 -#define TK_TODAY 192 -#define TK_TIMEZONE 193 -#define TK_COUNT 194 -#define TK_FIRST 195 -#define TK_LAST 196 -#define TK_LAST_ROW 197 -#define TK_BETWEEN 198 -#define TK_IS 199 -#define TK_NK_LT 200 -#define TK_NK_GT 201 -#define TK_NK_LE 202 -#define TK_NK_GE 203 -#define TK_NK_NE 204 -#define TK_MATCH 205 -#define TK_NMATCH 206 -#define TK_CONTAINS 207 -#define TK_JOIN 208 -#define TK_INNER 209 -#define TK_SELECT 210 -#define TK_DISTINCT 211 -#define TK_WHERE 212 -#define TK_PARTITION 213 -#define TK_BY 214 -#define TK_SESSION 215 -#define TK_STATE_WINDOW 216 -#define TK_SLIDING 217 -#define TK_FILL 218 -#define TK_VALUE 219 -#define TK_NONE 220 -#define TK_PREV 221 -#define TK_LINEAR 222 -#define TK_NEXT 223 -#define TK_HAVING 224 -#define TK_ORDER 225 -#define TK_SLIMIT 226 -#define TK_SOFFSET 227 -#define TK_LIMIT 228 -#define TK_OFFSET 229 -#define TK_ASC 230 -#define TK_NULLS 231 -#define TK_ID 232 -#define TK_NK_BITNOT 233 -#define TK_INSERT 234 -#define TK_VALUES 235 -#define TK_IMPORT 236 -#define TK_NK_SEMI 237 -#define TK_FILE 238 +#define TK_MAX_DELAY 169 +#define TK_WATERMARK 170 +#define TK_KILL 171 +#define TK_CONNECTION 172 +#define TK_TRANSACTION 173 +#define TK_BALANCE 174 +#define TK_VGROUP 175 +#define TK_MERGE 176 +#define TK_REDISTRIBUTE 177 +#define TK_SPLIT 178 +#define TK_SYNCDB 179 +#define TK_DELETE 180 +#define TK_NULL 181 +#define TK_NK_QUESTION 182 +#define TK_NK_ARROW 183 +#define TK_ROWTS 184 +#define TK_TBNAME 185 +#define TK_QSTARTTS 186 +#define TK_QENDTS 187 +#define TK_WSTARTTS 188 +#define TK_WENDTS 189 +#define TK_WDURATION 190 +#define TK_CAST 191 +#define TK_NOW 192 +#define TK_TODAY 193 +#define TK_TIMEZONE 194 +#define TK_COUNT 195 +#define TK_FIRST 196 +#define TK_LAST 197 +#define TK_LAST_ROW 198 +#define TK_BETWEEN 199 +#define TK_IS 200 +#define TK_NK_LT 201 +#define TK_NK_GT 202 +#define TK_NK_LE 203 +#define TK_NK_GE 204 +#define TK_NK_NE 205 +#define TK_MATCH 206 +#define TK_NMATCH 207 +#define TK_CONTAINS 208 +#define TK_JOIN 209 +#define TK_INNER 210 +#define TK_SELECT 211 +#define TK_DISTINCT 212 +#define TK_WHERE 213 +#define TK_PARTITION 214 +#define TK_BY 215 +#define TK_SESSION 216 +#define TK_STATE_WINDOW 217 +#define TK_SLIDING 218 +#define TK_FILL 219 +#define TK_VALUE 220 +#define TK_NONE 221 +#define TK_PREV 222 +#define TK_LINEAR 223 +#define TK_NEXT 224 +#define TK_HAVING 225 +#define TK_ORDER 226 +#define TK_SLIMIT 227 +#define TK_SOFFSET 228 +#define TK_LIMIT 229 +#define TK_OFFSET 230 +#define TK_ASC 231 +#define TK_NULLS 232 +#define TK_ID 233 +#define TK_NK_BITNOT 234 +#define TK_INSERT 235 +#define TK_VALUES 236 +#define TK_IMPORT 237 +#define TK_NK_SEMI 238 +#define TK_FILE 239 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 diff --git a/include/dnode/mnode/mnode.h b/include/dnode/mnode/mnode.h index ab090940f2..21d8405f58 100644 --- a/include/dnode/mnode/mnode.h +++ b/include/dnode/mnode/mnode.h @@ -32,9 +32,7 @@ typedef struct { int32_t dnodeId; bool standby; bool deploy; - int8_t replica; - int8_t selfIndex; - SReplica replicas[TSDB_MAX_REPLICA]; + SReplica replica; SMsgCb msgCb; } SMnodeOpt; @@ -61,7 +59,13 @@ void mndClose(SMnode *pMnode); * @param pMnode The mnode object. */ int32_t mndStart(SMnode *pMnode); -void mndStop(SMnode *pMnode); + +/** + * @brief Stop mnode + * + * @param pMnode The mnode object. + */ +void mndStop(SMnode *pMnode); /** * @brief Get mnode monitor info. @@ -73,16 +77,25 @@ void mndStop(SMnode *pMnode); * @return int32_t 0 for success, -1 for failure. */ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pCluster, SMonVgroupInfo *pVgroup, SMonGrantInfo *pGrant); + +/** + * @brief Get mnode loads for status msg. + * + * @param pMnode The mnode object. + * @param pLoad + * @return int32_t 0 for success, -1 for failure. + */ int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad); /** - * @brief Process the read, write, sync request. + * @brief Process the rpc, sync request. * * @param pMsg The request msg. * @return int32_t 0 for success, -1 for failure. */ int32_t mndProcessRpcMsg(SRpcMsg *pMsg); int32_t mndProcessSyncMsg(SRpcMsg *pMsg); +int32_t mndPreProcessMsg(SRpcMsg *pMsg); /** * @brief Generate machine code diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index e86d643c0d..a73b9b47f4 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -138,6 +138,14 @@ typedef enum EFunctionType { FUNCTION_TYPE_TOP_MERGE, FUNCTION_TYPE_BOTTOM_PARTIAL, FUNCTION_TYPE_BOTTOM_MERGE, + FUNCTION_TYPE_FIRST_PARTIAL, + FUNCTION_TYPE_FIRST_MERGE, + FUNCTION_TYPE_LAST_PARTIAL, + FUNCTION_TYPE_LAST_MERGE, + FUNCTION_TYPE_AVG_PARTIAL, + FUNCTION_TYPE_AVG_MERGE, + FUNCTION_TYPE_STDDEV_PARTIAL, + FUNCTION_TYPE_STDDEV_MERGE, // user defined funcion FUNCTION_TYPE_UDF = 10000 @@ -175,6 +183,7 @@ bool fmIsRepeatScanFunc(int32_t funcId); bool fmIsUserDefinedFunc(int32_t funcId); bool fmIsDistExecFunc(int32_t funcId); bool fmIsForbidFillFunc(int32_t funcId); +bool fmIsForbidStreamFunc(int32_t funcId); int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMergeFunc); diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index 25369f2342..8d4e94663f 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -289,6 +289,7 @@ typedef struct SKillStmt { typedef struct SStreamOptions { ENodeType type; int8_t triggerType; + SNode* pDelay; SNode* pWatermark; } SStreamOptions; diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 7df731b95c..3937fc13f4 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -252,22 +252,20 @@ typedef struct SNodeList { SListCell* pTail; } SNodeList; -#define SNodeptr void* - -SNodeptr nodesMakeNode(ENodeType type); -void nodesDestroyNode(SNodeptr pNode); +SNode* nodesMakeNode(ENodeType type); +void nodesDestroyNode(SNode* pNode); SNodeList* nodesMakeList(); -int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode); -int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode); -int32_t nodesListMakeAppend(SNodeList** pList, SNodeptr pNode); -int32_t nodesListMakeStrictAppend(SNodeList** pList, SNodeptr pNode); +int32_t nodesListAppend(SNodeList* pList, SNode* pNode); +int32_t nodesListStrictAppend(SNodeList* pList, SNode* pNode); +int32_t nodesListMakeAppend(SNodeList** pList, SNode* pNode); +int32_t nodesListMakeStrictAppend(SNodeList** pList, SNode* pNode); int32_t nodesListAppendList(SNodeList* pTarget, SNodeList* pSrc); int32_t nodesListStrictAppendList(SNodeList* pTarget, SNodeList* pSrc); -int32_t nodesListPushFront(SNodeList* pList, SNodeptr pNode); +int32_t nodesListPushFront(SNodeList* pList, SNode* pNode); SListCell* nodesListErase(SNodeList* pList, SListCell* pCell); void nodesListInsertList(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc); -SNodeptr nodesListGetNode(SNodeList* pList, int32_t index); +SNode* nodesListGetNode(SNodeList* pList, int32_t index); void nodesDestroyList(SNodeList* pList); // Only clear the linked list structure, without releasing the elements inside void nodesClearList(SNodeList* pList); @@ -275,9 +273,9 @@ void nodesClearList(SNodeList* pList); typedef enum EDealRes { DEAL_RES_CONTINUE = 1, DEAL_RES_IGNORE_CHILD, DEAL_RES_ERROR, DEAL_RES_END } EDealRes; typedef EDealRes (*FNodeWalker)(SNode* pNode, void* pContext); -void nodesWalkExpr(SNodeptr pNode, FNodeWalker walker, void* pContext); +void nodesWalkExpr(SNode* pNode, FNodeWalker walker, void* pContext); void nodesWalkExprs(SNodeList* pList, FNodeWalker walker, void* pContext); -void nodesWalkExprPostOrder(SNodeptr pNode, FNodeWalker walker, void* pContext); +void nodesWalkExprPostOrder(SNode* pNode, FNodeWalker walker, void* pContext); void nodesWalkExprsPostOrder(SNodeList* pList, FNodeWalker walker, void* pContext); typedef EDealRes (*FNodeRewriter)(SNode** pNode, void* pContext); @@ -286,13 +284,13 @@ void nodesRewriteExprs(SNodeList* pList, FNodeRewriter rewriter, void* pContext) void nodesRewriteExprPostOrder(SNode** pNode, FNodeRewriter rewriter, void* pContext); void nodesRewriteExprsPostOrder(SNodeList* pList, FNodeRewriter rewriter, void* pContext); -bool nodesEqualNode(const SNodeptr a, const SNodeptr b); +bool nodesEqualNode(const SNode* a, const SNode* b); -SNodeptr nodesCloneNode(const SNodeptr pNode); +SNode* nodesCloneNode(const SNode* pNode); SNodeList* nodesCloneList(const SNodeList* pList); const char* nodesNodeName(ENodeType type); -int32_t nodesNodeToString(const SNodeptr pNode, bool format, char** pStr, int32_t* pLen); +int32_t nodesNodeToString(const SNode* pNode, bool format, char** pStr, int32_t* pLen); int32_t nodesStringToNode(const char* pStr, SNode** pNode); int32_t nodesListToString(const SNodeList* pList, bool format, char** pStr, int32_t* pLen); diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 42c7c27951..989dcc9492 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -336,23 +336,22 @@ typedef enum EQueryExecMode { } EQueryExecMode; typedef struct SQuery { - ENodeType type; - EQueryExecMode execMode; - bool haveResultSet; - SNode* pRoot; - int32_t numOfResCols; - SSchema* pResSchema; - int8_t precision; - SCmdMsgInfo* pCmdMsg; - int32_t msgType; - SArray* pTableList; - SArray* pDbList; - bool showRewrite; - int32_t placeholderNum; - SArray* pPlaceholderValues; - SNode* pPrepareRoot; - struct SParseMetaCache* pMetaCache; - bool stableQuery; + ENodeType type; + EQueryExecMode execMode; + bool haveResultSet; + SNode* pRoot; + int32_t numOfResCols; + SSchema* pResSchema; + int8_t precision; + SCmdMsgInfo* pCmdMsg; + int32_t msgType; + SArray* pTableList; + SArray* pDbList; + bool showRewrite; + int32_t placeholderNum; + SArray* pPlaceholderValues; + SNode* pPrepareRoot; + bool stableQuery; } SQuery; void nodesWalkSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeWalker walker, void* pContext); diff --git a/include/libs/parser/parser.h b/include/libs/parser/parser.h index 76a290364e..e45e5bd160 100644 --- a/include/libs/parser/parser.h +++ b/include/libs/parser/parser.h @@ -65,6 +65,7 @@ void qDestroyQuery(SQuery* pQueryNode); int32_t qExtractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema); int32_t qSetSTableIdForRsma(SNode* pStmt, int64_t uid); +void qCleanupKeywordsTable(); int32_t qBuildStmtOutput(SQuery* pQuery, SHashObj* pVgHash, SHashObj* pBlockHash); int32_t qResetStmtDataBlock(void* block, bool keepBuf); diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index 3a77cc1e19..a369b81d26 100644 --- a/include/libs/sync/sync.h +++ b/include/libs/sync/sync.h @@ -47,8 +47,9 @@ typedef enum { typedef enum { TAOS_SYNC_PROPOSE_SUCCESS = 0, TAOS_SYNC_PROPOSE_NOT_LEADER = 1, - TAOS_SYNC_PROPOSE_OTHER_ERROR = 2, - TAOS_SYNC_ONLY_ONE_REPLICA = 3, + TAOS_SYNC_ONLY_ONE_REPLICA = 2, + TAOS_SYNC_NOT_IN_NEW_CONFIG = 3, + TAOS_SYNC_OTHER_ERROR = 100, } ESyncProposeCode; typedef enum { @@ -110,6 +111,7 @@ typedef struct SSyncFSM { void (*FpRestoreFinishCb)(struct SSyncFSM* pFsm); void (*FpReConfigCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta cbMeta); + void (*FpLeaderTransferCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta); int32_t (*FpGetSnapshot)(struct SSyncFSM* pFsm, SSnapshot* pSnapshot); @@ -199,15 +201,13 @@ bool syncIsRestoreFinish(int64_t rid); int32_t syncGetSnapshotMeta(int64_t rid, struct SSnapshotMeta* sMeta); int32_t syncReconfig(int64_t rid, const SSyncCfg* pNewCfg); -int32_t syncReconfigRaw(int64_t rid, const SSyncCfg* pNewCfg, SRpcMsg* pRpcMsg); + +// build SRpcMsg, need to call syncPropose with SRpcMsg +int32_t syncReconfigBuild(int64_t rid, const SSyncCfg* pNewCfg, SRpcMsg* pRpcMsg); int32_t syncLeaderTransfer(int64_t rid); int32_t syncLeaderTransferTo(int64_t rid, SNodeInfo newLeader); -// to be moved to static -void syncStartNormal(int64_t rid); -void syncStartStandBy(int64_t rid); - #ifdef __cplusplus } #endif diff --git a/include/libs/sync/syncTools.h b/include/libs/sync/syncTools.h index 68a33d48cb..fbf124bf47 100644 --- a/include/libs/sync/syncTools.h +++ b/include/libs/sync/syncTools.h @@ -467,6 +467,7 @@ typedef struct SyncLeaderTransfer { SRaftId srcId; SRaftId destId; */ + SNodeInfo newNodeInfo; SRaftId newLeaderId; } SyncLeaderTransfer; diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 03308e395f..30cbbbeb11 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -653,6 +653,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_PAR_INVALID_DELETE_WHERE TAOS_DEF_ERROR_CODE(0, 0x2655) #define TSDB_CODE_PAR_INVALID_REDISTRIBUTE_VG TAOS_DEF_ERROR_CODE(0, 0x2656) #define TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x2657) +#define TSDB_CODE_PAR_INVALID_WINDOW_PC TAOS_DEF_ERROR_CODE(0, 0x2658) //planner #define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700) @@ -684,17 +685,23 @@ int32_t* taosGetErrno(); #define TSDB_CODE_SML_INVALID_DB_CONF TAOS_DEF_ERROR_CODE(0, 0x3003) //tsma -#define TSDB_CODE_TSMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x3100) -#define TSDB_CODE_TSMA_NO_INDEX_IN_META TAOS_DEF_ERROR_CODE(0, 0x3101) -#define TSDB_CODE_TSMA_INVALID_ENV TAOS_DEF_ERROR_CODE(0, 0x3102) -#define TSDB_CODE_TSMA_INVALID_STAT TAOS_DEF_ERROR_CODE(0, 0x3103) -#define TSDB_CODE_TSMA_NO_INDEX_IN_CACHE TAOS_DEF_ERROR_CODE(0, 0x3104) -#define TSDB_CODE_TSMA_RM_SKEY_IN_HASH TAOS_DEF_ERROR_CODE(0, 0x3105) +#define TSDB_CODE_TSMA_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x3100) +#define TSDB_CODE_TSMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x3101) +#define TSDB_CODE_TSMA_NO_INDEX_IN_META TAOS_DEF_ERROR_CODE(0, 0x3102) +#define TSDB_CODE_TSMA_INVALID_ENV TAOS_DEF_ERROR_CODE(0, 0x3103) +#define TSDB_CODE_TSMA_INVALID_STAT TAOS_DEF_ERROR_CODE(0, 0x3104) +#define TSDB_CODE_TSMA_INVALID_PTR TAOS_DEF_ERROR_CODE(0, 0x3105) +#define TSDB_CODE_TSMA_INVALID_PARA TAOS_DEF_ERROR_CODE(0, 0x3106) +#define TSDB_CODE_TSMA_NO_INDEX_IN_CACHE TAOS_DEF_ERROR_CODE(0, 0x3107) + //rsma #define TSDB_CODE_RSMA_INVALID_ENV TAOS_DEF_ERROR_CODE(0, 0x3150) #define TSDB_CODE_RSMA_INVALID_STAT TAOS_DEF_ERROR_CODE(0, 0x3151) +//index +#define TSDB_CODE_INDEX_REBUILDING TAOS_DEF_ERROR_CODE(0, 0x3200) + #ifdef __cplusplus } diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index 3ea40627a1..2365e6e259 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -713,7 +713,7 @@ SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) { return NULL; } - taosHashSetFreeFp(pAppHbMgr->activeInfo, tFreeClientHbReq); + // taosHashSetFreeFp(pAppHbMgr->activeInfo, tFreeClientHbReq); taosThreadMutexLock(&clientHbMgr.lock); taosArrayPush(clientHbMgr.appHbMgrs, &pAppHbMgr); diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 949aa22cd1..10c2161478 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -206,7 +206,7 @@ int32_t execLocalCmd(SRequestObj* pRequest, SQuery* pQuery) { SRetrieveTableRsp* pRsp = NULL; int32_t code = qExecCommand(pQuery->pRoot, &pRsp); if (TSDB_CODE_SUCCESS == code && NULL != pRsp) { - code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp, false, false); + code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp, false, true); } return code; @@ -233,9 +233,7 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQuery* pQuery) { return TSDB_CODE_SUCCESS; } -static SAppInstInfo* getAppInfo(SRequestObj* pRequest) { - return pRequest->pTscObj->pAppInfo; -} +static SAppInstInfo* getAppInfo(SRequestObj* pRequest) { return pRequest->pTscObj->pAppInfo; } void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) { SRetrieveTableRsp* pRsp = NULL; @@ -259,7 +257,7 @@ void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) { } pRequest->body.queryFp(pRequest->body.param, pRequest, 0); -// pRequest->body.fetchFp(pRequest->body.param, pRequest, pResultInfo->numOfRows); + // pRequest->body.fetchFp(pRequest->body.param, pRequest, pResultInfo->numOfRows); } int32_t asyncExecDdlQuery(SRequestObj* pRequest, SQuery* pQuery) { @@ -323,7 +321,7 @@ int32_t getQnodeList(SRequestObj* pRequest, SArray** pNodeList) { code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog); if (TSDB_CODE_SUCCESS == code) { *pNodeList = taosArrayInit(5, sizeof(SQueryNodeLoad)); - SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter, + SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter, .requestId = pRequest->requestId, .requestObjRefId = pRequest->self, .mgmtEps = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp)}; @@ -401,21 +399,19 @@ void setResPrecision(SReqResultInfo* pResInfo, int32_t precision) { int32_t scheduleAsyncQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList) { tsem_init(&schdRspSem, 0, 0); - SQueryResult res = {.code = 0, .numOfRows = 0}; - SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter, + SQueryResult res = {.code = 0, .numOfRows = 0}; + SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter, .requestId = pRequest->requestId, - .requestObjRefId = pRequest->self - }; - SSchedulerReq req = {.pConn = &conn, - .pNodeList = pNodeList, - .pDag = pDag, - .sql = pRequest->sqlstr, - .startTs = pRequest->metric.start, - .fp = schdExecCallback, - .cbParam = &res - }; - - int32_t code = schedulerAsyncExecJob(&req, &pRequest->body.queryJob); + .requestObjRefId = pRequest->self}; + SSchedulerReq req = {.pConn = &conn, + .pNodeList = pNodeList, + .pDag = pDag, + .sql = pRequest->sqlstr, + .startTs = pRequest->metric.start, + .fp = schdExecCallback, + .cbParam = &res}; + + int32_t code = schedulerAsyncExecJob(&req, &pRequest->body.queryJob); pRequest->body.resInfo.execRes = res.res; @@ -455,21 +451,19 @@ int32_t scheduleAsyncQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNod int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList) { void* pTransporter = pRequest->pTscObj->pAppInfo->pTransporter; - SQueryResult res = {0}; - SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter, + SQueryResult res = {0}; + SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter, .requestId = pRequest->requestId, - .requestObjRefId = pRequest->self - }; - SSchedulerReq req = {.pConn = &conn, - .pNodeList = pNodeList, - .pDag = pDag, - .sql = pRequest->sqlstr, - .startTs = pRequest->metric.start, - .fp = NULL, - .cbParam = NULL - }; - - int32_t code = schedulerExecJob(&req,&pRequest->body.queryJob, &res); + .requestObjRefId = pRequest->self}; + SSchedulerReq req = {.pConn = &conn, + .pNodeList = pNodeList, + .pDag = pDag, + .sql = pRequest->sqlstr, + .startTs = pRequest->metric.start, + .fp = NULL, + .cbParam = NULL}; + + int32_t code = schedulerExecJob(&req, &pRequest->body.queryJob, &res); pRequest->body.resInfo.execRes = res.res; if (code != TSDB_CODE_SUCCESS) { @@ -482,7 +476,8 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList return pRequest->code; } - if (TDMT_VND_SUBMIT == pRequest->type || TDMT_VND_DELETE == pRequest->type || TDMT_VND_CREATE_TABLE == pRequest->type) { + if (TDMT_VND_SUBMIT == pRequest->type || TDMT_VND_DELETE == pRequest->type || + TDMT_VND_CREATE_TABLE == pRequest->type) { pRequest->body.resInfo.numOfRows = res.numOfRows; if (pRequest->body.queryJob != 0) { @@ -495,9 +490,9 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList return pRequest->code; } -int32_t handleSubmitExecRes(SRequestObj* pRequest, void* res, SCatalog* pCatalog, SEpSet *epset) { - int32_t code = 0; - SArray* pArray = NULL; +int32_t handleSubmitExecRes(SRequestObj* pRequest, void* res, SCatalog* pCatalog, SEpSet* epset) { + int32_t code = 0; + SArray* pArray = NULL; SSubmitRsp* pRsp = (SSubmitRsp*)res; if (pRsp->nBlocks <= 0) { return TSDB_CODE_SUCCESS; @@ -519,7 +514,7 @@ int32_t handleSubmitExecRes(SRequestObj* pRequest, void* res, SCatalog* pCatalog taosArrayPush(pArray, &tbSver); } - SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter, + SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter, .requestId = pRequest->requestId, .requestObjRefId = pRequest->self, .mgmtEps = *epset}; @@ -532,7 +527,7 @@ _return: return code; } -int32_t handleQueryExecRes(SRequestObj* pRequest, void* res, SCatalog* pCatalog, SEpSet *epset) { +int32_t handleQueryExecRes(SRequestObj* pRequest, void* res, SCatalog* pCatalog, SEpSet* epset) { int32_t code = 0; SArray* pArray = NULL; SArray* pTbArray = (SArray*)res; @@ -553,7 +548,7 @@ int32_t handleQueryExecRes(SRequestObj* pRequest, void* res, SCatalog* pCatalog, taosArrayPush(pArray, &tbSver); } - SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter, + SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter, .requestId = pRequest->requestId, .requestObjRefId = pRequest->self, .mgmtEps = *epset}; @@ -575,15 +570,15 @@ int32_t handleQueryExecRsp(SRequestObj* pRequest) { return TSDB_CODE_SUCCESS; } - SCatalog* pCatalog = NULL; - SAppInstInfo* pAppInfo = getAppInfo(pRequest); + SCatalog* pCatalog = NULL; + SAppInstInfo* pAppInfo = getAppInfo(pRequest); int32_t code = catalogGetHandle(pAppInfo->clusterId, &pCatalog); if (code) { return code; } - SEpSet epset = getEpSet_s(&pAppInfo->mgmtEp); + SEpSet epset = getEpSet_s(&pAppInfo->mgmtEp); SQueryExecRes* pRes = &pRequest->body.resInfo.execRes; switch (pRes->msgType) { @@ -601,8 +596,8 @@ int32_t handleQueryExecRsp(SRequestObj* pRequest) { break; } default: - tscError("0x%"PRIx64", invalid exec result for request type %d, reqId:0x%"PRIx64, pRequest->self, - pRequest->type, pRequest->requestId); + tscError("0x%" PRIx64 ", invalid exec result for request type %d, reqId:0x%" PRIx64, pRequest->self, + pRequest->type, pRequest->requestId); code = TSDB_CODE_APP_ERROR; } @@ -610,13 +605,13 @@ int32_t handleQueryExecRsp(SRequestObj* pRequest) { } void schedulerExecCb(SQueryResult* pResult, void* param, int32_t code) { - SRequestObj* pRequest = (SRequestObj*) param; + SRequestObj* pRequest = (SRequestObj*)param; pRequest->code = code; STscObj* pTscObj = pRequest->pTscObj; if (code != TSDB_CODE_SUCCESS && NEED_CLIENT_HANDLE_ERROR(code)) { - tscDebug("0x%"PRIx64" client retry to handle the error, code:%d - %s, tryCount:%d, reqId:0x%"PRIx64, pRequest->self, code, tstrerror(code), - pRequest->retry, pRequest->requestId); + tscDebug("0x%" PRIx64 " client retry to handle the error, code:%d - %s, tryCount:%d, reqId:0x%" PRIx64, + pRequest->self, code, tstrerror(code), pRequest->retry, pRequest->requestId); pRequest->prevCode = code; doAsyncQuery(pRequest, true); return; @@ -624,7 +619,7 @@ void schedulerExecCb(SQueryResult* pResult, void* param, int32_t code) { if (code == TSDB_CODE_SUCCESS) { code = handleQueryExecRsp(pRequest); - ASSERT(pRequest->code == TSDB_CODE_SUCCESS); + ASSERT(pRequest->code == TSDB_CODE_SUCCESS); pRequest->code = code; } @@ -729,35 +724,34 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery) { if (TSDB_CODE_SUCCESS == code) { code = qCreateQueryPlan(&cxt, &pRequest->body.pDag, pNodeList); if (code) { - tscError("0x%"PRIx64" failed to create query plan, code:%s 0x%"PRIx64, pRequest->self, tstrerror(code), pRequest->requestId); + tscError("0x%" PRIx64 " failed to create query plan, code:%s 0x%" PRIx64, pRequest->self, tstrerror(code), + pRequest->requestId); } } if (TSDB_CODE_SUCCESS == code) { - SRequestConnInfo conn = {.pTrans = pAppInfo->pTransporter, - .requestId = pRequest->requestId, - .requestObjRefId = pRequest->self - }; + SRequestConnInfo conn = { + .pTrans = pAppInfo->pTransporter, .requestId = pRequest->requestId, .requestObjRefId = pRequest->self}; SSchedulerReq req = {.pConn = &conn, .pNodeList = pNodeList, .pDag = pRequest->body.pDag, .sql = pRequest->sqlstr, .startTs = pRequest->metric.start, .fp = schedulerExecCb, - .cbParam = pRequest - }; + .cbParam = pRequest}; code = schedulerAsyncExecJob(&req, &pRequest->body.queryJob); } else { - tscError("0x%"PRIx64" failed to create query plan, code:%s 0x%"PRIx64, pRequest->self, tstrerror(code), pRequest->requestId); + tscError("0x%" PRIx64 " failed to create query plan, code:%s 0x%" PRIx64, pRequest->self, tstrerror(code), + pRequest->requestId); pRequest->body.queryFp(pRequest->body.param, pRequest, code); } - //todo not to be released here + // todo not to be released here taosArrayDestroy(pNodeList); break; } case QUERY_EXEC_MODE_EMPTY_RESULT: - pRequest->type = TSDB_SQL_RETRIEVE_EMPTY_RESULT; + pRequest->type = TSDB_SQL_RETRIEVE_EMPTY_RESULT; pRequest->body.queryFp(pRequest->body.param, pRequest, 0); break; default: @@ -788,7 +782,7 @@ int32_t refreshMeta(STscObj* pTscObj, SRequestObj* pRequest) { return code; } - SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter, + SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter, .requestId = pRequest->requestId, .requestObjRefId = pRequest->self, .mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)}; @@ -991,23 +985,22 @@ void updateTargetEpSet(SMsgSendInfo* pSendInfo, STscObj* pTscObj, SRpcMsg* pMsg, switch (pSendInfo->target.type) { case TARGET_TYPE_MNODE: if (NULL == pTscObj) { - tscError("mnode epset changed but not able to update it, msg:%s, reqObjRefId:%" PRIx64, - TMSG_INFO(pMsg->msgType), pSendInfo->requestObjRefId); + tscError("mnode epset changed but not able to update it, msg:%s, reqObjRefId:%" PRIx64, + TMSG_INFO(pMsg->msgType), pSendInfo->requestObjRefId); return; } SEpSet* pOrig = &pTscObj->pAppInfo->mgmtEp.epSet; - SEp* pOrigEp = &pOrig->eps[pOrig->inUse]; - SEp* pNewEp = &pEpSet->eps[pEpSet->inUse]; - tscDebug("mnode epset updated from %d/%d=>%s:%d to %d/%d=>%s:%d in client", - pOrig->inUse, pOrig->numOfEps, pOrigEp->fqdn, pOrigEp->port, - pEpSet->inUse, pEpSet->numOfEps, pNewEp->fqdn, pNewEp->port); + SEp* pOrigEp = &pOrig->eps[pOrig->inUse]; + SEp* pNewEp = &pEpSet->eps[pEpSet->inUse]; + tscDebug("mnode epset updated from %d/%d=>%s:%d to %d/%d=>%s:%d in client", pOrig->inUse, pOrig->numOfEps, + pOrigEp->fqdn, pOrigEp->port, pEpSet->inUse, pEpSet->numOfEps, pNewEp->fqdn, pNewEp->port); updateEpSet_s(&pTscObj->pAppInfo->mgmtEp, pEpSet); break; case TARGET_TYPE_VNODE: { if (NULL == pTscObj) { - tscError("vnode epset changed but not able to update it, msg:%s, reqObjRefId:%" PRIx64, - TMSG_INFO(pMsg->msgType), pSendInfo->requestObjRefId); + tscError("vnode epset changed but not able to update it, msg:%s, reqObjRefId:%" PRIx64, + TMSG_INFO(pMsg->msgType), pSendInfo->requestObjRefId); return; } @@ -1422,14 +1415,14 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32 p += sizeof(uint64_t); // check fields - for(int32_t i = 0; i < numOfCols; ++i) { - int16_t type = *(int16_t*) p; + for (int32_t i = 0; i < numOfCols; ++i) { + int16_t type = *(int16_t*)p; p += sizeof(int16_t); - int32_t bytes = *(int32_t*) p; + int32_t bytes = *(int32_t*)p; p += sizeof(int32_t); -// ASSERT(type == pFields[i].type && bytes == pFields[i].bytes); + /*ASSERT(type == pFields[i].type && bytes == pFields[i].bytes);*/ } int32_t* colLength = (int32_t*)p; diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 5f0dbdd415..13a5acb472 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -25,12 +25,13 @@ #include "tref.h" #include "trpc.h" #include "version.h" +#include "functionMgt.h" #define TSC_VAR_NOT_RELEASE 1 #define TSC_VAR_RELEASED 0 static int32_t sentinel = TSC_VAR_NOT_RELEASE; -static int32_t createParseContext(const SRequestObj *pRequest, SParseContext** pCxt); +static int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt); int taos_options(TSDB_OPTION option, const void *arg, ...) { static int32_t lock = 0; @@ -61,6 +62,9 @@ void taos_cleanup(void) { cleanupTaskQueue(); + fmFuncMgtDestroy(); + qCleanupKeywordsTable(); + id = clientConnRefPool; clientConnRefPool = -1; taosCloseRef(id); @@ -193,8 +197,8 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) { return pResInfo->userFields; } -static void syncQueryFn(void* param, void* res, int32_t code) { - SSyncQueryParam* pParam = param; +static void syncQueryFn(void *param, void *res, int32_t code) { + SSyncQueryParam *pParam = param; pParam->pRequest = res; pParam->pRequest->code = code; @@ -209,7 +213,7 @@ TAOS_RES *taos_query(TAOS *taos, const char *sql) { } #if SYNC_ON_TOP_OF_ASYNC - SSyncQueryParam* param = taosMemoryCalloc(1, sizeof(SSyncQueryParam)); + SSyncQueryParam *param = taosMemoryCalloc(1, sizeof(SSyncQueryParam)); tsem_init(¶m->sem, 0, 0); taos_query_a(taos, sql, syncQueryFn, param); @@ -639,16 +643,30 @@ const char *taos_get_server_info(TAOS *taos) { } typedef struct SqlParseWrapper { - SParseContext* pCtx; + SParseContext *pCtx; SCatalogReq catalogReq; - SRequestObj* pRequest; - SQuery* pQuery; + SRequestObj *pRequest; + SQuery *pQuery; } SqlParseWrapper; -void retrieveMetaCallback(SMetaData* pResultMeta, void* param, int32_t code) { - SqlParseWrapper *pWrapper = (SqlParseWrapper*) param; - SQuery* pQuery = pWrapper->pQuery; - SRequestObj* pRequest = pWrapper->pRequest; +static void destorySqlParseWrapper(SqlParseWrapper *pWrapper) { + taosArrayDestroy(pWrapper->catalogReq.pDbVgroup); + taosArrayDestroy(pWrapper->catalogReq.pDbCfg); + taosArrayDestroy(pWrapper->catalogReq.pDbInfo); + taosArrayDestroy(pWrapper->catalogReq.pTableMeta); + taosArrayDestroy(pWrapper->catalogReq.pTableHash); + taosArrayDestroy(pWrapper->catalogReq.pUdf); + taosArrayDestroy(pWrapper->catalogReq.pIndex); + taosArrayDestroy(pWrapper->catalogReq.pUser); + taosArrayDestroy(pWrapper->catalogReq.pTableIndex); + taosMemoryFree(pWrapper->pCtx); + taosMemoryFree(pWrapper); +} + +void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) { + SqlParseWrapper *pWrapper = (SqlParseWrapper *)param; + SQuery *pQuery = pWrapper->pQuery; + SRequestObj *pRequest = pWrapper->pRequest; if (code == TSDB_CODE_SUCCESS) { code = qAnalyseSqlSemantic(pWrapper->pCtx, &pWrapper->catalogReq, pResultMeta, pQuery); @@ -664,22 +682,22 @@ void retrieveMetaCallback(SMetaData* pResultMeta, void* param, int32_t code) { TSWAP(pRequest->dbList, (pQuery)->pDbList); TSWAP(pRequest->tableList, (pQuery)->pTableList); - taosMemoryFree(pWrapper); + destorySqlParseWrapper(pWrapper); launchAsyncQuery(pRequest, pQuery); } else { + destorySqlParseWrapper(pWrapper); tscDebug("error happens, code:%d", code); if (NEED_CLIENT_HANDLE_ERROR(code)) { - tscDebug("0x%"PRIx64" client retry to handle the error, code:%d - %s, tryCount:%d, reqId:0x%"PRIx64, pRequest->self, code, tstrerror(code), - pRequest->retry, pRequest->requestId); + tscDebug("0x%" PRIx64 " client retry to handle the error, code:%d - %s, tryCount:%d, reqId:0x%" PRIx64, + pRequest->self, code, tstrerror(code), pRequest->retry, pRequest->requestId); pRequest->prevCode = code; doAsyncQuery(pRequest, true); return; } // return to app directly - taosMemoryFree(pWrapper); - tscError("0x%" PRIx64 " error occurs, code:%s, return to user app, reqId:0x%" PRIx64, pRequest->self, tstrerror(code), - pRequest->requestId); + tscError("0x%" PRIx64 " error occurs, code:%s, return to user app, reqId:0x%" PRIx64, pRequest->self, + tstrerror(code), pRequest->requestId); pRequest->code = code; pRequest->body.queryFp(pRequest->body.param, pRequest, code); } @@ -716,11 +734,11 @@ void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param } pRequest->body.queryFp = fp; - pRequest->body.param = param; + pRequest->body.param = param; doAsyncQuery(pRequest, false); } -int32_t createParseContext(const SRequestObj *pRequest, SParseContext** pCxt) { +int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt) { const STscObj *pTscObj = pRequest->pTscObj; *pCxt = taosMemoryCalloc(1, sizeof(SParseContext)); @@ -728,28 +746,30 @@ int32_t createParseContext(const SRequestObj *pRequest, SParseContext** pCxt) { return TSDB_CODE_OUT_OF_MEMORY; } - **pCxt = (SParseContext){.requestId = pRequest->requestId, - .requestRid = pRequest->self, - .acctId = pTscObj->acctId, - .db = pRequest->pDb, - .topicQuery = false, - .pSql = pRequest->sqlstr, - .sqlLen = pRequest->sqlLen, - .pMsg = pRequest->msgBuf, - .msgLen = ERROR_MSG_BUF_DEFAULT_SIZE, - .pTransporter = pTscObj->pAppInfo->pTransporter, - .pStmtCb = NULL, - .pUser = pTscObj->user, - .schemalessType = pTscObj->schemalessType, - .isSuperUser = (0 == strcmp(pTscObj->user, TSDB_DEFAULT_USER)), - .async = true,}; + **pCxt = (SParseContext){ + .requestId = pRequest->requestId, + .requestRid = pRequest->self, + .acctId = pTscObj->acctId, + .db = pRequest->pDb, + .topicQuery = false, + .pSql = pRequest->sqlstr, + .sqlLen = pRequest->sqlLen, + .pMsg = pRequest->msgBuf, + .msgLen = ERROR_MSG_BUF_DEFAULT_SIZE, + .pTransporter = pTscObj->pAppInfo->pTransporter, + .pStmtCb = NULL, + .pUser = pTscObj->user, + .schemalessType = pTscObj->schemalessType, + .isSuperUser = (0 == strcmp(pTscObj->user, TSDB_DEFAULT_USER)), + .async = true, + }; return TSDB_CODE_SUCCESS; } -void doAsyncQuery(SRequestObj* pRequest, bool updateMetaForce) { - SParseContext* pCxt = NULL; - STscObj *pTscObj = pRequest->pTscObj; - int32_t code = 0; +void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) { + SParseContext *pCxt = NULL; + STscObj *pTscObj = pRequest->pTscObj; + int32_t code = 0; if (pRequest->retry++ > REQUEST_TOTAL_EXEC_TIMES) { code = pRequest->prevCode; @@ -786,28 +806,29 @@ void doAsyncQuery(SRequestObj* pRequest, bool updateMetaForce) { pWrapper->pRequest = pRequest; pWrapper->catalogReq = catalogReq; - SRequestConnInfo conn = {.pTrans = pCxt->pTransporter, + SRequestConnInfo conn = {.pTrans = pCxt->pTransporter, .requestId = pCxt->requestId, .requestObjRefId = pCxt->requestRid, .mgmtEps = pCxt->mgmtEpSet}; - code = catalogAsyncGetAllMeta(pCxt->pCatalog, &conn, pRequest->requestId, - &catalogReq, retrieveMetaCallback, pWrapper, &pRequest->body.queryJob); + code = catalogAsyncGetAllMeta(pCxt->pCatalog, &conn, pRequest->requestId, &catalogReq, retrieveMetaCallback, pWrapper, + &pRequest->body.queryJob); if (code == TSDB_CODE_SUCCESS) { return; } - _error: - tscError("0x%"PRIx64" error happens, code:%d - %s, reqId:0x%"PRIx64, pRequest->self, code, tstrerror(code), pRequest->requestId); +_error: + tscError("0x%" PRIx64 " error happens, code:%d - %s, reqId:0x%" PRIx64, pRequest->self, code, tstrerror(code), + pRequest->requestId); terrno = code; pRequest->code = code; pRequest->body.queryFp(pRequest->body.param, pRequest, code); } -static void fetchCallback(void* pResult, void* param, int32_t code) { - SRequestObj* pRequest = (SRequestObj*) param; +static void fetchCallback(void *pResult, void *param, int32_t code) { + SRequestObj *pRequest = (SRequestObj *)param; - SReqResultInfo* pResultInfo = &pRequest->body.resInfo; + SReqResultInfo *pResultInfo = &pRequest->body.resInfo; pResultInfo->pData = pResult; pResultInfo->numOfRows = 0; @@ -823,7 +844,8 @@ static void fetchCallback(void* pResult, void* param, int32_t code) { return; } - pRequest->code = setQueryResultFromRsp(pResultInfo, (SRetrieveTableRsp*)pResultInfo->pData, pResultInfo->convertUcs4, false); + pRequest->code = + setQueryResultFromRsp(pResultInfo, (SRetrieveTableRsp *)pResultInfo->pData, pResultInfo->convertUcs4, false); if (pRequest->code != TSDB_CODE_SUCCESS) { pResultInfo->numOfRows = 0; pRequest->code = code; @@ -839,7 +861,7 @@ static void fetchCallback(void* pResult, void* param, int32_t code) { } void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) { - ASSERT (res != NULL && fp != NULL); + ASSERT(res != NULL && fp != NULL); SRequestObj *pRequest = res; pRequest->body.fetchFp = fp; @@ -863,7 +885,7 @@ void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) { schedulerAsyncFetchRows(pRequest->body.queryJob, fetchCallback, pRequest); } -void taos_fetch_raw_block_a(TAOS_RES* res, __taos_async_fn_t fp, void* param) { +void taos_fetch_raw_block_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) { ASSERT(res != NULL && fp != NULL); SRequestObj *pRequest = res; @@ -876,9 +898,9 @@ void taos_fetch_raw_block_a(TAOS_RES* res, __taos_async_fn_t fp, void* param) { taos_fetch_rows_a(res, fp, param); } -const void* taos_get_raw_block(TAOS_RES* res) { +const void *taos_get_raw_block(TAOS_RES *res) { ASSERT(res != NULL); - SRequestObj* pRequest = res; + SRequestObj *pRequest = res; return pRequest->body.resInfo.pData; } @@ -967,26 +989,25 @@ int taos_stmt_set_tags(TAOS_STMT *stmt, TAOS_MULTI_BIND *tags) { return stmtSetTbTags(stmt, tags); } - int taos_stmt_set_sub_tbname(TAOS_STMT *stmt, const char *name) { return taos_stmt_set_tbname(stmt, name); } -int taos_stmt_get_tag_fields(TAOS_STMT *stmt, int* fieldNum, TAOS_FIELD_E** fields) { +int taos_stmt_get_tag_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields) { if (stmt == NULL || NULL == fieldNum) { tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return terrno; } - + return stmtGetTagFields(stmt, fieldNum, fields); } -int taos_stmt_get_col_fields(TAOS_STMT *stmt, int* fieldNum, TAOS_FIELD_E** fields) { +int taos_stmt_get_col_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields) { if (stmt == NULL || NULL == fieldNum) { tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return terrno; } - + return stmtGetColFields(stmt, fieldNum, fields); } @@ -1145,4 +1166,3 @@ int taos_stmt_close(TAOS_STMT *stmt) { return stmtClose(stmt); } - diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index 274ae9984d..2ec6c2539a 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -3,22 +3,22 @@ #include #include +#include "cJSON.h" +#include "catalog.h" +#include "clientInt.h" +#include "osSemaphore.h" +#include "osThread.h" #include "query.h" #include "taos.h" #include "taoserror.h" +#include "tcommon.h" #include "tdef.h" +#include "tglobal.h" #include "tlog.h" #include "tmsg.h" +#include "tname.h" #include "ttime.h" #include "ttypes.h" -#include "tcommon.h" -#include "catalog.h" -#include "clientInt.h" -#include "tname.h" -#include "cJSON.h" -#include "tglobal.h" -#include "osSemaphore.h" -#include "osThread.h" //================================================================================================= @@ -28,34 +28,41 @@ #define QUOTE '"' #define SLASH '\\' -#define JUMP_SPACE(sql) while (*sql != '\0'){if(*sql == SPACE) sql++;else break;} +#define JUMP_SPACE(sql) \ + while (*sql != '\0') { \ + if (*sql == SPACE) \ + sql++; \ + else \ + break; \ + } // comma , -#define IS_SLASH_COMMA(sql) (*(sql) == COMMA && *((sql) - 1) == SLASH) -#define IS_COMMA(sql) (*(sql) == COMMA && *((sql) - 1) != SLASH) +#define IS_SLASH_COMMA(sql) (*(sql) == COMMA && *((sql)-1) == SLASH) +#define IS_COMMA(sql) (*(sql) == COMMA && *((sql)-1) != SLASH) // space -#define IS_SLASH_SPACE(sql) (*(sql) == SPACE && *((sql) - 1) == SLASH) -#define IS_SPACE(sql) (*(sql) == SPACE && *((sql) - 1) != SLASH) +#define IS_SLASH_SPACE(sql) (*(sql) == SPACE && *((sql)-1) == SLASH) +#define IS_SPACE(sql) (*(sql) == SPACE && *((sql)-1) != SLASH) // equal = -#define IS_SLASH_EQUAL(sql) (*(sql) == EQUAL && *((sql) - 1) == SLASH) -#define IS_EQUAL(sql) (*(sql) == EQUAL && *((sql) - 1) != SLASH) +#define IS_SLASH_EQUAL(sql) (*(sql) == EQUAL && *((sql)-1) == SLASH) +#define IS_EQUAL(sql) (*(sql) == EQUAL && *((sql)-1) != SLASH) // quote " -#define IS_SLASH_QUOTE(sql) (*(sql) == QUOTE && *((sql) - 1) == SLASH) -#define IS_QUOTE(sql) (*(sql) == QUOTE && *((sql) - 1) != SLASH) +#define IS_SLASH_QUOTE(sql) (*(sql) == QUOTE && *((sql)-1) == SLASH) +#define IS_QUOTE(sql) (*(sql) == QUOTE && *((sql)-1) != SLASH) // SLASH -#define IS_SLASH_SLASH(sql) (*(sql) == SLASH && *((sql) - 1) == SLASH) +#define IS_SLASH_SLASH(sql) (*(sql) == SLASH && *((sql)-1) == SLASH) -#define IS_SLASH_LETTER(sql) (IS_SLASH_COMMA(sql) || IS_SLASH_SPACE(sql) || IS_SLASH_EQUAL(sql) || IS_SLASH_QUOTE(sql) || IS_SLASH_SLASH(sql)) +#define IS_SLASH_LETTER(sql) \ + (IS_SLASH_COMMA(sql) || IS_SLASH_SPACE(sql) || IS_SLASH_EQUAL(sql) || IS_SLASH_QUOTE(sql) || IS_SLASH_SLASH(sql)) -#define MOVE_FORWARD_ONE(sql,len) (memmove((void*)((sql) - 1), (sql), len)) +#define MOVE_FORWARD_ONE(sql, len) (memmove((void *)((sql)-1), (sql), len)) -#define PROCESS_SLASH(key,keyLen) \ -for (int i = 1; i < keyLen; ++i) { \ - if(IS_SLASH_LETTER(key+i)){ \ - MOVE_FORWARD_ONE(key+i, keyLen-i); \ - i--; \ - keyLen--; \ - } \ -} +#define PROCESS_SLASH(key, keyLen) \ + for (int i = 1; i < keyLen; ++i) { \ + if (IS_SLASH_LETTER(key + i)) { \ + MOVE_FORWARD_ONE(key + i, keyLen - i); \ + i--; \ + keyLen--; \ + } \ + } #define IS_INVALID_COL_LEN(len) ((len) <= 0 || (len) >= TSDB_COL_NAME_LEN) #define IS_INVALID_TABLE_LEN(len) ((len) <= 0 || (len) >= TSDB_TABLE_NAME_LEN) @@ -63,16 +70,16 @@ for (int i = 1; i < keyLen; ++i) { \ #define OTD_JSON_SUB_FIELDS_NUM 2 #define OTD_JSON_FIELDS_NUM 4 -#define TS "_ts" -#define TS_LEN 3 -#define VALUE "_value" -#define VALUE_LEN 6 +#define TS "_ts" +#define TS_LEN 3 +#define VALUE "_value" +#define VALUE_LEN 6 -#define BINARY_ADD_LEN 2 // "binary" 2 means " " -#define NCHAR_ADD_LEN 3 // L"nchar" 3 means L" " +#define BINARY_ADD_LEN 2 // "binary" 2 means " " +#define NCHAR_ADD_LEN 3 // L"nchar" 3 means L" " #define MAX_RETRY_TIMES 5 -#define LINE_BATCH 20000 +#define LINE_BATCH 20000 //================================================================================================= typedef TSDB_SML_PROTOCOL_TYPE SMLProtocolType; @@ -85,18 +92,18 @@ typedef enum { } ESchemaAction; typedef struct { - char sTableName[TSDB_TABLE_NAME_LEN]; - SArray *tags; - SArray *fields; + char sTableName[TSDB_TABLE_NAME_LEN]; + SArray *tags; + SArray *fields; } SCreateSTableActionInfo; typedef struct { - char sTableName[TSDB_TABLE_NAME_LEN]; - SSmlKv *field; + char sTableName[TSDB_TABLE_NAME_LEN]; + SSmlKv *field; } SAlterSTableActionInfo; typedef struct { - ESchemaAction action; + ESchemaAction action; union { SCreateSTableActionInfo createSTable; SAlterSTableActionInfo alterSTable; @@ -104,10 +111,10 @@ typedef struct { } SSchemaAction; typedef struct { - const char *measure; - const char *tags; - const char *cols; - const char *timestamp; + const char *measure; + const char *tags; + const char *cols; + const char *timestamp; int32_t measureLen; int32_t measureTagsLen; @@ -117,31 +124,31 @@ typedef struct { } SSmlLineInfo; typedef struct { - const char *sTableName; // super table name - int32_t sTableNameLen; - char childTableName[TSDB_TABLE_NAME_LEN]; - uint64_t uid; + const char *sTableName; // super table name + int32_t sTableNameLen; + char childTableName[TSDB_TABLE_NAME_LEN]; + uint64_t uid; - SArray *tags; + SArray *tags; // if info->formatData is true, elements are SArray. // if info->formatData is false, elements are SHashObj for find by key quickly - SArray *cols; + SArray *cols; } SSmlTableInfo; typedef struct { - SArray *tags; // save the origin order to create table - SHashObj *tagHash; // elements are + SArray *tags; // save the origin order to create table + SHashObj *tagHash; // elements are - SArray *cols; - SHashObj *colHash; + SArray *cols; + SHashObj *colHash; STableMeta *tableMeta; } SSmlSTableMeta; typedef struct { - int32_t len; - char *buf; + int32_t len; + char *buf; } SSmlMsgBuf; typedef struct { @@ -159,53 +166,53 @@ typedef struct { int64_t endTime; } SSmlCostInfo; -typedef struct{ - SRequestObj* request; - tsem_t sem; +typedef struct { + SRequestObj *request; + tsem_t sem; TdThreadSpinlock lock; } Params; typedef struct { - int64_t id; - Params *params; - bool isLast; + int64_t id; + Params *params; + bool isLast; - SMLProtocolType protocol; - int8_t precision; - bool dataFormat; // true means that the name and order of keys in each line are the same(only for influx protocol) + SMLProtocolType protocol; + int8_t precision; + bool dataFormat; // true means that the name and order of keys in each line are the same(only for influx protocol) - SHashObj *childTables; - SHashObj *superTables; - SHashObj *pVgHash; - void *exec; + SHashObj *childTables; + SHashObj *superTables; + SHashObj *pVgHash; + void *exec; - STscObj *taos; - SCatalog *pCatalog; - SRequestObj *pRequest; - SQuery *pQuery; + STscObj *taos; + SCatalog *pCatalog; + SRequestObj *pRequest; + SQuery *pQuery; - SSmlCostInfo cost; - int32_t affectedRows; - SSmlMsgBuf msgBuf; - SHashObj *dumplicateKey; // for dumplicate key - SArray *colsContainer; // for cols parse, if dataFormat == false + SSmlCostInfo cost; + int32_t affectedRows; + SSmlMsgBuf msgBuf; + SHashObj *dumplicateKey; // for dumplicate key + SArray *colsContainer; // for cols parse, if dataFormat == false } SSmlHandle; //================================================================================================= //================================================================================================= static volatile int64_t linesSmlHandleId = 0; -static int64_t smlGenId() { - int64_t id; +static int64_t smlGenId() { + int64_t id; - do { - id = atomic_add_fetch_64(&linesSmlHandleId, 1); + do { + id = atomic_add_fetch_64(&linesSmlHandleId, 1); } while (id == 0); - return id; + return id; } static inline bool smlDoubleToInt64OverFlow(double num) { - if(num >= (double)INT64_MAX || num <= (double)INT64_MIN) return true; + if (num >= (double)INT64_MAX || num <= (double)INT64_MIN) return true; return false; } @@ -218,29 +225,31 @@ static inline bool smlCheckDuplicateKey(const char *key, int32_t keyLen, SHashOb return false; } -static int32_t smlBuildInvalidDataMsg(SSmlMsgBuf* pBuf, const char *msg1, const char *msg2) { - memset(pBuf->buf, 0 , pBuf->len); - if(msg1) strncat(pBuf->buf, msg1, pBuf->len); +static int32_t smlBuildInvalidDataMsg(SSmlMsgBuf *pBuf, const char *msg1, const char *msg2) { + memset(pBuf->buf, 0, pBuf->len); + if (msg1) strncat(pBuf->buf, msg1, pBuf->len); int32_t left = pBuf->len - strlen(pBuf->buf); - if(left > 2 && msg2) { + if (left > 2 && msg2) { strncat(pBuf->buf, ":", left - 1); strncat(pBuf->buf, msg2, left - 2); } return TSDB_CODE_SML_INVALID_DATA; } -static int32_t smlGenerateSchemaAction(SSchema* colField, SHashObj* colHash, SSmlKv* kv, bool isTag, - SSchemaAction* action, bool* actionNeeded, SSmlHandle* info) { +static int32_t smlGenerateSchemaAction(SSchema *colField, SHashObj *colHash, SSmlKv *kv, bool isTag, + SSchemaAction *action, bool *actionNeeded, SSmlHandle *info) { uint16_t *index = (uint16_t *)taosHashGet(colHash, kv->key, kv->keyLen); if (index) { if (colField[*index].type != kv->type) { - uError("SML:0x%"PRIx64" point type and db type mismatch. key: %s. point type: %d, db type: %d", info->id, kv->key, - colField[*index].type, kv->type); + uError("SML:0x%" PRIx64 " point type and db type mismatch. key: %s. point type: %d, db type: %d", info->id, + kv->key, colField[*index].type, kv->type); return TSDB_CODE_TSC_INVALID_VALUE; } - if ((colField[*index].type == TSDB_DATA_TYPE_VARCHAR && (colField[*index].bytes - VARSTR_HEADER_SIZE) < kv->length) || - (colField[*index].type == TSDB_DATA_TYPE_NCHAR &&((colField[*index].bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE < kv->length))) { + if ((colField[*index].type == TSDB_DATA_TYPE_VARCHAR && + (colField[*index].bytes - VARSTR_HEADER_SIZE) < kv->length) || + (colField[*index].type == TSDB_DATA_TYPE_NCHAR && + ((colField[*index].bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE < kv->length))) { if (isTag) { action->action = SCHEMA_ACTION_CHANGE_TAG_SIZE; } else { @@ -260,27 +269,26 @@ static int32_t smlGenerateSchemaAction(SSchema* colField, SHashObj* colHash, SSm } if (*actionNeeded) { uDebug("SML:0x%" PRIx64 " generate schema action. column name: %s, action: %d", info->id, colField->name, - action->action); + action->action); } return 0; } -static int32_t smlFindNearestPowerOf2(int32_t length){ +static int32_t smlFindNearestPowerOf2(int32_t length) { int32_t result = 1; - while(result <= length){ + while (result <= length) { result *= 2; } return result; } -static int32_t smlBuildColumnDescription(SSmlKv* field, char* buf, int32_t bufSize, int32_t* outBytes) { +static int32_t smlBuildColumnDescription(SSmlKv *field, char *buf, int32_t bufSize, int32_t *outBytes) { uint8_t type = field->type; char tname[TSDB_TABLE_NAME_LEN] = {0}; memcpy(tname, field->key, field->keyLen); if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { int32_t bytes = smlFindNearestPowerOf2(field->length); - int out = snprintf(buf, bufSize, "`%s` %s(%d)", - tname, tDataTypes[field->type].name, bytes); + int out = snprintf(buf, bufSize, "`%s` %s(%d)", tname, tDataTypes[field->type].name, bytes); *outBytes = out; } else { int out = snprintf(buf, bufSize, "`%s` %s", tname, tDataTypes[type].name); @@ -290,22 +298,22 @@ static int32_t smlBuildColumnDescription(SSmlKv* field, char* buf, int32_t bufSi return 0; } -static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) { +static int32_t smlApplySchemaAction(SSmlHandle *info, SSchemaAction *action) { int32_t code = 0; int32_t outBytes = 0; - char *result = (char *)taosMemoryCalloc(1, TSDB_MAX_ALLOWED_SQL_LEN); + char *result = (char *)taosMemoryCalloc(1, TSDB_MAX_ALLOWED_SQL_LEN); int32_t capacity = TSDB_MAX_ALLOWED_SQL_LEN; - uDebug("SML:0x%"PRIx64" apply schema action. action: %d", info->id, action->action); + uDebug("SML:0x%" PRIx64 " apply schema action. action: %d", info->id, action->action); switch (action->action) { case SCHEMA_ACTION_ADD_COLUMN: { int n = sprintf(result, "alter stable `%s` add column ", action->alterSTable.sTableName); - smlBuildColumnDescription(action->alterSTable.field, result+n, capacity-n, &outBytes); - TAOS_RES* res = taos_query(info->taos, result); //TODO async doAsyncQuery + smlBuildColumnDescription(action->alterSTable.field, result + n, capacity - n, &outBytes); + TAOS_RES *res = taos_query(info->taos, result); // TODO async doAsyncQuery code = taos_errno(res); - const char* errStr = taos_errstr(res); + const char *errStr = taos_errstr(res); if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%"PRIx64" apply schema action. error: %s", info->id, errStr); + uError("SML:0x%" PRIx64 " apply schema action. error: %s", info->id, errStr); taosMsleep(100); } taos_free_result(res); @@ -314,13 +322,12 @@ static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) { } case SCHEMA_ACTION_ADD_TAG: { int n = sprintf(result, "alter stable `%s` add tag ", action->alterSTable.sTableName); - smlBuildColumnDescription(action->alterSTable.field, - result+n, capacity-n, &outBytes); - TAOS_RES* res = taos_query(info->taos, result); //TODO async doAsyncQuery + smlBuildColumnDescription(action->alterSTable.field, result + n, capacity - n, &outBytes); + TAOS_RES *res = taos_query(info->taos, result); // TODO async doAsyncQuery code = taos_errno(res); - const char* errStr = taos_errstr(res); + const char *errStr = taos_errstr(res); if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%"PRIx64" apply schema action. error : %s", info->id, taos_errstr(res)); + uError("SML:0x%" PRIx64 " apply schema action. error : %s", info->id, taos_errstr(res)); taosMsleep(100); } taos_free_result(res); @@ -329,12 +336,11 @@ static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) { } case SCHEMA_ACTION_CHANGE_COLUMN_SIZE: { int n = sprintf(result, "alter stable `%s` modify column ", action->alterSTable.sTableName); - smlBuildColumnDescription(action->alterSTable.field, result+n, - capacity-n, &outBytes); - TAOS_RES* res = taos_query(info->taos, result); //TODO async doAsyncQuery + smlBuildColumnDescription(action->alterSTable.field, result + n, capacity - n, &outBytes); + TAOS_RES *res = taos_query(info->taos, result); // TODO async doAsyncQuery code = taos_errno(res); if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%"PRIx64" apply schema action. error : %s", info->id, taos_errstr(res)); + uError("SML:0x%" PRIx64 " apply schema action. error : %s", info->id, taos_errstr(res)); taosMsleep(100); } taos_free_result(res); @@ -343,12 +349,11 @@ static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) { } case SCHEMA_ACTION_CHANGE_TAG_SIZE: { int n = sprintf(result, "alter stable `%s` modify tag ", action->alterSTable.sTableName); - smlBuildColumnDescription(action->alterSTable.field, result+n, - capacity-n, &outBytes); - TAOS_RES* res = taos_query(info->taos, result); //TODO async doAsyncQuery + smlBuildColumnDescription(action->alterSTable.field, result + n, capacity - n, &outBytes); + TAOS_RES *res = taos_query(info->taos, result); // TODO async doAsyncQuery code = taos_errno(res); if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%"PRIx64" apply schema action. error : %s", info->id, taos_errstr(res)); + uError("SML:0x%" PRIx64 " apply schema action. error : %s", info->id, taos_errstr(res)); taosMsleep(100); } taos_free_result(res); @@ -356,42 +361,54 @@ static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) { break; } case SCHEMA_ACTION_CREATE_STABLE: { - int n = sprintf(result, "create stable `%s` (", action->createSTable.sTableName); - char* pos = result + n; int freeBytes = capacity - n; + int n = sprintf(result, "create stable `%s` (", action->createSTable.sTableName); + char *pos = result + n; + int freeBytes = capacity - n; SArray *cols = action->createSTable.fields; - for(int i = 0; i < taosArrayGetSize(cols); i++){ + for (int i = 0; i < taosArrayGetSize(cols); i++) { SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, i); smlBuildColumnDescription(kv, pos, freeBytes, &outBytes); - pos += outBytes; freeBytes -= outBytes; - *pos = ','; ++pos; --freeBytes; + pos += outBytes; + freeBytes -= outBytes; + *pos = ','; + ++pos; + --freeBytes; } - --pos; ++freeBytes; + --pos; + ++freeBytes; outBytes = snprintf(pos, freeBytes, ") tags ("); - pos += outBytes; freeBytes -= outBytes; + pos += outBytes; + freeBytes -= outBytes; cols = action->createSTable.tags; - for(int i = 0; i < taosArrayGetSize(cols); i++){ + for (int i = 0; i < taosArrayGetSize(cols); i++) { SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, i); smlBuildColumnDescription(kv, pos, freeBytes, &outBytes); - pos += outBytes; freeBytes -= outBytes; - *pos = ','; ++pos; --freeBytes; + pos += outBytes; + freeBytes -= outBytes; + *pos = ','; + ++pos; + --freeBytes; } - if(taosArrayGetSize(cols) == 0){ - outBytes = snprintf(pos, freeBytes,"`%s` %s(%d)", - tsSmlTagName, tDataTypes[TSDB_DATA_TYPE_NCHAR].name, 1); - pos += outBytes; freeBytes -= outBytes; - *pos = ','; ++pos; --freeBytes; + if (taosArrayGetSize(cols) == 0) { + outBytes = snprintf(pos, freeBytes, "`%s` %s(%d)", tsSmlTagName, tDataTypes[TSDB_DATA_TYPE_NCHAR].name, 1); + pos += outBytes; + freeBytes -= outBytes; + *pos = ','; + ++pos; + --freeBytes; } - pos--; ++freeBytes; + pos--; + ++freeBytes; outBytes = snprintf(pos, freeBytes, ")"); - TAOS_RES* res = taos_query(info->taos, result); + TAOS_RES *res = taos_query(info->taos, result); code = taos_errno(res); if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%"PRIx64" apply schema action. error : %s", info->id, taos_errstr(res)); + uError("SML:0x%" PRIx64 " apply schema action. error : %s", info->id, taos_errstr(res)); taosMsleep(100); } taos_free_result(res); @@ -405,18 +422,19 @@ static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) { taosMemoryFreeClear(result); if (code != 0) { - uError("SML:0x%"PRIx64 " apply schema action failure. %s", info->id, tstrerror(code)); + uError("SML:0x%" PRIx64 " apply schema action failure. %s", info->id, tstrerror(code)); } return code; } -static int32_t smlProcessSchemaAction(SSmlHandle* info, SSchema* schemaField, SHashObj* schemaHash, SArray *cols, SSchemaAction* action, bool isTag){ +static int32_t smlProcessSchemaAction(SSmlHandle *info, SSchema *schemaField, SHashObj *schemaHash, SArray *cols, + SSchemaAction *action, bool isTag) { int32_t code = TSDB_CODE_SUCCESS; for (int j = 0; j < taosArrayGetSize(cols); ++j) { - SSmlKv* kv = (SSmlKv*)taosArrayGetP(cols, j); - bool actionNeeded = false; + SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, j); + bool actionNeeded = false; code = smlGenerateSchemaAction(schemaField, schemaHash, kv, isTag, action, &actionNeeded, info); - if(code != TSDB_CODE_SUCCESS){ + if (code != TSDB_CODE_SUCCESS) { return code; } if (actionNeeded) { @@ -429,24 +447,24 @@ static int32_t smlProcessSchemaAction(SSmlHandle* info, SSchema* schemaField, SH return TSDB_CODE_SUCCESS; } -static int32_t smlCheckMeta(SSchema* schema, int32_t length, SArray* cols){ +static int32_t smlCheckMeta(SSchema *schema, int32_t length, SArray *cols) { SHashObj *hashTmp = taosHashInit(length, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); - for(uint16_t i = 0; i < length; i++){ + for (uint16_t i = 0; i < length; i++) { taosHashPut(hashTmp, schema[i].name, strlen(schema[i].name), &i, SHORT_BYTES); } - for(int32_t i = 0; i < taosArrayGetSize(cols); i++){ - SSmlKv* kv = (SSmlKv*)taosArrayGetP(cols, i); - if(taosHashGet(hashTmp, kv->key, kv->keyLen) == NULL){ + for (int32_t i = 0; i < taosArrayGetSize(cols); i++) { + SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, i); + if (taosHashGet(hashTmp, kv->key, kv->keyLen) == NULL) { return -1; } } return 0; } -static int32_t smlModifyDBSchemas(SSmlHandle* info) { +static int32_t smlModifyDBSchemas(SSmlHandle *info) { int32_t code = 0; - SName pName = {TSDB_TABLE_NAME_T, info->taos->acctId, {0}, {0}}; + SName pName = {TSDB_TABLE_NAME_T, info->taos->acctId, {0}, {0}}; strcpy(pName.dbname, info->pRequest->pDb); SRequestConnInfo conn = {0}; @@ -454,15 +472,15 @@ static int32_t smlModifyDBSchemas(SSmlHandle* info) { conn.requestId = info->pRequest->requestId; conn.requestObjRefId = info->pRequest->self; conn.mgmtEps = getEpSet_s(&info->taos->pAppInfo->mgmtEp); - - SSmlSTableMeta** tableMetaSml = (SSmlSTableMeta**)taosHashIterate(info->superTables, NULL); + + SSmlSTableMeta **tableMetaSml = (SSmlSTableMeta **)taosHashIterate(info->superTables, NULL); while (tableMetaSml) { - SSmlSTableMeta* sTableData = *tableMetaSml; - STableMeta *pTableMeta = NULL; - bool needCheckMeta = false; // for multi thread + SSmlSTableMeta *sTableData = *tableMetaSml; + STableMeta *pTableMeta = NULL; + bool needCheckMeta = false; // for multi thread size_t superTableLen = 0; - void *superTable = taosHashGetKey(tableMetaSml, &superTableLen); + void *superTable = taosHashGetKey(tableMetaSml, &superTableLen); memset(pName.tname, 0, TSDB_TABLE_NAME_LEN); memcpy(pName.tname, superTable, superTableLen); @@ -477,13 +495,16 @@ static int32_t smlModifyDBSchemas(SSmlHandle* info) { schemaAction.createSTable.fields = sTableData->cols; code = smlApplySchemaAction(info, &schemaAction); if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%"PRIx64" smlApplySchemaAction failed. can not create %s", info->id, schemaAction.createSTable.sTableName); + uError("SML:0x%" PRIx64 " smlApplySchemaAction failed. can not create %s", info->id, + schemaAction.createSTable.sTableName); goto end; } info->cost.numOfCreateSTables++; - }else if (code == TSDB_CODE_SUCCESS) { - SHashObj *hashTmp = taosHashInit(pTableMeta->tableInfo.numOfTags, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); - for(uint16_t i = pTableMeta->tableInfo.numOfColumns; i < pTableMeta->tableInfo.numOfColumns + pTableMeta->tableInfo.numOfTags; i++){ + } else if (code == TSDB_CODE_SUCCESS) { + SHashObj *hashTmp = taosHashInit(pTableMeta->tableInfo.numOfTags, + taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + for (uint16_t i = pTableMeta->tableInfo.numOfColumns; + i < pTableMeta->tableInfo.numOfColumns + pTableMeta->tableInfo.numOfTags; i++) { taosHashPut(hashTmp, pTableMeta->schema[i].name, strlen(pTableMeta->schema[i].name), &i, SHORT_BYTES); } @@ -497,7 +518,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle* info) { } taosHashClear(hashTmp); - for(uint16_t i = 0; i < pTableMeta->tableInfo.numOfColumns; i++){ + for (uint16_t i = 0; i < pTableMeta->tableInfo.numOfColumns; i++) { taosHashPut(hashTmp, pTableMeta->schema[i].name, strlen(pTableMeta->schema[i].name), &i, SHORT_BYTES); } code = smlProcessSchemaAction(info, pTableMeta->schema, hashTmp, sTableData->cols, &schemaAction, false); @@ -512,33 +533,34 @@ static int32_t smlModifyDBSchemas(SSmlHandle* info) { } needCheckMeta = true; } else { - uError("SML:0x%"PRIx64" load table meta error: %s", info->id, tstrerror(code)); + uError("SML:0x%" PRIx64 " load table meta error: %s", info->id, tstrerror(code)); goto end; } - if(pTableMeta) taosMemoryFree(pTableMeta); + if (pTableMeta) taosMemoryFree(pTableMeta); code = catalogGetSTableMeta(info->pCatalog, &conn, &pName, &pTableMeta); if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%"PRIx64" catalogGetSTableMeta failed. super table name %s", info->id, (char*)superTable); + uError("SML:0x%" PRIx64 " catalogGetSTableMeta failed. super table name %s", info->id, (char *)superTable); goto end; } - if(needCheckMeta){ - code = smlCheckMeta(&(pTableMeta->schema[pTableMeta->tableInfo.numOfColumns]), pTableMeta->tableInfo.numOfTags, sTableData->tags); + if (needCheckMeta) { + code = smlCheckMeta(&(pTableMeta->schema[pTableMeta->tableInfo.numOfColumns]), pTableMeta->tableInfo.numOfTags, + sTableData->tags); if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%"PRIx64" check tag failed. super table name %s", info->id, (char*)superTable); + uError("SML:0x%" PRIx64 " check tag failed. super table name %s", info->id, (char *)superTable); goto end; } code = smlCheckMeta(&(pTableMeta->schema[0]), pTableMeta->tableInfo.numOfColumns, sTableData->cols); if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%"PRIx64" check cols failed. super table name %s", info->id, (char*)superTable); + uError("SML:0x%" PRIx64 " check cols failed. super table name %s", info->id, (char *)superTable); goto end; } } sTableData->tableMeta = pTableMeta; - tableMetaSml = (SSmlSTableMeta**)taosHashIterate(info->superTables, tableMetaSml); + tableMetaSml = (SSmlSTableMeta **)taosHashIterate(info->superTables, tableMetaSml); } return 0; @@ -547,32 +569,32 @@ end: return code; } -static bool smlParseNumber(SSmlKv *kvVal, SSmlMsgBuf *msg){ +static bool smlParseNumber(SSmlKv *kvVal, SSmlMsgBuf *msg) { const char *pVal = kvVal->value; - int32_t len = kvVal->length; - char *endptr = NULL; - double result = taosStr2Double(pVal, &endptr); - if(pVal == endptr){ + int32_t len = kvVal->length; + char *endptr = NULL; + double result = taosStr2Double(pVal, &endptr); + if (pVal == endptr) { smlBuildInvalidDataMsg(msg, "invalid data", pVal); return false; } int32_t left = len - (endptr - pVal); - if(left == 0 || (left == 3 && strncasecmp(endptr, "f64", left) == 0)){ + if (left == 0 || (left == 3 && strncasecmp(endptr, "f64", left) == 0)) { kvVal->type = TSDB_DATA_TYPE_DOUBLE; kvVal->d = result; - }else if ((left == 3 && strncasecmp(endptr, "f32", left) == 0)){ - if(!IS_VALID_FLOAT(result)){ + } else if ((left == 3 && strncasecmp(endptr, "f32", left) == 0)) { + if (!IS_VALID_FLOAT(result)) { smlBuildInvalidDataMsg(msg, "float out of range[-3.402823466e+38,3.402823466e+38]", pVal); return false; } kvVal->type = TSDB_DATA_TYPE_FLOAT; kvVal->f = (float)result; - }else if ((left == 1 && *endptr == 'i') || (left == 3 && strncasecmp(endptr, "i64", left) == 0)){ - if(smlDoubleToInt64OverFlow(result)){ + } else if ((left == 1 && *endptr == 'i') || (left == 3 && strncasecmp(endptr, "i64", left) == 0)) { + if (smlDoubleToInt64OverFlow(result)) { errno = 0; int64_t tmp = taosStr2Int64(pVal, &endptr, 10); - if(errno == ERANGE){ + if (errno == ERANGE) { smlBuildInvalidDataMsg(msg, "big int out of range[-9223372036854775808,9223372036854775807]", pVal); return false; } @@ -582,11 +604,11 @@ static bool smlParseNumber(SSmlKv *kvVal, SSmlMsgBuf *msg){ } kvVal->type = TSDB_DATA_TYPE_BIGINT; kvVal->i = (int64_t)result; - }else if ((left == 3 && strncasecmp(endptr, "u64", left) == 0)){ - if(result >= (double)UINT64_MAX || result < 0){ + } else if ((left == 3 && strncasecmp(endptr, "u64", left) == 0)) { + if (result >= (double)UINT64_MAX || result < 0) { errno = 0; uint64_t tmp = taosStr2UInt64(pVal, &endptr, 10); - if(errno == ERANGE || result < 0){ + if (errno == ERANGE || result < 0) { smlBuildInvalidDataMsg(msg, "unsigned big int out of range[0,18446744073709551615]", pVal); return false; } @@ -596,49 +618,49 @@ static bool smlParseNumber(SSmlKv *kvVal, SSmlMsgBuf *msg){ } kvVal->type = TSDB_DATA_TYPE_UBIGINT; kvVal->u = result; - }else if (left == 3 && strncasecmp(endptr, "i32", left) == 0){ - if(!IS_VALID_INT(result)){ + } else if (left == 3 && strncasecmp(endptr, "i32", left) == 0) { + if (!IS_VALID_INT(result)) { smlBuildInvalidDataMsg(msg, "int out of range[-2147483648,2147483647]", pVal); return false; } kvVal->type = TSDB_DATA_TYPE_INT; kvVal->i = result; - }else if (left == 3 && strncasecmp(endptr, "u32", left) == 0){ - if(!IS_VALID_UINT(result)){ + } else if (left == 3 && strncasecmp(endptr, "u32", left) == 0) { + if (!IS_VALID_UINT(result)) { smlBuildInvalidDataMsg(msg, "unsigned int out of range[0,4294967295]", pVal); return false; } kvVal->type = TSDB_DATA_TYPE_UINT; kvVal->u = result; - }else if (left == 3 && strncasecmp(endptr, "i16", left) == 0){ - if(!IS_VALID_SMALLINT(result)){ + } else if (left == 3 && strncasecmp(endptr, "i16", left) == 0) { + if (!IS_VALID_SMALLINT(result)) { smlBuildInvalidDataMsg(msg, "small int our of range[-32768,32767]", pVal); return false; } kvVal->type = TSDB_DATA_TYPE_SMALLINT; kvVal->i = result; - }else if (left == 3 && strncasecmp(endptr, "u16", left) == 0){ - if(!IS_VALID_USMALLINT(result)){ + } else if (left == 3 && strncasecmp(endptr, "u16", left) == 0) { + if (!IS_VALID_USMALLINT(result)) { smlBuildInvalidDataMsg(msg, "unsigned small int out of rang[0,65535]", pVal); return false; } kvVal->type = TSDB_DATA_TYPE_USMALLINT; kvVal->u = result; - }else if (left == 2 && strncasecmp(endptr, "i8", left) == 0){ - if(!IS_VALID_TINYINT(result)){ + } else if (left == 2 && strncasecmp(endptr, "i8", left) == 0) { + if (!IS_VALID_TINYINT(result)) { smlBuildInvalidDataMsg(msg, "tiny int out of range[-128,127]", pVal); return false; } kvVal->type = TSDB_DATA_TYPE_TINYINT; kvVal->i = result; - }else if (left == 2 && strncasecmp(endptr, "u8", left) == 0){ - if(!IS_VALID_UTINYINT(result)){ + } else if (left == 2 && strncasecmp(endptr, "u8", left) == 0) { + if (!IS_VALID_UTINYINT(result)) { smlBuildInvalidDataMsg(msg, "unsigned tiny int out of range[0,255]", pVal); return false; } kvVal->type = TSDB_DATA_TYPE_UTINYINT; kvVal->u = result; - }else{ + } else { smlBuildInvalidDataMsg(msg, "invalid data", pVal); return false; } @@ -647,7 +669,7 @@ static bool smlParseNumber(SSmlKv *kvVal, SSmlMsgBuf *msg){ static bool smlParseBool(SSmlKv *kvVal) { const char *pVal = kvVal->value; - int32_t len = kvVal->length; + int32_t len = kvVal->length; if ((len == 1) && (pVal[0] == 't' || pVal[0] == 'T')) { kvVal->i = true; return true; @@ -658,11 +680,11 @@ static bool smlParseBool(SSmlKv *kvVal) { return true; } - if((len == 4) && !strncasecmp(pVal, "true", len)) { + if ((len == 4) && !strncasecmp(pVal, "true", len)) { kvVal->i = true; return true; } - if((len == 5) && !strncasecmp(pVal, "false", len)) { + if ((len == 5) && !strncasecmp(pVal, "false", len)) { kvVal->i = false; return true; } @@ -670,7 +692,7 @@ static bool smlParseBool(SSmlKv *kvVal) { } static bool smlIsBinary(const char *pVal, uint16_t len) { - //binary: "abc" + // binary: "abc" if (len < 2) { return false; } @@ -681,20 +703,20 @@ static bool smlIsBinary(const char *pVal, uint16_t len) { } static bool smlIsNchar(const char *pVal, uint16_t len) { - //nchar: L"abc" + // nchar: L"abc" if (len < 3) { return false; } - if ((pVal[0] == 'l' || pVal[0] == 'L')&& pVal[1] == '"' && pVal[len - 1] == '"') { + if ((pVal[0] == 'l' || pVal[0] == 'L') && pVal[1] == '"' && pVal[len - 1] == '"') { return true; } return false; } static int64_t smlGetTimeValue(const char *value, int32_t len, int8_t type) { - char *endPtr = NULL; + char *endPtr = NULL; int64_t tsInt64 = taosStr2Int64(value, &endPtr, 10); - if(value + len != endPtr){ + if (value + len != endPtr) { return -1; } double ts = tsInt64; @@ -724,7 +746,7 @@ static int64_t smlGetTimeValue(const char *value, int32_t len, int8_t type) { default: ASSERT(0); } - if(ts >= (double)INT64_MAX || ts < 0){ + if (ts >= (double)INT64_MAX || ts < 0) { return -1; } @@ -761,8 +783,8 @@ static int8_t smlGetTsTypeByPrecision(int8_t precision) { } } -static int64_t smlParseInfluxTime(SSmlHandle* info, const char* data, int32_t len){ - if(len == 0 || (len == 1 && data[0] == '0')){ +static int64_t smlParseInfluxTime(SSmlHandle *info, const char *data, int32_t len) { + if (len == 0 || (len == 1 && data[0] == '0')) { return taosGetTimestampNs(); } @@ -773,49 +795,50 @@ static int64_t smlParseInfluxTime(SSmlHandle* info, const char* data, int32_t le } int64_t ts = smlGetTimeValue(data, len, tsType); - if(ts == -1){ + if (ts == -1) { smlBuildInvalidDataMsg(&info->msgBuf, "invalid timestamp", data); return -1; } return ts; } -static int64_t smlParseOpenTsdbTime(SSmlHandle* info, const char* data, int32_t len){ - if(!data){ +static int64_t smlParseOpenTsdbTime(SSmlHandle *info, const char *data, int32_t len) { + if (!data) { smlBuildInvalidDataMsg(&info->msgBuf, "timestamp can not be null", NULL); return -1; } - if(len == 1 && data[0] == '0'){ + if (len == 1 && data[0] == '0') { return taosGetTimestampNs(); } int8_t tsType = smlGetTsTypeByLen(len); if (tsType == -1) { - smlBuildInvalidDataMsg(&info->msgBuf, "timestamp precision can only be seconds(10 digits) or milli seconds(13 digits)", data); + smlBuildInvalidDataMsg(&info->msgBuf, + "timestamp precision can only be seconds(10 digits) or milli seconds(13 digits)", data); return -1; } int64_t ts = smlGetTimeValue(data, len, tsType); - if(ts == -1){ + if (ts == -1) { smlBuildInvalidDataMsg(&info->msgBuf, "invalid timestamp", data); return -1; } return ts; } -static int32_t smlParseTS(SSmlHandle* info, const char* data, int32_t len, SArray *cols){ +static int32_t smlParseTS(SSmlHandle *info, const char *data, int32_t len, SArray *cols) { int64_t ts = 0; - if(info->protocol == TSDB_SML_LINE_PROTOCOL){ + if (info->protocol == TSDB_SML_LINE_PROTOCOL) { ts = smlParseInfluxTime(info, data, len); - }else if(info->protocol == TSDB_SML_TELNET_PROTOCOL){ + } else if (info->protocol == TSDB_SML_TELNET_PROTOCOL) { ts = smlParseOpenTsdbTime(info, data, len); - }else{ + } else { ASSERT(0); } - if(ts == -1) return TSDB_CODE_TSC_INVALID_TIME_STAMP; + if (ts == -1) return TSDB_CODE_TSC_INVALID_TIME_STAMP; // add ts to SSmlKv *kv = (SSmlKv *)taosMemoryCalloc(sizeof(SSmlKv), 1); - if(!kv){ + if (!kv) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -824,19 +847,19 @@ static int32_t smlParseTS(SSmlHandle* info, const char* data, int32_t len, SArra kv->i = ts; kv->type = TSDB_DATA_TYPE_TIMESTAMP; kv->length = (int16_t)tDataTypes[kv->type].bytes; - if(cols) taosArrayPush(cols, &kv); + if (cols) taosArrayPush(cols, &kv); return TSDB_CODE_SUCCESS; } static bool smlParseValue(SSmlKv *pVal, SSmlMsgBuf *msg) { - //binary + // binary if (smlIsBinary(pVal->value, pVal->length)) { pVal->type = TSDB_DATA_TYPE_BINARY; pVal->length -= BINARY_ADD_LEN; pVal->value += (BINARY_ADD_LEN - 1); return true; } - //nchar + // nchar if (smlIsNchar(pVal->value, pVal->length)) { pVal->type = TSDB_DATA_TYPE_NCHAR; pVal->length -= NCHAR_ADD_LEN; @@ -844,13 +867,13 @@ static bool smlParseValue(SSmlKv *pVal, SSmlMsgBuf *msg) { return true; } - //bool + // bool if (smlParseBool(pVal)) { pVal->type = TSDB_DATA_TYPE_BOOL; pVal->length = (int16_t)tDataTypes[pVal->type].bytes; return true; } - //number + // number if (smlParseNumber(pVal, msg)) { pVal->length = (int16_t)tDataTypes[pVal->type].bytes; return true; @@ -859,41 +882,41 @@ static bool smlParseValue(SSmlKv *pVal, SSmlMsgBuf *msg) { return false; } -static int32_t smlParseInfluxString(const char* sql, SSmlLineInfo *elements, SSmlMsgBuf *msg){ - if(!sql) return TSDB_CODE_SML_INVALID_DATA; +static int32_t smlParseInfluxString(const char *sql, SSmlLineInfo *elements, SSmlMsgBuf *msg) { + if (!sql) return TSDB_CODE_SML_INVALID_DATA; JUMP_SPACE(sql) - if(*sql == COMMA) return TSDB_CODE_SML_INVALID_DATA; + if (*sql == COMMA) return TSDB_CODE_SML_INVALID_DATA; elements->measure = sql; // parse measure while (*sql != '\0') { - if((sql != elements->measure) && IS_SLASH_LETTER(sql)){ - MOVE_FORWARD_ONE(sql,strlen(sql) + 1); + if ((sql != elements->measure) && IS_SLASH_LETTER(sql)) { + MOVE_FORWARD_ONE(sql, strlen(sql) + 1); continue; } - if(IS_COMMA(sql)){ + if (IS_COMMA(sql)) { break; } - if(IS_SPACE(sql)){ + if (IS_SPACE(sql)) { break; } sql++; } elements->measureLen = sql - elements->measure; - if(IS_INVALID_TABLE_LEN(elements->measureLen)) { + if (IS_INVALID_TABLE_LEN(elements->measureLen)) { smlBuildInvalidDataMsg(msg, "measure is empty or too large than 192", NULL); return TSDB_CODE_SML_INVALID_DATA; } // parse tag - if(*sql == SPACE){ + if (*sql == SPACE) { elements->tagsLen = 0; - }else{ - if(*sql == COMMA) sql++; + } else { + if (*sql == COMMA) sql++; elements->tags = sql; while (*sql != '\0') { - if(IS_SPACE(sql)){ + if (IS_SPACE(sql)) { break; } sql++; @@ -907,20 +930,20 @@ static int32_t smlParseInfluxString(const char* sql, SSmlLineInfo *elements, SSm elements->cols = sql; bool isInQuote = false; while (*sql != '\0') { - if(IS_QUOTE(sql)){ + if (IS_QUOTE(sql)) { isInQuote = !isInQuote; } - if(!isInQuote && IS_SPACE(sql)){ + if (!isInQuote && IS_SPACE(sql)) { break; } sql++; } - if(isInQuote){ + if (isInQuote) { smlBuildInvalidDataMsg(msg, "only one quote", elements->cols); return TSDB_CODE_SML_INVALID_DATA; } elements->colsLen = sql - elements->cols; - if(elements->colsLen == 0) { + if (elements->colsLen == 0) { smlBuildInvalidDataMsg(msg, "cols is empty", NULL); return TSDB_CODE_SML_INVALID_DATA; } @@ -929,7 +952,7 @@ static int32_t smlParseInfluxString(const char* sql, SSmlLineInfo *elements, SSm JUMP_SPACE(sql) elements->timestamp = sql; while (*sql != '\0') { - if(*sql == SPACE){ + if (*sql == SPACE) { break; } sql++; @@ -939,11 +962,11 @@ static int32_t smlParseInfluxString(const char* sql, SSmlLineInfo *elements, SSm return TSDB_CODE_SUCCESS; } -static void smlParseTelnetElement(const char **sql, const char **data, int32_t *len){ +static void smlParseTelnetElement(const char **sql, const char **data, int32_t *len) { while (**sql != '\0') { - if(**sql != SPACE && !(*data)) { + if (**sql != SPACE && !(*data)) { *data = *sql; - }else if (**sql == SPACE && *data) { + } else if (**sql == SPACE && *data) { *len = *sql - *data; break; } @@ -951,23 +974,24 @@ static void smlParseTelnetElement(const char **sql, const char **data, int32_t * } } -static int32_t smlParseTelnetTags(const char* data, SArray *cols, char *childTableName, SHashObj *dumplicateKey, SSmlMsgBuf *msg){ +static int32_t smlParseTelnetTags(const char *data, SArray *cols, char *childTableName, SHashObj *dumplicateKey, + SSmlMsgBuf *msg) { const char *sql = data; - size_t childTableNameLen = strlen(tsSmlChildTableName); - while(*sql != '\0'){ + size_t childTableNameLen = strlen(tsSmlChildTableName); + while (*sql != '\0') { JUMP_SPACE(sql) - if(*sql == '\0') break; + if (*sql == '\0') break; const char *key = sql; - int32_t keyLen = 0; + int32_t keyLen = 0; // parse key - while(*sql != '\0'){ - if(*sql == SPACE) { + while (*sql != '\0') { + if (*sql == SPACE) { smlBuildInvalidDataMsg(msg, "invalid data", sql); return TSDB_CODE_SML_INVALID_DATA; } - if(*sql == EQUAL) { + if (*sql == EQUAL) { keyLen = sql - key; sql++; break; @@ -975,19 +999,19 @@ static int32_t smlParseTelnetTags(const char* data, SArray *cols, char *childTab sql++; } - if(IS_INVALID_COL_LEN(keyLen)){ + if (IS_INVALID_COL_LEN(keyLen)) { smlBuildInvalidDataMsg(msg, "invalid key or key is too long than 64", key); return TSDB_CODE_SML_INVALID_DATA; } - if(smlCheckDuplicateKey(key, keyLen, dumplicateKey)){ + if (smlCheckDuplicateKey(key, keyLen, dumplicateKey)) { smlBuildInvalidDataMsg(msg, "dumplicate key", key); return TSDB_CODE_TSC_DUP_TAG_NAMES; } // parse value const char *value = sql; - int32_t valueLen = 0; - while(*sql != '\0') { + int32_t valueLen = 0; + while (*sql != '\0') { // parse value if (*sql == SPACE) { break; @@ -1000,13 +1024,13 @@ static int32_t smlParseTelnetTags(const char* data, SArray *cols, char *childTab } valueLen = sql - value; - if(valueLen == 0){ + if (valueLen == 0) { smlBuildInvalidDataMsg(msg, "invalid value", value); return TSDB_CODE_SML_INVALID_DATA; } - //handle child table name - if(childTableNameLen != 0 && strncmp(key, tsSmlChildTableName, keyLen) == 0){ + // handle child table name + if (childTableNameLen != 0 && strncmp(key, tsSmlChildTableName, keyLen) == 0) { memset(childTableName, 0, TSDB_TABLE_NAME_LEN); strncpy(childTableName, value, (valueLen < TSDB_TABLE_NAME_LEN ? valueLen : TSDB_TABLE_NAME_LEN)); continue; @@ -1014,22 +1038,22 @@ static int32_t smlParseTelnetTags(const char* data, SArray *cols, char *childTab // add kv to SSmlKv SSmlKv *kv = (SSmlKv *)taosMemoryCalloc(sizeof(SSmlKv), 1); - if(!kv) return TSDB_CODE_OUT_OF_MEMORY; + if (!kv) return TSDB_CODE_OUT_OF_MEMORY; kv->key = key; kv->keyLen = keyLen; kv->value = value; kv->length = valueLen; kv->type = TSDB_DATA_TYPE_NCHAR; - if(cols) taosArrayPush(cols, &kv); + if (cols) taosArrayPush(cols, &kv); } return TSDB_CODE_SUCCESS; } // format: =[ =] -static int32_t smlParseTelnetString(SSmlHandle *info, const char* sql, SSmlTableInfo *tinfo, SArray *cols){ - if(!sql) return TSDB_CODE_SML_INVALID_DATA; +static int32_t smlParseTelnetString(SSmlHandle *info, const char *sql, SSmlTableInfo *tinfo, SArray *cols) { + if (!sql) return TSDB_CODE_SML_INVALID_DATA; // parse metric smlParseTelnetElement(&sql, &tinfo->sTableName, &tinfo->sTableNameLen); @@ -1040,7 +1064,7 @@ static int32_t smlParseTelnetString(SSmlHandle *info, const char* sql, SSmlTable // parse timestamp const char *timestamp = NULL; - int32_t tLen = 0; + int32_t tLen = 0; smlParseTelnetElement(&sql, ×tamp, &tLen); if (!timestamp || tLen == 0) { smlBuildInvalidDataMsg(&info->msgBuf, "invalid timestamp", sql); @@ -1055,7 +1079,7 @@ static int32_t smlParseTelnetString(SSmlHandle *info, const char* sql, SSmlTable // parse value const char *value = NULL; - int32_t valueLen = 0; + int32_t valueLen = 0; smlParseTelnetElement(&sql, &value, &valueLen); if (!value || valueLen == 0) { smlBuildInvalidDataMsg(&info->msgBuf, "invalid value", sql); @@ -1063,13 +1087,13 @@ static int32_t smlParseTelnetString(SSmlHandle *info, const char* sql, SSmlTable } SSmlKv *kv = (SSmlKv *)taosMemoryCalloc(sizeof(SSmlKv), 1); - if(!kv) return TSDB_CODE_OUT_OF_MEMORY; + if (!kv) return TSDB_CODE_OUT_OF_MEMORY; taosArrayPush(cols, &kv); kv->key = VALUE; kv->keyLen = VALUE_LEN; kv->value = value; kv->length = valueLen; - if(!smlParseValue(kv, &info->msgBuf)){ + if (!smlParseValue(kv, &info->msgBuf)) { return TSDB_CODE_SML_INVALID_DATA; } @@ -1083,24 +1107,25 @@ static int32_t smlParseTelnetString(SSmlHandle *info, const char* sql, SSmlTable return TSDB_CODE_SUCCESS; } -static int32_t smlParseCols(const char* data, int32_t len, SArray *cols, char *childTableName, bool isTag, SHashObj *dumplicateKey, SSmlMsgBuf *msg){ - if(len == 0){ +static int32_t smlParseCols(const char *data, int32_t len, SArray *cols, char *childTableName, bool isTag, + SHashObj *dumplicateKey, SSmlMsgBuf *msg) { + if (len == 0) { return TSDB_CODE_SUCCESS; } - size_t childTableNameLen = strlen(tsSmlChildTableName); + size_t childTableNameLen = strlen(tsSmlChildTableName); const char *sql = data; - while(sql < data + len){ + while (sql < data + len) { const char *key = sql; - int32_t keyLen = 0; + int32_t keyLen = 0; - while(sql < data + len){ + while (sql < data + len) { // parse key - if(IS_COMMA(sql)) { + if (IS_COMMA(sql)) { smlBuildInvalidDataMsg(msg, "invalid data", sql); return TSDB_CODE_SML_INVALID_DATA; } - if(IS_EQUAL(sql)) { + if (IS_EQUAL(sql)) { keyLen = sql - key; sql++; break; @@ -1108,22 +1133,22 @@ static int32_t smlParseCols(const char* data, int32_t len, SArray *cols, char *c sql++; } - if(IS_INVALID_COL_LEN(keyLen)){ + if (IS_INVALID_COL_LEN(keyLen)) { smlBuildInvalidDataMsg(msg, "invalid key or key is too long than 64", key); return TSDB_CODE_SML_INVALID_DATA; } - if(smlCheckDuplicateKey(key, keyLen, dumplicateKey)){ + if (smlCheckDuplicateKey(key, keyLen, dumplicateKey)) { smlBuildInvalidDataMsg(msg, "dumplicate key", key); return TSDB_CODE_TSC_DUP_TAG_NAMES; } // parse value const char *value = sql; - int32_t valueLen = 0; - bool isInQuote = false; - while(sql < data + len) { + int32_t valueLen = 0; + bool isInQuote = false; + while (sql < data + len) { // parse value - if(!isTag && IS_QUOTE(sql)){ + if (!isTag && IS_QUOTE(sql)) { isInQuote = !isInQuote; sql++; continue; @@ -1140,19 +1165,19 @@ static int32_t smlParseCols(const char* data, int32_t len, SArray *cols, char *c valueLen = sql - value; sql++; - if(isInQuote){ + if (isInQuote) { smlBuildInvalidDataMsg(msg, "only one quote", value); return TSDB_CODE_SML_INVALID_DATA; } - if(valueLen == 0){ + if (valueLen == 0) { smlBuildInvalidDataMsg(msg, "invalid value", value); return TSDB_CODE_SML_INVALID_DATA; } PROCESS_SLASH(key, keyLen) PROCESS_SLASH(value, valueLen) - //handle child table name - if(childTableName && childTableNameLen != 0 && strncmp(key, tsSmlChildTableName, keyLen) == 0){ + // handle child table name + if (childTableName && childTableNameLen != 0 && strncmp(key, tsSmlChildTableName, keyLen) == 0) { memset(childTableName, 0, TSDB_TABLE_NAME_LEN); strncpy(childTableName, value, (valueLen < TSDB_TABLE_NAME_LEN ? valueLen : TSDB_TABLE_NAME_LEN)); continue; @@ -1160,17 +1185,17 @@ static int32_t smlParseCols(const char* data, int32_t len, SArray *cols, char *c // add kv to SSmlKv SSmlKv *kv = (SSmlKv *)taosMemoryCalloc(sizeof(SSmlKv), 1); - if(!kv) return TSDB_CODE_OUT_OF_MEMORY; - if(cols) taosArrayPush(cols, &kv); + if (!kv) return TSDB_CODE_OUT_OF_MEMORY; + if (cols) taosArrayPush(cols, &kv); kv->key = key; kv->keyLen = keyLen; kv->value = value; kv->length = valueLen; - if(isTag){ + if (isTag) { kv->type = TSDB_DATA_TYPE_NCHAR; - }else{ - if(!smlParseValue(kv, msg)){ + } else { + if (!smlParseValue(kv, msg)) { return TSDB_CODE_SML_INVALID_DATA; } } @@ -1179,24 +1204,24 @@ static int32_t smlParseCols(const char* data, int32_t len, SArray *cols, char *c return TSDB_CODE_SUCCESS; } -static bool smlUpdateMeta(SHashObj *metaHash, SArray *metaArray, SArray *cols, SSmlMsgBuf *msg){ - for (int i = 0; i < taosArrayGetSize(cols); ++i) { //jump timestamp +static bool smlUpdateMeta(SHashObj *metaHash, SArray *metaArray, SArray *cols, SSmlMsgBuf *msg) { + for (int i = 0; i < taosArrayGetSize(cols); ++i) { // jump timestamp SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, i); int16_t *index = (int16_t *)taosHashGet(metaHash, kv->key, kv->keyLen); - if(index){ + if (index) { SSmlKv **value = (SSmlKv **)taosArrayGet(metaArray, *index); - if(kv->type != (*value)->type){ + if (kv->type != (*value)->type) { smlBuildInvalidDataMsg(msg, "the type is not the same like before", kv->key); return false; - }else{ - if(IS_VAR_DATA_TYPE(kv->type)){ // update string len, if bigger - if(kv->length > (*value)->length){ + } else { + if (IS_VAR_DATA_TYPE(kv->type)) { // update string len, if bigger + if (kv->length > (*value)->length) { *value = kv; } } } - }else{ + } else { size_t tmp = taosArrayGetSize(metaArray); ASSERT(tmp <= INT16_MAX); int16_t size = tmp; @@ -1208,7 +1233,7 @@ static bool smlUpdateMeta(SHashObj *metaHash, SArray *metaArray, SArray *cols, S return true; } -static void smlInsertMeta(SHashObj *metaHash, SArray *metaArray, SArray *cols){ +static void smlInsertMeta(SHashObj *metaHash, SArray *metaArray, SArray *cols) { for (int16_t i = 0; i < taosArrayGetSize(cols); ++i) { SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, i); taosArrayPush(metaArray, &kv); @@ -1216,9 +1241,9 @@ static void smlInsertMeta(SHashObj *metaHash, SArray *metaArray, SArray *cols){ } } -static SSmlTableInfo* smlBuildTableInfo(){ +static SSmlTableInfo *smlBuildTableInfo() { SSmlTableInfo *tag = (SSmlTableInfo *)taosMemoryCalloc(sizeof(SSmlTableInfo), 1); - if(!tag){ + if (!tag) { return NULL; } @@ -1240,50 +1265,50 @@ cleanup: return NULL; } -static void smlDestroyTableInfo(SSmlHandle* info, SSmlTableInfo *tag){ - if(info->dataFormat){ - for(size_t i = 0; i < taosArrayGetSize(tag->cols); i++){ +static void smlDestroyTableInfo(SSmlHandle *info, SSmlTableInfo *tag) { + if (info->dataFormat) { + for (size_t i = 0; i < taosArrayGetSize(tag->cols); i++) { SArray *kvArray = (SArray *)taosArrayGetP(tag->cols, i); for (int j = 0; j < taosArrayGetSize(kvArray); ++j) { SSmlKv *p = (SSmlKv *)taosArrayGetP(kvArray, j); - if(info->protocol == TSDB_SML_JSON_PROTOCOL && - (p->type == TSDB_DATA_TYPE_NCHAR || p->type == TSDB_DATA_TYPE_BINARY)){ - taosMemoryFree((void*)p->value); + if (info->protocol == TSDB_SML_JSON_PROTOCOL && + (p->type == TSDB_DATA_TYPE_NCHAR || p->type == TSDB_DATA_TYPE_BINARY)) { + taosMemoryFree((void *)p->value); } taosMemoryFree(p); } taosArrayDestroy(kvArray); } - }else{ - for(size_t i = 0; i < taosArrayGetSize(tag->cols); i++){ + } else { + for (size_t i = 0; i < taosArrayGetSize(tag->cols); i++) { SHashObj *kvHash = (SHashObj *)taosArrayGetP(tag->cols, i); - void** p1 = (void**)taosHashIterate(kvHash, NULL); + void **p1 = (void **)taosHashIterate(kvHash, NULL); while (p1) { taosMemoryFree(*p1); - p1 = (void**)taosHashIterate(kvHash, p1); + p1 = (void **)taosHashIterate(kvHash, p1); } taosHashCleanup(kvHash); } } - for(size_t i = 0; i < taosArrayGetSize(tag->tags); i++){ + for (size_t i = 0; i < taosArrayGetSize(tag->tags); i++) { SSmlKv *p = (SSmlKv *)taosArrayGetP(tag->tags, i); - if(info->protocol == TSDB_SML_JSON_PROTOCOL){ - taosMemoryFree((void*)p->key); - if(p->type == TSDB_DATA_TYPE_NCHAR || p->type == TSDB_DATA_TYPE_BINARY){ - taosMemoryFree((void*)p->value); + if (info->protocol == TSDB_SML_JSON_PROTOCOL) { + taosMemoryFree((void *)p->key); + if (p->type == TSDB_DATA_TYPE_NCHAR || p->type == TSDB_DATA_TYPE_BINARY) { + taosMemoryFree((void *)p->value); } } taosMemoryFree(p); } - if(info->protocol == TSDB_SML_JSON_PROTOCOL && tag->sTableName){ - taosMemoryFree((void*)tag->sTableName); + if (info->protocol == TSDB_SML_JSON_PROTOCOL && tag->sTableName) { + taosMemoryFree((void *)tag->sTableName); } taosArrayDestroy(tag->cols); taosArrayDestroy(tag->tags); taosMemoryFree(tag); } -static int32_t smlKvTimeArrayCompare(const void* key1, const void* key2) { +static int32_t smlKvTimeArrayCompare(const void *key1, const void *key2) { SArray *s1 = *(SArray **)key1; SArray *s2 = *(SArray **)key2; SSmlKv *kv1 = (SSmlKv *)taosArrayGetP(s1, 0); @@ -1299,11 +1324,11 @@ static int32_t smlKvTimeArrayCompare(const void* key1, const void* key2) { } } -static int32_t smlKvTimeHashCompare(const void* key1, const void* key2) { +static int32_t smlKvTimeHashCompare(const void *key1, const void *key2) { SHashObj *s1 = *(SHashObj **)key1; SHashObj *s2 = *(SHashObj **)key2; - SSmlKv *kv1 = (SSmlKv *)taosHashGet(s1, TS, TS_LEN); - SSmlKv *kv2 = (SSmlKv *)taosHashGet(s2, TS, TS_LEN); + SSmlKv *kv1 = *(SSmlKv **)taosHashGet(s1, TS, TS_LEN); + SSmlKv *kv2 = *(SSmlKv **)taosHashGet(s2, TS, TS_LEN); ASSERT(kv1->type == TSDB_DATA_TYPE_TIMESTAMP); ASSERT(kv2->type == TSDB_DATA_TYPE_TIMESTAMP); if (kv1->i < kv2->i) { @@ -1317,69 +1342,37 @@ static int32_t smlKvTimeHashCompare(const void* key1, const void* key2) { static int32_t smlDealCols(SSmlTableInfo* oneTable, bool dataFormat, SArray *cols){ if(dataFormat){ - void *p = taosArraySearch(oneTable->cols, &cols, smlKvTimeArrayCompare, TD_GE); + void *p = taosArraySearch(oneTable->cols, &cols, smlKvTimeArrayCompare, TD_GT); if(p == NULL){ taosArrayPush(oneTable->cols, &cols); - }else{ // to make the sort stable for update data - SArray *sa = (SArray *)p; - SSmlKv *cur = (SSmlKv*)taosArrayGet(sa, 0); - SSmlKv *dCur = (SSmlKv*)taosArrayGet(cols, 0); - if(cur->i > dCur->i){ - taosArrayInsert(oneTable->cols, TARRAY_ELEM_IDX(oneTable->cols, p), &cols); - }else{ - ASSERT(cur->i == dCur->i); - int32_t index = TARRAY_ELEM_IDX(oneTable->cols, p) + 1; - for(; index < taosArrayGetSize(oneTable->cols); index++){ - SArray *tmp = (SArray *)taosArrayGet(oneTable->cols, index); - SSmlKv *curTs = (SSmlKv*)taosArrayGet(tmp, 0); - if(curTs->i > dCur->i){ - break; - } - } - taosArrayInsert(oneTable->cols, index, &cols); - } + }else{ + taosArrayInsert(oneTable->cols, TARRAY_ELEM_IDX(oneTable->cols, p), &cols); } return TSDB_CODE_SUCCESS; } SHashObj *kvHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); - if(!kvHash){ + if (!kvHash) { uError("SML:smlDealCols failed to allocate memory"); return TSDB_CODE_TSC_OUT_OF_MEMORY; } - for(size_t i = 0; i < taosArrayGetSize(cols); i++){ + for (size_t i = 0; i < taosArrayGetSize(cols); i++) { SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, i); taosHashPut(kvHash, kv->key, kv->keyLen, &kv, POINTER_BYTES); } - void *p = taosArraySearch(oneTable->cols, &kvHash, smlKvTimeHashCompare, TD_GE); + void *p = taosArraySearch(oneTable->cols, &kvHash, smlKvTimeHashCompare, TD_GT); if(p == NULL){ taosArrayPush(oneTable->cols, &kvHash); - }else{ // to make the sort stable for update data - SHashObj *sa = (SHashObj *)p; - SSmlKv *cur = (SSmlKv *)taosHashGet(sa, TS, TS_LEN); - SSmlKv *dCur = (SSmlKv*)taosArrayGet(cols, 0); - if(cur->i > dCur->i){ - taosArrayInsert(oneTable->cols, TARRAY_ELEM_IDX(oneTable->cols, p), &cols); - }else{ - ASSERT(cur->i == dCur->i); - int32_t index = TARRAY_ELEM_IDX(oneTable->cols, p) + 1; - for(; index < taosArrayGetSize(oneTable->cols); index++){ - SHashObj *tmp = (SHashObj *)taosArrayGet(oneTable->cols, index); - SSmlKv *curTs = (SSmlKv *)taosHashGet(tmp, TS, TS_LEN); - if(curTs->i > dCur->i){ - break; - } - } - taosArrayInsert(oneTable->cols, index, &cols); - } + }else{ + taosArrayInsert(oneTable->cols, TARRAY_ELEM_IDX(oneTable->cols, p), &kvHash); } return TSDB_CODE_SUCCESS; } -static SSmlSTableMeta* smlBuildSTableMeta(){ - SSmlSTableMeta* meta = (SSmlSTableMeta*)taosMemoryCalloc(sizeof(SSmlSTableMeta), 1); - if(!meta){ +static SSmlSTableMeta *smlBuildSTableMeta() { + SSmlSTableMeta *meta = (SSmlSTableMeta *)taosMemoryCalloc(sizeof(SSmlSTableMeta), 1); + if (!meta) { return NULL; } meta->tagHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); @@ -1412,7 +1405,7 @@ cleanup: return NULL; } -static void smlDestroySTableMeta(SSmlSTableMeta *meta){ +static void smlDestroySTableMeta(SSmlSTableMeta *meta) { taosHashCleanup(meta->tagHash); taosHashCleanup(meta->colHash); taosArrayDestroy(meta->tags); @@ -1429,31 +1422,31 @@ static void smlDestroyCols(SArray *cols) { } } -static void smlDestroyInfo(SSmlHandle* info){ - if(!info) return; +static void smlDestroyInfo(SSmlHandle *info) { + if (!info) return; qDestroyQuery(info->pQuery); smlDestroyHandle(info->exec); // destroy info->childTables - void** p1 = (void**)taosHashIterate(info->childTables, NULL); + void **p1 = (void **)taosHashIterate(info->childTables, NULL); while (p1) { - smlDestroyTableInfo(info, (SSmlTableInfo*)(*p1)); - p1 = (void**)taosHashIterate(info->childTables, p1); + smlDestroyTableInfo(info, (SSmlTableInfo *)(*p1)); + p1 = (void **)taosHashIterate(info->childTables, p1); } taosHashCleanup(info->childTables); // destroy info->superTables - p1 = (void**)taosHashIterate(info->superTables, NULL); + p1 = (void **)taosHashIterate(info->superTables, NULL); while (p1) { - smlDestroySTableMeta((SSmlSTableMeta*)(*p1)); - p1 = (void**)taosHashIterate(info->superTables, p1); + smlDestroySTableMeta((SSmlSTableMeta *)(*p1)); + p1 = (void **)taosHashIterate(info->superTables, p1); } taosHashCleanup(info->superTables); // destroy info->pVgHash taosHashCleanup(info->pVgHash); taosHashCleanup(info->dumplicateKey); - if(!info->dataFormat){ + if (!info->dataFormat) { taosArrayDestroy(info->colsContainer); } destroyRequest(info->pRequest); @@ -1466,58 +1459,57 @@ static SSmlHandle* smlBuildSmlInfo(STscObj* pTscObj, SRequestObj* request, SMLPr if (NULL == info) { return NULL; } - info->id = smlGenId(); + info->id = smlGenId(); - info->pQuery = (SQuery *)taosMemoryCalloc(1, sizeof(SQuery)); + info->pQuery = (SQuery *)taosMemoryCalloc(1, sizeof(SQuery)); if (NULL == info->pQuery) { - uError("SML:0x%"PRIx64" create info->pQuery error", info->id); + uError("SML:0x%" PRIx64 " create info->pQuery error", info->id); goto cleanup; } - info->pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE; + info->pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE; info->pQuery->haveResultSet = false; - info->pQuery->msgType = TDMT_VND_SUBMIT; - info->pQuery->pRoot = (SNode*)nodesMakeNode(QUERY_NODE_VNODE_MODIF_STMT); - if(NULL == info->pQuery->pRoot){ - uError("SML:0x%"PRIx64" create info->pQuery->pRoot error", info->id); + info->pQuery->msgType = TDMT_VND_SUBMIT; + info->pQuery->pRoot = (SNode *)nodesMakeNode(QUERY_NODE_VNODE_MODIF_STMT); + if (NULL == info->pQuery->pRoot) { + uError("SML:0x%" PRIx64 " create info->pQuery->pRoot error", info->id); goto cleanup; } - ((SVnodeModifOpStmt*)(info->pQuery->pRoot))->payloadType = PAYLOAD_TYPE_KV; + ((SVnodeModifOpStmt *)(info->pQuery->pRoot))->payloadType = PAYLOAD_TYPE_KV; info->taos = pTscObj; code = catalogGetHandle(info->taos->pAppInfo->clusterId, &info->pCatalog); - if(code != TSDB_CODE_SUCCESS){ - uError("SML:0x%"PRIx64" get catalog error %d", info->id, code); + if (code != TSDB_CODE_SUCCESS) { + uError("SML:0x%" PRIx64 " get catalog error %d", info->id, code); goto cleanup; } - info->precision = precision; - info->protocol = protocol; - if(protocol == TSDB_SML_LINE_PROTOCOL){ + info->precision = precision; + info->protocol = protocol; + if (protocol == TSDB_SML_LINE_PROTOCOL) { info->dataFormat = tsSmlDataFormat; - }else{ + } else { info->dataFormat = true; } - info->pRequest = request; - info->msgBuf.buf = info->pRequest->msgBuf; - info->msgBuf.len = ERROR_MSG_BUF_DEFAULT_SIZE; + info->pRequest = request; + info->msgBuf.buf = info->pRequest->msgBuf; + info->msgBuf.len = ERROR_MSG_BUF_DEFAULT_SIZE; - info->exec = smlInitHandle(info->pQuery); + info->exec = smlInitHandle(info->pQuery); info->childTables = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); info->superTables = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); - info->pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK); + info->pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK); info->dumplicateKey = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); - if(!info->dataFormat){ + if (!info->dataFormat) { info->colsContainer = taosArrayInit(32, POINTER_BYTES); - if(NULL == info->colsContainer){ - uError("SML:0x%"PRIx64" create info failed", info->id); + if (NULL == info->colsContainer) { + uError("SML:0x%" PRIx64 " create info failed", info->id); goto cleanup; } } - if(NULL == info->exec || NULL == info->childTables - || NULL == info->superTables || NULL == info->pVgHash - || NULL == info->dumplicateKey){ - uError("SML:0x%"PRIx64" create info failed", info->id); + if (NULL == info->exec || NULL == info->childTables || NULL == info->superTables || NULL == info->pVgHash || + NULL == info->dumplicateKey) { + uError("SML:0x%" PRIx64 " create info failed", info->id); goto cleanup; } @@ -1528,25 +1520,25 @@ cleanup: } /************* TSDB_SML_JSON_PROTOCOL function start **************/ -static int32_t smlJsonCreateSring(const char **output, char *input, int32_t inputLen){ +static int32_t smlJsonCreateSring(const char **output, char *input, int32_t inputLen) { *output = (const char *)taosMemoryMalloc(inputLen); - if (*output == NULL){ + if (*output == NULL) { return TSDB_CODE_TSC_OUT_OF_MEMORY; } - memcpy((void*)(*output), input, inputLen); + memcpy((void *)(*output), input, inputLen); return TSDB_CODE_SUCCESS; } static int32_t smlParseMetricFromJSON(SSmlHandle *info, cJSON *root, SSmlTableInfo *tinfo) { cJSON *metric = cJSON_GetObjectItem(root, "metric"); if (!cJSON_IsString(metric)) { - return TSDB_CODE_TSC_INVALID_JSON; + return TSDB_CODE_TSC_INVALID_JSON; } tinfo->sTableNameLen = strlen(metric->valuestring); if (IS_INVALID_TABLE_LEN(tinfo->sTableNameLen)) { - uError("OTD:0x%"PRIx64" Metric lenght is 0 or large than 192", info->id); + uError("OTD:0x%" PRIx64 " Metric lenght is 0 or large than 192", info->id); return TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH; } @@ -1570,19 +1562,19 @@ static int32_t smlParseTSFromJSONObj(SSmlHandle *info, cJSON *root, int64_t *tsV } double timeDouble = value->valuedouble; - if(smlDoubleToInt64OverFlow(timeDouble)){ + if (smlDoubleToInt64OverFlow(timeDouble)) { smlBuildInvalidDataMsg(&info->msgBuf, "timestamp is too large", NULL); return TSDB_CODE_TSC_INVALID_TIME_STAMP; } - if(timeDouble <= 0){ + if (timeDouble <= 0) { return TSDB_CODE_TSC_INVALID_TIME_STAMP; } size_t typeLen = strlen(type->valuestring); if (typeLen == 1 && (type->valuestring[0] == 's' || type->valuestring[0] == 'S')) { - //seconds + // seconds timeDouble = timeDouble * 1e9; - if(smlDoubleToInt64OverFlow(timeDouble)){ + if (smlDoubleToInt64OverFlow(timeDouble)) { smlBuildInvalidDataMsg(&info->msgBuf, "timestamp is too large", NULL); return TSDB_CODE_TSC_INVALID_TIME_STAMP; } @@ -1591,9 +1583,9 @@ static int32_t smlParseTSFromJSONObj(SSmlHandle *info, cJSON *root, int64_t *tsV switch (type->valuestring[0]) { case 'm': case 'M': - //milliseconds + // milliseconds timeDouble = timeDouble * 1e6; - if(smlDoubleToInt64OverFlow(timeDouble)){ + if (smlDoubleToInt64OverFlow(timeDouble)) { smlBuildInvalidDataMsg(&info->msgBuf, "timestamp is too large", NULL); return TSDB_CODE_TSC_INVALID_TIME_STAMP; } @@ -1601,9 +1593,9 @@ static int32_t smlParseTSFromJSONObj(SSmlHandle *info, cJSON *root, int64_t *tsV break; case 'u': case 'U': - //microseconds + // microseconds timeDouble = timeDouble * 1e3; - if(smlDoubleToInt64OverFlow(timeDouble)){ + if (smlDoubleToInt64OverFlow(timeDouble)) { smlBuildInvalidDataMsg(&info->msgBuf, "timestamp is too large", NULL); return TSDB_CODE_TSC_INVALID_TIME_STAMP; } @@ -1611,7 +1603,7 @@ static int32_t smlParseTSFromJSONObj(SSmlHandle *info, cJSON *root, int64_t *tsV break; case 'n': case 'N': - //nanoseconds + // nanoseconds *tsVal = timeDouble; break; default: @@ -1634,45 +1626,45 @@ static uint8_t smlGetTimestampLen(int64_t num) { } static int32_t smlParseTSFromJSON(SSmlHandle *info, cJSON *root, SArray *cols) { - //Timestamp must be the first KV to parse + // Timestamp must be the first KV to parse int64_t tsVal = 0; cJSON *timestamp = cJSON_GetObjectItem(root, "timestamp"); if (cJSON_IsNumber(timestamp)) { - //timestamp value 0 indicates current system time + // timestamp value 0 indicates current system time double timeDouble = timestamp->valuedouble; - if(smlDoubleToInt64OverFlow(timeDouble)){ + if (smlDoubleToInt64OverFlow(timeDouble)) { smlBuildInvalidDataMsg(&info->msgBuf, "timestamp is too large", NULL); return TSDB_CODE_TSC_INVALID_TIME_STAMP; } - if(timeDouble < 0){ + if (timeDouble < 0) { return TSDB_CODE_TSC_INVALID_TIME_STAMP; } uint8_t tsLen = smlGetTimestampLen((int64_t)timeDouble); if (tsLen == TSDB_TIME_PRECISION_SEC_DIGITS) { timeDouble = timeDouble * 1e9; - if(smlDoubleToInt64OverFlow(timeDouble)){ + if (smlDoubleToInt64OverFlow(timeDouble)) { smlBuildInvalidDataMsg(&info->msgBuf, "timestamp is too large", NULL); return TSDB_CODE_TSC_INVALID_TIME_STAMP; } tsVal = timeDouble; } else if (tsLen == TSDB_TIME_PRECISION_MILLI_DIGITS) { timeDouble = timeDouble * 1e6; - if(smlDoubleToInt64OverFlow(timeDouble)){ + if (smlDoubleToInt64OverFlow(timeDouble)) { smlBuildInvalidDataMsg(&info->msgBuf, "timestamp is too large", NULL); return TSDB_CODE_TSC_INVALID_TIME_STAMP; } tsVal = timeDouble; - } else if(timeDouble == 0){ + } else if (timeDouble == 0) { tsVal = taosGetTimestampNs(); - }else { + } else { return TSDB_CODE_TSC_INVALID_TIME_STAMP; } } else if (cJSON_IsObject(timestamp)) { int32_t ret = smlParseTSFromJSONObj(info, timestamp, &tsVal); if (ret != TSDB_CODE_SUCCESS) { - uError("SML:0x%"PRIx64" Failed to parse timestamp from JSON Obj", info->id); + uError("SML:0x%" PRIx64 " Failed to parse timestamp from JSON Obj", info->id); return ret; } } else { @@ -1681,7 +1673,7 @@ static int32_t smlParseTSFromJSON(SSmlHandle *info, cJSON *root, SArray *cols) { // add ts to SSmlKv *kv = (SSmlKv *)taosMemoryCalloc(sizeof(SSmlKv), 1); - if(!kv){ + if (!kv) { return TSDB_CODE_OUT_OF_MEMORY; } kv->key = TS; @@ -1689,12 +1681,11 @@ static int32_t smlParseTSFromJSON(SSmlHandle *info, cJSON *root, SArray *cols) { kv->i = tsVal; kv->type = TSDB_DATA_TYPE_TIMESTAMP; kv->length = (int16_t)tDataTypes[kv->type].bytes; - if(cols) taosArrayPush(cols, &kv); + if (cols) taosArrayPush(cols, &kv); return TSDB_CODE_SUCCESS; - } -static int32_t smlConvertJSONBool(SSmlKv *pVal, char* typeStr, cJSON *value) { +static int32_t smlConvertJSONBool(SSmlKv *pVal, char *typeStr, cJSON *value) { if (strcasecmp(typeStr, "bool") != 0) { uError("OTD:invalid type(%s) for JSON Bool", typeStr); return TSDB_CODE_TSC_INVALID_JSON_TYPE; @@ -1706,10 +1697,9 @@ static int32_t smlConvertJSONBool(SSmlKv *pVal, char* typeStr, cJSON *value) { return TSDB_CODE_SUCCESS; } -static int32_t smlConvertJSONNumber(SSmlKv *pVal, char* typeStr, cJSON *value) { - //tinyint - if (strcasecmp(typeStr, "i8") == 0 || - strcasecmp(typeStr, "tinyint") == 0) { +static int32_t smlConvertJSONNumber(SSmlKv *pVal, char *typeStr, cJSON *value) { + // tinyint + if (strcasecmp(typeStr, "i8") == 0 || strcasecmp(typeStr, "tinyint") == 0) { if (!IS_VALID_TINYINT(value->valuedouble)) { uError("OTD:JSON value(%f) cannot fit in type(tinyint)", value->valuedouble); return TSDB_CODE_TSC_VALUE_OUT_OF_RANGE; @@ -1719,9 +1709,8 @@ static int32_t smlConvertJSONNumber(SSmlKv *pVal, char* typeStr, cJSON *value) { pVal->i = value->valuedouble; return TSDB_CODE_SUCCESS; } - //smallint - if (strcasecmp(typeStr, "i16") == 0 || - strcasecmp(typeStr, "smallint") == 0) { + // smallint + if (strcasecmp(typeStr, "i16") == 0 || strcasecmp(typeStr, "smallint") == 0) { if (!IS_VALID_SMALLINT(value->valuedouble)) { uError("OTD:JSON value(%f) cannot fit in type(smallint)", value->valuedouble); return TSDB_CODE_TSC_VALUE_OUT_OF_RANGE; @@ -1731,9 +1720,8 @@ static int32_t smlConvertJSONNumber(SSmlKv *pVal, char* typeStr, cJSON *value) { pVal->i = value->valuedouble; return TSDB_CODE_SUCCESS; } - //int - if (strcasecmp(typeStr, "i32") == 0 || - strcasecmp(typeStr, "int") == 0) { + // int + if (strcasecmp(typeStr, "i32") == 0 || strcasecmp(typeStr, "int") == 0) { if (!IS_VALID_INT(value->valuedouble)) { uError("OTD:JSON value(%f) cannot fit in type(int)", value->valuedouble); return TSDB_CODE_TSC_VALUE_OUT_OF_RANGE; @@ -1743,23 +1731,21 @@ static int32_t smlConvertJSONNumber(SSmlKv *pVal, char* typeStr, cJSON *value) { pVal->i = value->valuedouble; return TSDB_CODE_SUCCESS; } - //bigint - if (strcasecmp(typeStr, "i64") == 0 || - strcasecmp(typeStr, "bigint") == 0) { + // bigint + if (strcasecmp(typeStr, "i64") == 0 || strcasecmp(typeStr, "bigint") == 0) { pVal->type = TSDB_DATA_TYPE_BIGINT; pVal->length = (int16_t)tDataTypes[pVal->type].bytes; - if(value->valuedouble >= (double)INT64_MAX){ + if (value->valuedouble >= (double)INT64_MAX) { pVal->i = INT64_MAX; - }else if(value->valuedouble <= (double)INT64_MIN){ + } else if (value->valuedouble <= (double)INT64_MIN) { pVal->i = INT64_MIN; - }else{ + } else { pVal->i = value->valuedouble; } return TSDB_CODE_SUCCESS; } - //float - if (strcasecmp(typeStr, "f32") == 0 || - strcasecmp(typeStr, "float") == 0) { + // float + if (strcasecmp(typeStr, "f32") == 0 || strcasecmp(typeStr, "float") == 0) { if (!IS_VALID_FLOAT(value->valuedouble)) { uError("OTD:JSON value(%f) cannot fit in type(float)", value->valuedouble); return TSDB_CODE_TSC_VALUE_OUT_OF_RANGE; @@ -1769,21 +1755,20 @@ static int32_t smlConvertJSONNumber(SSmlKv *pVal, char* typeStr, cJSON *value) { pVal->f = value->valuedouble; return TSDB_CODE_SUCCESS; } - //double - if (strcasecmp(typeStr, "f64") == 0 || - strcasecmp(typeStr, "double") == 0) { + // double + if (strcasecmp(typeStr, "f64") == 0 || strcasecmp(typeStr, "double") == 0) { pVal->type = TSDB_DATA_TYPE_DOUBLE; pVal->length = (int16_t)tDataTypes[pVal->type].bytes; pVal->d = value->valuedouble; return TSDB_CODE_SUCCESS; } - //if reach here means type is unsupported + // if reach here means type is unsupported uError("OTD:invalid type(%s) for JSON Number", typeStr); return TSDB_CODE_TSC_INVALID_JSON_TYPE; } -static int32_t smlConvertJSONString(SSmlKv *pVal, char* typeStr, cJSON *value) { +static int32_t smlConvertJSONString(SSmlKv *pVal, char *typeStr, cJSON *value) { if (strcasecmp(typeStr, "binary") == 0) { pVal->type = TSDB_DATA_TYPE_BINARY; } else if (strcasecmp(typeStr, "nchar") == 0) { @@ -1864,7 +1849,7 @@ static int32_t smlParseValueFromJSON(cJSON *root, SSmlKv *kv) { * user configured parameter tsDefaultJSONStrType */ - char *tsDefaultJSONStrType = "nchar"; //todo + char *tsDefaultJSONStrType = "nchar"; // todo smlConvertJSONString(kv, tsDefaultJSONStrType, root); break; } @@ -1890,10 +1875,10 @@ static int32_t smlParseColsFromJSON(cJSON *root, SArray *cols) { } SSmlKv *kv = (SSmlKv *)taosMemoryCalloc(sizeof(SSmlKv), 1); - if(!kv){ + if (!kv) { return TSDB_CODE_OUT_OF_MEMORY; } - if(cols) taosArrayPush(cols, &kv); + if (cols) taosArrayPush(cols, &kv); kv->key = VALUE; kv->keyLen = VALUE_LEN; @@ -1904,7 +1889,8 @@ static int32_t smlParseColsFromJSON(cJSON *root, SArray *cols) { return TSDB_CODE_SUCCESS; } -static int32_t smlParseTagsFromJSON(cJSON *root, SArray *pKVs, char *childTableName, SHashObj *dumplicateKey, SSmlMsgBuf *msg) { +static int32_t smlParseTagsFromJSON(cJSON *root, SArray *pKVs, char *childTableName, SHashObj *dumplicateKey, + SSmlMsgBuf *msg) { int32_t ret = TSDB_CODE_SUCCESS; cJSON *tags = cJSON_GetObjectItem(root, "tags"); @@ -1912,7 +1898,7 @@ static int32_t smlParseTagsFromJSON(cJSON *root, SArray *pKVs, char *childTableN return TSDB_CODE_TSC_INVALID_JSON; } - size_t childTableNameLen = strlen(tsSmlChildTableName); + size_t childTableNameLen = strlen(tsSmlChildTableName); int32_t tagNum = cJSON_GetArraySize(tags); for (int32_t i = 0; i < tagNum; ++i) { cJSON *tag = cJSON_GetArrayItem(tags, i); @@ -1924,13 +1910,13 @@ static int32_t smlParseTagsFromJSON(cJSON *root, SArray *pKVs, char *childTableN uError("OTD:Tag key length is 0 or too large than 64"); return TSDB_CODE_TSC_INVALID_COLUMN_LENGTH; } - //check duplicate keys + // check duplicate keys if (smlCheckDuplicateKey(tag->string, keyLen, dumplicateKey)) { return TSDB_CODE_TSC_DUP_TAG_NAMES; } - //handle child table name - if(childTableNameLen != 0 && strcmp(tag->string, tsSmlChildTableName) == 0){ + // handle child table name + if (childTableNameLen != 0 && strcmp(tag->string, tsSmlChildTableName) == 0) { if (!cJSON_IsString(tag)) { uError("OTD:ID must be JSON string"); return TSDB_CODE_TSC_INVALID_JSON; @@ -1942,16 +1928,16 @@ static int32_t smlParseTagsFromJSON(cJSON *root, SArray *pKVs, char *childTableN // add kv to SSmlKv SSmlKv *kv = (SSmlKv *)taosMemoryCalloc(sizeof(SSmlKv), 1); - if(!kv) return TSDB_CODE_OUT_OF_MEMORY; - if(pKVs) taosArrayPush(pKVs, &kv); + if (!kv) return TSDB_CODE_OUT_OF_MEMORY; + if (pKVs) taosArrayPush(pKVs, &kv); - //key + // key kv->keyLen = keyLen; ret = smlJsonCreateSring(&kv->key, tag->string, kv->keyLen); if (ret != TSDB_CODE_SUCCESS) { return ret; } - //value + // value ret = smlParseValueFromJSON(tag, kv); if (ret != TSDB_CODE_SUCCESS) { return ret; @@ -1959,105 +1945,103 @@ static int32_t smlParseTagsFromJSON(cJSON *root, SArray *pKVs, char *childTableN } return ret; - } static int32_t smlParseJSONString(SSmlHandle *info, cJSON *root, SSmlTableInfo *tinfo, SArray *cols) { int32_t ret = TSDB_CODE_SUCCESS; if (!cJSON_IsObject(root)) { - uError("OTD:0x%"PRIx64" data point needs to be JSON object", info->id); + uError("OTD:0x%" PRIx64 " data point needs to be JSON object", info->id); return TSDB_CODE_TSC_INVALID_JSON; } int32_t size = cJSON_GetArraySize(root); - //outmost json fields has to be exactly 4 + // outmost json fields has to be exactly 4 if (size != OTD_JSON_FIELDS_NUM) { - uError("OTD:0x%"PRIx64" Invalid number of JSON fields in data point %d", info->id, size); + uError("OTD:0x%" PRIx64 " Invalid number of JSON fields in data point %d", info->id, size); return TSDB_CODE_TSC_INVALID_JSON; } - //Parse metric + // Parse metric ret = smlParseMetricFromJSON(info, root, tinfo); if (ret != TSDB_CODE_SUCCESS) { - uError("OTD:0x%"PRIx64" Unable to parse metric from JSON payload", info->id); + uError("OTD:0x%" PRIx64 " Unable to parse metric from JSON payload", info->id); return ret; } - uDebug("OTD:0x%"PRIx64" Parse metric from JSON payload finished", info->id); + uDebug("OTD:0x%" PRIx64 " Parse metric from JSON payload finished", info->id); - //Parse timestamp + // Parse timestamp ret = smlParseTSFromJSON(info, root, cols); if (ret) { - uError("OTD:0x%"PRIx64" Unable to parse timestamp from JSON payload", info->id); + uError("OTD:0x%" PRIx64 " Unable to parse timestamp from JSON payload", info->id); return ret; } - uDebug("OTD:0x%"PRIx64" Parse timestamp from JSON payload finished", info->id); + uDebug("OTD:0x%" PRIx64 " Parse timestamp from JSON payload finished", info->id); - //Parse metric value + // Parse metric value ret = smlParseColsFromJSON(root, cols); if (ret) { - uError("OTD:0x%"PRIx64" Unable to parse metric value from JSON payload", info->id); + uError("OTD:0x%" PRIx64 " Unable to parse metric value from JSON payload", info->id); return ret; } - uDebug("OTD:0x%"PRIx64" Parse metric value from JSON payload finished", info->id); + uDebug("OTD:0x%" PRIx64 " Parse metric value from JSON payload finished", info->id); - //Parse tags + // Parse tags ret = smlParseTagsFromJSON(root, tinfo->tags, tinfo->childTableName, info->dumplicateKey, &info->msgBuf); if (ret) { - uError("OTD:0x%"PRIx64" Unable to parse tags from JSON payload", info->id); + uError("OTD:0x%" PRIx64 " Unable to parse tags from JSON payload", info->id); return ret; } - uDebug("OTD:0x%"PRIx64" Parse tags from JSON payload finished", info->id); + uDebug("OTD:0x%" PRIx64 " Parse tags from JSON payload finished", info->id); return TSDB_CODE_SUCCESS; } /************* TSDB_SML_JSON_PROTOCOL function end **************/ - - -static int32_t smlParseInfluxLine(SSmlHandle* info, const char* sql) { +static int32_t smlParseInfluxLine(SSmlHandle *info, const char *sql) { SSmlLineInfo elements = {0}; - int ret = smlParseInfluxString(sql, &elements, &info->msgBuf); - if(ret != TSDB_CODE_SUCCESS){ - uError("SML:0x%"PRIx64" smlParseInfluxLine failed", info->id); + int ret = smlParseInfluxString(sql, &elements, &info->msgBuf); + if (ret != TSDB_CODE_SUCCESS) { + uError("SML:0x%" PRIx64 " smlParseInfluxLine failed", info->id); return ret; } SArray *cols = NULL; - if(info->dataFormat){ // if dataFormat, cols need new memory to save data + if (info->dataFormat) { // if dataFormat, cols need new memory to save data cols = taosArrayInit(16, POINTER_BYTES); if (cols == NULL) { - uError("SML:0x%"PRIx64" smlParseInfluxLine failed to allocate memory", info->id); + uError("SML:0x%" PRIx64 " smlParseInfluxLine failed to allocate memory", info->id); return TSDB_CODE_TSC_OUT_OF_MEMORY; } - }else{ // if dataFormat is false, cols do not need to save data, there is another new memory to save data + } else { // if dataFormat is false, cols do not need to save data, there is another new memory to save data cols = info->colsContainer; } ret = smlParseTS(info, elements.timestamp, elements.timestampLen, cols); - if(ret != TSDB_CODE_SUCCESS){ - uError("SML:0x%"PRIx64" smlParseTS failed", info->id); - if(info->dataFormat) taosArrayDestroy(cols); + if (ret != TSDB_CODE_SUCCESS) { + uError("SML:0x%" PRIx64 " smlParseTS failed", info->id); + if (info->dataFormat) taosArrayDestroy(cols); return ret; } ret = smlParseCols(elements.cols, elements.colsLen, cols, NULL, false, info->dumplicateKey, &info->msgBuf); - if(ret != TSDB_CODE_SUCCESS){ - uError("SML:0x%"PRIx64" smlParseCols parse cloums fields failed", info->id); + if (ret != TSDB_CODE_SUCCESS) { + uError("SML:0x%" PRIx64 " smlParseCols parse cloums fields failed", info->id); smlDestroyCols(cols); - if(info->dataFormat) taosArrayDestroy(cols); + if (info->dataFormat) taosArrayDestroy(cols); return ret; } - if(taosArrayGetSize(cols) > TSDB_MAX_COLUMNS){ + if (taosArrayGetSize(cols) > TSDB_MAX_COLUMNS) { smlBuildInvalidDataMsg(&info->msgBuf, "too many columns than 4096", NULL); return TSDB_CODE_SML_INVALID_DATA; } - bool hasTable = true; - SSmlTableInfo *tinfo = NULL; - SSmlTableInfo **oneTable = (SSmlTableInfo **)taosHashGet(info->childTables, elements.measure, elements.measureTagsLen); - if(!oneTable){ + bool hasTable = true; + SSmlTableInfo *tinfo = NULL; + SSmlTableInfo **oneTable = + (SSmlTableInfo **)taosHashGet(info->childTables, elements.measure, elements.measureTagsLen); + if (!oneTable) { tinfo = smlBuildTableInfo(); - if(!tinfo){ + if (!tinfo) { return TSDB_CODE_TSC_OUT_OF_MEMORY; } taosHashPut(info->childTables, elements.measure, elements.measureTagsLen, &tinfo, POINTER_BYTES); @@ -2066,89 +2050,89 @@ static int32_t smlParseInfluxLine(SSmlHandle* info, const char* sql) { } ret = smlDealCols(*oneTable, info->dataFormat, cols); - if(ret != TSDB_CODE_SUCCESS){ + if (ret != TSDB_CODE_SUCCESS) { return ret; } - if(!hasTable){ - ret = smlParseCols(elements.tags, elements.tagsLen, (*oneTable)->tags, (*oneTable)->childTableName, true, info->dumplicateKey, &info->msgBuf); - if(ret != TSDB_CODE_SUCCESS){ - uError("SML:0x%"PRIx64" smlParseCols parse tag fields failed", info->id); + if (!hasTable) { + ret = smlParseCols(elements.tags, elements.tagsLen, (*oneTable)->tags, (*oneTable)->childTableName, true, + info->dumplicateKey, &info->msgBuf); + if (ret != TSDB_CODE_SUCCESS) { + uError("SML:0x%" PRIx64 " smlParseCols parse tag fields failed", info->id); return ret; } - if(taosArrayGetSize((*oneTable)->tags) > TSDB_MAX_TAGS){ + if (taosArrayGetSize((*oneTable)->tags) > TSDB_MAX_TAGS) { smlBuildInvalidDataMsg(&info->msgBuf, "too many tags than 128", NULL); return TSDB_CODE_SML_INVALID_DATA; } (*oneTable)->sTableName = elements.measure; (*oneTable)->sTableNameLen = elements.measureLen; - if(strlen((*oneTable)->childTableName) == 0){ - RandTableName rName = { (*oneTable)->tags, (*oneTable)->sTableName, (uint8_t)(*oneTable)->sTableNameLen, - (*oneTable)->childTableName, 0 }; + if (strlen((*oneTable)->childTableName) == 0) { + RandTableName rName = {(*oneTable)->tags, (*oneTable)->sTableName, (uint8_t)(*oneTable)->sTableNameLen, + (*oneTable)->childTableName, 0}; buildChildTableName(&rName); (*oneTable)->uid = rName.uid; - }else{ - (*oneTable)->uid = *(uint64_t*)((*oneTable)->childTableName); + } else { + (*oneTable)->uid = *(uint64_t *)((*oneTable)->childTableName); } - } - SSmlSTableMeta** tableMeta = (SSmlSTableMeta**)taosHashGet(info->superTables, elements.measure, elements.measureLen); - if(tableMeta){ // update meta + SSmlSTableMeta **tableMeta = (SSmlSTableMeta **)taosHashGet(info->superTables, elements.measure, elements.measureLen); + if (tableMeta) { // update meta ret = smlUpdateMeta((*tableMeta)->colHash, (*tableMeta)->cols, cols, &info->msgBuf); - if(!hasTable && ret){ + if (!hasTable && ret) { ret = smlUpdateMeta((*tableMeta)->tagHash, (*tableMeta)->tags, (*oneTable)->tags, &info->msgBuf); } - if(!ret){ - uError("SML:0x%"PRIx64" smlUpdateMeta failed", info->id); + if (!ret) { + uError("SML:0x%" PRIx64 " smlUpdateMeta failed", info->id); return TSDB_CODE_SML_INVALID_DATA; } - }else{ + } else { SSmlSTableMeta *meta = smlBuildSTableMeta(); smlInsertMeta(meta->tagHash, meta->tags, (*oneTable)->tags); smlInsertMeta(meta->colHash, meta->cols, cols); taosHashPut(info->superTables, elements.measure, elements.measureLen, &meta, POINTER_BYTES); } - if(!info->dataFormat){ + if (!info->dataFormat) { taosArrayClear(info->colsContainer); } taosHashClear(info->dumplicateKey); return TSDB_CODE_SUCCESS; } -static int32_t smlParseTelnetLine(SSmlHandle* info, void *data) { - int ret = TSDB_CODE_SUCCESS; +static int32_t smlParseTelnetLine(SSmlHandle *info, void *data) { + int ret = TSDB_CODE_SUCCESS; SSmlTableInfo *tinfo = smlBuildTableInfo(); - if(!tinfo){ + if (!tinfo) { return TSDB_CODE_TSC_OUT_OF_MEMORY; } SArray *cols = taosArrayInit(16, POINTER_BYTES); if (cols == NULL) { - uError("SML:0x%"PRIx64" smlParseTelnetLine failed to allocate memory", info->id); + uError("SML:0x%" PRIx64 " smlParseTelnetLine failed to allocate memory", info->id); return TSDB_CODE_TSC_OUT_OF_MEMORY; } - if(info->protocol == TSDB_SML_TELNET_PROTOCOL){ - ret = smlParseTelnetString(info, (const char*)data, tinfo, cols); - }else if(info->protocol == TSDB_SML_JSON_PROTOCOL){ + if (info->protocol == TSDB_SML_TELNET_PROTOCOL) { + ret = smlParseTelnetString(info, (const char *)data, tinfo, cols); + } else if (info->protocol == TSDB_SML_JSON_PROTOCOL) { ret = smlParseJSONString(info, (cJSON *)data, tinfo, cols); - }else{ + } else { ASSERT(0); } - if(ret != TSDB_CODE_SUCCESS){ - uError("SML:0x%"PRIx64" smlParseTelnetLine failed", info->id); + if (ret != TSDB_CODE_SUCCESS) { + uError("SML:0x%" PRIx64 " smlParseTelnetLine failed", info->id); smlDestroyTableInfo(info, tinfo); smlDestroyCols(cols); taosArrayDestroy(cols); return ret; } - if(taosArrayGetSize(tinfo->tags) <= 0 || taosArrayGetSize(tinfo->tags) > TSDB_MAX_TAGS){ + if (taosArrayGetSize(tinfo->tags) <= 0 || taosArrayGetSize(tinfo->tags) > TSDB_MAX_TAGS) { smlBuildInvalidDataMsg(&info->msgBuf, "invalidate tags length:[1,128]", NULL); smlDestroyTableInfo(info, tinfo); smlDestroyCols(cols); @@ -2157,38 +2141,38 @@ static int32_t smlParseTelnetLine(SSmlHandle* info, void *data) { } taosHashClear(info->dumplicateKey); - if(strlen(tinfo->childTableName) == 0){ - RandTableName rName = { tinfo->tags, tinfo->sTableName, (uint8_t)tinfo->sTableNameLen, - tinfo->childTableName, 0 }; + if (strlen(tinfo->childTableName) == 0) { + RandTableName rName = {tinfo->tags, tinfo->sTableName, (uint8_t)tinfo->sTableNameLen, tinfo->childTableName, 0}; buildChildTableName(&rName); tinfo->uid = rName.uid; - }else{ - tinfo->uid = *(uint64_t*)(tinfo->childTableName); // generate uid by name simple + } else { + tinfo->uid = *(uint64_t *)(tinfo->childTableName); // generate uid by name simple } - - bool hasTable = true; - SSmlTableInfo **oneTable = (SSmlTableInfo **)taosHashGet(info->childTables, tinfo->childTableName, strlen(tinfo->childTableName)); - if(!oneTable) { + bool hasTable = true; + SSmlTableInfo **oneTable = + (SSmlTableInfo **)taosHashGet(info->childTables, tinfo->childTableName, strlen(tinfo->childTableName)); + if (!oneTable) { taosHashPut(info->childTables, tinfo->childTableName, strlen(tinfo->childTableName), &tinfo, POINTER_BYTES); oneTable = &tinfo; hasTable = false; - }else{ + } else { smlDestroyTableInfo(info, tinfo); } taosArrayPush((*oneTable)->cols, &cols); - SSmlSTableMeta** tableMeta = (SSmlSTableMeta** )taosHashGet(info->superTables, (*oneTable)->sTableName, (*oneTable)->sTableNameLen); - if(tableMeta){ // update meta + SSmlSTableMeta **tableMeta = + (SSmlSTableMeta **)taosHashGet(info->superTables, (*oneTable)->sTableName, (*oneTable)->sTableNameLen); + if (tableMeta) { // update meta ret = smlUpdateMeta((*tableMeta)->colHash, (*tableMeta)->cols, cols, &info->msgBuf); - if(!hasTable && ret){ + if (!hasTable && ret) { ret = smlUpdateMeta((*tableMeta)->tagHash, (*tableMeta)->tags, (*oneTable)->tags, &info->msgBuf); } - if(!ret){ - uError("SML:0x%"PRIx64" smlUpdateMeta failed", info->id); + if (!ret) { + uError("SML:0x%" PRIx64 " smlUpdateMeta failed", info->id); return TSDB_CODE_SML_INVALID_DATA; } - }else{ + } else { SSmlSTableMeta *meta = smlBuildSTableMeta(); smlInsertMeta(meta->tagHash, meta->tags, (*oneTable)->tags); smlInsertMeta(meta->colHash, meta->cols, cols); @@ -2198,27 +2182,27 @@ static int32_t smlParseTelnetLine(SSmlHandle* info, void *data) { return TSDB_CODE_SUCCESS; } -static int32_t smlParseJSON(SSmlHandle *info, char* payload) { +static int32_t smlParseJSON(SSmlHandle *info, char *payload) { int32_t payloadNum = 0; int32_t ret = TSDB_CODE_SUCCESS; if (payload == NULL) { - uError("SML:0x%"PRIx64" empty JSON Payload", info->id); + uError("SML:0x%" PRIx64 " empty JSON Payload", info->id); return TSDB_CODE_TSC_INVALID_JSON; } cJSON *root = cJSON_Parse(payload); if (root == NULL) { - uError("SML:0x%"PRIx64" parse json failed:%s", info->id, payload); + uError("SML:0x%" PRIx64 " parse json failed:%s", info->id, payload); return TSDB_CODE_TSC_INVALID_JSON; } - //multiple data points must be sent in JSON array + // multiple data points must be sent in JSON array if (cJSON_IsObject(root)) { payloadNum = 1; } else if (cJSON_IsArray(root)) { payloadNum = cJSON_GetArraySize(root); } else { - uError("SML:0x%"PRIx64" Invalid JSON Payload", info->id); + uError("SML:0x%" PRIx64 " Invalid JSON Payload", info->id); ret = TSDB_CODE_TSC_INVALID_JSON; goto end; } @@ -2226,8 +2210,8 @@ static int32_t smlParseJSON(SSmlHandle *info, char* payload) { for (int32_t i = 0; i < payloadNum; ++i) { cJSON *dataPoint = (payloadNum == 1 && cJSON_IsObject(root)) ? root : cJSON_GetArrayItem(root, i); ret = smlParseTelnetLine(info, dataPoint); - if(ret != TSDB_CODE_SUCCESS){ - uError("SML:0x%"PRIx64" Invalid JSON Payload", info->id); + if (ret != TSDB_CODE_SUCCESS) { + uError("SML:0x%" PRIx64 " Invalid JSON Payload", info->id); goto end; } } @@ -2237,12 +2221,12 @@ end: return ret; } -static int32_t smlInsertData(SSmlHandle* info) { +static int32_t smlInsertData(SSmlHandle *info) { int32_t code = TSDB_CODE_SUCCESS; - SSmlTableInfo** oneTable = (SSmlTableInfo**)taosHashIterate(info->childTables, NULL); + SSmlTableInfo **oneTable = (SSmlTableInfo **)taosHashIterate(info->childTables, NULL); while (oneTable) { - SSmlTableInfo* tableData = *oneTable; + SSmlTableInfo *tableData = *oneTable; SName pName = {TSDB_TABLE_NAME_T, info->taos->acctId, {0}, {0}}; strcpy(pName.dbname, info->pRequest->pDb); @@ -2253,56 +2237,59 @@ static int32_t smlInsertData(SSmlHandle* info) { conn.requestId = info->pRequest->requestId; conn.requestObjRefId = info->pRequest->self; conn.mgmtEps = getEpSet_s(&info->taos->pAppInfo->mgmtEp); - + SVgroupInfo vg; code = catalogGetTableHashVgroup(info->pCatalog, &conn, &pName, &vg); if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%"PRIx64" catalogGetTableHashVgroup failed. table name: %s", info->id, tableData->childTableName); + uError("SML:0x%" PRIx64 " catalogGetTableHashVgroup failed. table name: %s", info->id, tableData->childTableName); return code; } - taosHashPut(info->pVgHash, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg)); + taosHashPut(info->pVgHash, (const char *)&vg.vgId, sizeof(vg.vgId), (char *)&vg, sizeof(vg)); - SSmlSTableMeta** pMeta = (SSmlSTableMeta** )taosHashGet(info->superTables, tableData->sTableName, tableData->sTableNameLen); - ASSERT (NULL != pMeta && NULL != *pMeta); + SSmlSTableMeta **pMeta = + (SSmlSTableMeta **)taosHashGet(info->superTables, tableData->sTableName, tableData->sTableNameLen); + ASSERT(NULL != pMeta && NULL != *pMeta); // use tablemeta of stable to save vgid and uid of child table (*pMeta)->tableMeta->vgId = vg.vgId; - (*pMeta)->tableMeta->uid = tableData->uid; // one table merge data block together according uid + (*pMeta)->tableMeta->uid = tableData->uid; // one table merge data block together according uid code = smlBindData(info->exec, tableData->tags, (*pMeta)->cols, tableData->cols, info->dataFormat, (*pMeta)->tableMeta, tableData->childTableName, info->msgBuf.buf, info->msgBuf.len); - if(code != TSDB_CODE_SUCCESS){ - uError("SML:0x%"PRIx64" smlBindData failed", info->id); + if (code != TSDB_CODE_SUCCESS) { + uError("SML:0x%" PRIx64 " smlBindData failed", info->id); return code; } - oneTable = (SSmlTableInfo**)taosHashIterate(info->childTables, oneTable); + oneTable = (SSmlTableInfo **)taosHashIterate(info->childTables, oneTable); } code = smlBuildOutput(info->exec, info->pVgHash); if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%"PRIx64" smlBuildOutput failed", info->id); + uError("SML:0x%" PRIx64 " smlBuildOutput failed", info->id); return code; } info->cost.insertRpcTime = taosGetTimestampUs(); - //launchQueryImpl(info->pRequest, info->pQuery, false, NULL); -// info->affectedRows = taos_affected_rows(info->pRequest); -// return info->pRequest->code; + // launchQueryImpl(info->pRequest, info->pQuery, false, NULL); + // info->affectedRows = taos_affected_rows(info->pRequest); + // return info->pRequest->code; launchAsyncQuery(info->pRequest, info->pQuery); return TSDB_CODE_SUCCESS; } -static void smlPrintStatisticInfo(SSmlHandle *info){ - uError("SML:0x%"PRIx64" smlInsertLines result, code:%d,lineNum:%d,stable num:%d,ctable num:%d,create stable num:%d \ - parse cost:%"PRId64",schema cost:%"PRId64",bind cost:%"PRId64",rpc cost:%"PRId64",total cost:%"PRId64"", info->id, info->cost.code, - info->cost.lineNum, info->cost.numOfSTables, info->cost.numOfCTables, info->cost.numOfCreateSTables, - info->cost.schemaTime-info->cost.parseTime, info->cost.insertBindTime-info->cost.schemaTime, - info->cost.insertRpcTime-info->cost.insertBindTime, info->cost.endTime-info->cost.insertRpcTime, - info->cost.endTime-info->cost.parseTime); +static void smlPrintStatisticInfo(SSmlHandle *info) { + uError("SML:0x%" PRIx64 + " smlInsertLines result, code:%d,lineNum:%d,stable num:%d,ctable num:%d,create stable num:%d \ + parse cost:%" PRId64 ",schema cost:%" PRId64 ",bind cost:%" PRId64 ",rpc cost:%" PRId64 ",total cost:%" PRId64 + "", + info->id, info->cost.code, info->cost.lineNum, info->cost.numOfSTables, info->cost.numOfCTables, + info->cost.numOfCreateSTables, info->cost.schemaTime - info->cost.parseTime, + info->cost.insertBindTime - info->cost.schemaTime, info->cost.insertRpcTime - info->cost.insertBindTime, + info->cost.endTime - info->cost.insertRpcTime, info->cost.endTime - info->cost.parseTime); } -static int32_t smlParseLine(SSmlHandle *info, char* lines[], int numLines){ +static int32_t smlParseLine(SSmlHandle *info, char *lines[], int numLines) { int32_t code = TSDB_CODE_SUCCESS; if (info->protocol == TSDB_SML_JSON_PROTOCOL) { code = smlParseJSON(info, *lines); @@ -2314,11 +2301,11 @@ static int32_t smlParseLine(SSmlHandle *info, char* lines[], int numLines){ } for (int32_t i = 0; i < numLines; ++i) { - if(info->protocol == TSDB_SML_LINE_PROTOCOL){ + if (info->protocol == TSDB_SML_LINE_PROTOCOL) { code = smlParseInfluxLine(info, lines[i]); - }else if(info->protocol == TSDB_SML_TELNET_PROTOCOL){ + } else if (info->protocol == TSDB_SML_TELNET_PROTOCOL) { code = smlParseTelnetLine(info, lines[i]); - }else{ + } else { ASSERT(0); } if (code != TSDB_CODE_SUCCESS) { @@ -2329,7 +2316,7 @@ static int32_t smlParseLine(SSmlHandle *info, char* lines[], int numLines){ return code; } -static int smlProcess(SSmlHandle *info, char* lines[], int numLines) { +static int smlProcess(SSmlHandle *info, char *lines[], int numLines) { int32_t code = TSDB_CODE_SUCCESS; int32_t retryNum = 0; @@ -2337,7 +2324,7 @@ static int smlProcess(SSmlHandle *info, char* lines[], int numLines) { code = smlParseLine(info, lines, numLines); if (code != 0) { - uError("SML:0x%"PRIx64" smlParseLine error : %s", info->id, tstrerror(code)); + uError("SML:0x%" PRIx64 " smlParseLine error : %s", info->id, tstrerror(code)); return code; } @@ -2347,65 +2334,65 @@ static int smlProcess(SSmlHandle *info, char* lines[], int numLines) { info->cost.schemaTime = taosGetTimestampUs(); - do{ + do { code = smlModifyDBSchemas(info); if (code == 0) break; } while (retryNum++ < taosHashGetSize(info->superTables) * MAX_RETRY_TIMES); if (code != 0) { - uError("SML:0x%"PRIx64" smlModifyDBSchemas error : %s", info->id, tstrerror(code)); + uError("SML:0x%" PRIx64 " smlModifyDBSchemas error : %s", info->id, tstrerror(code)); return code; } info->cost.insertBindTime = taosGetTimestampUs(); code = smlInsertData(info); if (code != 0) { - uError("SML:0x%"PRIx64" smlInsertData error : %s", info->id, tstrerror(code)); + uError("SML:0x%" PRIx64 " smlInsertData error : %s", info->id, tstrerror(code)); return code; } return code; } -static int32_t isSchemalessDb(STscObj *taos, SRequestObj* request){ - SCatalog* catalog = NULL; - int32_t code = catalogGetHandle(((STscObj *)taos)->pAppInfo->clusterId, &catalog); - if(code != TSDB_CODE_SUCCESS){ - uError("SML get catalog error %d", code); - return code; - } - - SName name; - tNameSetDbName(&name, taos->acctId, taos->db, strlen(taos->db)); - char dbFname[TSDB_DB_FNAME_LEN] = {0}; - tNameGetFullDbName(&name, dbFname); - SDbCfgInfo pInfo = {0}; - - SRequestConnInfo conn = {0}; - conn.pTrans = taos->pAppInfo->pTransporter; - conn.requestId = request->requestId; - conn.requestObjRefId = request->self; - conn.mgmtEps = getEpSet_s(&taos->pAppInfo->mgmtEp); - - code = catalogGetDBCfg(catalog, &conn, dbFname, &pInfo); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - taosArrayDestroy(pInfo.pRetensions); - - if (!pInfo.schemaless){ - return TSDB_CODE_SML_INVALID_DB_CONF; - } +static int32_t isSchemalessDb(STscObj *taos, SRequestObj *request) { +// SCatalog *catalog = NULL; +// int32_t code = catalogGetHandle(((STscObj *)taos)->pAppInfo->clusterId, &catalog); +// if (code != TSDB_CODE_SUCCESS) { +// uError("SML get catalog error %d", code); +// return code; +// } +// +// SName name; +// tNameSetDbName(&name, taos->acctId, taos->db, strlen(taos->db)); +// char dbFname[TSDB_DB_FNAME_LEN] = {0}; +// tNameGetFullDbName(&name, dbFname); +// SDbCfgInfo pInfo = {0}; +// +// SRequestConnInfo conn = {0}; +// conn.pTrans = taos->pAppInfo->pTransporter; +// conn.requestId = request->requestId; +// conn.requestObjRefId = request->self; +// conn.mgmtEps = getEpSet_s(&taos->pAppInfo->mgmtEp); +// +// code = catalogGetDBCfg(catalog, &conn, dbFname, &pInfo); +// if (code != TSDB_CODE_SUCCESS) { +// return code; +// } +// taosArrayDestroy(pInfo.pRetensions); +// +// if (!pInfo.schemaless) { +// return TSDB_CODE_SML_INVALID_DB_CONF; +// } return TSDB_CODE_SUCCESS; } -static void smlInsertCallback(void* param, void* res, int32_t code) { +static void smlInsertCallback(void *param, void *res, int32_t code) { SRequestObj *pRequest = (SRequestObj *)res; - SSmlHandle* info = (SSmlHandle *)param; + SSmlHandle *info = (SSmlHandle *)param; - uDebug("SML:0x%"PRIx64" result. code:%d, msg:%s", info->id, pRequest->code, pRequest->msgBuf); + uDebug("SML:0x%" PRIx64 " result. code:%d, msg:%s", info->id, pRequest->code, pRequest->msgBuf); // lock - if(code != TSDB_CODE_SUCCESS){ + if (code != TSDB_CODE_SUCCESS) { taosThreadSpinLock(&info->params->lock); info->params->request->code = code; taosThreadSpinUnlock(&info->params->lock); @@ -2414,13 +2401,13 @@ static void smlInsertCallback(void* param, void* res, int32_t code) { printf("SML:0x%" PRIx64 " insert finished, code: %d, total: %d\n", info->id, code, info->affectedRows); Params *pParam = info->params; - bool isLast = info->isLast; + bool isLast = info->isLast; info->cost.endTime = taosGetTimestampUs(); info->cost.code = code; smlPrintStatisticInfo(info); smlDestroyInfo(info); - if(isLast){ + if (isLast) { tsem_post(&pParam->sem); } } @@ -2464,13 +2451,13 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr pTscObj->schemalessType = 1; SSmlMsgBuf msg = {ERROR_MSG_BUF_DEFAULT_SIZE, request->msgBuf}; - int cnt = ceil(((double)numLines)/LINE_BATCH); + int cnt = ceil(((double)numLines) / LINE_BATCH); Params params; params.request = request; tsem_init(¶ms.sem, 0, 0); taosThreadSpinInit(&(params.lock), 0); - if(request->pDb == NULL){ + if (request->pDb == NULL) { request->code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; smlBuildInvalidDataMsg(&msg, "Database not specified", NULL); goto end; @@ -2488,13 +2475,14 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr goto end; } - if(protocol < TSDB_SML_LINE_PROTOCOL || protocol > TSDB_SML_JSON_PROTOCOL){ + if (protocol < TSDB_SML_LINE_PROTOCOL || protocol > TSDB_SML_JSON_PROTOCOL) { request->code = TSDB_CODE_SML_INVALID_PROTOCOL_TYPE; smlBuildInvalidDataMsg(&msg, "protocol invalidate", NULL); goto end; } - if(protocol == TSDB_SML_LINE_PROTOCOL && (precision < TSDB_SML_TIMESTAMP_NOT_CONFIGURED || precision > TSDB_SML_TIMESTAMP_NANO_SECONDS)){ + if (protocol == TSDB_SML_LINE_PROTOCOL && + (precision < TSDB_SML_TIMESTAMP_NOT_CONFIGURED || precision > TSDB_SML_TIMESTAMP_NANO_SECONDS)) { request->code = TSDB_CODE_SML_INVALID_PRECISION_TYPE; smlBuildInvalidDataMsg(&msg, "precision invalidate for line protocol", NULL); goto end; @@ -2516,10 +2504,10 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr int32_t perBatch = LINE_BATCH; - if(numLines > perBatch){ + if (numLines > perBatch) { numLines -= perBatch; info->isLast = false; - }else{ + } else { perBatch = numLines; numLines = 0; info->isLast = true; @@ -2528,10 +2516,10 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr info->params = ¶ms; info->affectedRows = perBatch; info->pRequest->body.queryFp = smlInsertCallback; - info->pRequest->body.param = info; + info->pRequest->body.param = info; int32_t code = smlProcess(info, lines, perBatch); lines += perBatch; - if (code != TSDB_CODE_SUCCESS){ + if (code != TSDB_CODE_SUCCESS) { info->pRequest->body.queryFp(info, req, code); } } @@ -2546,4 +2534,3 @@ end: releaseTscObj((int64_t)taos); return (TAOS_RES*)request; } - diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index 7d49c4206f..10c6c3623a 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -132,6 +132,7 @@ typedef struct { // statistics int64_t pollCnt; // offset + int64_t committedOffset; int64_t currentOffset; // connection info int32_t vgId; @@ -193,6 +194,26 @@ typedef struct { void* userParam; } SMqCommitCbParam; +typedef struct { + tmq_t* tmq; + int8_t automatic; + int8_t async; + int8_t freeOffsets; + int32_t waitingRspNum; + int32_t totalRspNum; + tmq_resp_err_t rspErr; + tmq_commit_cb* userCb; + SArray* successfulOffsets; + SArray* failedOffsets; + void* userParam; + tsem_t rspSem; +} SMqCommitCbParamSet; + +typedef struct { + SMqCommitCbParamSet* params; + STqOffset* pOffset; +} SMqCommitCbParam2; + tmq_conf_t* tmq_conf_new() { tmq_conf_t* conf = taosMemoryCalloc(1, sizeof(tmq_conf_t)); conf->withTbName = false; @@ -343,6 +364,139 @@ int32_t tmqCommitCb(void* param, const SDataBuf* pMsg, int32_t code) { return 0; } +int32_t tmqCommitCb2(void* param, const SDataBuf* pBuf, int32_t code) { + SMqCommitCbParam2* pParam = (SMqCommitCbParam2*)param; + SMqCommitCbParamSet* pParamSet = (SMqCommitCbParamSet*)pParam->params; + // push into array + if (code == 0) { + taosArrayPush(pParamSet->failedOffsets, &pParam->pOffset); + } else { + taosArrayPush(pParamSet->successfulOffsets, &pParam->pOffset); + } + + // count down waiting rsp + int32_t waitingRspNum = atomic_sub_fetch_32(&pParamSet->waitingRspNum, 1); + ASSERT(waitingRspNum >= 0); + + if (waitingRspNum == 0) { + // if no more waiting rsp + if (pParamSet->async) { + // call async cb func + if (pParamSet->automatic && pParamSet->tmq->commitCb) { + pParamSet->tmq->commitCb(pParamSet->tmq, pParamSet->rspErr, NULL, pParamSet->tmq->commitCbUserParam); + } else if (!pParamSet->automatic && pParamSet->userCb) { + // sem post + pParamSet->userCb(pParamSet->tmq, pParamSet->rspErr, NULL, pParamSet->userParam); + } + } + + taosArrayDestroyP(pParamSet->successfulOffsets, taosMemoryFree); + taosArrayDestroyP(pParamSet->failedOffsets, taosMemoryFree); + } + return 0; +} + +int32_t tmqCommitInner2(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, int8_t automatic, int8_t async, + tmq_commit_cb* userCb, void* userParam) { + int32_t code = -1; + + SMqCommitCbParamSet* pParamSet = taosMemoryCalloc(1, sizeof(SMqCommitCbParamSet)); + if (pParamSet == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + pParamSet->tmq = tmq; + pParamSet->automatic = automatic; + pParamSet->async = async; + pParamSet->freeOffsets = 1; + pParamSet->userCb = userCb; + pParamSet->userParam = userParam; + tsem_init(&pParamSet->rspSem, 0, 0); + + for (int32_t i = 0; i < taosArrayGetSize(tmq->clientTopics); i++) { + SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i); + for (int32_t j = 0; j < taosArrayGetSize(pTopic->vgs); j++) { + SMqClientVg* pVg = taosArrayGet(pTopic->vgs, i); + STqOffset* pOffset = taosMemoryCalloc(1, sizeof(STqOffset)); + if (pOffset == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + int32_t tlen = strlen(tmq->groupId); + memcpy(pOffset->subKey, tmq->groupId, tlen); + pOffset->subKey[tlen] = TMQ_SEPARATOR; + strcpy(pOffset->subKey + tlen + 1, pTopic->topicName); + int32_t len; + int32_t code; + tEncodeSize(tEncodeSTqOffset, pOffset, len, code); + if (code < 0) { + ASSERT(0); + } + void* buf = taosMemoryCalloc(1, sizeof(SMsgHead) + len); + ((SMsgHead*)buf)->vgId = htonl(pVg->vgId); + + void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); + + SEncoder encoder; + tEncoderInit(&encoder, abuf, len); + tEncodeSTqOffset(&encoder, pOffset); + + // build param + SMqCommitCbParam2* pParam = taosMemoryCalloc(1, sizeof(SMqCommitCbParam2)); + pParam->params = pParamSet; + pParam->pOffset = pOffset; + + // build send info + SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); + if (pMsgSendInfo == NULL) { + // TODO + continue; + } + pMsgSendInfo->msgInfo = (SDataBuf){ + .pData = buf, + .len = len, + .handle = NULL, + }; + + pMsgSendInfo->requestId = generateRequestId(); + pMsgSendInfo->requestObjRefId = 0; + pMsgSendInfo->param = pParam; + pMsgSendInfo->fp = tmqCommitCb2; + pMsgSendInfo->msgType = TDMT_MND_MQ_COMMIT_OFFSET; + // send msg + + SEpSet epSet = getEpSet_s(&tmq->pTscObj->pAppInfo->mgmtEp); + int64_t transporterId = 0; + asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, pMsgSendInfo); + pParamSet->waitingRspNum++; + pParamSet->totalRspNum++; + } + } + + if (!async) { + tsem_wait(&pParamSet->rspSem); + code = pParamSet->rspErr; + tsem_destroy(&pParamSet->rspSem); + } else { + code = 0; + } + + if (code != 0 && async) { + if (automatic) { + tmq->commitCb(tmq, code, NULL, tmq->commitCbUserParam); + } else { + userCb(tmq, code, NULL, userParam); + } + } + + if (!async) { + taosArrayDestroyP(pParamSet->successfulOffsets, taosMemoryFree); + taosArrayDestroyP(pParamSet->failedOffsets, taosMemoryFree); + } + + return 0; +} + int32_t tmqCommitInner(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, int8_t automatic, int8_t async, tmq_commit_cb* userCb, void* userParam) { SMqCMCommitOffsetReq req; @@ -890,12 +1044,13 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) { sprintf(vgKey, "%s:%d", topic.topicName, pVgEp->vgId); int64_t* pOffset = taosHashGet(pHash, vgKey, strlen(vgKey)); int64_t offset = pVgEp->offset; - tscDebug("consumer %ld epoch %d vg %d offset og to %ld", tmq->consumerId, epoch, pVgEp->vgId, offset); + tscDebug("consumer %ld(epoch %d) original offset of vg %d is %ld", tmq->consumerId, epoch, pVgEp->vgId, offset); if (pOffset != NULL) { offset = *pOffset; - tscDebug("consumer %ld epoch %d vg %d found %s", tmq->consumerId, epoch, pVgEp->vgId, vgKey); + tscDebug("consumer %ld(epoch %d) receive offset of vg %d, full key is %s", tmq->consumerId, epoch, pVgEp->vgId, + vgKey); } - tscDebug("consumer %ld epoch %d vg %d offset set to %ld", tmq->consumerId, epoch, pVgEp->vgId, offset); + tscDebug("consumer %ld(epoch %d) offset of vg %d updated to %ld", tmq->consumerId, epoch, pVgEp->vgId, offset); SMqClientVg clientVg = { .pollCnt = 0, .currentOffset = offset, @@ -1226,9 +1381,8 @@ SMqRspObj* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) { if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_RSP) { SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)rspWrapper; /*atomic_sub_fetch_32(&tmq->readyRequest, 1);*/ - /*printf("handle poll rsp %d\n", rspMsg->head.mqMsgType);*/ - if (pollRspWrapper->msg.head.epoch == atomic_load_32(&tmq->epoch)) { - /*printf("epoch match\n");*/ + int32_t consumerEpoch = atomic_load_32(&tmq->epoch); + if (pollRspWrapper->msg.head.epoch == consumerEpoch) { SMqClientVg* pVg = pollRspWrapper->vgHandle; /*printf("vg %d offset %ld up to %ld\n", pVg->vgId, pVg->currentOffset, rspMsg->msg.rspOffset);*/ pVg->currentOffset = pollRspWrapper->msg.rspOffset; @@ -1243,7 +1397,8 @@ SMqRspObj* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) { taosFreeQitem(pollRspWrapper); return pRsp; } else { - /*printf("epoch mismatch\n");*/ + tscDebug("msg discard since epoch mismatch: msg epoch %d, consumer epoch %d\n", pollRspWrapper->msg.head.epoch, + consumerEpoch); taosFreeQitem(pollRspWrapper); } } else { @@ -1263,10 +1418,14 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) { SMqRspObj* rspObj; int64_t startTime = taosGetTimestampMs(); +#if 0 + tmqHandleAllDelayedTask(tmq); + tmqPollImpl(tmq, timeout); rspObj = tmqHandleAllRsp(tmq, timeout, false); if (rspObj) { return (TAOS_RES*)rspObj; } +#endif // in no topic status also need process delayed task if (atomic_load_8(&tmq->status) == TMQ_CONSUMER_STATUS__INIT) { @@ -1359,8 +1518,7 @@ const char* tmq_get_table_name(TAOS_RES* res) { pRspObj->resIter >= pRspObj->rsp.blockNum) { return NULL; } - const char* name = taosArrayGetP(pRspObj->rsp.blockTbName, pRspObj->resIter); - return name; + return (const char*)taosArrayGetP(pRspObj->rsp.blockTbName, pRspObj->resIter); } return NULL; } diff --git a/source/client/test/smlTest.cpp b/source/client/test/smlTest.cpp index 4ad73a6424..fffb03d9a5 100644 --- a/source/client/test/smlTest.cpp +++ b/source/client/test/smlTest.cpp @@ -1260,4 +1260,28 @@ TEST(testCase, sml_16368_Test) { pRes = taos_schemaless_insert(taos, (char**)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_MICRO_SECONDS); ASSERT_EQ(taos_errno(pRes), 0); taos_free_result(pRes); -}*/ +} + +TEST(testCase, sml_dup_time_Test) { + TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); + ASSERT_NE(taos, nullptr); + + TAOS_RES* pRes = taos_query(taos, "create database if not exists dup_time schemaless 1"); + taos_free_result(pRes); + + const char *sql[] = { + //"test_ms,t0=t c0=f 1626006833641", + "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=false,c1=1i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"xcxvwjvf\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=T,c1=2i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"fixrzcuq\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=3i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"iupzdqub\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=4i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"yvvtzzof\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", + "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=5i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"vbxpilkj\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000" + }; + pRes = taos_query(taos, "use dup_time"); + taos_free_result(pRes); + + pRes = taos_schemaless_insert(taos, (char**)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, 0); + ASSERT_EQ(taos_errno(pRes), 0); + taos_free_result(pRes); +} +*/ diff --git a/source/common/src/systable.c b/source/common/src/systable.c index 98e16a05a6..cb89784faf 100644 --- a/source/common/src/systable.c +++ b/source/common/src/systable.c @@ -91,8 +91,8 @@ static const SSysDbTableSchema userDBSchema[] = { {.name = "precision", .bytes = 2 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "single_stable_model", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL}, {.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, -// {.name = "schemaless", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL}, - {.name = "retension", .bytes = 60 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, + // {.name = "schemaless", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL}, + {.name = "retention", .bytes = 60 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, // {.name = "update", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, // disable update }; @@ -137,7 +137,7 @@ static const SSysDbTableSchema streamSchema[] = { {.name = "target_table", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "watermark", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT}, {.name = "trigger", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, - }; +}; static const SSysDbTableSchema userTblsSchema[] = { {.name = "table_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR}, @@ -221,7 +221,9 @@ static const SSysDbTableSchema transSchema[] = { {.name = "db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "failed_times", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "last_exec_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, - {.name = "last_action_info", .bytes = (TSDB_TRANS_ERROR_LEN - 1) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "last_action_info", + .bytes = (TSDB_TRANS_ERROR_LEN - 1) + VARSTR_HEADER_SIZE, + .type = TSDB_DATA_TYPE_VARCHAR}, }; static const SSysDbTableSchema configSchema[] = { @@ -313,8 +315,6 @@ static const SSysDbTableSchema querySchema[] = { {.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, }; - - static const SSysTableMeta perfsMeta[] = { {TSDB_PERFS_TABLE_CONNECTIONS, connectionsSchema, tListLen(connectionsSchema)}, {TSDB_PERFS_TABLE_QUERIES, querySchema, tListLen(querySchema)}, diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index b7a9ef88b6..5a2aaed74e 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -1708,6 +1708,7 @@ char* buildCtbNameByGroupId(const char* stbName, uint64_t groupId) { pTag->keyLen = strlen(pTag->key); pTag->type = TSDB_DATA_TYPE_UBIGINT; pTag->u = groupId; + pTag->length = sizeof(uint64_t); taosArrayPush(tags, &pTag); void* cname = taosMemoryCalloc(1, TSDB_TABLE_NAME_LEN + 1); @@ -1728,173 +1729,6 @@ char* buildCtbNameByGroupId(const char* stbName, uint64_t groupId) { return rname.childTableName; } -SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, bool createTb, int64_t suid, - const char* stbFullName, int32_t vgId) { - SSubmitReq* ret = NULL; - SArray* tagArray = taosArrayInit(1, sizeof(STagVal)); - if (!tagArray) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; - } - - // cal size - int32_t cap = sizeof(SSubmitReq); - int32_t sz = taosArrayGetSize(pBlocks); - for (int32_t i = 0; i < sz; i++) { - SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i); - int32_t rows = pDataBlock->info.rows; - // TODO min - int32_t rowSize = pDataBlock->info.rowSize; - int32_t maxLen = TD_ROW_MAX_BYTES_FROM_SCHEMA(pTSchema); - int32_t schemaLen = 0; - - if (createTb) { - SVCreateTbReq createTbReq = {0}; - char* cname = buildCtbNameByGroupId(stbFullName, pDataBlock->info.groupId); - createTbReq.name = cname; - createTbReq.flags = 0; - createTbReq.type = TSDB_CHILD_TABLE; - createTbReq.ctb.suid = suid; - - STagVal tagVal = {.cid = 1, - .type = TSDB_DATA_TYPE_UBIGINT, - .pData = (uint8_t*)&pDataBlock->info.groupId, - .nData = sizeof(uint64_t)}; - STag* pTag = NULL; - taosArrayClear(tagArray); - taosArrayPush(tagArray, &tagVal); - tTagNew(tagArray, 1, false, &pTag); - if (pTag == NULL) { - tdDestroySVCreateTbReq(&createTbReq); - taosArrayDestroy(tagArray); - return NULL; - } - createTbReq.ctb.pTag = (uint8_t*)pTag; - - int32_t code; - tEncodeSize(tEncodeSVCreateTbReq, &createTbReq, schemaLen, code); - - tdDestroySVCreateTbReq(&createTbReq); - if (code < 0) { - taosArrayDestroy(tagArray); - return NULL; - } - } - - cap += sizeof(SSubmitBlk) + schemaLen + rows * maxLen; - } - - // assign data - // TODO - ret = taosMemoryCalloc(1, cap + 46); - ret = POINTER_SHIFT(ret, 46); - ret->header.vgId = vgId; - ret->version = htonl(1); - ret->length = sizeof(SSubmitReq); - ret->numOfBlocks = htonl(sz); - - void* submitBlk = POINTER_SHIFT(ret, sizeof(SSubmitReq)); - for (int32_t i = 0; i < sz; i++) { - SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i); - - SSubmitBlk* blkHead = submitBlk; - blkHead->numOfRows = htons(pDataBlock->info.rows); - blkHead->sversion = htonl(pTSchema->version); - // TODO - blkHead->suid = htobe64(suid); - // uid is assigned by vnode - blkHead->uid = 0; - - int32_t rows = pDataBlock->info.rows; - /*int32_t maxLen = TD_ROW_MAX_BYTES_FROM_SCHEMA(pTSchema);*/ - /*blkHead->dataLen = htonl(rows * maxLen);*/ - blkHead->dataLen = 0; - - void* blockData = POINTER_SHIFT(submitBlk, sizeof(SSubmitBlk)); - - int32_t schemaLen = 0; - if (createTb) { - SVCreateTbReq createTbReq = {0}; - char* cname = buildCtbNameByGroupId(stbFullName, pDataBlock->info.groupId); - createTbReq.name = cname; - createTbReq.flags = 0; - createTbReq.type = TSDB_CHILD_TABLE; - createTbReq.ctb.suid = suid; - - STagVal tagVal = {.cid = 1, - .type = TSDB_DATA_TYPE_UBIGINT, - .pData = (uint8_t*)&pDataBlock->info.groupId, - .nData = sizeof(uint64_t)}; - taosArrayClear(tagArray); - taosArrayPush(tagArray, &tagVal); - STag* pTag = NULL; - tTagNew(tagArray, 1, false, &pTag); - if (pTag == NULL) { - tdDestroySVCreateTbReq(&createTbReq); - taosArrayDestroy(tagArray); - taosMemoryFreeClear(ret); - return NULL; - } - createTbReq.ctb.pTag = (uint8_t*)pTag; - - int32_t code; - tEncodeSize(tEncodeSVCreateTbReq, &createTbReq, schemaLen, code); - if (code < 0) { - tdDestroySVCreateTbReq(&createTbReq); - taosArrayDestroy(tagArray); - taosMemoryFreeClear(ret); - return NULL; - } - - SEncoder encoder = {0}; - tEncoderInit(&encoder, blockData, schemaLen); - code = tEncodeSVCreateTbReq(&encoder, &createTbReq); - tEncoderClear(&encoder); - tdDestroySVCreateTbReq(&createTbReq); - - if (code < 0) { - taosArrayDestroy(tagArray); - taosMemoryFreeClear(ret); - return NULL; - } - } - blkHead->schemaLen = htonl(schemaLen); - - STSRow* rowData = POINTER_SHIFT(blockData, schemaLen); - - for (int32_t j = 0; j < rows; j++) { - SRowBuilder rb = {0}; - tdSRowInit(&rb, pTSchema->version); - tdSRowSetTpInfo(&rb, pTSchema->numOfCols, pTSchema->flen); - tdSRowResetBuf(&rb, rowData); - - for (int32_t k = 0; k < pTSchema->numOfCols; k++) { - const STColumn* pColumn = &pTSchema->columns[k]; - SColumnInfoData* pColData = taosArrayGet(pDataBlock->pDataBlock, k); - if (colDataIsNull_s(pColData, j)) { - tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NONE, NULL, false, pColumn->offset, k); - } else { - void* data = colDataGetData(pColData, j); - tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, data, true, pColumn->offset, k); - } - } - int32_t rowLen = TD_ROW_LEN(rowData); - rowData = POINTER_SHIFT(rowData, rowLen); - blkHead->dataLen += rowLen; - } - int32_t dataLen = blkHead->dataLen; - blkHead->dataLen = htonl(dataLen); - - ret->length += sizeof(SSubmitBlk) + schemaLen + dataLen; - blkHead = POINTER_SHIFT(blkHead, schemaLen + dataLen); - /*submitBlk = blkHead;*/ - } - - ret->length = htonl(ret->length); - taosArrayDestroy(tagArray); - return ret; -} - void blockCompressEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_t numOfCols, int8_t needCompress) { // todo extract method diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 73fd0e7e71..923e59fbe8 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -694,6 +694,7 @@ int32_t tDeserializeSMAlterStbReq(void *buf, int32_t bufLen, SMAlterStbReq *pReq void tFreeSMAltertbReq(SMAlterStbReq *pReq) { taosArrayDestroy(pReq->pFields); pReq->pFields = NULL; + taosMemoryFreeClear(pReq->comment); } int32_t tSerializeSEpSet(void *buf, int32_t bufLen, const SEpSet *pEpset) { @@ -2654,7 +2655,7 @@ int32_t tSerializeSSTbHbRsp(void *buf, int32_t bufLen, SSTbHbRsp *pRsp) { } int32_t numOfIndex = taosArrayGetSize(pRsp->pIndexRsp); - if (tEncodeI32(&encoder, numOfIndex) < 0) return -1; + if (tEncodeI32(&encoder, numOfIndex) < 0) return -1; for (int32_t i = 0; i < numOfIndex; ++i) { STableIndexRsp *pIndexRsp = taosArrayGet(pRsp->pIndexRsp, i); if (tEncodeCStr(&encoder, pIndexRsp->tbName) < 0) return -1; @@ -2739,7 +2740,7 @@ int32_t tDeserializeSSTbHbRsp(void *buf, int32_t bufLen, SSTbHbRsp *pRsp) { } taosArrayPush(pRsp->pIndexRsp, &tableIndexRsp); } - + tEndDecode(&decoder); tDecoderClear(&decoder); @@ -3583,6 +3584,33 @@ int32_t tDeserializeSDCreateMnodeReq(void *buf, int32_t bufLen, SDCreateMnodeReq return 0; } +int32_t tSerializeSSetStandbyReq(void *buf, int32_t bufLen, SSetStandbyReq *pReq) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeI32(&encoder, pReq->dnodeId) < 0) return -1; + if (tEncodeI8(&encoder, pReq->standby) < 0) return -1; + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSSetStandbyReq(void *buf, int32_t bufLen, SSetStandbyReq *pReq) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->dnodeId) < 0) return -1; + if (tDecodeI8(&decoder, &pReq->standby) < 0) return -1; + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} + int32_t tSerializeSAuthReq(void *buf, int32_t bufLen, SAuthReq *pReq) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); @@ -3974,7 +4002,7 @@ int32_t tEncodeTSma(SEncoder *pCoder, const STSma *pSma) { return 0; } -int32_t tDecodeTSma(SDecoder *pCoder, STSma *pSma) { +int32_t tDecodeTSma(SDecoder *pCoder, STSma *pSma, bool deepCopy) { if (tDecodeI8(pCoder, &pSma->version) < 0) return -1; if (tDecodeI8(pCoder, &pSma->intervalUnit) < 0) return -1; if (tDecodeI8(pCoder, &pSma->slidingUnit) < 0) return -1; @@ -3986,17 +4014,30 @@ int32_t tDecodeTSma(SDecoder *pCoder, STSma *pSma) { if (tDecodeI64(pCoder, &pSma->indexUid) < 0) return -1; if (tDecodeI64(pCoder, &pSma->tableUid) < 0) return -1; if (tDecodeI64(pCoder, &pSma->dstTbUid) < 0) return -1; - if (tDecodeCStr(pCoder, &pSma->dstTbName) < 0) return -1; + if (deepCopy) { + if (tDecodeCStrAlloc(pCoder, &pSma->dstTbName) < 0) return -1; + } else { + if (tDecodeCStr(pCoder, &pSma->dstTbName) < 0) return -1; + } + if (tDecodeI64(pCoder, &pSma->interval) < 0) return -1; if (tDecodeI64(pCoder, &pSma->offset) < 0) return -1; if (tDecodeI64(pCoder, &pSma->sliding) < 0) return -1; if (pSma->exprLen > 0) { - if (tDecodeCStr(pCoder, &pSma->expr) < 0) return -1; + if (deepCopy) { + if (tDecodeCStrAlloc(pCoder, &pSma->expr) < 0) return -1; + } else { + if (tDecodeCStr(pCoder, &pSma->expr) < 0) return -1; + } } else { pSma->expr = NULL; } if (pSma->tagsFilterLen > 0) { - if (tDecodeCStr(pCoder, &pSma->tagsFilter) < 0) return -1; + if (deepCopy) { + if (tDecodeCStrAlloc(pCoder, &pSma->tagsFilter) < 0) return -1; + } else { + if (tDecodeCStr(pCoder, &pSma->tagsFilter) < 0) return -1; + } } else { pSma->tagsFilter = NULL; } @@ -4019,7 +4060,7 @@ int32_t tEncodeSVCreateTSmaReq(SEncoder *pCoder, const SVCreateTSmaReq *pReq) { int32_t tDecodeSVCreateTSmaReq(SDecoder *pCoder, SVCreateTSmaReq *pReq) { if (tStartDecode(pCoder) < 0) return -1; - tDecodeTSma(pCoder, pReq); + tDecodeTSma(pCoder, pReq, false); tEndDecode(pCoder); return 0; @@ -4141,6 +4182,7 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS if (tEncodeI32(&encoder, sqlLen) < 0) return -1; if (tEncodeI32(&encoder, astLen) < 0) return -1; if (tEncodeI8(&encoder, pReq->triggerType) < 0) return -1; + if (tEncodeI64(&encoder, pReq->maxDelay) < 0) return -1; if (tEncodeI64(&encoder, pReq->watermark) < 0) return -1; if (sqlLen > 0 && tEncodeCStr(&encoder, pReq->sql) < 0) return -1; if (astLen > 0 && tEncodeCStr(&encoder, pReq->ast) < 0) return -1; @@ -4167,6 +4209,7 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea if (tDecodeI32(&decoder, &sqlLen) < 0) return -1; if (tDecodeI32(&decoder, &astLen) < 0) return -1; if (tDecodeI8(&decoder, &pReq->triggerType) < 0) return -1; + if (tDecodeI64(&decoder, &pReq->maxDelay) < 0) return -1; if (tDecodeI64(&decoder, &pReq->watermark) < 0) return -1; if (sqlLen > 0) { @@ -4823,3 +4866,31 @@ void tFreeSMAlterStbRsp(SMAlterStbRsp *pRsp) { taosMemoryFree(pRsp->pMeta); } } + +int32_t tEncodeSTqOffset(SEncoder *pEncoder, const STqOffset *pOffset) { + if (tEncodeI8(pEncoder, pOffset->type) < 0) return -1; + if (pOffset->type == TMQ_OFFSET__SNAPSHOT) { + if (tEncodeI64(pEncoder, pOffset->uid) < 0) return -1; + if (tEncodeI64(pEncoder, pOffset->ts) < 0) return -1; + } else if (pOffset->type == TMQ_OFFSET__LOG) { + if (tEncodeI64(pEncoder, pOffset->version) < 0) return -1; + } else { + ASSERT(0); + } + if (tEncodeCStr(pEncoder, pOffset->subKey) < 0) return -1; + return 0; +} + +int32_t tDecodeSTqOffset(SDecoder *pDecoder, STqOffset *pOffset) { + if (tDecodeI8(pDecoder, &pOffset->type) < 0) return -1; + if (pOffset->type == TMQ_OFFSET__SNAPSHOT) { + if (tDecodeI64(pDecoder, &pOffset->uid) < 0) return -1; + if (tDecodeI64(pDecoder, &pOffset->ts) < 0) return -1; + } else if (pOffset->type == TMQ_OFFSET__LOG) { + if (tDecodeI64(pDecoder, &pOffset->version) < 0) return -1; + } else { + ASSERT(0); + } + if (tDecodeCStrTo(pDecoder, pOffset->subKey) < 0) return -1; + return 0; +} diff --git a/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h b/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h index 22691300bc..c5c3d76f1e 100644 --- a/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h +++ b/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h @@ -34,39 +34,31 @@ typedef struct SMnodeMgmt { SSingleWorker writeWorker; SSingleWorker syncWorker; SSingleWorker monitorWorker; - SReplica replicas[TSDB_MAX_REPLICA]; - int8_t replica; bool stopped; int32_t refCount; TdThreadRwlock lock; } SMnodeMgmt; // mmFile.c -int32_t mmReadFile(SMnodeMgmt *pMgmt, bool *pDeployed); -int32_t mmWriteFile(SMnodeMgmt *pMgmt, SDCreateMnodeReq *pMsg, bool deployed); - -// mmInt.c -int32_t mmAcquire(SMnodeMgmt *pMgmt); -void mmRelease(SMnodeMgmt *pMgmt); +int32_t mmReadFile(SMnodeMgmt *pMgmt, SReplica *pReplica, bool *pDeployed); +int32_t mmWriteFile(SMnodeMgmt *pMgmt, const SReplica *pReplica, bool deployed); // mmHandle.c SArray *mmGetMsgHandles(); int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg); int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg); -int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t mmProcessGetLoadsReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); -int32_t mndPreprocessQueryMsg(SMnode * pMnode, SRpcMsg * pMsg); // mmWorker.c int32_t mmStartWorker(SMnodeMgmt *pMgmt); void mmStopWorker(SMnodeMgmt *pMgmt); -int32_t mmPutNodeMsgToWriteQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); -int32_t mmPutNodeMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); -int32_t mmPutNodeMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); -int32_t mmPutNodeMsgToQueryQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); -int32_t mmPutNodeMsgToMonitorQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); -int32_t mmPutRpcMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc); +int32_t mmPutMsgToWriteQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); +int32_t mmPutMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); +int32_t mmPutMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); +int32_t mmPutMsgToQueryQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); +int32_t mmPutMsgToMonitorQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); +int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc); #ifdef __cplusplus } diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmFile.c b/source/dnode/mgmt/mgmt_mnode/src/mmFile.c index 478d6abd52..27a35ae17a 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmFile.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmFile.c @@ -16,7 +16,7 @@ #define _DEFAULT_SOURCE #include "mmInt.h" -int32_t mmReadFile(SMnodeMgmt *pMgmt, bool *pDeployed) { +int32_t mmReadFile(SMnodeMgmt *pMgmt, SReplica *pReplica, bool *pDeployed) { int32_t code = TSDB_CODE_INVALID_JSON_FORMAT; int32_t len = 0; int32_t maxLen = 4096; @@ -52,61 +52,54 @@ int32_t mmReadFile(SMnodeMgmt *pMgmt, bool *pDeployed) { } *pDeployed = deployed->valueint; - cJSON *mnodes = cJSON_GetObjectItem(root, "mnodes"); - if (mnodes != NULL) { - if (!mnodes || mnodes->type != cJSON_Array) { - dError("failed to read %s since nodes not found", file); + cJSON *id = cJSON_GetObjectItem(root, "id"); + if (id) { + if (id->type != cJSON_Number) { + dError("failed to read %s since id not found", file); goto _OVER; } - - pMgmt->replica = cJSON_GetArraySize(mnodes); - if (pMgmt->replica <= 0 || pMgmt->replica > TSDB_MAX_REPLICA) { - dError("failed to read %s since mnodes size %d invalid", file, pMgmt->replica); - goto _OVER; - } - - for (int32_t i = 0; i < pMgmt->replica; ++i) { - cJSON *node = cJSON_GetArrayItem(mnodes, i); - if (node == NULL) break; - - SReplica *pReplica = &pMgmt->replicas[i]; - - cJSON *id = cJSON_GetObjectItem(node, "id"); - if (!id || id->type != cJSON_Number) { - dError("failed to read %s since id not found", file); - goto _OVER; - } + if (pReplica) { pReplica->id = id->valueint; + } + } - cJSON *fqdn = cJSON_GetObjectItem(node, "fqdn"); - if (!fqdn || fqdn->type != cJSON_String || fqdn->valuestring == NULL) { - dError("failed to read %s since fqdn not found", file); - goto _OVER; - } + cJSON *fqdn = cJSON_GetObjectItem(root, "fqdn"); + if (fqdn) { + if (fqdn->type != cJSON_String || fqdn->valuestring == NULL) { + dError("failed to read %s since fqdn not found", file); + goto _OVER; + } + if (pReplica) { tstrncpy(pReplica->fqdn, fqdn->valuestring, TSDB_FQDN_LEN); + } + } - cJSON *port = cJSON_GetObjectItem(node, "port"); - if (!port || port->type != cJSON_Number) { - dError("failed to read %s since port not found", file); - goto _OVER; - } - pReplica->port = port->valueint; + cJSON *port = cJSON_GetObjectItem(root, "port"); + if (port) { + if (port->type != cJSON_Number) { + dError("failed to read %s since port not found", file); + goto _OVER; + } + if (pReplica) { + pReplica->port = (uint16_t)port->valueint; } } code = 0; - dDebug("succcessed to read file %s, deployed:%d", file, *pDeployed); _OVER: if (content != NULL) taosMemoryFree(content); if (root != NULL) cJSON_Delete(root); if (pFile != NULL) taosCloseFile(&pFile); + if (code == 0) { + dDebug("succcessed to read file %s, deployed:%d", file, *pDeployed); + } terrno = code; return code; } -int32_t mmWriteFile(SMnodeMgmt *pMgmt, SDCreateMnodeReq *pMsg, bool deployed) { +int32_t mmWriteFile(SMnodeMgmt *pMgmt, const SReplica *pReplica, bool deployed) { char file[PATH_MAX] = {0}; char realfile[PATH_MAX] = {0}; snprintf(file, sizeof(file), "%s%smnode.json.bak", pMgmt->path, TD_DIRSEP); @@ -124,26 +117,11 @@ int32_t mmWriteFile(SMnodeMgmt *pMgmt, SDCreateMnodeReq *pMsg, bool deployed) { char *content = taosMemoryCalloc(1, maxLen + 1); len += snprintf(content + len, maxLen - len, "{\n"); - - int8_t replica = (pMsg != NULL ? pMsg->replica : pMgmt->replica); - if (replica > 0) { - len += snprintf(content + len, maxLen - len, " \"mnodes\": [{\n"); - for (int32_t i = 0; i < replica; ++i) { - SReplica *pReplica = &pMgmt->replicas[i]; - if (pMsg != NULL) { - pReplica = &pMsg->replicas[i]; - } - len += snprintf(content + len, maxLen - len, " \"id\": %d,\n", pReplica->id); - len += snprintf(content + len, maxLen - len, " \"fqdn\": \"%s\",\n", pReplica->fqdn); - len += snprintf(content + len, maxLen - len, " \"port\": %u\n", pReplica->port); - if (i < replica - 1) { - len += snprintf(content + len, maxLen - len, " },{\n"); - } else { - len += snprintf(content + len, maxLen - len, " }],\n"); - } - } + if (pReplica != NULL && pReplica->id > 0) { + len += snprintf(content + len, maxLen - len, " \"id\": %d,\n", pReplica->id); + len += snprintf(content + len, maxLen - len, " \"fqdn\": \"%s\",\n", pReplica->fqdn); + len += snprintf(content + len, maxLen - len, " \"port\": %u\n,", pReplica->port); } - len += snprintf(content + len, maxLen - len, " \"deployed\": %d\n", deployed); len += snprintf(content + len, maxLen - len, "}\n"); diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c index 2589bbd690..8cda8fcec3 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c @@ -20,11 +20,6 @@ void mmGetMonitorInfo(SMnodeMgmt *pMgmt, SMonMmInfo *pInfo) { mndGetMonitorInfo(pMgmt->pMnode, &pInfo->cluster, &pInfo->vgroup, &pInfo->grant); } -void mmGetMnodeLoads(SMnodeMgmt *pMgmt, SMonMloadInfo *pInfo) { - pInfo->isMnode = 1; - mndGetLoad(pMgmt->pMnode, &pInfo->load); -} - int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { SMonMmInfo mmInfo = {0}; mmGetMonitorInfo(pMgmt, &mmInfo); @@ -50,6 +45,11 @@ int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { return 0; } +void mmGetMnodeLoads(SMnodeMgmt *pMgmt, SMonMloadInfo *pInfo) { + pInfo->isMnode = 1; + mndGetLoad(pMgmt->pMnode, &pInfo->load); +} + int32_t mmProcessGetLoadsReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { SMonMloadInfo mloads = {0}; mmGetMnodeLoads(pMgmt, &mloads); @@ -90,7 +90,7 @@ int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) { SMnodeMgmt mgmt = {0}; mgmt.path = pInput->path; mgmt.name = pInput->name; - if (mmWriteFile(&mgmt, &createReq, deployed) != 0) { + if (mmWriteFile(&mgmt, &createReq.replicas[0], deployed) != 0) { dError("failed to write mnode file since %s", terrstr()); return -1; } @@ -126,115 +126,119 @@ int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) { SArray *mmGetMsgHandles() { int32_t code = -1; - SArray *pArray = taosArrayInit(64, sizeof(SMgmtHandle)); + SArray *pArray = taosArrayInit(128, sizeof(SMgmtHandle)); if (pArray == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_MNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_MNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_QNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_QNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_SNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_SNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_BNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_BNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_VNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_VNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_DND_CONFIG_DNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_MNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_MNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_QNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_QNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_SNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_SNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_BNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_BNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_VNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_VNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_DND_CONFIG_DNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_CONNECT, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_ACCT, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_ACCT, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_ACCT, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_USER, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_USER, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_USER, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_GET_USER_AUTH, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_DNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_CONFIG_DNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_DNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_MNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_MNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_MNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_MNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_QNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_QNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_QNODE_LIST, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_SNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_SNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_BNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_BNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_DB, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_DB, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_USE_DB, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_DB, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_COMPACT_DB, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_GET_DB_CFG, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_VGROUP_LIST, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_REDISTRIBUTE_VGROUP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_MERGE_VGROUP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_BALANCE_VGROUP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_FUNC, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_RETRIEVE_FUNC, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_FUNC, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_STB, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_STB, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_STB, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_TABLE_META, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_SMA, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_SMA, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_STREAM, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_GET_INDEX, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_GET_TABLE_INDEX, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_TOPIC, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_TOPIC, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_TOPIC, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_SUBSCRIBE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_ASK_EP, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_DROP_CGROUP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_DROP_CGROUP_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_COMMIT_OFFSET, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_TRANS, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_QUERY, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_CONN, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_HEARTBEAT, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_STATUS, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_SYSTABLE_RETRIEVE, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MND_AUTH, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_CONNECT, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_ACCT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_ACCT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_ACCT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_USER, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_USER, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_USER, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_GET_USER_AUTH, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_DNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_CONFIG_DNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_DNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_MNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_MNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_MNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_MNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_QNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_QNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_QNODE_LIST, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_SNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_SNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_BNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_BNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_DB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_DB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_USE_DB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_DB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_COMPACT_DB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_GET_DB_CFG, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_VGROUP_LIST, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_REDISTRIBUTE_VGROUP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_MERGE_VGROUP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_BALANCE_VGROUP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_FUNC, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_RETRIEVE_FUNC, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_FUNC, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_STB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_STB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_STB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_TABLE_META, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_SMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_SMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_STREAM, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_GET_INDEX, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_GET_TABLE_INDEX, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_TOPIC, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_TOPIC, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_TOPIC, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_SUBSCRIBE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_ASK_EP, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_DROP_CGROUP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_DROP_CGROUP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_COMMIT_OFFSET, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_TRANS, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_QUERY, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_CONN, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_HEARTBEAT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_STATUS, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_SYSTABLE_RETRIEVE, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_AUTH, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY, mmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_CONTINUE, mmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_HEARTBEAT, mmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH, mmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_STB_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_STB_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_STB_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_SMA_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_SMA_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_CHANGE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_DELETE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TASK, mmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIG_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_REPLICA_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIRM_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_HASHRANGE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_COMPACT_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_CONTINUE, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_HEARTBEAT, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_STB_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_STB_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_STB_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_SMA_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_SMA_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_CHANGE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_DELETE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TASK, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIG_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_REPLICA_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIRM_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_HASHRANGE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_COMPACT_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MON_MM_INFO, mmPutNodeMsgToMonitorQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_MON_MM_LOAD, mmPutNodeMsgToMonitorQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MON_MM_INFO, mmPutMsgToMonitorQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MON_MM_LOAD, mmPutMsgToMonitorQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_PING, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_PING_REPLY, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST_REPLY, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_REQUEST_VOTE, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_REQUEST_VOTE_REPLY, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_SEND, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_PING, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_PING_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_REQUEST_VOTE, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_REQUEST_VOTE_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_SEND, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_SET_MNODE_STANDBY, mmPutMsgToSyncQueue, 0) == NULL) goto _OVER; + + if (dmSetMgmtHandle(pArray, TDMT_SYNC_SET_MNODE_STANDBY_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_SET_VNODE_STANDBY_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; code = 0; diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmInt.c b/source/dnode/mgmt/mgmt_mnode/src/mmInt.c index 0f3c06cb3a..b7124dfaa5 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmInt.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmInt.c @@ -27,7 +27,7 @@ static bool mmDeployRequired(const SMgmtInputOpt *pInput) { static int32_t mmRequire(const SMgmtInputOpt *pInput, bool *required) { SMnodeMgmt mgmt = {0}; mgmt.path = pInput->path; - if (mmReadFile(&mgmt, required) != 0) { + if (mmReadFile(&mgmt, NULL, required) != 0) { return -1; } @@ -43,33 +43,19 @@ static void mmBuildOptionForDeploy(SMnodeMgmt *pMgmt, const SMgmtInputOpt *pInpu pOption->deploy = true; pOption->msgCb = pMgmt->msgCb; pOption->dnodeId = pMgmt->pData->dnodeId; - - pOption->replica = 1; - pOption->selfIndex = 0; - - SReplica *pReplica = &pOption->replicas[0]; - pReplica->id = 1; - pReplica->port = tsServerPort; - tstrncpy(pReplica->fqdn, tsLocalFqdn, TSDB_FQDN_LEN); + pOption->replica.id = 1; + pOption->replica.port = tsServerPort; + tstrncpy(pOption->replica.fqdn, tsLocalFqdn, TSDB_FQDN_LEN); } -static void mmBuildOptionForOpen(SMnodeMgmt *pMgmt, SMnodeOpt *pOption) { - pOption->deploy = false; +static void mmBuildOptionForOpen(SMnodeMgmt *pMgmt, const SReplica *pReplica, SMnodeOpt *pOption) { pOption->standby = false; + pOption->deploy = false; pOption->msgCb = pMgmt->msgCb; pOption->dnodeId = pMgmt->pData->dnodeId; - - if (pMgmt->replica > 0) { + if (pReplica->id > 0) { pOption->standby = true; - pOption->replica = 1; - pOption->selfIndex = 0; - SReplica *pReplica = &pOption->replicas[0]; - for (int32_t i = 0; i < pMgmt->replica; ++i) { - if (pMgmt->replicas[i].id != pMgmt->pData->dnodeId) continue; - pReplica->id = pMgmt->replicas[i].id; - pReplica->port = pMgmt->replicas[i].port; - memcpy(pReplica->fqdn, pMgmt->replicas[i].fqdn, TSDB_FQDN_LEN); - } + pOption->replica = *pReplica; } } @@ -105,12 +91,13 @@ static int32_t mmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) { pMgmt->path = pInput->path; pMgmt->name = pInput->name; pMgmt->msgCb = pInput->msgCb; - pMgmt->msgCb.putToQueueFp = (PutToQueueFp)mmPutRpcMsgToQueue; + pMgmt->msgCb.putToQueueFp = (PutToQueueFp)mmPutMsgToQueue; pMgmt->msgCb.mgmt = pMgmt; taosThreadRwlockInit(&pMgmt->lock, NULL); - bool deployed = false; - if (mmReadFile(pMgmt, &deployed) != 0) { + bool deployed = false; + SReplica replica = {0}; + if (mmReadFile(pMgmt, &replica, &deployed) != 0) { dError("failed to read file since %s", terrstr()); mmClose(pMgmt); return -1; @@ -123,7 +110,7 @@ static int32_t mmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) { mmBuildOptionForDeploy(pMgmt, pInput, &option); } else { dInfo("mnode start to open"); - mmBuildOptionForOpen(pMgmt, &option); + mmBuildOptionForOpen(pMgmt, &replica, &option); } pMgmt->pMnode = mndOpen(pMgmt->path, &option); @@ -141,8 +128,7 @@ static int32_t mmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) { } tmsgReportStartup("mnode-worker", "initialized"); - if (!deployed || pMgmt->replica > 0) { - pMgmt->replica = 0; + if (!deployed || replica.id > 0) { deployed = true; if (mmWriteFile(pMgmt, NULL, deployed) != 0) { dError("failed to write mnode file since %s", terrstr()); @@ -178,22 +164,3 @@ SMgmtFunc mmGetMgmtFunc() { return mgmtFunc; } - -int32_t mmAcquire(SMnodeMgmt *pMgmt) { - int32_t code = 0; - - taosThreadRwlockRdlock(&pMgmt->lock); - if (pMgmt->stopped) { - code = -1; - } else { - atomic_add_fetch_32(&pMgmt->refCount, 1); - } - taosThreadRwlockUnlock(&pMgmt->lock); - return code; -} - -void mmRelease(SMnodeMgmt *pMgmt) { - taosThreadRwlockRdlock(&pMgmt->lock); - atomic_sub_fetch_32(&pMgmt->refCount, 1); - taosThreadRwlockUnlock(&pMgmt->lock); -} \ No newline at end of file diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c index 53943b61b0..7cd7da1aa9 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c @@ -16,6 +16,25 @@ #define _DEFAULT_SOURCE #include "mmInt.h" +static inline int32_t mmAcquire(SMnodeMgmt *pMgmt) { + int32_t code = 0; + + taosThreadRwlockRdlock(&pMgmt->lock); + if (pMgmt->stopped) { + code = -1; + } else { + atomic_add_fetch_32(&pMgmt->refCount, 1); + } + taosThreadRwlockUnlock(&pMgmt->lock); + return code; +} + +static inline void mmRelease(SMnodeMgmt *pMgmt) { + taosThreadRwlockRdlock(&pMgmt->lock); + atomic_sub_fetch_32(&pMgmt->refCount, 1); + taosThreadRwlockUnlock(&pMgmt->lock); +} + static inline void mmSendRsp(SRpcMsg *pMsg, int32_t code) { SRpcMsg rsp = { .code = code, @@ -26,7 +45,7 @@ static inline void mmSendRsp(SRpcMsg *pMsg, int32_t code) { tmsgSendRsp(&rsp); } -static void mmProcessQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) { +static void mmProcessRpcMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) { SMnodeMgmt *pMgmt = pInfo->ahandle; int32_t code = -1; dTrace("msg:%p, get from mnode queue", pMsg); @@ -53,11 +72,10 @@ static void mmProcessQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) { taosFreeQitem(pMsg); } -static void mmProcessSyncQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) { +static void mmProcessSyncMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) { SMnodeMgmt *pMgmt = pInfo->ahandle; - dTrace("msg:%p, get from mnode-sync queue", pMsg); - pMsg->info.node = pMgmt->pMnode; + dTrace("msg:%p, get from mnode-sync queue", pMsg); SMsgHead *pHead = pMsg->pCont; pHead->contLen = ntohl(pHead->contLen); @@ -70,66 +88,70 @@ static void mmProcessSyncQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) { taosFreeQitem(pMsg); } -static int32_t mmPutNodeMsgToWorker(SSingleWorker *pWorker, SRpcMsg *pMsg) { - dTrace("msg:%p, put into %s queue, type:%s", pMsg, pWorker->name, TMSG_INFO(pMsg->msgType)); - taosWriteQitem(pWorker->queue, pMsg); - return 0; +static inline int32_t mmPutMsgToWorker(SMnodeMgmt *pMgmt, SSingleWorker *pWorker, SRpcMsg *pMsg) { + if (mmAcquire(pMgmt) == 0) { + dTrace("msg:%p, put into %s queue, type:%s", pMsg, pWorker->name, TMSG_INFO(pMsg->msgType)); + taosWriteQitem(pWorker->queue, pMsg); + mmRelease(pMgmt); + return 0; + } else { + dTrace("msg:%p, failed to put into %s queue since %s, type:%s", pMsg, pWorker->name, terrstr(), + TMSG_INFO(pMsg->msgType)); + return -1; + } } -int32_t mmPutNodeMsgToWriteQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { - return mmPutNodeMsgToWorker(&pMgmt->writeWorker, pMsg); +int32_t mmPutMsgToWriteQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { + return mmPutMsgToWorker(pMgmt, &pMgmt->writeWorker, pMsg); } -int32_t mmPutNodeMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { - return mmPutNodeMsgToWorker(&pMgmt->syncWorker, pMsg); +int32_t mmPutMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { + return mmPutMsgToWorker(pMgmt, &pMgmt->syncWorker, pMsg); } -int32_t mmPutNodeMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { - return mmPutNodeMsgToWorker(&pMgmt->readWorker, pMsg); +int32_t mmPutMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { + return mmPutMsgToWorker(pMgmt, &pMgmt->readWorker, pMsg); } -int32_t mmPutNodeMsgToQueryQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { - mndPreprocessQueryMsg(pMgmt->pMnode, pMsg); - - return mmPutNodeMsgToWorker(&pMgmt->queryWorker, pMsg); +int32_t mmPutMsgToQueryQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { + pMsg->info.node = pMgmt->pMnode; + if (mndPreProcessMsg(pMsg) != 0) { + dError("msg:%p, failed to pre-process in mnode since %s, type:%s", pMsg, terrstr(), TMSG_INFO(pMsg->msgType)); + return -1; + } + return mmPutMsgToWorker(pMgmt, &pMgmt->queryWorker, pMsg); } -int32_t mmPutNodeMsgToMonitorQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { - return mmPutNodeMsgToWorker(&pMgmt->monitorWorker, pMsg); +int32_t mmPutMsgToMonitorQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { + return mmPutMsgToWorker(pMgmt, &pMgmt->monitorWorker, pMsg); } -int32_t mmPutRpcMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) { +int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) { + SSingleWorker *pWorker = NULL; + switch (qtype) { + case WRITE_QUEUE: + pWorker = &pMgmt->writeWorker; + break; + case QUERY_QUEUE: + pWorker = &pMgmt->queryWorker; + break; + case READ_QUEUE: + pWorker = &pMgmt->readWorker; + break; + case SYNC_QUEUE: + pWorker = &pMgmt->syncWorker; + break; + default: + terrno = TSDB_CODE_INVALID_PARA; + } + + if (pWorker == NULL) return -1; SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM); if (pMsg == NULL) return -1; memcpy(pMsg, pRpc, sizeof(SRpcMsg)); - switch (qtype) { - case WRITE_QUEUE: - dTrace("msg:%p, is created and will put into vnode-write queue", pMsg); - taosWriteQitem(pMgmt->writeWorker.queue, pMsg); - return 0; - case QUERY_QUEUE: - dTrace("msg:%p, is created and will put into vnode-query queue", pMsg); - taosWriteQitem(pMgmt->queryWorker.queue, pMsg); - return 0; - - case READ_QUEUE: - dTrace("msg:%p, is created and will put into vnode-read queue", pMsg); - taosWriteQitem(pMgmt->readWorker.queue, pMsg); - return 0; - case SYNC_QUEUE: - if (mmAcquire(pMgmt) == 0) { - dTrace("msg:%p, is created and will put into vnode-sync queue", pMsg); - taosWriteQitem(pMgmt->syncWorker.queue, pMsg); - mmRelease(pMgmt); - return 0; - } else { - return -1; - } - default: - terrno = TSDB_CODE_INVALID_PARA; - return -1; - } + dTrace("msg:%p, is created and will put int %s queue", pMsg, pWorker->name); + return mmPutMsgToWorker(pMgmt, pWorker, pMsg); } int32_t mmStartWorker(SMnodeMgmt *pMgmt) { @@ -137,7 +159,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) { .min = tsNumOfMnodeQueryThreads, .max = tsNumOfMnodeQueryThreads, .name = "mnode-query", - .fp = (FItem)mmProcessQueue, + .fp = (FItem)mmProcessRpcMsg, .param = pMgmt, }; if (tSingleWorkerInit(&pMgmt->queryWorker, &qCfg) != 0) { @@ -149,7 +171,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) { .min = tsNumOfMnodeReadThreads, .max = tsNumOfMnodeReadThreads, .name = "mnode-read", - .fp = (FItem)mmProcessQueue, + .fp = (FItem)mmProcessRpcMsg, .param = pMgmt, }; if (tSingleWorkerInit(&pMgmt->readWorker, &rCfg) != 0) { @@ -161,7 +183,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) { .min = 1, .max = 1, .name = "mnode-write", - .fp = (FItem)mmProcessQueue, + .fp = (FItem)mmProcessRpcMsg, .param = pMgmt, }; if (tSingleWorkerInit(&pMgmt->writeWorker, &wCfg) != 0) { @@ -173,7 +195,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) { .min = 1, .max = 1, .name = "mnode-sync", - .fp = (FItem)mmProcessSyncQueue, + .fp = (FItem)mmProcessSyncMsg, .param = pMgmt, }; if (tSingleWorkerInit(&pMgmt->syncWorker, &sCfg) != 0) { @@ -185,7 +207,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) { .min = 1, .max = 1, .name = "mnode-monitor", - .fp = (FItem)mmProcessQueue, + .fp = (FItem)mmProcessRpcMsg, .param = pMgmt, }; if (tSingleWorkerInit(&pMgmt->monitorWorker, &mCfg) != 0) { diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index ee120576c3..8d3f3e9284 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -344,6 +344,7 @@ SArray *vmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_VND_SUBMIT_RSMA, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_CHANGE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_DELETE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_COMMIT_OFFSET, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_CONSUME, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_DELETE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_HEARTBEAT, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; @@ -373,6 +374,7 @@ SArray *vmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_SYNC_REQUEST_VOTE_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_SET_VNODE_STANDBY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; code = 0; diff --git a/source/dnode/mgmt/node_mgmt/src/dmEnv.c b/source/dnode/mgmt/node_mgmt/src/dmEnv.c index 528beb280b..119d521827 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmEnv.c +++ b/source/dnode/mgmt/node_mgmt/src/dmEnv.c @@ -123,10 +123,12 @@ static int32_t dmProcessCreateNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) { dError("node:%s, failed to create since %s", pWrapper->name, terrstr()); } else { dInfo("node:%s, has been created", pWrapper->name); - (void)dmOpenNode(pWrapper); - (void)dmStartNode(pWrapper); - pWrapper->required = true; + code = dmOpenNode(pWrapper); + if (code == 0) { + code = dmStartNode(pWrapper); + } pWrapper->deployed = true; + pWrapper->required = true; pWrapper->proc.ptype = pDnode->ptype; } diff --git a/source/dnode/mnode/impl/inc/mndInt.h b/source/dnode/mnode/impl/inc/mndInt.h index 4869a19856..cc9bc5b634 100644 --- a/source/dnode/mnode/impl/inc/mndInt.h +++ b/source/dnode/mnode/impl/inc/mndInt.h @@ -76,11 +76,12 @@ typedef struct { } STelemMgmt; typedef struct { - sem_t syncSem; - int64_t sync; - bool standby; - int32_t errCode; - int32_t transId; + sem_t syncSem; + int64_t sync; + bool standby; + SReplica replica; + int32_t errCode; + int32_t transId; } SSyncMgmt; typedef struct { @@ -98,9 +99,6 @@ typedef struct SMnode { bool stopped; bool restored; bool deploy; - int8_t replica; - int8_t selfIndex; - SReplica replicas[TSDB_MAX_REPLICA]; char *path; int64_t checkTime; SSdb *pSdb; @@ -126,8 +124,6 @@ void mndReleaseRpcRef(SMnode *pMnode); void mndSetRestore(SMnode *pMnode, bool restored); void mndSetStop(SMnode *pMnode); bool mndGetStop(SMnode *pMnode); -int32_t mndAcquireSyncRef(SMnode *pMnode); -void mndReleaseSyncRef(SMnode *pMnode); #ifdef __cplusplus } diff --git a/source/dnode/mnode/impl/inc/mndSma.h b/source/dnode/mnode/impl/inc/mndSma.h index 63530b403d..48e93c43fb 100644 --- a/source/dnode/mnode/impl/inc/mndSma.h +++ b/source/dnode/mnode/impl/inc/mndSma.h @@ -26,6 +26,8 @@ int32_t mndInitSma(SMnode *pMnode); void mndCleanupSma(SMnode *pMnode); SSmaObj *mndAcquireSma(SMnode *pMnode, char *smaName); void mndReleaseSma(SMnode *pMnode, SSmaObj *pSma); +int32_t mndDropSmasByStb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb); +int32_t mndDropSmasByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb); int32_t mndGetTableSma(SMnode *pMnode, char *tbFName, STableIndexRsp *rsp, bool *exist); #ifdef __cplusplus diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index b4237466d4..b1e691de82 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -183,12 +183,12 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) { pDb->cfg.pRetensions = taosArrayInit(pDb->cfg.numOfRetensions, sizeof(SRetention)); if (pDb->cfg.pRetensions == NULL) goto _OVER; for (int32_t i = 0; i < pDb->cfg.numOfRetensions; ++i) { - SRetention retension = {0}; - SDB_GET_INT64(pRaw, dataPos, &retension.freq, _OVER) - SDB_GET_INT64(pRaw, dataPos, &retension.keep, _OVER) - SDB_GET_INT8(pRaw, dataPos, &retension.freqUnit, _OVER) - SDB_GET_INT8(pRaw, dataPos, &retension.keepUnit, _OVER) - if (taosArrayPush(pDb->cfg.pRetensions, &retension) == NULL) { + SRetention retention = {0}; + SDB_GET_INT64(pRaw, dataPos, &retention.freq, _OVER) + SDB_GET_INT64(pRaw, dataPos, &retention.keep, _OVER) + SDB_GET_INT8(pRaw, dataPos, &retention.freqUnit, _OVER) + SDB_GET_INT8(pRaw, dataPos, &retention.keepUnit, _OVER) + if (taosArrayPush(pDb->cfg.pRetensions, &retention) == NULL) { goto _OVER; } } @@ -472,7 +472,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate, } int32_t code = -1; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq); if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to create db:%s", pTrans->id, pCreate->db); @@ -935,6 +935,7 @@ static int32_t mndDropDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb) { if (mndDropOffsetByDB(pMnode, pTrans, pDb) != 0) goto _OVER; if (mndDropSubByDB(pMnode, pTrans, pDb) != 0) goto _OVER; if (mndDropTopicByDB(pMnode, pTrans, pDb) != 0) goto _OVER; + if (mndDropSmasByDb(pMnode, pTrans, pDb) != 0) goto _OVER; if (mndSetDropDbRedoActions(pMnode, pTrans, pDb) != 0) goto _OVER; SUserObj *pUser = mndAcquireUser(pMnode, pDb->createUser); @@ -1366,7 +1367,7 @@ char *buildRetension(SArray *pRetension) { } static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, int32_t rows, int64_t numOfTables, - bool sysDb) { + bool sysDb, ESdbStatus objStatus) { int32_t cols = 0; int32_t bytes = pShow->pMeta->pSchemas[cols].bytes; @@ -1379,7 +1380,9 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in } char *status = "ready"; - char statusB[24] = {0}; + if (objStatus == SDB_STATUS_CREATING) status = "creating"; + if (objStatus == SDB_STATUS_DROPPING) status = "dropping"; + char statusB[24] = {0}; STR_WITH_SIZE_TO_VARSTR(statusB, status, strlen(status)); if (sysDb) { @@ -1503,8 +1506,8 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, rows, (const char *)statusB, false); -// pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); -// colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.schemaless, false); + // pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + // colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.schemaless, false); char *p = buildRetension(pDb->cfg.pRetensions); @@ -1548,29 +1551,30 @@ static bool mndGetTablesOfDbFp(SMnode *pMnode, void *pObj, void *p1, void *p2, v } static int32_t mndRetrieveDbs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rowsCapacity) { - SMnode *pMnode = pReq->info.node; - SSdb *pSdb = pMnode->pSdb; - int32_t numOfRows = 0; - SDbObj *pDb = NULL; + SMnode *pMnode = pReq->info.node; + SSdb *pSdb = pMnode->pSdb; + int32_t numOfRows = 0; + SDbObj *pDb = NULL; + ESdbStatus objStatus = 0; // Append the information_schema database into the result. if (!pShow->sysDbRsp) { SDbObj infoschemaDb = {0}; setInformationSchemaDbCfg(&infoschemaDb); - dumpDbInfoData(pBlock, &infoschemaDb, pShow, numOfRows, 14, true); + dumpDbInfoData(pBlock, &infoschemaDb, pShow, numOfRows, 14, true, 0); numOfRows += 1; SDbObj perfschemaDb = {0}; setPerfSchemaDbCfg(&perfschemaDb); - dumpDbInfoData(pBlock, &perfschemaDb, pShow, numOfRows, 3, true); + dumpDbInfoData(pBlock, &perfschemaDb, pShow, numOfRows, 3, true, 0); numOfRows += 1; pShow->sysDbRsp = true; } while (numOfRows < rowsCapacity) { - pShow->pIter = sdbFetch(pSdb, SDB_DB, pShow->pIter, (void **)&pDb); + pShow->pIter = sdbFetchAll(pSdb, SDB_DB, pShow->pIter, (void **)&pDb, &objStatus); if (pShow->pIter == NULL) { break; } @@ -1578,7 +1582,7 @@ static int32_t mndRetrieveDbs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc int32_t numOfTables = 0; sdbTraverse(pSdb, SDB_VGROUP, mndGetTablesOfDbFp, &numOfTables, NULL, NULL); - dumpDbInfoData(pBlock, pDb, pShow, numOfRows, numOfTables, false); + dumpDbInfoData(pBlock, pDb, pShow, numOfRows, numOfTables, false, objStatus); numOfRows++; sdbRelease(pSdb, pDb); } diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 73eea70195..c936c0f93d 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -95,8 +95,8 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) { dnodeObj.id = 1; dnodeObj.createdTime = taosGetTimestampMs(); dnodeObj.updateTime = dnodeObj.createdTime; - dnodeObj.port = pMnode->replicas[0].port; - memcpy(&dnodeObj.fqdn, pMnode->replicas[0].fqdn, TSDB_FQDN_LEN); + dnodeObj.port = tsServerPort; + memcpy(&dnodeObj.fqdn, tsLocalFqdn, TSDB_FQDN_LEN); snprintf(dnodeObj.ep, TSDB_EP_LEN, "%s:%u", dnodeObj.fqdn, dnodeObj.port); pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL); diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index d8a61461dd..59599ee134 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -289,11 +289,9 @@ static int32_t mndExecSteps(SMnode *pMnode) { } static void mndSetOptions(SMnode *pMnode, const SMnodeOpt *pOption) { - pMnode->replica = pOption->replica; - pMnode->selfIndex = pOption->selfIndex; - memcpy(&pMnode->replicas, pOption->replicas, sizeof(SReplica) * TSDB_MAX_REPLICA); pMnode->msgCb = pOption->msgCb; pMnode->selfDnodeId = pOption->dnodeId; + pMnode->syncMgmt.replica = pOption->replica; pMnode->syncMgmt.standby = pOption->standby; } @@ -382,22 +380,17 @@ void mndStop(SMnode *pMnode) { int32_t mndProcessSyncMsg(SRpcMsg *pMsg) { SMnode *pMnode = pMsg->info.node; SSyncMgmt *pMgmt = &pMnode->syncMgmt; - int32_t code = TAOS_SYNC_PROPOSE_OTHER_ERROR; + int32_t code = TAOS_SYNC_OTHER_ERROR; if (!syncEnvIsStart()) { mError("failed to process sync msg:%p type:%s since syncEnv stop", pMsg, TMSG_INFO(pMsg->msgType)); - return TAOS_SYNC_PROPOSE_OTHER_ERROR; + return TAOS_SYNC_OTHER_ERROR; } SSyncNode *pSyncNode = syncNodeAcquire(pMgmt->sync); if (pSyncNode == NULL) { mError("failed to process sync msg:%p type:%s since syncNode is null", pMsg, TMSG_INFO(pMsg->msgType)); - return TAOS_SYNC_PROPOSE_OTHER_ERROR; - } - - if (mndAcquireSyncRef(pMnode) != 0) { - mError("failed to process sync msg:%p type:%s since %s", pMsg, TMSG_INFO(pMsg->msgType), terrstr()); - return TAOS_SYNC_PROPOSE_OTHER_ERROR; + return TAOS_SYNC_OTHER_ERROR; } char logBuf[512] = {0}; @@ -428,7 +421,6 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) { SyncClientRequest *pSyncMsg = syncClientRequestFromRpcMsg2(pMsg); code = syncNodeOnClientRequestCb(pSyncNode, pSyncMsg); syncClientRequestDestroy(pSyncMsg); - } else if (pMsg->msgType == TDMT_SYNC_REQUEST_VOTE) { SyncRequestVote *pSyncMsg = syncRequestVoteFromRpcMsg2(pMsg); code = syncNodeOnRequestVoteSnapshotCb(pSyncNode, pSyncMsg); @@ -445,7 +437,6 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) { SyncAppendEntriesReply *pSyncMsg = syncAppendEntriesReplyFromRpcMsg2(pMsg); code = syncNodeOnAppendEntriesReplySnapshotCb(pSyncNode, pSyncMsg); syncAppendEntriesReplyDestroy(pSyncMsg); - } else if (pMsg->msgType == TDMT_SYNC_SNAPSHOT_SEND) { SyncSnapshotSend *pSyncMsg = syncSnapshotSendFromRpcMsg2(pMsg); code = syncNodeOnSnapshotSendCb(pSyncNode, pSyncMsg); @@ -454,12 +445,14 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) { SyncSnapshotRsp *pSyncMsg = syncSnapshotRspFromRpcMsg2(pMsg); code = syncNodeOnSnapshotRspCb(pSyncNode, pSyncMsg); syncSnapshotRspDestroy(pSyncMsg); - + } else if (pMsg->msgType == TDMT_SYNC_SET_MNODE_STANDBY) { + code = syncSetStandby(pMgmt->sync); + SRpcMsg rsp = {.code = code, .info = pMsg->info}; + tmsgSendRsp(&rsp); } else { mError("failed to process msg:%p since invalid type:%s", pMsg, TMSG_INFO(pMsg->msgType)); - code = TAOS_SYNC_PROPOSE_OTHER_ERROR; + code = TAOS_SYNC_OTHER_ERROR; } - } else { if (pMsg->msgType == TDMT_SYNC_TIMEOUT) { SyncTimeout *pSyncMsg = syncTimeoutFromRpcMsg2(pMsg); @@ -493,13 +486,16 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) { SyncAppendEntriesReply *pSyncMsg = syncAppendEntriesReplyFromRpcMsg2(pMsg); code = syncNodeOnAppendEntriesReplyCb(pSyncNode, pSyncMsg); syncAppendEntriesReplyDestroy(pSyncMsg); + } else if (pMsg->msgType == TDMT_SYNC_SET_MNODE_STANDBY) { + code = syncSetStandby(pMgmt->sync); + SRpcMsg rsp = {.code = code, .info = pMsg->info}; + tmsgSendRsp(&rsp); } else { mError("failed to process msg:%p since invalid type:%s", pMsg, TMSG_INFO(pMsg->msgType)); - code = TAOS_SYNC_PROPOSE_OTHER_ERROR; + code = TAOS_SYNC_OTHER_ERROR; } } - mndReleaseSyncRef(pMnode); return code; } @@ -752,24 +748,3 @@ void mndSetStop(SMnode *pMnode) { } bool mndGetStop(SMnode *pMnode) { return pMnode->stopped; } - -int32_t mndAcquireSyncRef(SMnode *pMnode) { - int32_t code = 0; - taosThreadRwlockRdlock(&pMnode->lock); - if (pMnode->stopped) { - terrno = TSDB_CODE_APP_NOT_READY; - code = -1; - } else { - int32_t ref = atomic_add_fetch_32(&pMnode->syncRef, 1); - // mTrace("mnode sync is acquired, ref:%d", ref); - } - taosThreadRwlockUnlock(&pMnode->lock); - return code; -} - -void mndReleaseSyncRef(SMnode *pMnode) { - taosThreadRwlockRdlock(&pMnode->lock); - int32_t ref = atomic_sub_fetch_32(&pMnode->syncRef, 1); - // mTrace("mnode sync is released, ref:%d", ref); - taosThreadRwlockUnlock(&pMnode->lock); -} diff --git a/source/dnode/mnode/impl/src/mndMnode.c b/source/dnode/mnode/impl/src/mndMnode.c index c5a4282b3b..f6cef945e2 100644 --- a/source/dnode/mnode/impl/src/mndMnode.c +++ b/source/dnode/mnode/impl/src/mndMnode.c @@ -55,6 +55,8 @@ int32_t mndInitMnode(SMnode *pMnode) { mndSetMsgHandle(pMnode, TDMT_MND_ALTER_MNODE_RSP, mndTransProcessRsp); mndSetMsgHandle(pMnode, TDMT_MND_DROP_MNODE, mndProcessDropMnodeReq); mndSetMsgHandle(pMnode, TDMT_DND_DROP_MNODE_RSP, mndTransProcessRsp); + mndSetMsgHandle(pMnode, TDMT_SYNC_SET_MNODE_STANDBY_RSP, mndTransProcessRsp); + mndSetMsgHandle(pMnode, TDMT_SYNC_SET_VNODE_STANDBY_RSP, mndTransProcessRsp); mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_MNODE, mndRetrieveMnodes); mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_MNODE, mndCancelGetNextMnode); @@ -460,6 +462,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode int32_t numOfReplicas = 0; SDAlterMnodeReq alterReq = {0}; SDDropMnodeReq dropReq = {0}; + SSetStandbyReq standbyReq = {0}; SEpSet alterEpset = {0}; SEpSet dropEpSet = {0}; @@ -494,6 +497,31 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode dropEpSet.eps[0].port = pDnode->port; memcpy(dropEpSet.eps[0].fqdn, pDnode->fqdn, TSDB_FQDN_LEN); + standbyReq.dnodeId = pDnode->id; + standbyReq.standby = 1; + + { + int32_t contLen = tSerializeSSetStandbyReq(NULL, 0, &standbyReq) + sizeof(SMsgHead); + void *pReq = taosMemoryMalloc(contLen); + tSerializeSSetStandbyReq((char*)pReq + sizeof(SMsgHead), contLen, &standbyReq); + SMsgHead *pHead = pReq; + pHead->contLen = htonl(contLen); + pHead->vgId = htonl(MNODE_HANDLE); + + STransAction action = { + .epSet = dropEpSet, + .pCont = pReq, + .contLen = contLen, + .msgType = TDMT_SYNC_SET_MNODE_STANDBY, + .acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED, + }; + + if (mndTransAppendRedoAction(pTrans, &action) != 0) { + taosMemoryFree(pReq); + return -1; + } + } + { int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, &alterReq); void *pReq = taosMemoryMalloc(contLen); @@ -632,7 +660,7 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB int32_t numOfRows = 0; int32_t cols = 0; SMnodeObj *pObj = NULL; - ESdbStatus objStatus; + ESdbStatus objStatus = 0; char *pWrite; int64_t curMs = taosGetTimestampMs(); diff --git a/source/dnode/mnode/impl/src/mndQuery.c b/source/dnode/mnode/impl/src/mndQuery.c index 12b39e5b78..5374f48e47 100644 --- a/source/dnode/mnode/impl/src/mndQuery.c +++ b/source/dnode/mnode/impl/src/mndQuery.c @@ -18,11 +18,10 @@ #include "mndMnode.h" #include "qworker.h" -int32_t mndPreprocessQueryMsg(SMnode * pMnode, SRpcMsg * pMsg) { - if (TDMT_VND_QUERY != pMsg->msgType) { - return 0; - } +int32_t mndPreProcessMsg(SRpcMsg *pMsg) { + if (TDMT_VND_QUERY != pMsg->msgType) return 0; + SMnode *pMnode = pMsg->info.node; return qWorkerPreprocessQueryMsg(pMnode->pQuery, pMsg); } diff --git a/source/dnode/mnode/impl/src/mndScheduler.c b/source/dnode/mnode/impl/src/mndScheduler.c index 2454a4686d..a3b7754a4e 100644 --- a/source/dnode/mnode/impl/src/mndScheduler.c +++ b/source/dnode/mnode/impl/src/mndScheduler.c @@ -77,7 +77,7 @@ int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64 terrno = TSDB_CODE_QRY_INVALID_INPUT; goto END; } - SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, 0); + SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, 0); int32_t opNum = LIST_LENGTH(inner->pNodeList); if (opNum != 1) { @@ -85,7 +85,7 @@ int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64 goto END; } - SSubplan* plan = nodesListGetNode(inner->pNodeList, 0); + SSubplan* plan = (SSubplan*)nodesListGetNode(inner->pNodeList, 0); if (qSubPlanToString(plan, pDst, pDstLen) < 0) { terrno = TSDB_CODE_QRY_INVALID_INPUT; goto END; @@ -93,7 +93,7 @@ int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64 END: if (pAst) nodesDestroyNode(pAst); - if (pPlan) nodesDestroyNode(pPlan); + if (pPlan) nodesDestroyNode((SNode*)pPlan); return terrno; } @@ -378,8 +378,8 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { SArray* taskInnerLevel = taosArrayInit(0, sizeof(void*)); taosArrayPush(pStream->tasks, &taskInnerLevel); - SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, 0); - SSubplan* plan = nodesListGetNode(inner->pNodeList, 0); + SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, 0); + SSubplan* plan = (SSubplan*)nodesListGetNode(inner->pNodeList, 0); ASSERT(plan->subplanType == SUBPLAN_TYPE_MERGE); pFinalTask = tNewSStreamTask(pStream->uid); @@ -407,8 +407,8 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { SArray* taskSourceLevel = taosArrayInit(0, sizeof(void*)); taosArrayPush(pStream->tasks, &taskSourceLevel); - SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, 1); - SSubplan* plan = nodesListGetNode(inner->pNodeList, 0); + SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, 1); + SSubplan* plan = (SSubplan*)nodesListGetNode(inner->pNodeList, 0); ASSERT(plan->subplanType == SUBPLAN_TYPE_SCAN); void* pIter = NULL; @@ -449,9 +449,9 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { SArray* taskOneLevel = taosArrayInit(0, sizeof(void*)); taosArrayPush(pStream->tasks, &taskOneLevel); - SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, 0); + SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, 0); ASSERT(LIST_LENGTH(inner->pNodeList) == 1); - SSubplan* plan = nodesListGetNode(inner->pNodeList, 0); + SSubplan* plan = (SSubplan*)nodesListGetNode(inner->pNodeList, 0); ASSERT(plan->subplanType == SUBPLAN_TYPE_SCAN); void* pIter = NULL; @@ -509,7 +509,7 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib return -1; } - SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, 0); + SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, 0); int32_t opNum = LIST_LENGTH(inner->pNodeList); if (opNum != 1) { @@ -517,7 +517,7 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib terrno = TSDB_CODE_MND_INVALID_TOPIC_QUERY; return -1; } - plan = nodesListGetNode(inner->pNodeList, 0); + plan = (SSubplan*)nodesListGetNode(inner->pNodeList, 0); } ASSERT(pSub->unassignedVgs); diff --git a/source/dnode/mnode/impl/src/mndSma.c b/source/dnode/mnode/impl/src/mndSma.c index 3f0d20348b..23117a1323 100644 --- a/source/dnode/mnode/impl/src/mndSma.c +++ b/source/dnode/mnode/impl/src/mndSma.c @@ -38,12 +38,13 @@ static int32_t mndSmaActionInsert(SSdb *pSdb, SSmaObj *pSma); static int32_t mndSmaActionDelete(SSdb *pSdb, SSmaObj *pSpSmatb); static int32_t mndSmaActionUpdate(SSdb *pSdb, SSmaObj *pOld, SSmaObj *pNew); static int32_t mndSmaGetVgEpSet(SMnode *pMnode, SDbObj *pDb, SVgEpSet **ppVgEpSet, int32_t *numOfVgroups); -static int32_t mndProcessMCreateSmaReq(SRpcMsg *pReq); -static int32_t mndProcessMDropSmaReq(SRpcMsg *pReq); +static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq); +static int32_t mndProcessDropSmaReq(SRpcMsg *pReq); static int32_t mndProcessGetSmaReq(SRpcMsg *pReq); -static int32_t mndProcessGetTbSmaReq(SRpcMsg *pReq); +static int32_t mndProcessGetTbSmaReq(SRpcMsg *pReq); static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); static void mndCancelGetNextSma(SMnode *pMnode, void *pIter); +static void mndDestroySmaObj(SSmaObj *pSmaObj); int32_t mndInitSma(SMnode *pMnode) { SSdbTable table = { @@ -56,8 +57,8 @@ int32_t mndInitSma(SMnode *pMnode) { .deleteFp = (SdbDeleteFp)mndSmaActionDelete, }; - mndSetMsgHandle(pMnode, TDMT_MND_CREATE_SMA, mndProcessMCreateSmaReq); - mndSetMsgHandle(pMnode, TDMT_MND_DROP_SMA, mndProcessMDropSmaReq); + mndSetMsgHandle(pMnode, TDMT_MND_CREATE_SMA, mndProcessCreateSmaReq); + mndSetMsgHandle(pMnode, TDMT_MND_DROP_SMA, mndProcessDropSmaReq); mndSetMsgHandle(pMnode, TDMT_VND_CREATE_SMA_RSP, mndTransProcessRsp); mndSetMsgHandle(pMnode, TDMT_VND_DROP_SMA_RSP, mndTransProcessRsp); mndSetMsgHandle(pMnode, TDMT_MND_GET_INDEX, mndProcessGetSmaReq); @@ -79,7 +80,6 @@ static SSdbRaw *mndSmaActionEncode(SSmaObj *pSma) { if (pRaw == NULL) goto _OVER; int32_t dataPos = 0; - SDB_SET_BINARY(pRaw, dataPos, pSma->name, TSDB_TABLE_FNAME_LEN, _OVER) SDB_SET_BINARY(pRaw, dataPos, pSma->stb, TSDB_TABLE_FNAME_LEN, _OVER) SDB_SET_BINARY(pRaw, dataPos, pSma->db, TSDB_DB_FNAME_LEN, _OVER) @@ -100,6 +100,7 @@ static SSdbRaw *mndSmaActionEncode(SSmaObj *pSma) { SDB_SET_INT32(pRaw, dataPos, pSma->tagsFilterLen, _OVER) SDB_SET_INT32(pRaw, dataPos, pSma->sqlLen, _OVER) SDB_SET_INT32(pRaw, dataPos, pSma->astLen, _OVER) + if (pSma->exprLen > 0) { SDB_SET_BINARY(pRaw, dataPos, pSma->expr, pSma->exprLen, _OVER) } @@ -115,6 +116,7 @@ static SSdbRaw *mndSmaActionEncode(SSmaObj *pSma) { SDB_SET_RESERVE(pRaw, dataPos, TSDB_SMA_RESERVE_SIZE, _OVER) SDB_SET_DATALEN(pRaw, dataPos, _OVER) + terrno = 0; _OVER: @@ -193,6 +195,7 @@ static SSdbRow *mndSmaActionDecode(SSdbRaw *pRaw) { } SDB_GET_RESERVE(pRaw, dataPos, TSDB_SMA_RESERVE_SIZE, _OVER) + terrno = 0; _OVER: @@ -383,6 +386,27 @@ static int32_t mndSetCreateSmaVgroupCommitLogs(SMnode *pMnode, STrans *pTrans, S return 0; } +static int32_t mndSetUpdateSmaStbCommitLogs(SMnode *pMnode, STrans *pTrans, SStbObj *pStb) { + SStbObj stbObj = {0}; + taosRLockLatch(&pStb->lock); + memcpy(&stbObj, pStb, sizeof(SStbObj)); + taosRUnLockLatch(&pStb->lock); + stbObj.numOfColumns = 0; + stbObj.pColumns = NULL; + stbObj.numOfTags = 0; + stbObj.pTags = NULL; + stbObj.updateTime = taosGetTimestampMs(); + stbObj.lock = 0; + stbObj.smaVer++; + + SSdbRaw *pCommitRaw = mndStbActionEncode(&stbObj); + if (pCommitRaw == NULL) return -1; + if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) return -1; + if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY) != 0) return -1; + + return 0; +} + static int32_t mndSetCreateSmaRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SSmaObj *pSma) { SSdb *pSdb = pMnode->pSdb; SVgObj *pVgroup = NULL; @@ -457,7 +481,6 @@ static int32_t mndSetCreateSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans, pSma->schemaTag.pSchema[0].flags = 0; snprintf(pSma->schemaTag.pSchema[0].name, TSDB_COL_NAME_LEN, "groupId"); - int32_t smaContLen = 0; void *pSmaReq = mndBuildVCreateSmaReq(pMnode, pVgroup, pSma, &smaContLen); if (pSmaReq == NULL) return -1; @@ -481,6 +504,13 @@ static int32_t mndSetCreateSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans, return 0; } +static void mndDestroySmaObj(SSmaObj *pSmaObj) { + if (pSmaObj) { + taosMemoryFreeClear(pSmaObj->schemaRow.pSchema); + taosMemoryFreeClear(pSmaObj->schemaTag.pSchema); + } +} + static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCreate, SDbObj *pDb, SStbObj *pStb) { SSmaObj smaObj = {0}; memcpy(smaObj.name, pCreate->name, TSDB_TABLE_FNAME_LEN); @@ -504,29 +534,17 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea smaObj.tagsFilterLen = pCreate->tagsFilterLen; smaObj.sqlLen = pCreate->sqlLen; smaObj.astLen = pCreate->astLen; - if (smaObj.exprLen > 0) { - smaObj.expr = taosMemoryMalloc(smaObj.exprLen); - if (smaObj.expr == NULL) goto _OVER; - memcpy(smaObj.expr, pCreate->expr, smaObj.exprLen); + smaObj.expr = pCreate->expr; } - if (smaObj.tagsFilterLen > 0) { - smaObj.tagsFilter = taosMemoryMalloc(smaObj.tagsFilterLen); - if (smaObj.tagsFilter == NULL) goto _OVER; - memcpy(smaObj.tagsFilter, pCreate->tagsFilter, smaObj.tagsFilterLen); + smaObj.tagsFilter = pCreate->tagsFilter; } - if (smaObj.sqlLen > 0) { - smaObj.sql = taosMemoryMalloc(smaObj.sqlLen); - if (smaObj.sql == NULL) goto _OVER; - memcpy(smaObj.sql, pCreate->sql, smaObj.sqlLen); + smaObj.sql = pCreate->sql; } - if (smaObj.astLen > 0) { - smaObj.ast = taosMemoryMalloc(smaObj.astLen); - if (smaObj.ast == NULL) goto _OVER; - memcpy(smaObj.ast, pCreate->ast, smaObj.astLen); + smaObj.ast = pCreate->ast; } SStreamObj streamObj = {0}; @@ -560,6 +578,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea if (mndSetCreateSmaVgroupRedoLogs(pMnode, pTrans, &streamObj.fixedSinkVg) != 0) goto _OVER; if (mndSetCreateSmaCommitLogs(pMnode, pTrans, &smaObj) != 0) goto _OVER; if (mndSetCreateSmaVgroupCommitLogs(pMnode, pTrans, &streamObj.fixedSinkVg) != 0) goto _OVER; + if (mndSetUpdateSmaStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER; if (mndSetCreateSmaRedoActions(pMnode, pTrans, pDb, &smaObj) != 0) goto _OVER; if (mndSetCreateSmaVgroupRedoActions(pMnode, pTrans, pDb, &streamObj.fixedSinkVg, &smaObj) != 0) goto _OVER; if (mndAddStreamToTrans(pMnode, &streamObj, pCreate->ast, STREAM_TRIGGER_AT_ONCE, 0, pTrans) != 0) goto _OVER; @@ -568,6 +587,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea code = 0; _OVER: + mndDestroySmaObj(&smaObj); mndTransDrop(pTrans); return code; } @@ -600,7 +620,7 @@ static int32_t mndCheckCreateSmaReq(SMCreateSmaReq *pCreate) { return 0; } -static int32_t mndProcessMCreateSmaReq(SRpcMsg *pReq) { +static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; int32_t code = -1; SStbObj *pStb = NULL; @@ -782,13 +802,17 @@ static int32_t mndSetDropSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans, SD } static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *pSma) { - int32_t code = -1; - SVgObj *pVgroup = NULL; - STrans *pTrans = NULL; + int32_t code = -1; + SVgObj *pVgroup = NULL; + SStbObj *pStb = NULL; + STrans *pTrans = NULL; pVgroup = mndAcquireVgroup(pMnode, pSma->dstVgId); if (pVgroup == NULL) goto _OVER; + pStb = mndAcquireStb(pMnode, pSma->stb); + if (pStb == NULL) goto _OVER; + pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB, pReq); if (pTrans == NULL) goto _OVER; @@ -799,6 +823,7 @@ static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *p if (mndSetDropSmaVgroupRedoLogs(pMnode, pTrans, pVgroup) != 0) goto _OVER; if (mndSetDropSmaCommitLogs(pMnode, pTrans, pSma) != 0) goto _OVER; if (mndSetDropSmaVgroupCommitLogs(pMnode, pTrans, pVgroup) != 0) goto _OVER; + if (mndSetUpdateSmaStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER; if (mndSetDropSmaRedoActions(pMnode, pTrans, pDb, pSma) != 0) goto _OVER; if (mndSetDropSmaVgroupRedoActions(pMnode, pTrans, pDb, pVgroup) != 0) goto _OVER; if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; @@ -808,10 +833,78 @@ static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *p _OVER: mndTransDrop(pTrans); mndReleaseVgroup(pMnode, pVgroup); + mndReleaseStb(pMnode, pStb); return code; } -static int32_t mndProcessMDropSmaReq(SRpcMsg *pReq) { +int32_t mndDropSmasByStb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) { + SSdb *pSdb = pMnode->pSdb; + SSmaObj *pSma = NULL; + void *pIter = NULL; + SVgObj *pVgroup = NULL; + int32_t code = -1; + + while (1) { + pIter = sdbFetch(pSdb, SDB_SMA, pIter, (void **)&pSma); + if (pIter == NULL) break; + + if (pSma->stbUid == pStb->uid) { + pVgroup = mndAcquireVgroup(pMnode, pSma->dstVgId); + if (pVgroup == NULL) goto _OVER; + if (mndSetDropSmaVgroupCommitLogs(pMnode, pTrans, pVgroup) != 0) goto _OVER; + if (mndSetDropSmaVgroupRedoActions(pMnode, pTrans, pDb, pVgroup) != 0) goto _OVER; + if (mndSetDropSmaCommitLogs(pMnode, pTrans, pSma) != 0) goto _OVER; + if (mndSetDropSmaRedoActions(pMnode, pTrans, pDb, pSma) != 0) goto _OVER; + mndReleaseVgroup(pMnode, pVgroup); + pVgroup = NULL; + } + + sdbRelease(pSdb, pSma); + } + + code = 0; + +_OVER: + sdbCancelFetch(pSdb, pIter); + sdbRelease(pSdb, pSma); + mndReleaseVgroup(pMnode, pVgroup); + return code; +} + +int32_t mndDropSmasByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) { + SSdb *pSdb = pMnode->pSdb; + SSmaObj *pSma = NULL; + void *pIter = NULL; + SVgObj *pVgroup = NULL; + int32_t code = -1; + + while (1) { + pIter = sdbFetch(pSdb, SDB_SMA, pIter, (void **)&pSma); + if (pIter == NULL) break; + + if (pSma->dbUid == pDb->uid) { + pVgroup = mndAcquireVgroup(pMnode, pSma->dstVgId); + if (pVgroup == NULL) goto _OVER; + if (mndSetDropSmaVgroupCommitLogs(pMnode, pTrans, pVgroup) != 0) goto _OVER; + if (mndSetDropSmaVgroupRedoActions(pMnode, pTrans, pDb, pVgroup) != 0) goto _OVER; + if (mndSetDropSmaCommitLogs(pMnode, pTrans, pSma) != 0) goto _OVER; + mndReleaseVgroup(pMnode, pVgroup); + pVgroup = NULL; + } + + sdbRelease(pSdb, pSma); + } + + code = 0; + +_OVER: + sdbCancelFetch(pSdb, pIter); + sdbRelease(pSdb, pSma); + mndReleaseVgroup(pMnode, pVgroup); + return code; +} + +static int32_t mndProcessDropSmaReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; int32_t code = -1; SUserObj *pUser = NULL; @@ -901,13 +994,13 @@ static int32_t mndGetSma(SMnode *pMnode, SUserIndexReq *indexReq, SUserIndexRsp } int32_t mndGetTableSma(SMnode *pMnode, char *tbFName, STableIndexRsp *rsp, bool *exist) { - int32_t code = 0; - SSmaObj *pSma = NULL; - SSdb *pSdb = pMnode->pSdb; - void *pIter = NULL; + int32_t code = 0; + SSmaObj *pSma = NULL; + SSdb *pSdb = pMnode->pSdb; + void *pIter = NULL; STableIndexInfo info; - SStbObj* pStb = mndAcquireStb(pMnode, tbFName); + SStbObj *pStb = mndAcquireStb(pMnode, tbFName); if (NULL == pStb) { *exist = false; return TSDB_CODE_SUCCESS; @@ -918,7 +1011,6 @@ int32_t mndGetTableSma(SMnode *pMnode, char *tbFName, STableIndexRsp *rsp, bool rsp->suid = pStb->uid; rsp->version = pStb->smaVer; mndReleaseStb(pMnode, pStb); - while (1) { pIter = sdbFetch(pSdb, SDB_SMA, pIter, (void **)&pSma); @@ -936,14 +1028,14 @@ int32_t mndGetTableSma(SMnode *pMnode, char *tbFName, STableIndexRsp *rsp, bool info.dstTbUid = pSma->dstTbUid; info.dstVgId = pSma->dstVgId; - SVgObj* pVg = mndAcquireVgroup(pMnode, pSma->dstVgId); + SVgObj *pVg = mndAcquireVgroup(pMnode, pSma->dstVgId); if (pVg == NULL) { code = -1; sdbRelease(pSdb, pSma); return code; } info.epSet = mndGetVgroupEpset(pMnode, pVg); - + info.expr = taosMemoryMalloc(pSma->exprLen + 1); if (info.expr == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -967,7 +1059,7 @@ int32_t mndGetTableSma(SMnode *pMnode, char *tbFName, STableIndexRsp *rsp, bool sdbRelease(pSdb, pSma); } - + return code; } @@ -1019,10 +1111,10 @@ _OVER: static int32_t mndProcessGetTbSmaReq(SRpcMsg *pReq) { STableIndexReq indexReq = {0}; - SMnode *pMnode = pReq->info.node; - int32_t code = -1; + SMnode *pMnode = pReq->info.node; + int32_t code = -1; STableIndexRsp rsp = {0}; - bool exist = false; + bool exist = false; if (tDeserializeSTableIndexReq(pReq->pCont, pReq->contLen, &indexReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; @@ -1069,7 +1161,6 @@ _OVER: return code; } - static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { SMnode *pMnode = pReq->info.node; SSdb *pSdb = pMnode->pSdb; diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 6f89c97f83..3e91bfa926 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -23,6 +23,7 @@ #include "mndPerfSchema.h" #include "mndScheduler.h" #include "mndShow.h" +#include "mndSma.h" #include "mndTopic.h" #include "mndTrans.h" #include "mndUser.h" @@ -37,9 +38,9 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw); static int32_t mndStbActionInsert(SSdb *pSdb, SStbObj *pStb); static int32_t mndStbActionDelete(SSdb *pSdb, SStbObj *pStb); static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew); -static int32_t mndProcessMCreateStbReq(SRpcMsg *pReq); -static int32_t mndProcessMAlterStbReq(SRpcMsg *pReq); -static int32_t mndProcessMDropStbReq(SRpcMsg *pReq); +static int32_t mndProcessCreateStbReq(SRpcMsg *pReq); +static int32_t mndProcessAlterStbReq(SRpcMsg *pReq); +static int32_t mndProcessDropStbReq(SRpcMsg *pReq); static int32_t mndProcessTableMetaReq(SRpcMsg *pReq); static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); static void mndCancelGetNextStb(SMnode *pMnode, void *pIter); @@ -55,9 +56,9 @@ int32_t mndInitStb(SMnode *pMnode) { .deleteFp = (SdbDeleteFp)mndStbActionDelete, }; - mndSetMsgHandle(pMnode, TDMT_MND_CREATE_STB, mndProcessMCreateStbReq); - mndSetMsgHandle(pMnode, TDMT_MND_ALTER_STB, mndProcessMAlterStbReq); - mndSetMsgHandle(pMnode, TDMT_MND_DROP_STB, mndProcessMDropStbReq); + mndSetMsgHandle(pMnode, TDMT_MND_CREATE_STB, mndProcessCreateStbReq); + mndSetMsgHandle(pMnode, TDMT_MND_ALTER_STB, mndProcessAlterStbReq); + mndSetMsgHandle(pMnode, TDMT_MND_DROP_STB, mndProcessDropStbReq); mndSetMsgHandle(pMnode, TDMT_VND_CREATE_STB_RSP, mndTransProcessRsp); mndSetMsgHandle(pMnode, TDMT_VND_ALTER_STB_RSP, mndTransProcessRsp); mndSetMsgHandle(pMnode, TDMT_VND_DROP_STB_RSP, mndTransProcessRsp); @@ -319,6 +320,7 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) { pOld->updateTime = pNew->updateTime; pOld->tagVer = pNew->tagVer; pOld->colVer = pNew->colVer; + pOld->smaVer = pNew->smaVer; pOld->nextColId = pNew->nextColId; pOld->ttl = pNew->ttl; pOld->numOfColumns = pNew->numOfColumns; @@ -362,7 +364,7 @@ SDbObj *mndAcquireDbByStb(SMnode *pMnode, const char *stbName) { return mndAcquireDb(pMnode, db); } -static FORCE_INLINE int schemaExColIdCompare(const void *colId, const void *pSchema) { +static FORCE_INLINE int32_t schemaExColIdCompare(const void *colId, const void *pSchema) { if (*(col_id_t *)colId < ((SSchema *)pSchema)->colId) { return -1; } else if (*(col_id_t *)colId > ((SSchema *)pSchema)->colId) { @@ -396,14 +398,14 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt req.pRSmaParam.xFilesFactor = pStb->xFilesFactor; req.pRSmaParam.delay = pStb->delay; if (pStb->ast1Len > 0) { - if (mndConvertRsmaTask(&req.pRSmaParam.qmsg1, &req.pRSmaParam.qmsg1Len, pStb->pAst1, pStb->uid, STREAM_TRIGGER_AT_ONCE, 0, - req.pRSmaParam.xFilesFactor) != TSDB_CODE_SUCCESS) { + if (mndConvertRsmaTask(&req.pRSmaParam.qmsg1, &req.pRSmaParam.qmsg1Len, pStb->pAst1, pStb->uid, + STREAM_TRIGGER_AT_ONCE, 0, req.pRSmaParam.xFilesFactor) != TSDB_CODE_SUCCESS) { return NULL; } } if (pStb->ast2Len > 0) { - if (mndConvertRsmaTask(&req.pRSmaParam.qmsg2, &req.pRSmaParam.qmsg2Len, pStb->pAst2, pStb->uid, STREAM_TRIGGER_AT_ONCE, 0, - req.pRSmaParam.xFilesFactor) != TSDB_CODE_SUCCESS) { + if (mndConvertRsmaTask(&req.pRSmaParam.qmsg2, &req.pRSmaParam.qmsg2Len, pStb->pAst2, pStb->uid, + STREAM_TRIGGER_AT_ONCE, 0, req.pRSmaParam.xFilesFactor) != TSDB_CODE_SUCCESS) { return NULL; } } @@ -762,7 +764,7 @@ int32_t mndAddStbToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *p return 0; } -static int32_t mndProcessMCreateStbReq(SRpcMsg *pReq) { +static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; int32_t code = -1; SStbObj *pStb = NULL; @@ -1301,7 +1303,7 @@ static int32_t mndBuildStbSchema(SMnode *pMnode, const char *dbFName, const char static int32_t mndBuildSMAlterStbRsp(SDbObj *pDb, const SMAlterStbReq *pAlter, SStbObj *pObj, void **pCont, int32_t *pLen) { - int ret; + int32_t ret; SEncoder ec = {0}; uint32_t contLen = 0; SMAlterStbRsp alterRsp = {0}; @@ -1420,7 +1422,7 @@ _OVER: return code; } -static int32_t mndProcessMAlterStbReq(SRpcMsg *pReq) { +static int32_t mndProcessAlterStbReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; int32_t code = -1; SDbObj *pDb = NULL; @@ -1550,6 +1552,7 @@ static int32_t mndDropStb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *p if (mndSetDropStbRedoLogs(pMnode, pTrans, pStb) != 0) goto _OVER; if (mndSetDropStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER; if (mndSetDropStbRedoActions(pMnode, pTrans, pDb, pStb) != 0) goto _OVER; + if (mndDropSmasByStb(pMnode, pTrans, pDb, pStb) != 0) goto _OVER; if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; code = 0; @@ -1559,7 +1562,7 @@ _OVER: return code; } -static int32_t mndProcessMDropStbReq(SRpcMsg *pReq) { +static int32_t mndProcessDropStbReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; int32_t code = -1; SUserObj *pUser = NULL; diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index a331534a93..96d199fcb6 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -235,10 +235,10 @@ static int32_t mndStreamGetPlanString(const char *ast, int8_t triggerType, int64 } if (TSDB_CODE_SUCCESS == code) { - code = nodesNodeToString(pPlan, false, pStr, NULL); + code = nodesNodeToString((SNode*)pPlan, false, pStr, NULL); } nodesDestroyNode(pAst); - nodesDestroyNode(pPlan); + nodesDestroyNode((SNode*)pPlan); terrno = code; return code; } diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index e0b4cc6a57..9940037356 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -188,15 +188,15 @@ int32_t mndInitSync(SMnode *pMnode) { syncInfo.isStandBy = pMgmt->standby; syncInfo.snapshotEnable = true; - SSyncCfg *pCfg = &syncInfo.syncCfg; - pCfg->replicaNum = pMnode->replica; - pCfg->myIndex = pMnode->selfIndex; - mInfo("start to open mnode sync, replica:%d myindex:%d standby:%d", pCfg->replicaNum, pCfg->myIndex, pMgmt->standby); - for (int32_t i = 0; i < pMnode->replica; ++i) { - SNodeInfo *pNode = &pCfg->nodeInfo[i]; - tstrncpy(pNode->nodeFqdn, pMnode->replicas[i].fqdn, sizeof(pNode->nodeFqdn)); - pNode->nodePort = pMnode->replicas[i].port; - mInfo("index:%d, fqdn:%s port:%d", i, pNode->nodeFqdn, pNode->nodePort); + mInfo("start to open mnode sync, standby:%d", pMgmt->standby); + if (pMgmt->standby || pMgmt->replica.id > 0) { + SSyncCfg *pCfg = &syncInfo.syncCfg; + pCfg->replicaNum = 1; + pCfg->myIndex = 0; + SNodeInfo *pNode = &pCfg->nodeInfo[0]; + tstrncpy(pNode->nodeFqdn, pMgmt->replica.fqdn, sizeof(pNode->nodeFqdn)); + pNode->nodePort = pMgmt->replica.port; + mInfo("fqdn:%s port:%u", pNode->nodeFqdn, pNode->nodePort); } tsem_init(&pMgmt->syncSem, 0, 0); @@ -236,7 +236,7 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) { tsem_wait(&pMgmt->syncSem); } else if (code == TAOS_SYNC_PROPOSE_NOT_LEADER) { terrno = TSDB_CODE_APP_NOT_READY; - } else if (code == TAOS_SYNC_PROPOSE_OTHER_ERROR) { + } else if (code == TAOS_SYNC_OTHER_ERROR) { terrno = TSDB_CODE_SYN_INTERNAL_ERROR; } else { terrno = TSDB_CODE_APP_ERROR; @@ -254,13 +254,16 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) { void mndSyncStart(SMnode *pMnode) { SSyncMgmt *pMgmt = &pMnode->syncMgmt; syncSetMsgCb(pMgmt->sync, &pMnode->msgCb); + syncStart(pMgmt->sync); + mDebug("mnode sync started, id:%" PRId64 " standby:%d", pMgmt->sync, pMgmt->standby); +/* if (pMgmt->standby) { syncStartStandBy(pMgmt->sync); } else { syncStart(pMgmt->sync); } - mDebug("mnode sync started, id:%" PRId64 " standby:%d", pMgmt->sync, pMgmt->standby); +*/ } void mndSyncStop(SMnode *pMnode) {} diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index c8333c32f0..3247008d58 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -387,7 +387,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq * return -1; } - if (nodesNodeToString(pPlan, false, &topicObj.physicalPlan, NULL) != 0) { + if (nodesNodeToString((SNode*)pPlan, false, &topicObj.physicalPlan, NULL) != 0) { mError("topic:%s, failed to create since %s", pCreate->name, terrstr()); taosMemoryFree(topicObj.ast); taosMemoryFree(topicObj.sql); diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index 1ec4799419..1631c9825b 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -1347,13 +1347,11 @@ int32_t mndKillTrans(SMnode *pMnode, STrans *pTrans) { for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) { STransAction *pAction = taosArrayGet(pArray, i); - if (pAction->errCode != 0) { - mInfo("trans:%d, %s:%d set processed for kill msg received, errCode from %s to success", pTrans->id, - mndTransStr(pAction->stage), i, tstrerror(pAction->errCode)); - pAction->msgSent = 1; - pAction->msgReceived = 1; - pAction->errCode = 0; - } + mInfo("trans:%d, %s:%d set processed for kill msg received, errCode from %s to success", pTrans->id, + mndTransStr(pAction->stage), i, tstrerror(pAction->errCode)); + pAction->msgSent = 1; + pAction->msgReceived = 1; + pAction->errCode = 0; } mndTransExecute(pMnode, pTrans); diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index 6b2ee03524..cd1d930846 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -322,6 +322,33 @@ void *mndBuildAlterVnodeReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup, int32_ return pReq; } +void *mndBuildSetVnodeStandbyReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen) { + SSetStandbyReq standbyReq = {0}; + standbyReq.dnodeId = pDnode->id; + standbyReq.standby = 1; + + int32_t contLen = tSerializeSSetStandbyReq(NULL, 0, &standbyReq); + if (contLen < 0) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } + + contLen += sizeof(SMsgHead); + void *pReq = taosMemoryMalloc(contLen); + if (pReq == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } + + tSerializeSSetStandbyReq((char *)pReq + sizeof(SMsgHead), contLen, &standbyReq); + SMsgHead *pHead = pReq; + pHead->contLen = htonl(contLen); + pHead->vgId = htonl(pVgroup->vgId); + + *pContLen = contLen; + return pReq; +} + void *mndBuildDropVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen) { SDropVnodeReq dropReq = {0}; dropReq.dnodeId = pDnode->id; @@ -898,6 +925,39 @@ int32_t mndAddAlterVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgO return 0; } +static int32_t mndAddSetVnodeStandByAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, + SVnodeGid *pVgid, bool isRedo) { + STransAction action = {0}; + + SDnodeObj *pDnode = mndAcquireDnode(pMnode, pVgid->dnodeId); + if (pDnode == NULL) return -1; + action.epSet = mndGetDnodeEpset(pDnode); + mndReleaseDnode(pMnode, pDnode); + + int32_t contLen = 0; + void *pReq = mndBuildSetVnodeStandbyReq(pMnode, pDnode, pDb, pVgroup, &contLen); + if (pReq == NULL) return -1; + + action.pCont = pReq; + action.contLen = contLen; + action.msgType = TDMT_SYNC_SET_VNODE_STANDBY; + action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED; + + if (isRedo) { + if (mndTransAppendRedoAction(pTrans, &action) != 0) { + taosMemoryFree(pReq); + return -1; + } + } else { + if (mndTransAppendUndoAction(pTrans, &action) != 0) { + taosMemoryFree(pReq); + return -1; + } + } + + return 0; +} + int32_t mndAddDropVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SVnodeGid *pVgid, bool isRedo) { STransAction action = {0}; @@ -952,6 +1012,7 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVnodeGid del = newVg.vnodeGid[vnIndex]; newVg.vnodeGid[vnIndex] = newVg.vnodeGid[newVg.replica]; memset(&newVg.vnodeGid[newVg.replica], 0, sizeof(SVnodeGid)); + if (mndAddSetVnodeStandByAction(pMnode, pTrans, pDb, pVgroup, &del, true) != 0) return -1; if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVg, TDMT_VND_ALTER_REPLICA) != 0) return -1; if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg, &del, true) != 0) return -1; if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1; @@ -1031,6 +1092,7 @@ static int32_t mndAddDecVgroupReplicaFromTrans(SMnode *pMnode, STrans *pTrans, S memcpy(pGid, &pVgroup->vnodeGid[pVgroup->replica], sizeof(SVnodeGid)); memset(&pVgroup->vnodeGid[pVgroup->replica], 0, sizeof(SVnodeGid)); + if (mndAddSetVnodeStandByAction(pMnode, pTrans, pDb, pVgroup, &delGid, true) != 0) return -1; if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, pVgroup, TDMT_VND_ALTER_REPLICA) != 0) return -1; if (mndAddDropVnodeAction(pMnode, pTrans, pDb, pVgroup, &delGid, true) != 0) return -1; if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, pVgroup) != 0) return -1; @@ -1341,12 +1403,14 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, S SVnodeGid del1 = {0}; if (mndRemoveVnodeFromVgroup(pMnode, &newVgroup, pArray, &del1) != 0) return -1; + if (mndAddSetVnodeStandByAction(pMnode, pTrans, pDb, pVgroup, &del1, true) != 0) return -1; if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVgroup, TDMT_VND_ALTER_REPLICA) != 0) return -1; if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVgroup, &del1, true) != 0) return -1; if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVgroup) != 0) return -1; SVnodeGid del2 = {0}; if (mndRemoveVnodeFromVgroup(pMnode, &newVgroup, pArray, &del2) != 0) return -1; + if (mndAddSetVnodeStandByAction(pMnode, pTrans, pDb, pVgroup, &del2, true) != 0) return -1; if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVgroup, TDMT_VND_ALTER_REPLICA) != 0) return -1; if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVgroup, &del2, true) != 0) return -1; if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVgroup) != 0) return -1; @@ -1396,6 +1460,7 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj } else if (newVg1.replica == 3) { SVnodeGid del1 = {0}; if (mndRemoveVnodeFromVgroup(pMnode, &newVg1, pArray, &del1) != 0) goto _OVER; + if (mndAddSetVnodeStandByAction(pMnode, pTrans, pDb, pVgroup, &del1, true) != 0) return -1; if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVg1, TDMT_VND_ALTER_REPLICA) != 0) goto _OVER; if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg1, &del1, true) != 0) goto _OVER; if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg1) != 0) goto _OVER; diff --git a/source/dnode/vnode/CMakeLists.txt b/source/dnode/vnode/CMakeLists.txt index 8dca589320..15eb35c700 100644 --- a/source/dnode/vnode/CMakeLists.txt +++ b/source/dnode/vnode/CMakeLists.txt @@ -31,7 +31,7 @@ target_sources( "src/sma/smaEnv.c" "src/sma/smaOpen.c" "src/sma/smaRollup.c" - "src/sma/smaTimeRange2.c" + "src/sma/smaTimeRange.c" # tsdb "src/tsdb/tsdbCommit.c" diff --git a/source/dnode/vnode/src/inc/sma.h b/source/dnode/vnode/src/inc/sma.h index e9da125841..1e77022d04 100644 --- a/source/dnode/vnode/src/inc/sma.h +++ b/source/dnode/vnode/src/inc/sma.h @@ -38,8 +38,6 @@ typedef struct SSmaStatItem SSmaStatItem; typedef struct SSmaKey SSmaKey; typedef struct SRSmaInfo SRSmaInfo; -#define SMA_IVLD_FID INT_MIN - struct SSmaEnv { TdThreadRwlock lock; int8_t type; @@ -49,45 +47,38 @@ struct SSmaEnv { #define SMA_ENV_LOCK(env) ((env)->lock) #define SMA_ENV_TYPE(env) ((env)->type) #define SMA_ENV_STAT(env) ((env)->pStat) -#define SMA_ENV_STAT_ITEMS(env) ((env)->pStat->smaStatItems) +#define SMA_ENV_STAT_ITEM(env) ((env)->pStat->tsmaStatItem) struct SSmaStatItem { - int8_t state; // ETsdbSmaStat - STSma *pTSma; // cache schema + int8_t state; // ETsdbSmaStat + STSma *pTSma; // cache schema + STSchema *pTSchema; }; struct SSmaStat { union { - SHashObj *smaStatItems; // key: indexUid, value: SSmaStatItem for tsma - SHashObj *rsmaInfoHash; // key: stbUid, value: SRSmaInfo; + SSmaStatItem tsmaStatItem; + SHashObj *rsmaInfoHash; // key: stbUid, value: SRSmaInfo; }; T_REF_DECLARE() }; -#define SMA_STAT_ITEMS(s) ((s)->smaStatItems) +#define SMA_STAT_ITEM(s) ((s)->tsmaStatItem) #define SMA_STAT_INFO_HASH(s) ((s)->rsmaInfoHash) void tdDestroySmaEnv(SSmaEnv *pSmaEnv); void *tdFreeSmaEnv(SSmaEnv *pSmaEnv); -#if 0 -int32_t tbGetTSmaStatus(SSma *pSma, STSma *param, void *result); -int32_t tbRemoveTSmaData(SSma *pSma, STSma *param, STimeWindow *pWin); -#endif -int32_t tdInitSma(SSma *pSma); int32_t tdDropTSma(SSma *pSma, char *pMsg); int32_t tdDropTSmaData(SSma *pSma, int64_t indexUid); int32_t tdInsertRSmaData(SSma *pSma, char *msg); int32_t tdRefSmaStat(SSma *pSma, SSmaStat *pStat); int32_t tdUnRefSmaStat(SSma *pSma, SSmaStat *pStat); -int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType, bool onlyCheck); +int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType); int32_t tdLockSma(SSma *pSma); int32_t tdUnLockSma(SSma *pSma); -static FORCE_INLINE int16_t tdTSmaAdd(SSma *pSma, int16_t n) { return atomic_add_fetch_16(&SMA_TSMA_NUM(pSma), n); } -static FORCE_INLINE int16_t tdTSmaSub(SSma *pSma, int16_t n) { return atomic_sub_fetch_16(&SMA_TSMA_NUM(pSma), n); } - static FORCE_INLINE int32_t tdRLockSmaEnv(SSmaEnv *pEnv) { int code = taosThreadRwlockRdlock(&(pEnv->lock)); if (code != 0) { @@ -160,11 +151,10 @@ static FORCE_INLINE void tdSmaStatSetDropped(SSmaStatItem *pStatItem) { } } -static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType); -void *tdFreeSmaStatItem(SSmaStatItem *pSmaStatItem); -static int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType); -static SSmaEnv *tdNewSmaEnv(const SSma *pSma, int8_t smaType, const char *path, SDiskID did); -static int32_t tdInitSmaEnv(SSma *pSma, int8_t smaType, const char *path, SDiskID did, SSmaEnv **pEnv); +static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType); +void *tdFreeSmaStatItem(SSmaStatItem *pSmaStatItem); +static int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType); +void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType); void *tdFreeRSmaInfo(SRSmaInfo *pInfo); diff --git a/source/dnode/vnode/src/inc/tq.h b/source/dnode/vnode/src/inc/tq.h index 5a8564bfd1..2ee0673ce5 100644 --- a/source/dnode/vnode/src/inc/tq.h +++ b/source/dnode/vnode/src/inc/tq.h @@ -41,7 +41,6 @@ extern "C" { #define tqTrace(...) do { if (tqDebugFlag & DEBUG_TRACE) { taosPrintLog("TQ ", DEBUG_TRACE, tqDebugFlag, __VA_ARGS__); }} while(0) // clang-format on -typedef struct STqOffsetCfg STqOffsetCfg; typedef struct STqOffsetStore STqOffsetStore; // tqRead @@ -127,14 +126,15 @@ typedef struct { } STqHandle; struct STQ { - char* path; - SHashObj* pushMgr; // consumerId -> STqHandle* - SHashObj* handles; // subKey -> STqHandle - SHashObj* pStreamTasks; // taksId -> SStreamTask - SVnode* pVnode; - SWal* pWal; - TDB* pMetaStore; - TTB* pExecStore; + char* path; + SHashObj* pushMgr; // consumerId -> STqHandle* + SHashObj* handles; // subKey -> STqHandle + SHashObj* pStreamTasks; // taksId -> SStreamTask + STqOffsetStore* pOffsetStore; + SVnode* pVnode; + SWal* pWal; + TDB* pMetaStore; + TTB* pExecStore; }; typedef struct { @@ -157,17 +157,19 @@ int32_t tqMetaClose(STQ* pTq); int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle); int32_t tqMetaDeleteHandle(STQ* pTq, const char* key); +typedef struct { + int32_t size; +} STqOffsetHead; + +STqOffsetStore* tqOffsetOpen(); +void tqOffsetClose(STqOffsetStore*); +STqOffset* tqOffsetRead(STqOffsetStore* pStore, const char* subscribeKey); +int32_t tqOffsetWrite(STqOffsetStore* pStore, const STqOffset* pOffset); +int32_t tqOffsetSnapshot(STqOffsetStore* pStore); + // tqSink void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data); -// tqOffset -STqOffsetStore* tqOffsetOpen(STqOffsetCfg*); -void tqOffsetClose(STqOffsetStore*); -int64_t tqOffsetFetch(STqOffsetStore* pStore, const char* subscribeKey); -int32_t tqOffsetCommit(STqOffsetStore* pStore, const char* subscribeKey, int64_t offset); -int32_t tqOffsetPersist(STqOffsetStore* pStore, const char* subscribeKey); -int32_t tqOffsetPersistAll(STqOffsetStore* pStore); - #ifdef __cplusplus } #endif diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index 0c2b09a493..52593f7afb 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -137,6 +137,7 @@ int tqCommit(STQ*); int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd); int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen); int32_t tqProcessVgDeleteReq(STQ* pTq, char* msg, int32_t msgLen); +int32_t tqProcessOffsetCommitReq(STQ* pTq, char* msg, int32_t msgLen); int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId); int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen); int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* data); @@ -146,6 +147,9 @@ int32_t tqProcessTaskRecoverReq(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg); +SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pSchema, bool createTb, int64_t suid, + const char* stbFullName, int32_t vgId); + // sma int32_t smaOpen(SVnode* pVnode); int32_t smaClose(SSma* pSma); @@ -244,7 +248,6 @@ struct STbUidStore { }; struct SSma { - int16_t nTSma; bool locked; TdThreadMutex mutex; SVnode* pVnode; @@ -260,7 +263,6 @@ struct SSma { #define SMA_META(s) ((s)->pVnode->pMeta) #define SMA_VID(s) TD_VID((s)->pVnode) #define SMA_TFS(s) ((s)->pVnode->pTfs) -#define SMA_TSMA_NUM(s) ((s)->nTSma) #define SMA_TSMA_ENV(s) ((s)->pTSmaEnv) #define SMA_RSMA_ENV(s) ((s)->pRSmaEnv) #define SMA_RSMA_TSDB0(s) ((s)->pVnode->pTsdb) diff --git a/source/dnode/vnode/src/meta/metaEntry.c b/source/dnode/vnode/src/meta/metaEntry.c index db99257ea7..15ef38719f 100644 --- a/source/dnode/vnode/src/meta/metaEntry.c +++ b/source/dnode/vnode/src/meta/metaEntry.c @@ -75,7 +75,7 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } - if (tDecodeTSma(pCoder, pME->smaEntry.tsma) < 0) return -1; + if (tDecodeTSma(pCoder, pME->smaEntry.tsma, true) < 0) return -1; } else { ASSERT(0); } diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index 1d8082084f..a6339125c4 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -663,12 +663,23 @@ int32_t metaFilteTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) { void * entryKey = NULL, *entryVal = NULL; int32_t nEntryKey, nEntryVal; + bool first = true; while (1) { valid = tdbTbcGet(pCursor->pCur, (const void **)&entryKey, &nEntryKey, (const void **)&entryVal, &nEntryVal); if (valid < 0) { break; } STagIdxKey *p = entryKey; + if (p->type != pCursor->type) { + if (first) { + valid = param->reverse ? tdbTbcMoveToPrev(pCursor->pCur) : tdbTbcMoveToNext(pCursor->pCur); + if (valid < 0) break; + continue; + } else { + break; + } + } + first = false; if (p != NULL) { int32_t cmp = (*param->filterFunc)(p->data, pKey->data, pKey->type); if (cmp == 0) { diff --git a/source/dnode/vnode/src/sma/sma.c b/source/dnode/vnode/src/sma/sma.c index 98e5d7c66d..b5c55a2f83 100644 --- a/source/dnode/vnode/src/sma/sma.c +++ b/source/dnode/vnode/src/sma/sma.c @@ -44,3 +44,209 @@ int32_t smaGetTSmaDays(SVnodeCfg* pCfg, void* pCont, uint32_t contLen, int32_t* smaDebug("vgId:%d, get tsma days %d", pCfg->vgId, *days); return code; } + +#if 0 + +/** + * @brief TODO: Assume that the final generated result it less than 3M + * + * @param pReq + * @param pDataBlocks + * @param vgId + * @param suid // TODO: check with Liao whether suid response is reasonable + * + * TODO: colId should be set + */ +int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks, STSchema* pTSchema, int32_t vgId, + tb_uid_t suid, const char* stbName, bool isCreateCtb) { + int32_t sz = taosArrayGetSize(pDataBlocks); + int32_t bufSize = sizeof(SSubmitReq); + for (int32_t i = 0; i < sz; ++i) { + SDataBlockInfo* pBlkInfo = &((SSDataBlock*)taosArrayGet(pDataBlocks, i))->info; + bufSize += pBlkInfo->rows * (TD_ROW_HEAD_LEN + pBlkInfo->rowSize + BitmapLen(pBlkInfo->numOfCols)); + bufSize += sizeof(SSubmitBlk); + } + + *pReq = taosMemoryCalloc(1, bufSize); + if (!(*pReq)) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return TSDB_CODE_FAILED; + } + void* pDataBuf = *pReq; + + SArray* pTagArray = NULL; + int32_t msgLen = sizeof(SSubmitReq); + int32_t numOfBlks = 0; + int32_t schemaLen = 0; + SRowBuilder rb = {0}; + tdSRowInit(&rb, pTSchema->version); + + for (int32_t i = 0; i < sz; ++i) { + SSDataBlock* pDataBlock = taosArrayGet(pDataBlocks, i); + SDataBlockInfo* pDataBlkInfo = &pDataBlock->info; + int32_t colNum = pDataBlkInfo->numOfCols; + int32_t rows = pDataBlkInfo->rows; + int32_t rowSize = pDataBlkInfo->rowSize; + int64_t groupId = pDataBlkInfo->groupId; + + if (rb.nCols != colNum) { + tdSRowSetTpInfo(&rb, colNum, pTSchema->flen); + } + + if(isCreateCtb) { + SMetaReader mr = {0}; + const char* ctbName = buildCtbNameByGroupId(stbName, pDataBlock->info.groupId); + if (metaGetTableEntryByName(&mr, ctbName) != 0) { + smaDebug("vgId:%d, no tsma ctb %s exists", vgId, ctbName); + } + SVCreateTbReq ctbReq = {0}; + ctbReq.name = ctbName; + ctbReq.type = TSDB_CHILD_TABLE; + ctbReq.ctb.suid = suid; + + STagVal tagVal = {.cid = colNum + PRIMARYKEY_TIMESTAMP_COL_ID, + .type = TSDB_DATA_TYPE_BIGINT, + .i64 = groupId}; + STag* pTag = NULL; + if(!pTagArray) { + pTagArray = taosArrayInit(1, sizeof(STagVal)); + if (!pTagArray) goto _err; + } + taosArrayClear(pTagArray); + taosArrayPush(pTagArray, &tagVal); + tTagNew(pTagArray, 1, false, &pTag); + if (pTag == NULL) { + tdDestroySVCreateTbReq(&ctbReq); + goto _err; + } + ctbReq.ctb.pTag = (uint8_t*)pTag; + + int32_t code; + tEncodeSize(tEncodeSVCreateTbReq, &ctbReq, schemaLen, code); + + tdDestroySVCreateTbReq(&ctbReq); + if (code < 0) { + goto _err; + } + } + + + + SSubmitBlk* pSubmitBlk = POINTER_SHIFT(pDataBuf, msgLen); + pSubmitBlk->suid = suid; + pSubmitBlk->uid = groupId; + pSubmitBlk->numOfRows = rows; + + msgLen += sizeof(SSubmitBlk); + int32_t dataLen = 0; + for (int32_t j = 0; j < rows; ++j) { // iterate by row + tdSRowResetBuf(&rb, POINTER_SHIFT(pDataBuf, msgLen)); // set row buf + bool isStartKey = false; + int32_t offset = 0; + for (int32_t k = 0; k < colNum; ++k) { // iterate by column + SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k); + STColumn* pCol = &pTSchema->columns[k]; + void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes); + switch (pColInfoData->info.type) { + case TSDB_DATA_TYPE_TIMESTAMP: + if (!isStartKey) { + isStartKey = true; + tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID, TSDB_DATA_TYPE_TIMESTAMP, TD_VTYPE_NORM, var, true, + offset, k); + + } else { + tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, TSDB_DATA_TYPE_TIMESTAMP, TD_VTYPE_NORM, var, + true, offset, k); + } + break; + case TSDB_DATA_TYPE_NCHAR: { + tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, TSDB_DATA_TYPE_NCHAR, TD_VTYPE_NORM, var, true, + offset, k); + break; + } + case TSDB_DATA_TYPE_VARCHAR: { // TSDB_DATA_TYPE_BINARY + tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, TSDB_DATA_TYPE_VARCHAR, TD_VTYPE_NORM, var, true, + offset, k); + break; + } + case TSDB_DATA_TYPE_VARBINARY: + case TSDB_DATA_TYPE_DECIMAL: + case TSDB_DATA_TYPE_BLOB: + case TSDB_DATA_TYPE_JSON: + case TSDB_DATA_TYPE_MEDIUMBLOB: + uError("the column type %" PRIi16 " is defined but not implemented yet", pColInfoData->info.type); + TASSERT(0); + break; + default: + if (pColInfoData->info.type < TSDB_DATA_TYPE_MAX && pColInfoData->info.type > TSDB_DATA_TYPE_NULL) { + if (pCol->type == pColInfoData->info.type) { + tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, pCol->type, TD_VTYPE_NORM, var, true, offset, + k); + } else { + char tv[8] = {0}; + if (pColInfoData->info.type == TSDB_DATA_TYPE_FLOAT) { + float v = 0; + GET_TYPED_DATA(v, float, pColInfoData->info.type, var); + SET_TYPED_DATA(&tv, pCol->type, v); + } else if (pColInfoData->info.type == TSDB_DATA_TYPE_DOUBLE) { + double v = 0; + GET_TYPED_DATA(v, double, pColInfoData->info.type, var); + SET_TYPED_DATA(&tv, pCol->type, v); + } else if (IS_SIGNED_NUMERIC_TYPE(pColInfoData->info.type)) { + int64_t v = 0; + GET_TYPED_DATA(v, int64_t, pColInfoData->info.type, var); + SET_TYPED_DATA(&tv, pCol->type, v); + } else { + uint64_t v = 0; + GET_TYPED_DATA(v, uint64_t, pColInfoData->info.type, var); + SET_TYPED_DATA(&tv, pCol->type, v); + } + tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, pCol->type, TD_VTYPE_NORM, tv, true, offset, + k); + } + } else { + uError("the column type %" PRIi16 " is undefined\n", pColInfoData->info.type); + TASSERT(0); + } + break; + } + offset += TYPE_BYTES[pCol->type]; // sum/avg would convert to int64_t/uint64_t/double during aggregation + } + dataLen += TD_ROW_LEN(rb.pBuf); +#ifdef TD_DEBUG_PRINT_ROW + tdSRowPrint(rb.pBuf, pTSchema, __func__); +#endif + } + + ++numOfBlks; + + pSubmitBlk->dataLen = dataLen; + msgLen += pSubmitBlk->dataLen; + } + + (*pReq)->length = msgLen; + + (*pReq)->header.vgId = htonl(vgId); + (*pReq)->header.contLen = htonl(msgLen); + (*pReq)->length = (*pReq)->header.contLen; + (*pReq)->numOfBlocks = htonl(numOfBlks); + SSubmitBlk* blk = (SSubmitBlk*)((*pReq) + 1); + while (numOfBlks--) { + int32_t dataLen = blk->dataLen; + blk->uid = htobe64(blk->uid); + blk->suid = htobe64(blk->suid); + blk->padding = htonl(blk->padding); + blk->sversion = htonl(blk->sversion); + blk->dataLen = htonl(blk->dataLen); + blk->schemaLen = htonl(blk->schemaLen); + blk->numOfRows = htons(blk->numOfRows); + blk = (SSubmitBlk*)(blk->data + dataLen); + } + return TSDB_CODE_SUCCESS; +_err: + taosMemoryFreeClear(*pReq); + taosArrayDestroy(pTagArray); + + return TSDB_CODE_FAILED; +} +#endif diff --git a/source/dnode/vnode/src/sma/smaEnv.c b/source/dnode/vnode/src/sma/smaEnv.c index 5eec5076e8..f71c222772 100644 --- a/source/dnode/vnode/src/sma/smaEnv.c +++ b/source/dnode/vnode/src/sma/smaEnv.c @@ -17,123 +17,17 @@ typedef struct SSmaStat SSmaStat; -static const char *TSDB_SMA_DNAME[] = { - "", // TSDB_SMA_TYPE_BLOCK - "tsma", // TSDB_SMA_TYPE_TIME_RANGE - "rsma", // TSDB_SMA_TYPE_ROLLUP -}; - -#define SMA_TEST_INDEX_NAME "smaTestIndexName" // TODO: just for test -#define SMA_TEST_INDEX_UID 2000000001 // TODO: just for test -#define SMA_STATE_HASH_SLOT 4 - #define RSMA_TASK_INFO_HASH_SLOT 8 -typedef struct SPoolMem { - int64_t size; - struct SPoolMem *prev; - struct SPoolMem *next; -} SPoolMem; - // declaration of static functions -// insert data - -static void tdGetSmaDir(int32_t vgId, ETsdbSmaType smaType, char dirName[]); - -// Pool Memory -static SPoolMem *openPool(); -static void clearPool(SPoolMem *pPool); -static void closePool(SPoolMem *pPool); -static void *poolMalloc(void *arg, size_t size); -static void poolFree(void *arg, void *ptr); +static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType); +static SSmaEnv *tdNewSmaEnv(const SSma *pSma, int8_t smaType, const char *path); +static int32_t tdInitSmaEnv(SSma *pSma, int8_t smaType, const char *path, SSmaEnv **pEnv); // implementation -static SPoolMem *openPool() { - SPoolMem *pPool = (SPoolMem *)taosMemoryMalloc(sizeof(*pPool)); - - pPool->prev = pPool->next = pPool; - pPool->size = 0; - - return pPool; -} - -static void clearPool(SPoolMem *pPool) { - if (!pPool) return; - - SPoolMem *pMem; - - do { - pMem = pPool->next; - - if (pMem == pPool) break; - - pMem->next->prev = pMem->prev; - pMem->prev->next = pMem->next; - pPool->size -= pMem->size; - - taosMemoryFree(pMem); - } while (1); - - assert(pPool->size == 0); -} - -static void closePool(SPoolMem *pPool) { - if (pPool) { - clearPool(pPool); - taosMemoryFree(pPool); - } -} - -static void *poolMalloc(void *arg, size_t size) { - void *ptr = NULL; - SPoolMem *pPool = (SPoolMem *)arg; - SPoolMem *pMem; - - pMem = (SPoolMem *)taosMemoryMalloc(sizeof(*pMem) + size); - if (!pMem) { - assert(0); - } - - pMem->size = sizeof(*pMem) + size; - pMem->next = pPool->next; - pMem->prev = pPool; - - pPool->next->prev = pMem; - pPool->next = pMem; - pPool->size += pMem->size; - - ptr = (void *)(&pMem[1]); - return ptr; -} - -static void poolFree(void *arg, void *ptr) { - SPoolMem *pPool = (SPoolMem *)arg; - SPoolMem *pMem; - - pMem = &(((SPoolMem *)ptr)[-1]); - - pMem->next->prev = pMem->prev; - pMem->prev->next = pMem->next; - pPool->size -= pMem->size; - - taosMemoryFree(pMem); -} - -int32_t tdInitSma(SSma *pSma) { - int32_t numOfTSma = taosArrayGetSize(metaGetSmaTbUids(SMA_META(pSma))); - if (numOfTSma > 0) { - atomic_store_16(&SMA_TSMA_NUM(pSma), (int16_t)numOfTSma); - } - return TSDB_CODE_SUCCESS; -} - -static void tdGetSmaDir(int32_t vgId, ETsdbSmaType smaType, char dirName[]) { - snprintf(dirName, TSDB_FILENAME_LEN, "vnode%svnode%d%s%s", TD_DIRSEP, vgId, TD_DIRSEP, TSDB_SMA_DNAME[smaType]); -} - -static SSmaEnv *tdNewSmaEnv(const SSma *pSma, int8_t smaType, const char *path, SDiskID did) { +static SSmaEnv *tdNewSmaEnv(const SSma *pSma, int8_t smaType, const char *path) { SSmaEnv *pEnv = NULL; pEnv = (SSmaEnv *)taosMemoryCalloc(1, sizeof(SSmaEnv)); @@ -156,18 +50,17 @@ static SSmaEnv *tdNewSmaEnv(const SSma *pSma, int8_t smaType, const char *path, return NULL; } - return pEnv; } -static int32_t tdInitSmaEnv(SSma *pSma, int8_t smaType, const char *path, SDiskID did, SSmaEnv **pEnv) { +static int32_t tdInitSmaEnv(SSma *pSma, int8_t smaType, const char *path, SSmaEnv **pEnv) { if (!pEnv) { terrno = TSDB_CODE_INVALID_PTR; return TSDB_CODE_FAILED; } if (!(*pEnv)) { - if (!(*pEnv = tdNewSmaEnv(pSma, smaType, path, did))) { + if (!(*pEnv = tdNewSmaEnv(pSma, smaType, path))) { return TSDB_CODE_FAILED; } } @@ -183,15 +76,16 @@ static int32_t tdInitSmaEnv(SSma *pSma, int8_t smaType, const char *path, SDiskI */ void tdDestroySmaEnv(SSmaEnv *pSmaEnv) { if (pSmaEnv) { - tdDestroySmaState(pSmaEnv->pStat, SMA_ENV_TYPE(pSmaEnv)); - taosMemoryFreeClear(pSmaEnv->pStat); + pSmaEnv->pStat = tdFreeSmaState(pSmaEnv->pStat, SMA_ENV_TYPE(pSmaEnv)); taosThreadRwlockDestroy(&(pSmaEnv->lock)); } } void *tdFreeSmaEnv(SSmaEnv *pSmaEnv) { - tdDestroySmaEnv(pSmaEnv); - taosMemoryFreeClear(pSmaEnv); + if (pSmaEnv) { + tdDestroySmaEnv(pSmaEnv); + taosMemoryFreeClear(pSmaEnv); + } return NULL; } @@ -239,13 +133,7 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType) { return TSDB_CODE_FAILED; } } else if (smaType == TSDB_SMA_TYPE_TIME_RANGE) { - SMA_STAT_ITEMS(*pSmaStat) = - taosHashInit(SMA_STATE_HASH_SLOT, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); - - if (!SMA_STAT_ITEMS(*pSmaStat)) { - taosMemoryFreeClear(*pSmaStat); - return TSDB_CODE_FAILED; - } + // TODO } else { ASSERT(0); } @@ -262,6 +150,12 @@ void *tdFreeSmaStatItem(SSmaStatItem *pSmaStatItem) { return NULL; } +void* tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType) { + tdDestroySmaState(pSmaStat, smaType); + taosMemoryFreeClear(pSmaStat); + return NULL; +} + /** * @brief Release resources allocated for its member fields, not including itself. * @@ -270,16 +164,10 @@ void *tdFreeSmaStatItem(SSmaStatItem *pSmaStatItem) { */ int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType) { if (pSmaStat) { - // TODO: use taosHashSetFreeFp when taosHashSetFreeFp is ready. if (smaType == TSDB_SMA_TYPE_TIME_RANGE) { - void *item = taosHashIterate(SMA_STAT_ITEMS(pSmaStat), NULL); - while (item) { - SSmaStatItem *pItem = *(SSmaStatItem **)item; - tdFreeSmaStatItem(pItem); - item = taosHashIterate(SMA_STAT_ITEMS(pSmaStat), item); - } - taosHashCleanup(SMA_STAT_ITEMS(pSmaStat)); + tdFreeSmaStatItem(&pSmaStat->tsmaStatItem); } else if (smaType == TSDB_SMA_TYPE_ROLLUP) { + // TODO: use taosHashSetFreeFp when taosHashSetFreeFp is ready. void *infoHash = taosHashIterate(SMA_STAT_INFO_HASH(pSmaStat), NULL); while (infoHash) { SRSmaInfo *pInfoHash = *(SRSmaInfo **)infoHash; @@ -317,7 +205,7 @@ int32_t tdUnLockSma(SSma *pSma) { return 0; } -int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType, bool onlyCheck) { +int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType) { SSmaEnv *pEnv = NULL; // return if already init @@ -344,26 +232,7 @@ int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType, bool onlyCheck) { if (!pEnv) { char rname[TSDB_FILENAME_LEN] = {0}; - SDiskID did = {0}; - if (tfsAllocDisk(SMA_TFS(pSma), TFS_PRIMARY_LEVEL, &did) < 0) { - tdUnLockSma(pSma); - return TSDB_CODE_FAILED; - } - - if (did.level < 0 || did.id < 0) { - tdUnLockSma(pSma); - smaError("vgId:%d, init sma env failed since invalid did(%d,%d)", SMA_VID(pSma), did.level, did.id); - return TSDB_CODE_FAILED; - } - - tdGetSmaDir(SMA_VID(pSma), smaType, rname); - - if (tfsMkdirRecurAt(SMA_TFS(pSma), rname, did) < 0) { - tdUnLockSma(pSma); - return TSDB_CODE_FAILED; - } - - if (tdInitSmaEnv(pSma, smaType, rname, did, &pEnv) < 0) { + if (tdInitSmaEnv(pSma, smaType, rname, &pEnv) < 0) { tdUnLockSma(pSma); return TSDB_CODE_FAILED; } diff --git a/source/dnode/vnode/src/sma/smaOpen.c b/source/dnode/vnode/src/sma/smaOpen.c index dde6578054..a1c47a96c0 100644 --- a/source/dnode/vnode/src/sma/smaOpen.c +++ b/source/dnode/vnode/src/sma/smaOpen.c @@ -132,7 +132,9 @@ int32_t smaClose(SSma *pSma) { if SMA_RSMA_TSDB0 (pSma) tsdbClose(&SMA_RSMA_TSDB0(pSma)); if SMA_RSMA_TSDB1 (pSma) tsdbClose(&SMA_RSMA_TSDB1(pSma)); if SMA_RSMA_TSDB2 (pSma) tsdbClose(&SMA_RSMA_TSDB2(pSma)); - taosMemoryFree(pSma); + // SMA_TSMA_ENV(pSma) = tdFreeSmaEnv(SMA_TSMA_ENV(pSma)); + // SMA_RSMA_ENV(pSma) = tdFreeSmaEnv(SMA_RSMA_ENV(pSma)); + taosMemoryFreeClear(pSma); } return 0; } \ No newline at end of file diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 1b34529506..b2dcce8f4c 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -181,7 +181,7 @@ int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) { return TSDB_CODE_SUCCESS; } - if (tdCheckAndInitSmaEnv(pSma, TSDB_SMA_TYPE_ROLLUP, false) != TSDB_CODE_SUCCESS) { + if (tdCheckAndInitSmaEnv(pSma, TSDB_SMA_TYPE_ROLLUP) != TSDB_CODE_SUCCESS) { terrno = TSDB_CODE_TDB_INIT_FAILED; return TSDB_CODE_FAILED; } diff --git a/source/dnode/vnode/src/sma/smaTimeRange2.c b/source/dnode/vnode/src/sma/smaTimeRange.c similarity index 66% rename from source/dnode/vnode/src/sma/smaTimeRange2.c rename to source/dnode/vnode/src/sma/smaTimeRange.c index 9c613873ab..4352c466c5 100644 --- a/source/dnode/vnode/src/sma/smaTimeRange2.c +++ b/source/dnode/vnode/src/sma/smaTimeRange.c @@ -16,21 +16,9 @@ #include "sma.h" #include "tsdb.h" -typedef STsdbCfg STSmaKeepCfg; - -#undef _TEST_SMA_PRINT_DEBUG_LOG_ #define SMA_STORAGE_MINUTES_MAX 86400 #define SMA_STORAGE_MINUTES_DAY 1440 -#define SMA_STORAGE_MINUTES_MIN 1440 -#define SMA_STORAGE_TSDB_MINUTES 86400 -#define SMA_STORAGE_TSDB_TIMES 10 -#define SMA_STORAGE_SPLIT_FACTOR 14400 // least records in tsma file TODO: the feasible value? -#define SMA_KEY_LEN 16 // TSKEY+groupId 8+8 -#define SMA_DROP_EXPIRED_TIME 10 // default is 10 seconds - -#define SMA_STATE_ITEM_HASH_SLOT 32 - -// static func +#define SMA_STORAGE_SPLIT_FACTOR 14400 // least records in tsma file /** * @brief Judge the tsma file split days @@ -80,79 +68,23 @@ _err: return -1; } -// read data - -// implementation - /** - * @brief Insert/Update Time-range-wise SMA data. - * - If interval < SMA_STORAGE_SPLIT_HOURS(e.g. 24), save the SMA data as a part of DFileSet to e.g. - * v3f1900.tsma.${sma_index_name}. The days is the same with that for TS data files. - * - If interval >= SMA_STORAGE_SPLIT_HOURS, save the SMA data to e.g. vnode3/tsma/v3f632.tsma.${sma_index_name}. The - * days is 30 times of the interval, and the minimum days is SMA_STORAGE_TSDB_DAYS(30d). - * - The destination file of one data block for some interval is determined by its start TS key. + * @brief create tsma meta and result stable * * @param pSma - * @param msg + * @param version + * @param pMsg * @return int32_t */ -int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) { - STsdbCfg *pCfg = SMA_TSDB_CFG(pSma); - - const SArray *pDataBlocks = (const SArray *)msg; - - // TODO: destroy SSDataBlocks(msg) - - // For super table aggregation, the sma data is stored in vgroup calculated from the hash value of stable name. Thus - // the sma data would arrive ahead of the update-expired-window msg. - if (tdCheckAndInitSmaEnv(pSma, TSDB_SMA_TYPE_TIME_RANGE, false) != TSDB_CODE_SUCCESS) { - terrno = TSDB_CODE_TDB_INIT_FAILED; - return TSDB_CODE_FAILED; - } - - if (!pDataBlocks) { - terrno = TSDB_CODE_INVALID_PTR; - smaWarn("vgId:%d, insert tsma data failed since pDataBlocks is NULL", SMA_VID(pSma)); - return terrno; - } - - if (taosArrayGetSize(pDataBlocks) <= 0) { - terrno = TSDB_CODE_INVALID_PARA; - smaWarn("vgId:%d, insert tsma data failed since pDataBlocks is empty", SMA_VID(pSma)); - return TSDB_CODE_FAILED; - } - - SSmaEnv *pEnv = SMA_TSMA_ENV(pSma); - SSmaStat *pStat = SMA_ENV_STAT(pEnv); - SSmaStatItem *pItem = NULL; - - tdRefSmaStat(pSma, pStat); - - if (pStat && SMA_STAT_ITEMS(pStat)) { - pItem = taosHashGet(SMA_STAT_ITEMS(pStat), &indexUid, sizeof(indexUid)); - } - - if (!pItem || !(pItem = *(SSmaStatItem **)pItem) || tdSmaStatIsDropped(pItem)) { - terrno = TSDB_CODE_TSMA_INVALID_STAT; - tdUnRefSmaStat(pSma, pStat); - return TSDB_CODE_FAILED; - } - - STSma *pTSma = pItem->pTSma; - - tdUnRefSmaStat(pSma, pStat); - - return TSDB_CODE_SUCCESS; -} - int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg) { SSmaCfg *pCfg = (SSmaCfg *)pMsg; - if (metaCreateTSma(SMA_META(pSma), version, pCfg) < 0) { - return -1; - } - if (TD_VID(pSma->pVnode) == pCfg->dstVgId) { + // create tsma meta in dstVgId + if (metaCreateTSma(SMA_META(pSma), version, pCfg) < 0) { + return -1; + } + // create stable to save tsma result in dstVgId SVCreateStbReq pReq = {0}; pReq.name = pCfg->dstTbName; @@ -165,6 +97,82 @@ int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg) { } } - tdTSmaAdd(pSma, 1); return 0; +} + +/** + * @brief Insert/Update Time-range-wise SMA data. + * + * @param pSma + * @param msg + * @return int32_t + */ +int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) { + const SArray *pDataBlocks = (const SArray *)msg; + // TODO: destroy SSDataBlocks(msg) + if (!pDataBlocks) { + terrno = TSDB_CODE_TSMA_INVALID_PTR; + smaWarn("vgId:%d, insert tsma data failed since pDataBlocks is NULL", SMA_VID(pSma)); + return terrno; + } + + if (taosArrayGetSize(pDataBlocks) <= 0) { + terrno = TSDB_CODE_TSMA_INVALID_PARA; + smaWarn("vgId:%d, insert tsma data failed since pDataBlocks is empty", SMA_VID(pSma)); + return TSDB_CODE_FAILED; + } + + if (tdCheckAndInitSmaEnv(pSma, TSDB_SMA_TYPE_TIME_RANGE) != 0) { + terrno = TSDB_CODE_TSMA_INIT_FAILED; + return TSDB_CODE_FAILED; + } + + SSmaEnv *pEnv = SMA_TSMA_ENV(pSma); + SSmaStat *pStat = NULL; + SSmaStatItem *pItem = NULL; + + if (!pEnv || !(pStat = SMA_ENV_STAT(pEnv))) { + terrno = TSDB_CODE_TSMA_INVALID_STAT; + return TSDB_CODE_FAILED; + } + + tdRefSmaStat(pSma, pStat); + pItem = &pStat->tsmaStatItem; + + ASSERT(pItem); + + if (!pItem->pTSma) { + STSma *pTSma = metaGetSmaInfoByIndex(SMA_META(pSma), indexUid); + if (!pTSma) { + terrno = TSDB_CODE_TSMA_NO_INDEX_IN_META; + smaWarn("vgId:%d, tsma insert for smaIndex %" PRIi64 " since %s", SMA_VID(pSma), indexUid, tstrerror(terrno)); + return TSDB_CODE_FAILED; + } + pItem->pTSma = pTSma; + pItem->pTSchema = metaGetTbTSchema(SMA_META(pSma), pTSma->dstTbUid, -1); + ASSERT(pItem->pTSchema); // TODO + } + + ASSERT(pItem->pTSma->indexUid == indexUid); + + SSubmitReq *pSubmitReq = NULL; + + pSubmitReq = tdBlockToSubmit((const SArray *)msg, pItem->pTSchema, true, pItem->pTSma->dstTbUid, + pItem->pTSma->dstTbName, pItem->pTSma->dstVgId); + + ASSERT(pSubmitReq); // TODO + + ASSERT(!strncasecmp("td.tsma.rst.tb", pItem->pTSma->dstTbName, 14)); + + SRpcMsg submitReqMsg = { + .msgType = TDMT_VND_SUBMIT, + .pCont = pSubmitReq, + .contLen = ntohl(pSubmitReq->length), + }; + + ASSERT(tmsgPutToQueue(&pSma->pVnode->msgCb, WRITE_QUEUE, &submitReqMsg) == 0); + + tdUnRefSmaStat(pSma, pStat); + + return TSDB_CODE_SUCCESS; } \ No newline at end of file diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index 4a5ea49d79..9f34ae39c0 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -47,7 +47,7 @@ void tqCleanUp() { } STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal) { - STQ* pTq = taosMemoryMalloc(sizeof(STQ)); + STQ* pTq = taosMemoryCalloc(1, sizeof(STQ)); if (pTq == NULL) { terrno = TSDB_CODE_TQ_OUT_OF_MEMORY; return NULL; @@ -66,19 +66,23 @@ STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal) { ASSERT(0); } + if (tqOffsetOpen(pTq) < 0) { + ASSERT(0); + } + return pTq; } void tqClose(STQ* pTq) { if (pTq) { - taosMemoryFreeClear(pTq->path); + tqOffsetClose(pTq->pOffsetStore); taosHashCleanup(pTq->handles); taosHashCleanup(pTq->pStreamTasks); taosHashCleanup(pTq->pushMgr); + taosMemoryFree(pTq->path); tqMetaClose(pTq); taosMemoryFree(pTq); } - // TODO } int32_t tqSendPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataBlkRsp* pRsp) { @@ -109,6 +113,33 @@ int32_t tqSendPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, con return 0; } +int32_t tqProcessOffsetCommitReq(STQ* pTq, char* msg, int32_t msgLen) { + STqOffset offset = {0}; + SDecoder decoder; + tDecoderInit(&decoder, msg, msgLen); + if (tDecodeSTqOffset(&decoder, &offset) < 0) { + ASSERT(0); + return -1; + } + tDecoderClear(&decoder); + + if (offset.type == TMQ_OFFSET__SNAPSHOT) { + tqDebug("receive offset commit msg to %s, offset(type:snapshot) uid: %ld, ts: %ld", offset.subKey, offset.uid, + offset.ts); + } else if (offset.type == TMQ_OFFSET__LOG) { + tqDebug("receive offset commit msg to %s, offset(type:log) version: %ld", offset.subKey, offset.version); + } else { + ASSERT(0); + } + + if (tqOffsetWrite(pTq->pOffsetStore, &offset) < 0) { + ASSERT(0); + return -1; + } + + return 0; +} + int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { SMqPollReq* pReq = pMsg->pCont; int64_t consumerId = pReq->consumerId; diff --git a/source/dnode/vnode/src/tq/tqOffset.c b/source/dnode/vnode/src/tq/tqOffset.c index 4d83a67579..8d6cb28065 100644 --- a/source/dnode/vnode/src/tq/tqOffset.c +++ b/source/dnode/vnode/src/tq/tqOffset.c @@ -16,26 +16,128 @@ #include "tq.h" -enum ETqOffsetPersist { - TQ_OFFSET_PERSIST__LAZY = 1, - TQ_OFFSET_PERSIST__EAGER, -}; - -struct STqOffsetCfg { - int8_t persistPolicy; -}; - struct STqOffsetStore { - STqOffsetCfg cfg; - SHashObj* pHash; // SHashObj + char* fname; + STQ* pTq; + SHashObj* pHash; // SHashObj }; -STqOffsetStore* tqOffsetOpen(STqOffsetCfg* pCfg) { - STqOffsetStore* pStore = taosMemoryMalloc(sizeof(STqOffsetStore)); +static char* buildFileName(const char* path) { + int32_t len = strlen(path); + char* fname = taosMemoryCalloc(1, len + 20); + snprintf(fname, len + 20, "%s/offset", path); + return fname; +} + +STqOffsetStore* tqOffsetOpen(STQ* pTq) { + STqOffsetStore* pStore = taosMemoryCalloc(1, sizeof(STqOffsetStore)); if (pStore == NULL) { return NULL; } - memcpy(&pStore->cfg, pCfg, sizeof(STqOffsetCfg)); + pStore->pTq = pTq; + pTq->pOffsetStore = pStore; + pStore->pHash = taosHashInit(64, MurmurHash3_32, true, HASH_NO_LOCK); + if (pStore->pHash == NULL) { + if (pStore->pHash) taosHashCleanup(pStore->pHash); + return NULL; + } + char* fname = buildFileName(pStore->pTq->path); + TdFilePtr pFile = taosOpenFile(fname, TD_FILE_READ); + if (pFile != NULL) { + STqOffsetHead head = {0}; + int64_t code; + + while (1) { + if ((code = taosReadFile(pFile, &head, sizeof(STqOffsetHead))) != sizeof(STqOffsetHead)) { + if (code == 0) { + break; + } else { + ASSERT(0); + // TODO handle error + } + } + int32_t size = htonl(head.size); + void* memBuf = taosMemoryCalloc(1, size); + if ((code = taosReadFile(pFile, memBuf, size)) != size) { + ASSERT(0); + // TODO handle error + } + STqOffset offset; + SDecoder decoder; + tDecoderInit(&decoder, memBuf, size); + if (tDecodeSTqOffset(&decoder, &offset) < 0) { + ASSERT(0); + } + tDecoderClear(&decoder); + if (taosHashPut(pStore->pHash, offset.subKey, strlen(offset.subKey), &offset, sizeof(STqOffset)) < 0) { + ASSERT(0); + // TODO + } + } + + taosCloseFile(&pFile); + taosMemoryFree(fname); + } return pStore; } + +void tqOffsetClose(STqOffsetStore* pStore) { + tqOffsetSnapshot(pStore); + taosHashCleanup(pStore->pHash); +} + +STqOffset* tqOffsetRead(STqOffsetStore* pStore, const char* subscribeKey) { + return (STqOffset*)taosHashGet(pStore->pHash, subscribeKey, strlen(subscribeKey)); +} + +int32_t tqOffsetWrite(STqOffsetStore* pStore, const STqOffset* pOffset) { + return taosHashPut(pStore->pHash, pOffset->subKey, strlen(pOffset->subKey), pOffset, sizeof(STqOffset)); +} + +int32_t tqOffsetSnapshot(STqOffsetStore* pStore) { + // open file + // TODO file name should be with a version + char* fname = buildFileName(pStore->pTq->path); + TdFilePtr pFile = taosOpenFile(fname, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND); + if (pFile == NULL) { + ASSERT(0); + return -1; + } + void* pIter = NULL; + while (1) { + pIter = taosHashIterate(pStore->pHash, pIter); + if (pIter == NULL) break; + STqOffset* pOffset = (STqOffset*)pIter; + int32_t bodyLen; + int32_t code; + tEncodeSize(tEncodeSTqOffset, pOffset, bodyLen, code); + ASSERT(code == 0); + if (code < 0) { + ASSERT(0); + taosHashCancelIterate(pStore->pHash, pIter); + return -1; + } + + int32_t totLen = sizeof(STqOffsetHead) + bodyLen; + void* buf = taosMemoryCalloc(1, totLen); + void* abuf = POINTER_SHIFT(buf, sizeof(STqOffsetHead)); + + ((STqOffsetHead*)buf)->size = htonl(bodyLen); + SEncoder encoder; + tEncoderInit(&encoder, abuf, bodyLen); + tEncodeSTqOffset(&encoder, pOffset); + // write file + int64_t writeLen; + if ((writeLen = taosWriteFile(pFile, buf, totLen)) != bodyLen) { + ASSERT(0); + tqError("write offset incomplete, len %d, write len %ld", bodyLen, writeLen); + taosHashCancelIterate(pStore->pHash, pIter); + return -1; + } + } + // close and rename file + taosCloseFile(&pFile); + taosMemoryFree(fname); + return 0; +} diff --git a/source/dnode/vnode/src/tq/tqSink.c b/source/dnode/vnode/src/tq/tqSink.c index 5c0bf971fb..b628f0dde5 100644 --- a/source/dnode/vnode/src/tq/tqSink.c +++ b/source/dnode/vnode/src/tq/tqSink.c @@ -15,6 +15,174 @@ #include "tq.h" +SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, bool createTb, int64_t suid, + const char* stbFullName, int32_t vgId) { + SSubmitReq* ret = NULL; + SArray* tagArray = taosArrayInit(1, sizeof(STagVal)); + if (!tagArray) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } + + // cal size + int32_t cap = sizeof(SSubmitReq); + int32_t sz = taosArrayGetSize(pBlocks); + for (int32_t i = 0; i < sz; i++) { + SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i); + int32_t rows = pDataBlock->info.rows; + // TODO min + int32_t rowSize = pDataBlock->info.rowSize; + int32_t maxLen = TD_ROW_MAX_BYTES_FROM_SCHEMA(pTSchema); + int32_t schemaLen = 0; + + if (createTb) { + SVCreateTbReq createTbReq = {0}; + char* cname = buildCtbNameByGroupId(stbFullName, pDataBlock->info.groupId); + createTbReq.name = cname; + createTbReq.flags = 0; + createTbReq.type = TSDB_CHILD_TABLE; + createTbReq.ctb.suid = suid; + + STagVal tagVal = { + .cid = pDataBlock->info.numOfCols + 1, + .type = TSDB_DATA_TYPE_UBIGINT, + .i64 = (int64_t)pDataBlock->info.groupId, + }; + STag* pTag = NULL; + taosArrayClear(tagArray); + taosArrayPush(tagArray, &tagVal); + tTagNew(tagArray, 1, false, &pTag); + if (pTag == NULL) { + tdDestroySVCreateTbReq(&createTbReq); + taosArrayDestroy(tagArray); + return NULL; + } + createTbReq.ctb.pTag = (uint8_t*)pTag; + + int32_t code; + tEncodeSize(tEncodeSVCreateTbReq, &createTbReq, schemaLen, code); + + tdDestroySVCreateTbReq(&createTbReq); + if (code < 0) { + taosArrayDestroy(tagArray); + return NULL; + } + } + + cap += sizeof(SSubmitBlk) + schemaLen + rows * maxLen; + } + + // assign data + // TODO + ret = rpcMallocCont(cap); + ret->header.vgId = vgId; + ret->version = htonl(1); + ret->length = sizeof(SSubmitReq); + ret->numOfBlocks = htonl(sz); + + void* submitBlk = POINTER_SHIFT(ret, sizeof(SSubmitReq)); + for (int32_t i = 0; i < sz; i++) { + SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i); + + SSubmitBlk* blkHead = submitBlk; + blkHead->numOfRows = htons(pDataBlock->info.rows); + blkHead->sversion = htonl(pTSchema->version); + // TODO + blkHead->suid = htobe64(suid); + // uid is assigned by vnode + blkHead->uid = 0; + + int32_t rows = pDataBlock->info.rows; + /*int32_t maxLen = TD_ROW_MAX_BYTES_FROM_SCHEMA(pTSchema);*/ + /*blkHead->dataLen = htonl(rows * maxLen);*/ + blkHead->dataLen = 0; + + void* blockData = POINTER_SHIFT(submitBlk, sizeof(SSubmitBlk)); + + int32_t schemaLen = 0; + if (createTb) { + SVCreateTbReq createTbReq = {0}; + char* cname = buildCtbNameByGroupId(stbFullName, pDataBlock->info.groupId); + createTbReq.name = cname; + createTbReq.flags = 0; + createTbReq.type = TSDB_CHILD_TABLE; + createTbReq.ctb.suid = suid; + + STagVal tagVal = { + .cid = pDataBlock->info.numOfCols + 1, + .type = TSDB_DATA_TYPE_UBIGINT, + .i64 = (int64_t)pDataBlock->info.groupId, + }; + taosArrayClear(tagArray); + taosArrayPush(tagArray, &tagVal); + STag* pTag = NULL; + tTagNew(tagArray, 1, false, &pTag); + if (pTag == NULL) { + tdDestroySVCreateTbReq(&createTbReq); + taosArrayDestroy(tagArray); + taosMemoryFreeClear(ret); + return NULL; + } + createTbReq.ctb.pTag = (uint8_t*)pTag; + + int32_t code; + tEncodeSize(tEncodeSVCreateTbReq, &createTbReq, schemaLen, code); + if (code < 0) { + tdDestroySVCreateTbReq(&createTbReq); + taosArrayDestroy(tagArray); + taosMemoryFreeClear(ret); + return NULL; + } + + SEncoder encoder = {0}; + tEncoderInit(&encoder, blockData, schemaLen); + code = tEncodeSVCreateTbReq(&encoder, &createTbReq); + tEncoderClear(&encoder); + tdDestroySVCreateTbReq(&createTbReq); + + if (code < 0) { + taosArrayDestroy(tagArray); + taosMemoryFreeClear(ret); + return NULL; + } + } + blkHead->schemaLen = htonl(schemaLen); + + STSRow* rowData = POINTER_SHIFT(blockData, schemaLen); + + for (int32_t j = 0; j < rows; j++) { + SRowBuilder rb = {0}; + tdSRowInit(&rb, pTSchema->version); + tdSRowSetTpInfo(&rb, pTSchema->numOfCols, pTSchema->flen); + tdSRowResetBuf(&rb, rowData); + + for (int32_t k = 0; k < pTSchema->numOfCols; k++) { + const STColumn* pColumn = &pTSchema->columns[k]; + SColumnInfoData* pColData = taosArrayGet(pDataBlock->pDataBlock, k); + if (colDataIsNull_s(pColData, j)) { + tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NONE, NULL, false, pColumn->offset, k); + } else { + void* data = colDataGetData(pColData, j); + tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, data, true, pColumn->offset, k); + } + } + int32_t rowLen = TD_ROW_LEN(rowData); + rowData = POINTER_SHIFT(rowData, rowLen); + blkHead->dataLen += rowLen; + } + int32_t dataLen = blkHead->dataLen; + blkHead->dataLen = htonl(dataLen); + + ret->length += sizeof(SSubmitBlk) + schemaLen + dataLen; + blkHead = POINTER_SHIFT(blkHead, schemaLen + dataLen); + /*submitBlk = blkHead;*/ + } + + ret->length = htonl(ret->length); + taosArrayDestroy(tagArray); + return ret; +} + void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data) { const SArray* pRes = (const SArray*)data; SVnode* pVnode = (SVnode*)vnode; diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index 90093f2510..fe89321ae9 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -110,6 +110,8 @@ int32_t tsdbBegin(STsdb *pTsdb) { } int32_t tsdbCommit(STsdb *pTsdb) { + if (!pTsdb) return 0; + int32_t code = 0; SCommitH commith = {0}; SDFileSet *pSet = NULL; diff --git a/source/dnode/vnode/src/tsdb/tsdbFS.c b/source/dnode/vnode/src/tsdb/tsdbFS.c index f1941a3bad..055b6c62de 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS.c +++ b/source/dnode/vnode/src/tsdb/tsdbFS.c @@ -20,6 +20,7 @@ extern const char *TSDB_LEVEL_DNAME[]; typedef enum { TSDB_TXN_TEMP_FILE = 0, TSDB_TXN_CURR_FILE } TSDB_TXN_FILE_T; static const char *tsdbTxnFname[] = {"current.t", "current"}; #define TSDB_MAX_FSETS(keep, days) ((keep) / (days) + 3) +#define TSDB_MAX_INIT_FSETS (365000) static int tsdbComparFidFSet(const void *arg1, const void *arg2); static void tsdbResetFSStatus(SFSStatus *pStatus); @@ -210,6 +211,10 @@ STsdbFS *tsdbNewFS(const STsdbKeepCfg *pCfg) { return NULL; } + if (maxFSet > TSDB_MAX_INIT_FSETS) { + maxFSet = TSDB_MAX_INIT_FSETS; + } + pfs->cstatus = tsdbNewFSStatus(maxFSet); if (pfs->cstatus == NULL) { tsdbFreeFS(pfs); diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index ab2efa4791..cd64bc8a9c 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -148,17 +148,24 @@ int32_t vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp case TDMT_VND_MQ_VG_CHANGE: if (tqProcessVgChangeReq(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), pMsg->contLen - sizeof(SMsgHead)) < 0) { - // TODO: handle error + goto _err; } break; case TDMT_VND_MQ_VG_DELETE: if (tqProcessVgDeleteReq(pVnode->pTq, pMsg->pCont, pMsg->contLen) < 0) { - // TODO: handle error + goto _err; + } + break; + case TDMT_VND_MQ_COMMIT_OFFSET: + if (tqProcessOffsetCommitReq(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), + pMsg->contLen - sizeof(SMsgHead)) < 0) { + goto _err; } break; case TDMT_STREAM_TASK_DEPLOY: { if (tqProcessTaskDeploy(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), pMsg->contLen - sizeof(SMsgHead)) < 0) { + goto _err; } } break; case TDMT_VND_ALTER_CONFIRM: @@ -277,7 +284,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, int64_t version, SRpcMsg *pMsg, SRp void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) { // TODO - // blockDebugShowData(data, __func__); + blockDebugShowData(data, __func__); tdProcessTSmaInsert(((SVnode *)pVnode)->pSma, smaId, (const char *)data); } @@ -289,7 +296,7 @@ void vnodeUpdateMetaRsp(SVnode *pVnode, STableMetaRsp *pMetaRsp) { } int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { - int32_t ret = TAOS_SYNC_PROPOSE_OTHER_ERROR; + int32_t ret = TAOS_SYNC_OTHER_ERROR; if (syncEnvIsStart()) { SSyncNode *pSyncNode = syncNodeAcquire(pVnode->sync); @@ -368,15 +375,19 @@ int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { ret = syncNodeOnAppendEntriesReplyCb(pSyncNode, pSyncMsg); syncAppendEntriesReplyDestroy(pSyncMsg); + } else if (pRpcMsg->msgType == TDMT_SYNC_SET_MNODE_STANDBY) { + ret = syncSetStandby(pVnode->sync); + SRpcMsg rsp = {.code = ret, .info = pMsg->info}; + tmsgSendRsp(&rsp); } else { vError("==vnodeProcessSyncReq== error msg type:%d", pRpcMsg->msgType); - ret = TAOS_SYNC_PROPOSE_OTHER_ERROR; + ret = TAOS_SYNC_OTHER_ERROR; } syncNodeRelease(pSyncNode); } else { vError("==vnodeProcessSyncReq== error syncEnv stop"); - ret = TAOS_SYNC_PROPOSE_OTHER_ERROR; + ret = TAOS_SYNC_OTHER_ERROR; } return ret; @@ -901,8 +912,8 @@ static int32_t vnodeProcessAlterConfirmReq(SVnode *pVnode, int64_t version, void static int32_t vnodeProcessAlterHasnRangeReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) { vInfo("vgId:%d, alter hashrange msg will be processed", TD_VID(pVnode)); - // todo - // 1. stop work + // todo + // 1. stop work // 2. adjust hash range / compact / remove wals / rename vgroups // 3. reload sync return 0; diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index 087bdb2b49..17c2c186be 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -66,7 +66,13 @@ static int32_t vnodeProcessAlterReplicaReq(SVnode *pVnode, SRpcMsg *pMsg) { vInfo("vgId:%d, replica:%d %s:%u", TD_VID(pVnode), r, pNode->nodeFqdn, pNode->nodePort); } - return syncReconfig(pVnode->sync, &cfg); + SRpcMsg rpcMsg = {.info = pMsg->info}; + if (syncReconfigBuild(pVnode->sync, &cfg, &rpcMsg) != 0) { + vError("vgId:%d, failed to build reconfig msg since %s", TD_VID(pVnode), terrstr()); + return -1; + } + + return syncPropose(pVnode->sync, &rpcMsg, false); } void vnodeProposeMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) { @@ -241,6 +247,30 @@ static void vnodeSyncRollBackMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg); } +int32_t vnodeSnapshotStartRead(struct SSyncFSM *pFsm, void **ppReader) { + return 0; +} + +int32_t vnodeSnapshotStopRead(struct SSyncFSM *pFsm, void *pReader) { + return 0; +} + +int32_t vnodeSnapshotDoRead(struct SSyncFSM *pFsm, void *pReader, void **ppBuf, int32_t *len) { + return 0; +} + +int32_t vnodeSnapshotStartWrite(struct SSyncFSM *pFsm, void **ppWriter) { + return 0; +} + +int32_t vnodeSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply) { + return 0; +} + +int32_t vnodeSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) { + return 0; +} + static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) { SSyncFSM *pFsm = taosMemoryCalloc(1, sizeof(SSyncFSM)); pFsm->data = pVnode; @@ -250,6 +280,14 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) { pFsm->FpGetSnapshot = vnodeSyncGetSnapshot; pFsm->FpRestoreFinishCb = NULL; pFsm->FpReConfigCb = vnodeSyncReconfig; + + pFsm->FpSnapshotStartRead = vnodeSnapshotStartRead; + pFsm->FpSnapshotStopRead = vnodeSnapshotStopRead; + pFsm->FpSnapshotDoRead = vnodeSnapshotDoRead; + pFsm->FpSnapshotStartWrite = vnodeSnapshotStartWrite; + pFsm->FpSnapshotStopWrite = vnodeSnapshotStopWrite; + pFsm->FpSnapshotDoWrite = vnodeSnapshotDoWrite; + return pFsm; } @@ -283,11 +321,14 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) { void vnodeSyncStart(SVnode *pVnode) { syncSetMsgCb(pVnode->sync, &pVnode->msgCb); + syncStart(pVnode->sync); + /* if (pVnode->config.standby) { syncStartStandBy(pVnode->sync); } else { syncStart(pVnode->sync); } + */ } void vnodeSyncClose(SVnode *pVnode) { syncStop(pVnode->sync); } diff --git a/source/dnode/vnode/test/tsdbSmaTest.cpp b/source/dnode/vnode/test/tsdbSmaTest.cpp index 0161fac9b5..2c1e6fbbbd 100644 --- a/source/dnode/vnode/test/tsdbSmaTest.cpp +++ b/source/dnode/vnode/test/tsdbSmaTest.cpp @@ -121,7 +121,7 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) { // decode STSmaWrapper dstTSmaWrapper = {0}; - void *result = tDecodeTSmaWrapper(pSW, &dstTSmaWrapper); + void *result = tDecodeTSmaWrapper(pSW, &dstTSmaWrapper, false); EXPECT_NE(result, nullptr); EXPECT_EQ(tSmaWrapper.number, dstTSmaWrapper.number); diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index 6aa86aa4ba..a3576f8738 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -392,8 +392,12 @@ int32_t ctgGetTbIndex(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTableName CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } - int32_t code = 0; - CTG_ERR_JRET(ctgGetTbIndexFromMnode(pCtg, pConn, (SName*)pTableName, pIndex, NULL)); + int32_t code = ctgGetTbIndexFromMnode(pCtg, pConn, (SName*)pTableName, pIndex, NULL); + if (TSDB_CODE_MND_DB_INDEX_NOT_EXIST == code) { + code = 0; + goto _return; + } + CTG_ERR_JRET(code); SArray* pInfo = NULL; CTG_ERR_JRET(ctgCloneTableIndex(pIndex->pIndex, &pInfo)); diff --git a/source/libs/catalog/src/ctgCache.c b/source/libs/catalog/src/ctgCache.c index 724b54d250..62890b8326 100644 --- a/source/libs/catalog/src/ctgCache.c +++ b/source/libs/catalog/src/ctgCache.c @@ -311,6 +311,9 @@ _return: ctgReleaseTbMetaToCache(pCtg, dbCache, pCache); CTG_CACHE_STAT_INC(tbMetaMissNum, 1); + + *pDb = NULL; + *pTb = NULL; return TSDB_CODE_SUCCESS; } @@ -427,8 +430,6 @@ int32_t ctgReadTbMetaFromCache(SCatalog* pCtg, SCtgTbMetaCtx* ctx, STableMeta** ctgDebug("Got ctb %s meta from cache, will continue to get its stb meta, type:%d, dbFName:%s", ctx->pName->tname, ctx->tbInfo.tbType, dbFName); - dbCache = NULL; - tbCache = NULL; ctgAcquireStbMetaFromCache(pCtg, dbFName, ctx->tbInfo.suid, &dbCache, &tbCache); if (NULL == tbCache) { ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache); diff --git a/source/libs/catalog/src/ctgDbg.c b/source/libs/catalog/src/ctgDbg.c index cd61abf6cc..9de1ea22be 100644 --- a/source/libs/catalog/src/ctgDbg.c +++ b/source/libs/catalog/src/ctgDbg.c @@ -19,7 +19,7 @@ #include "catalogInt.h" extern SCatalogMgmt gCtgMgmt; -SCtgDebug gCTGDebug = {.apiEnable = true, .lockEnable = true}; +SCtgDebug gCTGDebug = {0}; void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) { ASSERT(*(int32_t*)param == 1); diff --git a/source/libs/command/src/explain.c b/source/libs/command/src/explain.c index 960f8dc9ac..79861dfa05 100644 --- a/source/libs/command/src/explain.c +++ b/source/libs/command/src/explain.c @@ -211,7 +211,7 @@ int32_t qExplainGenerateResChildren(SPhysiNode *pNode, SExplainGroup *group, SNo SExplainResNode *pResNode = NULL; FOREACH(node, pPhysiChildren) { QRY_ERR_RET(qExplainGenerateResNode((SPhysiNode *)node, group, &pResNode)); - QRY_ERR_RET(nodesListAppend(*pChildren, pResNode)); + QRY_ERR_RET(nodesListAppend(*pChildren, (SNode*)pResNode)); } return TSDB_CODE_SUCCESS; @@ -715,7 +715,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i EXPLAIN_ROW_NEW(level + 1, "Sort Key: "); if (pResNode->pExecInfo) { for (int32_t i = 0; i < LIST_LENGTH(pSortNode->pSortKeys); ++i) { - SOrderByExprNode *ptn = nodesListGetNode(pSortNode->pSortKeys, i); + SOrderByExprNode *ptn = (SOrderByExprNode*)nodesListGetNode(pSortNode->pSortKeys, i); EXPLAIN_ROW_APPEND("%s ", nodesGetNameFromColumnNode(ptn->pExpr)); } } @@ -1039,7 +1039,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i EXPLAIN_ROW_NEW(level + 1, "Merge Key: "); if (pResNode->pExecInfo) { for (int32_t i = 0; i < LIST_LENGTH(pMergeNode->pMergeKeys); ++i) { - SOrderByExprNode *ptn = nodesListGetNode(pMergeNode->pMergeKeys, i); + SOrderByExprNode *ptn = (SOrderByExprNode*)nodesListGetNode(pMergeNode->pMergeKeys, i); EXPLAIN_ROW_APPEND("%s ", nodesGetNameFromColumnNode(ptn->pExpr)); } } @@ -1078,7 +1078,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i EXPLAIN_ROW_NEW(level + 1, EXPLAIN_MERGE_KEYS_FORMAT); for (int32_t i = 0; i < LIST_LENGTH(pMergeNode->pMergeKeys); ++i) { - SOrderByExprNode *ptn = nodesListGetNode(pMergeNode->pMergeKeys, i); + SOrderByExprNode *ptn = (SOrderByExprNode*)nodesListGetNode(pMergeNode->pMergeKeys, i); EXPLAIN_ROW_APPEND("%s ", nodesGetNameFromColumnNode(ptn->pExpr)); } EXPLAIN_ROW_END(); diff --git a/source/libs/executor/inc/executorInt.h b/source/libs/executor/inc/executorInt.h index 88f308710e..df54161720 100644 --- a/source/libs/executor/inc/executorInt.h +++ b/source/libs/executor/inc/executorInt.h @@ -27,10 +27,7 @@ typedef struct { int32_t bytes; } SGroupKeys, SStateKeys; -int32_t initGroupOptrInfo(SArray** pGroupColVals, int32_t* keyLen, char** keyBuf, const SArray* pGroupColList); uint64_t calcGroupId(char* pData, int32_t len); -void recordNewGroupKeys(SArray* pGroupCols, SArray* pGroupColVals, SSDataBlock* pBlock, int32_t rowIndex); -int32_t buildGroupKeys(void* pKey, const SArray* pGroupColVals); #ifdef __cplusplus } #endif diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 94c6512e77..ab60acab53 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -336,12 +336,6 @@ typedef struct STableScanInfo { int32_t dataBlockLoadFlag; SInterval interval; // if the upstream is an interval operator, the interval info is also kept here to get the time window to check if current data block needs to be loaded. - SArray* pGroupCols; - SArray* pGroupColVals; // current group column values, SArray - char* keyBuf; // group by keys for hash - int32_t groupKeyLen; // total group by column width - SHashObj* pGroupSet; // quick locate the window object for each result - SSampleExecInfo sample; // sample execution info int32_t curTWinIdx; } STableScanInfo; @@ -789,7 +783,7 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode* pExNode, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, tsdbReaderT pDataReader, SReadHandle* pHandle, SArray* groupKyes, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, tsdbReaderT pDataReader, SReadHandle* pHandle, SExecTaskInfo* pTaskInfo); SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pPhyNode, STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo); SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode *pScanPhyNode, SExecTaskInfo* pTaskInfo); @@ -827,7 +821,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx SExprInfo* pScalarExprInfo, int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo); SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHandle, SArray* pTableIdList, +SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHandle, STableScanPhysiNode* pTableScanNode, SExecTaskInfo* pTaskInfo, STimeWindowAggSupp* pTwSup); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 789fe9929b..99a9dcb6af 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -202,7 +202,7 @@ SSDataBlock* createResDataBlock(SDataBlockDescNode* pNode) { for (int32_t i = 0; i < numOfCols; ++i) { SColumnInfoData idata = {{0}}; - SSlotDescNode* pDescNode = nodesListGetNode(pNode->pSlots, i); + SSlotDescNode* pDescNode = (SSlotDescNode*)nodesListGetNode(pNode->pSlots, i); // if (!pDescNode->output) { // todo disable it temporarily // continue; // } @@ -2920,7 +2920,7 @@ static int32_t initExchangeOperator(SExchangePhysiNode* pExNode, SExchangeInfo* } for (int32_t i = 0; i < numOfSources; ++i) { - SNodeListNode* pNode = nodesListGetNode((SNodeList*)pExNode->pSrcEndPoints, i); + SNodeListNode* pNode = (SNodeListNode*)nodesListGetNode((SNodeList*)pExNode->pSrcEndPoints, i); taosArrayPush(pInfo->pSources, pNode); } @@ -4494,7 +4494,7 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* if (NULL == res) { // todo handle error } else { res->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_BIGINT}; - nodesListAppend(pFuncNode->pParameterList, res); + nodesListAppend(pFuncNode->pParameterList, (SNode*)res); } } #endif @@ -4558,7 +4558,6 @@ static tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SRead static int32_t getTableList(void* metaHandle, int32_t tableType, uint64_t tableUid, STableListInfo* pListInfo, SNode* pTagCond); -static SArray* extractTableIdList(const STableListInfo* pTableGroupInfo); static SArray* extractColumnInfo(SNodeList* pNodeList); static SArray* createSortInfo(SNodeList* pNodeList); @@ -4592,6 +4591,85 @@ int32_t extractTableSchemaVersion(SReadHandle* pHandle, uint64_t uid, SExecTaskI return TSDB_CODE_SUCCESS; } +int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, SArray* groupKey){ + if(groupKey == NULL) { + return TDB_CODE_SUCCESS; + } + + pTableListInfo->map = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); + if (pTableListInfo->map == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + int32_t keyLen = 0; + void *keyBuf = NULL; + int32_t numOfGroupCols = taosArrayGetSize(groupKey); + for (int32_t j = 0; j < numOfGroupCols; ++j) { + SColumn* pCol = taosArrayGet(groupKey, j); + keyLen += pCol->bytes; // actual data + null_flag + } + + int32_t nullFlagSize = sizeof(int8_t) * numOfGroupCols; + keyLen += nullFlagSize; + + keyBuf = taosMemoryCalloc(1, keyLen); + if (keyBuf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + for(int32_t i = 0; i < taosArrayGetSize(pTableListInfo->pTableList); i++){ + STableKeyInfo *info = taosArrayGet(pTableListInfo->pTableList, i); + SMetaReader mr = {0}; + metaReaderInit(&mr, pHandle->meta, 0); + metaGetTableEntryByUid(&mr, info->uid); + + char* isNull = (char*)keyBuf; + char* pStart = (char*)keyBuf + sizeof(int8_t) * numOfGroupCols; + for (int32_t j = 0; j < numOfGroupCols; ++j) { + SColumn* pCol = taosArrayGet(groupKey, j); + + if(strcmp(pCol->name, "tbname") == 0){ + isNull[i] = 0; + memcpy(pStart, mr.me.name, strlen(mr.me.name)); + pStart += strlen(mr.me.name); + }else{ + STagVal tagVal = {0}; + tagVal.cid = pCol->colId; + const char* p = metaGetTableTagVal(&mr.me, pCol->type, &tagVal); + if(p == NULL){ + isNull[j] = 1; + continue; + } + isNull[i] = 0; + if (pCol->type == TSDB_DATA_TYPE_JSON) { +// int32_t dataLen = getJsonValueLen(pkey->pData); +// memcpy(pStart, (pkey->pData), dataLen); +// pStart += dataLen; + } else if (IS_VAR_DATA_TYPE(pCol->type)) { + memcpy(pStart, tagVal.pData, tagVal.nData); + pStart += tagVal.nData; + ASSERT(tagVal.nData <= pCol->bytes); + } else { + memcpy(pStart, &(tagVal.i64), pCol->bytes); + pStart += pCol->bytes; + } + } + } + + int32_t len = (int32_t) (pStart - (char*)keyBuf); + uint64_t* groupId = taosHashGet(pTableListInfo->map, keyBuf, len); + if (groupId) { + taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), groupId, sizeof(uint64_t)); + } else { + uint64_t tmpId = calcGroupId(keyBuf, len); + taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), &tmpId, sizeof(uint64_t)); + } + + metaReaderClear(&mr); + } + taosMemoryFree(keyBuf); + return TDB_CODE_SUCCESS; +} + SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHandle* pHandle, uint64_t queryId, uint64_t taskId, STableListInfo* pTableListInfo, SNode* pTagCond) { int32_t type = nodeType(pPhyNode); @@ -4605,15 +4683,23 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo if (pDataReader == NULL && terrno != 0) { return NULL; } - SArray* groupKyes = extractPartitionColInfo(pTableScanNode->pPartitionKeys); + int32_t code = extractTableSchemaVersion(pHandle, pTableScanNode->scan.uid, pTaskInfo); if (code) { tsdbCleanupReadHandle(pDataReader); return NULL; } - + + SArray* groupKeys = extractPartitionColInfo(pTableScanNode->pPartitionKeys); + code = generateGroupIdMap(pTableListInfo, pHandle, groupKeys); //todo for json + taosArrayDestroy(groupKeys); + if (code){ + tsdbCleanupReadHandle(pDataReader); + return NULL; + } + SOperatorInfo* pOperator = - createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, groupKyes, pTaskInfo); + createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, pTaskInfo); STableScanInfo* pScanInfo = pOperator->info; pTaskInfo->cost.pRecoder = &pScanInfo->readRecorder; @@ -4639,12 +4725,18 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo } else { qDebug("%s pDataReader is not NULL", GET_TASKID(pTaskInfo)); } - SArray* tableIdList = extractTableIdList(pTableListInfo); + + SArray* groupKeys = extractPartitionColInfo(pTableScanNode->pPartitionKeys); + int32_t code = generateGroupIdMap(pTableListInfo, pHandle, groupKeys); //todo for json + taosArrayDestroy(groupKeys); + if (code){ + tsdbCleanupReadHandle(pDataReader); + return NULL; + } SOperatorInfo* pOperator = - createStreamScanOperatorInfo(pDataReader, pHandle, tableIdList, pTableScanNode, pTaskInfo, &twSup); + createStreamScanOperatorInfo(pDataReader, pHandle, pTableScanNode, pTaskInfo, &twSup); - taosArrayDestroy(tableIdList); return pOperator; } else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) { SSystemTableScanPhysiNode* pSysScanPhyNode = (SSystemTableScanPhysiNode*)pPhyNode; @@ -4969,6 +5061,7 @@ SArray* extractColumnInfo(SNodeList* pNodeList) { } SArray* extractPartitionColInfo(SNodeList* pNodeList) { + if(!pNodeList) return NULL; size_t numOfCols = LIST_LENGTH(pNodeList); SArray* pList = taosArrayInit(numOfCols, sizeof(SColumn)); if (pList == NULL) { @@ -5073,7 +5166,9 @@ int32_t getTableList(void* metaHandle, int32_t tableType, uint64_t tableUid, STa SArray* res = taosArrayInit(8, sizeof(uint64_t)); code = doFilterTag(pTagCond, &metaArg, res); - if (code != TSDB_CODE_SUCCESS) { + if (code == TSDB_CODE_INDEX_REBUILDING){ // todo + // doFilter(); + } else if (code != TSDB_CODE_SUCCESS) { qError("failed to get tableIds, reason: %s, suid: %" PRIu64 "", tstrerror(code), tableUid); taosArrayDestroy(res); terrno = code; @@ -5081,6 +5176,7 @@ int32_t getTableList(void* metaHandle, int32_t tableType, uint64_t tableUid, STa } else { qDebug("sucess to get tableIds, size: %d, suid: %" PRIu64 "", (int)taosArrayGetSize(res), tableUid); } + for (int i = 0; i < taosArrayGetSize(res); i++) { STableKeyInfo info = {.lastKey = TSKEY_INITIAL_VAL, .uid = *(uint64_t*)taosArrayGet(res, i)}; taosArrayPush(pListInfo->pTableList, &info); @@ -5097,18 +5193,6 @@ int32_t getTableList(void* metaHandle, int32_t tableType, uint64_t tableUid, STa return code; } -SArray* extractTableIdList(const STableListInfo* pTableGroupInfo) { - SArray* tableIdList = taosArrayInit(4, sizeof(uint64_t)); - - // Transfer the Array of STableKeyInfo into uid list. - for (int32_t i = 0; i < taosArrayGetSize(pTableGroupInfo->pTableList); ++i) { - STableKeyInfo* pkeyInfo = taosArrayGet(pTableGroupInfo->pTableList, i); - taosArrayPush(tableIdList, &pkeyInfo->uid); - } - - return tableIdList; -} - tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle, STableListInfo* pTableListInfo, uint64_t queryId, uint64_t taskId, SNode* pTagCond) { int32_t code = diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index 132f93a6a5..a48b4080a3 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -37,7 +37,7 @@ static void destroyGroupOperatorInfo(void* param, int32_t numOfOutput) { taosArrayDestroy(pInfo->pGroupColVals); } -int32_t initGroupOptrInfo(SArray** pGroupColVals, int32_t* keyLen, char** keyBuf, const SArray* pGroupColList) { +static int32_t initGroupOptrInfo(SArray** pGroupColVals, int32_t* keyLen, char** keyBuf, const SArray* pGroupColList) { *pGroupColVals = taosArrayInit(4, sizeof(SGroupKeys)); if ((*pGroupColVals) == NULL) { return TSDB_CODE_OUT_OF_MEMORY; @@ -118,7 +118,7 @@ static bool groupKeyCompare(SArray* pGroupCols, SArray* pGroupColVals, SSDataBlo return true; } -void recordNewGroupKeys(SArray* pGroupCols, SArray* pGroupColVals, SSDataBlock* pBlock, int32_t rowIndex) { +static void recordNewGroupKeys(SArray* pGroupCols, SArray* pGroupColVals, SSDataBlock* pBlock, int32_t rowIndex) { SColumnDataAgg* pColAgg = NULL; size_t numOfGroupCols = taosArrayGetSize(pGroupCols); @@ -150,7 +150,7 @@ void recordNewGroupKeys(SArray* pGroupCols, SArray* pGroupColVals, SSDataBlock* } } -int32_t buildGroupKeys(void* pKey, const SArray* pGroupColVals) { +static int32_t buildGroupKeys(void* pKey, const SArray* pGroupColVals) { ASSERT(pKey != NULL); size_t numOfGroupCols = taosArrayGetSize(pGroupColVals); @@ -582,6 +582,15 @@ int32_t* setupColumnOffset(const SSDataBlock* pBlock, int32_t rowCapacity) { return offset; } +static void clearPartitionOperator(SPartitionOperatorInfo* pInfo) { + void *ite = NULL; + while( (ite = taosHashIterate(pInfo->pGroupSet, ite)) != NULL ) { + taosArrayDestroy( ((SDataGroupInfo *)ite)->pPageList); + } + taosHashClear(pInfo->pGroupSet); + clearDiskbasedBuf(pInfo->pBuf); +} + static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) { SPartitionOperatorInfo* pInfo = pOperator->info; @@ -591,6 +600,7 @@ static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) { pInfo->pGroupIter = taosHashIterate(pInfo->pGroupSet, pInfo->pGroupIter); if (pInfo->pGroupIter == NULL) { doSetOperatorCompleted(pOperator); + clearPartitionOperator(pInfo); return NULL; } diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 8fb4878cd9..d30e4ef6db 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -391,22 +391,16 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) { longjmp(pOperator->pTaskInfo->env, code); } - recordNewGroupKeys(pTableScanInfo->pGroupCols, pTableScanInfo->pGroupColVals, pBlock, 0); - int32_t len = buildGroupKeys(pTableScanInfo->keyBuf, pTableScanInfo->pGroupColVals); - - uint64_t* groupId = taosHashGet(pTableScanInfo->pGroupSet, pTableScanInfo->keyBuf, len); - if (groupId) { - pBlock->info.groupId = *groupId; - } else if (len != 0) { - pBlock->info.groupId = calcGroupId(pTableScanInfo->keyBuf, len); - taosHashPut(pTableScanInfo->pGroupSet, pTableScanInfo->keyBuf, len, &pBlock->info.groupId, sizeof(uint64_t)); - } - // current block is filter out according to filter condition, continue load the next block if (status == FUNC_DATA_REQUIRED_FILTEROUT || pBlock->info.rows == 0) { continue; } + uint64_t* groupId = taosHashGet(pOperator->pTaskInfo->tableqinfoList.map, &pBlock->info.uid, sizeof(int64_t)); + if (groupId) { + pBlock->info.groupId = *groupId; + } + pOperator->resultInfo.totalRows = pTableScanInfo->readRecorder.totalRows; pTableScanInfo->readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0; @@ -530,21 +524,13 @@ static void destroyTableScanOperatorInfo(void* param, int32_t numOfOutput) { tsdbCleanupReadHandle(pTableScanInfo->dataReader); - taosArrayDestroy(pTableScanInfo->pGroupCols); - for (int i = 0; i < taosArrayGetSize(pTableScanInfo->pGroupColVals); i++) { - SGroupKeys key = *(SGroupKeys*)taosArrayGet(pTableScanInfo->pGroupColVals, i); - taosMemoryFree(key.pData); - } - taosArrayDestroy(pTableScanInfo->pGroupColVals); - taosMemoryFree(pTableScanInfo->keyBuf); - taosHashCleanup(pTableScanInfo->pGroupSet); if (pTableScanInfo->pColMatchInfo != NULL) { taosArrayDestroy(pTableScanInfo->pColMatchInfo); } } SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, tsdbReaderT pDataReader, - SReadHandle* readHandle, SArray* groupKyes, SExecTaskInfo* pTaskInfo) { + SReadHandle* readHandle, SExecTaskInfo* pTaskInfo) { STableScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STableScanInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { @@ -591,18 +577,6 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, pOperator->numOfExprs = numOfCols; pOperator->pTaskInfo = pTaskInfo; - // for table group - pInfo->pGroupCols = groupKyes; - _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); - pInfo->pGroupSet = taosHashInit(100, hashFn, false, HASH_NO_LOCK); - if (pInfo->pGroupSet == NULL) { - goto _error; - } - code = initGroupOptrInfo(&pInfo->pGroupColVals, &pInfo->groupKeyLen, &pInfo->keyBuf, groupKyes); - if (code != TSDB_CODE_SUCCESS) { - goto _error; - } - pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTableScan, NULL, NULL, destroyTableScanOperatorInfo, NULL, NULL, getTableScannerExecInfo); @@ -912,6 +886,11 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) { pInfo->pRes->info.groupId = groupId; } + uint64_t* groupIdPre = taosHashGet(pOperator->pTaskInfo->tableqinfoList.map, &uid, sizeof(int64_t)); + if (groupIdPre) { + pInfo->pRes->info.groupId = *groupIdPre; + } + for (int32_t i = 0; i < taosArrayGetSize(pInfo->pColMatchInfo); ++i) { SColMatchInfo* pColMatchInfo = taosArrayGet(pInfo->pColMatchInfo, i); if (!pColMatchInfo->output) { @@ -979,11 +958,24 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) { } } -SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHandle, SArray* pTableIdList, +static SArray* extractTableIdList(const STableListInfo* pTableGroupInfo) { + SArray* tableIdList = taosArrayInit(4, sizeof(uint64_t)); + + // Transfer the Array of STableKeyInfo into uid list. + for (int32_t i = 0; i < taosArrayGetSize(pTableGroupInfo->pTableList); ++i) { + STableKeyInfo* pkeyInfo = taosArrayGet(pTableGroupInfo->pTableList, i); + taosArrayPush(tableIdList, &pkeyInfo->uid); + } + + return tableIdList; +} + +SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHandle, STableScanPhysiNode* pTableScanNode, SExecTaskInfo* pTaskInfo, STimeWindowAggSupp* pTwSup) { SStreamBlockScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamBlockScanInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + if (pInfo == NULL || pOperator == NULL) { terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; goto _error; @@ -992,7 +984,7 @@ SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHan SScanPhysiNode* pScanPhyNode = &pTableScanNode->scan; SDataBlockDescNode* pDescNode = pScanPhyNode->node.pOutputDataBlockDesc; - SOperatorInfo* pTableScanDummy = createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, NULL, pTaskInfo); + SOperatorInfo* pTableScanDummy = createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, pTaskInfo); STableScanInfo* pSTInfo = (STableScanInfo*)pTableScanDummy->info; @@ -1014,10 +1006,13 @@ SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHan // set the extract column id to streamHandle tqReadHandleSetColIdList((STqReadHandle*)pHandle->reader, pColIds); - int32_t code = tqReadHandleSetTbUidList(pHandle->reader, pTableIdList); + SArray* tableIdList = extractTableIdList(&pTaskInfo->tableqinfoList); + int32_t code = tqReadHandleSetTbUidList(pHandle->reader, tableIdList); if (code != 0) { + taosArrayDestroy(tableIdList); goto _error; } + taosArrayDestroy(tableIdList); pInfo->pBlockLists = taosArrayInit(4, POINTER_BYTES); if (pInfo->pBlockLists == NULL) { diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 9a7045110c..0151474008 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -1378,7 +1378,7 @@ void destroyStreamFinalIntervalOperatorInfo(void* param, int32_t numOfOutput) { taosMemoryFreeClear(pChildOp); } } - nodesDestroyNode(pInfo->pPhyNode); + nodesDestroyNode((SNode*)pInfo->pPhyNode); } static bool allInvertible(SqlFunctionCtx* pFCtx, int32_t numOfCols) { @@ -2157,7 +2157,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, pInfo->pUpdateRes = createResDataBlock(pPhyNode->pOutputDataBlockDesc); pInfo->pUpdateRes->info.type = STREAM_REPROCESS; blockDataEnsureCapacity(pInfo->pUpdateRes, 128); - pInfo->pPhyNode = nodesCloneNode(pPhyNode); + pInfo->pPhyNode = (SPhysiNode*)nodesCloneNode((SNode*)pPhyNode); pOperator->name = "StreamFinalIntervalOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL; diff --git a/source/libs/function/inc/builtinsimpl.h b/source/libs/function/inc/builtinsimpl.h index a528041964..f3060243ed 100644 --- a/source/libs/function/inc/builtinsimpl.h +++ b/source/libs/function/inc/builtinsimpl.h @@ -55,16 +55,22 @@ int32_t maxCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); bool getAvgFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); bool avgFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); int32_t avgFunction(SqlFunctionCtx* pCtx); +int32_t avgFunctionMerge(SqlFunctionCtx* pCtx); int32_t avgFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); +int32_t avgPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t avgInvertFunction(SqlFunctionCtx* pCtx); int32_t avgCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); +int32_t getAvgInfoSize(); bool getStddevFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); bool stddevFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); int32_t stddevFunction(SqlFunctionCtx* pCtx); +int32_t stddevFunctionMerge(SqlFunctionCtx* pCtx); int32_t stddevFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); +int32_t stddevPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t stddevInvertFunction(SqlFunctionCtx* pCtx); int32_t stddevCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); +int32_t getStddevInfoSize(); bool getLeastSQRFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); bool leastSQRFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); @@ -93,10 +99,14 @@ int32_t diffFunction(SqlFunctionCtx *pCtx); bool getFirstLastFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); int32_t firstFunction(SqlFunctionCtx *pCtx); +int32_t firstFunctionMerge(SqlFunctionCtx *pCtx); int32_t lastFunction(SqlFunctionCtx *pCtx); +int32_t lastFunctionMerge(SqlFunctionCtx *pCtx); int32_t firstLastFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); +int32_t firstLastPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t firstCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); +int32_t getFirstLastInfoSize(int32_t resBytes); bool getTopBotFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv); bool getTopBotMergeFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv); diff --git a/source/libs/function/inc/functionMgtInt.h b/source/libs/function/inc/functionMgtInt.h index d1af6b6051..6fefcceb87 100644 --- a/source/libs/function/inc/functionMgtInt.h +++ b/source/libs/function/inc/functionMgtInt.h @@ -42,6 +42,7 @@ extern "C" { #define FUNC_MGT_SELECT_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(13) #define FUNC_MGT_REPEAT_SCAN_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(14) #define FUNC_MGT_FORBID_FILL_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(15) +#define FUNC_MGT_FORBID_STREAM_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(16) #define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0) diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 23940a415e..833f6db0c3 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -155,6 +155,64 @@ static int32_t translateSum(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { return TSDB_CODE_SUCCESS; } +static int32_t translateAvgPartial(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; + if (!IS_NUMERIC_TYPE(paraType) && !IS_NULL_TYPE(paraType)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + pFunc->node.resType = (SDataType){.bytes = getAvgInfoSize() + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateAvgMerge(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; + if (TSDB_DATA_TYPE_BINARY != paraType) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE}; + + return TSDB_CODE_SUCCESS; +} + +static int32_t translateStddevPartial(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; + if (!IS_NUMERIC_TYPE(paraType) && !IS_NULL_TYPE(paraType)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + pFunc->node.resType = (SDataType){.bytes = getStddevInfoSize() + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateStddevMerge(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; + if (TSDB_DATA_TYPE_BINARY != paraType) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE}; + + return TSDB_CODE_SUCCESS; +} + static int32_t translateWduration(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { // pseudo column do not need to check parameters pFunc->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_BIGINT}; @@ -393,7 +451,8 @@ static int32_t translateTopBotImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t pValue->notReserved = true; // set result type - pFunc->node.resType = (SDataType){.bytes = getTopBotInfoSize(pValue->datum.i) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}; + pFunc->node.resType = + (SDataType){.bytes = getTopBotInfoSize(pValue->datum.i) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}; } else { if (1 != numOfParams) { return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); @@ -954,6 +1013,41 @@ static int32_t translateFirstLast(SFunctionNode* pFunc, char* pErrBuf, int32_t l return TSDB_CODE_SUCCESS; } +static int32_t translateFirstLastImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t len, bool isPartial) { + // first(col_list) will be rewritten as first(col) + if (2 != LIST_LENGTH(pFunc->pParameterList)) { // input has two params c0,ts, is this a bug? + return TSDB_CODE_SUCCESS; + } + + SNode* pPara = nodesListGetNode(pFunc->pParameterList, 0); + uint8_t paraType = ((SExprNode*)pPara)->resType.type; + int32_t paraBytes = ((SExprNode*)pPara)->resType.bytes; + if (isPartial) { + if (QUERY_NODE_COLUMN != nodeType(pPara)) { + return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR, + "The parameters of first/last can only be columns"); + } + + pFunc->node.resType = + (SDataType){.bytes = getFirstLastInfoSize(paraBytes) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}; + } else { + if (TSDB_DATA_TYPE_BINARY != paraType) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + pFunc->node.resType = ((SExprNode*)pPara)->resType; + } + return TSDB_CODE_SUCCESS; +} + +static int32_t translateFirstLastPartial(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + return translateFirstLastImpl(pFunc, pErrBuf, len, true); +} + +static int32_t translateFirstLastMerge(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + return translateFirstLastImpl(pFunc, pErrBuf, len, false); +} + static int32_t translateUnique(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { if (1 != LIST_LENGTH(pFunc->pParameterList)) { return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); @@ -1274,7 +1368,7 @@ void static addTimezoneParam(SNodeList* pList) { varDataSetLen(pVal->datum.p, len); strncpy(varDataVal(pVal->datum.p), pVal->literal, len); - nodesListAppend(pList, pVal); + nodesListAppend(pList, (SNode*)pVal); } static int32_t translateToIso8601(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { @@ -1363,7 +1457,7 @@ static int32_t translateToJson(SFunctionNode* pFunc, char* pErrBuf, int32_t len) return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); } - SExprNode* pPara = nodesListGetNode(pFunc->pParameterList, 0); + SExprNode* pPara = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 0); if (QUERY_NODE_VALUE != nodeType(pPara) || (!IS_VAR_DATA_TYPE(pPara->resType.type))) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } @@ -1458,6 +1552,32 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .finalizeFunc = stddevFinalize, .invertFunc = stddevInvertFunction, .combineFunc = stddevCombine, + .pPartialFunc = "_stddev_partial", + .pMergeFunc = "_stddev_merge" + }, + { + .name = "_stddev_partial", + .type = FUNCTION_TYPE_STDDEV_PARTIAL, + .classification = FUNC_MGT_AGG_FUNC, + .translateFunc = translateStddevPartial, + .getEnvFunc = getStddevFuncEnv, + .initFunc = stddevFunctionSetup, + .processFunc = stddevFunction, + .finalizeFunc = stddevPartialFinalize, + .invertFunc = stddevInvertFunction, + .combineFunc = stddevCombine, + }, + { + .name = "_stddev_merge", + .type = FUNCTION_TYPE_STDDEV_MERGE, + .classification = FUNC_MGT_AGG_FUNC, + .translateFunc = translateStddevMerge, + .getEnvFunc = getStddevFuncEnv, + .initFunc = stddevFunctionSetup, + .processFunc = stddevFunctionMerge, + .finalizeFunc = stddevFinalize, + .invertFunc = stddevInvertFunction, + .combineFunc = stddevCombine, }, { .name = "leastsquares", @@ -1482,11 +1602,37 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .finalizeFunc = avgFinalize, .invertFunc = avgInvertFunction, .combineFunc = avgCombine, + .pPartialFunc = "_avg_partial", + .pMergeFunc = "_avg_merge" + }, + { + .name = "_avg_partial", + .type = FUNCTION_TYPE_AVG_PARTIAL, + .classification = FUNC_MGT_AGG_FUNC, + .translateFunc = translateAvgPartial, + .getEnvFunc = getAvgFuncEnv, + .initFunc = avgFunctionSetup, + .processFunc = avgFunction, + .finalizeFunc = avgPartialFinalize, + .invertFunc = avgInvertFunction, + .combineFunc = avgCombine, + }, + { + .name = "_avg_merge", + .type = FUNCTION_TYPE_AVG_MERGE, + .classification = FUNC_MGT_AGG_FUNC, + .translateFunc = translateAvgMerge, + .getEnvFunc = getAvgFuncEnv, + .initFunc = avgFunctionSetup, + .processFunc = avgFunctionMerge, + .finalizeFunc = avgFinalize, + .invertFunc = avgInvertFunction, + .combineFunc = avgCombine, }, { .name = "percentile", .type = FUNCTION_TYPE_PERCENTILE, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_REPEAT_SCAN_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_REPEAT_SCAN_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translatePercentile, .getEnvFunc = getPercentileFuncEnv, .initFunc = percentileFunctionSetup, @@ -1647,7 +1793,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "elapsed", .type = FUNCTION_TYPE_ELAPSED, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .dataRequiredFunc = statisDataRequired, .translateFunc = translateElapsed, .getEnvFunc = getElapsedFuncEnv, @@ -1656,8 +1802,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .finalizeFunc = elapsedFinalize, .invertFunc = NULL, .combineFunc = elapsedCombine, - .pPartialFunc = "_elapsed_partial", - .pMergeFunc = "_elapsed_merge" + //.pPartialFunc = "_elapsed_partial", + //.pMergeFunc = "_elapsed_merge" }, { .name = "_elapsed_partial", @@ -1704,6 +1850,30 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .initFunc = functionSetup, .processFunc = firstFunction, .finalizeFunc = firstLastFinalize, + .pPartialFunc = "_first_partial", + .pMergeFunc = "_first_merge", + .combineFunc = firstCombine, + }, + { + .name = "_first_partial", + .type = FUNCTION_TYPE_FIRST_PARTIAL, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, + .translateFunc = translateFirstLastPartial, + .getEnvFunc = getFirstLastFuncEnv, + .initFunc = functionSetup, + .processFunc = firstFunction, + .finalizeFunc = firstLastPartialFinalize, + .combineFunc = firstCombine, + }, + { + .name = "_first_merge", + .type = FUNCTION_TYPE_FIRST_MERGE, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, + .translateFunc = translateFirstLastMerge, + .getEnvFunc = getFirstLastFuncEnv, + .initFunc = functionSetup, + .processFunc = firstFunctionMerge, + .finalizeFunc = firstLastFinalize, .combineFunc = firstCombine, }, { @@ -1715,12 +1885,36 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .initFunc = functionSetup, .processFunc = lastFunction, .finalizeFunc = firstLastFinalize, + .pPartialFunc = "_last_partial", + .pMergeFunc = "_last_merge", + .combineFunc = lastCombine, + }, + { + .name = "_last_partial", + .type = FUNCTION_TYPE_LAST_PARTIAL, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, + .translateFunc = translateFirstLastPartial, + .getEnvFunc = getFirstLastFuncEnv, + .initFunc = functionSetup, + .processFunc = lastFunction, + .finalizeFunc = firstLastPartialFinalize, + .combineFunc = lastCombine, + }, + { + .name = "_last_merge", + .type = FUNCTION_TYPE_LAST_MERGE, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, + .translateFunc = translateFirstLastMerge, + .getEnvFunc = getFirstLastFuncEnv, + .initFunc = functionSetup, + .processFunc = lastFunctionMerge, + .finalizeFunc = firstLastFinalize, .combineFunc = lastCombine, }, { .name = "twa", .type = FUNCTION_TYPE_TWA, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateInNumOutDou, .getEnvFunc = getTwaFuncEnv, .initFunc = twaFunctionSetup, @@ -1806,7 +2000,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "diff", .type = FUNCTION_TYPE_DIFF, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateDiff, .getEnvFunc = getDiffFuncEnv, .initFunc = diffFunctionSetup, @@ -1816,7 +2010,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "statecount", .type = FUNCTION_TYPE_STATE_COUNT, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateStateCount, .getEnvFunc = getStateFuncEnv, .initFunc = functionSetup, @@ -1826,7 +2020,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "stateduration", .type = FUNCTION_TYPE_STATE_DURATION, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateStateDuration, .getEnvFunc = getStateFuncEnv, .initFunc = functionSetup, @@ -1836,7 +2030,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "csum", .type = FUNCTION_TYPE_CSUM, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateCsum, .getEnvFunc = getCsumFuncEnv, .initFunc = functionSetup, @@ -1846,7 +2040,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "mavg", .type = FUNCTION_TYPE_MAVG, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateMavg, .getEnvFunc = getMavgFuncEnv, .initFunc = mavgFunctionSetup, @@ -1856,7 +2050,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "sample", .type = FUNCTION_TYPE_SAMPLE, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateSample, .getEnvFunc = getSampleFuncEnv, .initFunc = sampleFunctionSetup, @@ -1866,7 +2060,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "tail", .type = FUNCTION_TYPE_TAIL, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateTail, .getEnvFunc = getTailFuncEnv, .initFunc = tailFunctionSetup, @@ -1876,7 +2070,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "unique", .type = FUNCTION_TYPE_UNIQUE, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateUnique, .getEnvFunc = getUniqueFuncEnv, .initFunc = uniqueFunctionSetup, diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 3d64f82eba..c6ab9f859d 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -14,7 +14,6 @@ */ #include "builtinsimpl.h" -#include "tglobal.h" #include "cJSON.h" #include "function.h" #include "querynodes.h" @@ -22,23 +21,23 @@ #include "tcompare.h" #include "tdatablock.h" #include "tdigest.h" +#include "tglobal.h" #include "thistogram.h" #include "tpercentile.h" -#define HISTOGRAM_MAX_BINS_NUM 1000 -#define MAVG_MAX_POINTS_NUM 1000 -#define SAMPLE_MAX_POINTS_NUM 1000 -#define TAIL_MAX_POINTS_NUM 100 -#define TAIL_MAX_OFFSET 100 +#define HISTOGRAM_MAX_BINS_NUM 1000 +#define MAVG_MAX_POINTS_NUM 1000 +#define SAMPLE_MAX_POINTS_NUM 1000 +#define TAIL_MAX_POINTS_NUM 100 +#define TAIL_MAX_OFFSET 100 -#define UNIQUE_MAX_RESULT_SIZE (1024*1024*10) - -#define HLL_BUCKET_BITS 14 // The bits of the bucket -#define HLL_DATA_BITS (64-HLL_BUCKET_BITS) -#define HLL_BUCKETS (1<initialized) { @@ -329,15 +323,14 @@ int32_t functionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t firstCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); - char* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); - int32_t type = pDestCtx->input.pData[0]->info.type; - int32_t bytes = pDestCtx->input.pData[0]->info.bytes; + char* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); + int32_t type = pDestCtx->input.pData[0]->info.type; + int32_t bytes = pDestCtx->input.pData[0]->info.bytes; SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); - char* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); + char* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); - if (pSResInfo->numOfRes != 0 && - (pDResInfo->numOfRes == 0 || *(TSKEY*)(pDBuf + bytes) > *(TSKEY*)(pSBuf + bytes)) ) { + if (pSResInfo->numOfRes != 0 && (pDResInfo->numOfRes == 0 || *(TSKEY*)(pDBuf + bytes) > *(TSKEY*)(pSBuf + bytes))) { memcpy(pDBuf, pSBuf, bytes); *(TSKEY*)(pDBuf + bytes) = *(TSKEY*)(pSBuf + bytes); pDResInfo->numOfRes = 1; @@ -409,14 +402,14 @@ static FORCE_INLINE int32_t getNumOfElems(SqlFunctionCtx* pCtx) { int32_t countFunction(SqlFunctionCtx* pCtx) { int32_t numOfElem = getNumOfElems(pCtx); - SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); + SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); SInputColumnInfoData* pInput = &pCtx->input; int32_t type = pInput->pData[0]->info.type; char* buf = GET_ROWCELL_INTERBUF(pResInfo); if (IS_NULL_TYPE(type)) { - //select count(NULL) returns 0 + // select count(NULL) returns 0 numOfElem = 1; *((int64_t*)buf) = 0; } else { @@ -445,7 +438,7 @@ int32_t countInvertFunction(SqlFunctionCtx* pCtx) { int32_t combineFunction(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); - char* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); + char* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); char* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); @@ -484,8 +477,8 @@ int32_t sumFunction(SqlFunctionCtx* pCtx) { // Only the pre-computing information loaded and actual data does not loaded SInputColumnInfoData* pInput = &pCtx->input; - SColumnDataAgg* pAgg = pInput->pColumnDataAgg[0]; - int32_t type = pInput->pData[0]->info.type; + SColumnDataAgg* pAgg = pInput->pColumnDataAgg[0]; + int32_t type = pInput->pData[0]->info.type; SSumRes* pSumRes = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); @@ -539,7 +532,7 @@ int32_t sumFunction(SqlFunctionCtx* pCtx) { } } - //check for overflow + // check for overflow if (IS_FLOAT_TYPE(type) && (isinf(pSumRes->dsum) || isnan(pSumRes->dsum))) { GET_RES_INFO(pCtx)->isNullRes = 1; } @@ -611,11 +604,11 @@ int32_t sumInvertFunction(SqlFunctionCtx* pCtx) { int32_t sumCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); - SSumRes* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); - int32_t type = pDestCtx->input.pData[0]->info.type; + SSumRes* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); + int32_t type = pDestCtx->input.pData[0]->info.type; SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); - SSumRes* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); + SSumRes* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); if (IS_SIGNED_NUMERIC_TYPE(type) || type == TSDB_DATA_TYPE_BOOL) { pDBuf->isum += pSBuf->isum; @@ -633,6 +626,8 @@ bool getSumFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) { return true; } +int32_t getAvgInfoSize() { return (int32_t)sizeof(SAvgRes); } + bool getAvgFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) { pEnv->calcMemSize = sizeof(SAvgRes); return true; @@ -651,11 +646,12 @@ bool avgFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) { int32_t avgFunction(SqlFunctionCtx* pCtx) { int32_t numOfElem = 0; - // Only the pre-computing information loaded and actual data does not loaded SInputColumnInfoData* pInput = &pCtx->input; + SColumnDataAgg* pAgg = pInput->pColumnDataAgg[0]; int32_t type = pInput->pData[0]->info.type; SAvgRes* pAvgRes = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); + pAvgRes->type = type; // computing based on the true data block SColumnInfoData* pCol = pInput->pData[0]; @@ -669,95 +665,107 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) { goto _avg_over; } - switch (type) { - case TSDB_DATA_TYPE_TINYINT: { - int8_t* plist = (int8_t*)pCol->pData; - for (int32_t i = start; i < numOfRows + pInput->startRowIndex; ++i) { - if (pCol->hasNull && colDataIsNull_f(pCol->nullbitmap, i)) { - continue; + if (pInput->colDataAggIsSet) { + numOfElem = numOfRows - pAgg->numOfNull; + ASSERT(numOfElem >= 0); + + pAvgRes->count += numOfElem; + if (IS_INTEGER_TYPE(type)) { + pAvgRes->sum.isum += pAgg->sum; + } else if (IS_FLOAT_TYPE(type)) { + pAvgRes->sum.dsum += GET_DOUBLE_VAL((const char*)&(pAgg->sum)); + } + } else { // computing based on the true data block + switch (type) { + case TSDB_DATA_TYPE_TINYINT: { + int8_t* plist = (int8_t*)pCol->pData; + for (int32_t i = start; i < numOfRows + pInput->startRowIndex; ++i) { + if (pCol->hasNull && colDataIsNull_f(pCol->nullbitmap, i)) { + continue; + } + + numOfElem += 1; + pAvgRes->count += 1; + pAvgRes->sum.isum += plist[i]; } - numOfElem += 1; - pAvgRes->count += 1; - pAvgRes->sum.isum += plist[i]; + break; } - break; - } + case TSDB_DATA_TYPE_SMALLINT: { + int16_t* plist = (int16_t*)pCol->pData; + for (int32_t i = start; i < numOfRows + pInput->startRowIndex; ++i) { + if (pCol->hasNull && colDataIsNull_f(pCol->nullbitmap, i)) { + continue; + } - case TSDB_DATA_TYPE_SMALLINT: { - int16_t* plist = (int16_t*)pCol->pData; - for (int32_t i = start; i < numOfRows + pInput->startRowIndex; ++i) { - if (pCol->hasNull && colDataIsNull_f(pCol->nullbitmap, i)) { - continue; + numOfElem += 1; + pAvgRes->count += 1; + pAvgRes->sum.isum += plist[i]; + } + break; + } + + case TSDB_DATA_TYPE_INT: { + int32_t* plist = (int32_t*)pCol->pData; + for (int32_t i = start; i < numOfRows + pInput->startRowIndex; ++i) { + if (pCol->hasNull && colDataIsNull_f(pCol->nullbitmap, i)) { + continue; + } + + numOfElem += 1; + pAvgRes->count += 1; + pAvgRes->sum.isum += plist[i]; } - numOfElem += 1; - pAvgRes->count += 1; - pAvgRes->sum.isum += plist[i]; + break; } - break; - } - case TSDB_DATA_TYPE_INT: { - int32_t* plist = (int32_t*)pCol->pData; - for (int32_t i = start; i < numOfRows + pInput->startRowIndex; ++i) { - if (pCol->hasNull && colDataIsNull_f(pCol->nullbitmap, i)) { - continue; + case TSDB_DATA_TYPE_BIGINT: { + int64_t* plist = (int64_t*)pCol->pData; + for (int32_t i = start; i < numOfRows + pInput->startRowIndex; ++i) { + if (pCol->hasNull && colDataIsNull_f(pCol->nullbitmap, i)) { + continue; + } + + numOfElem += 1; + pAvgRes->count += 1; + pAvgRes->sum.isum += plist[i]; } - - numOfElem += 1; - pAvgRes->count += 1; - pAvgRes->sum.isum += plist[i]; + break; } - break; - } + case TSDB_DATA_TYPE_FLOAT: { + float* plist = (float*)pCol->pData; + for (int32_t i = start; i < numOfRows + pInput->startRowIndex; ++i) { + if (pCol->hasNull && colDataIsNull_f(pCol->nullbitmap, i)) { + continue; + } - case TSDB_DATA_TYPE_BIGINT: { - int64_t* plist = (int64_t*)pCol->pData; - for (int32_t i = start; i < numOfRows + pInput->startRowIndex; ++i) { - if (pCol->hasNull && colDataIsNull_f(pCol->nullbitmap, i)) { - continue; + numOfElem += 1; + pAvgRes->count += 1; + pAvgRes->sum.dsum += plist[i]; } - - numOfElem += 1; - pAvgRes->count += 1; - pAvgRes->sum.isum += plist[i]; + break; } - break; - } - case TSDB_DATA_TYPE_FLOAT: { - float* plist = (float*)pCol->pData; - for (int32_t i = start; i < numOfRows + pInput->startRowIndex; ++i) { - if (pCol->hasNull && colDataIsNull_f(pCol->nullbitmap, i)) { - continue; + case TSDB_DATA_TYPE_DOUBLE: { + double* plist = (double*)pCol->pData; + for (int32_t i = start; i < numOfRows + pInput->startRowIndex; ++i) { + if (pCol->hasNull && colDataIsNull_f(pCol->nullbitmap, i)) { + continue; + } + + numOfElem += 1; + pAvgRes->count += 1; + pAvgRes->sum.dsum += plist[i]; } - - numOfElem += 1; - pAvgRes->count += 1; - pAvgRes->sum.dsum += plist[i]; + break; } - break; + + default: + break; } - - case TSDB_DATA_TYPE_DOUBLE: { - double* plist = (double*)pCol->pData; - for (int32_t i = start; i < numOfRows + pInput->startRowIndex; ++i) { - if (pCol->hasNull && colDataIsNull_f(pCol->nullbitmap, i)) { - continue; - } - - numOfElem += 1; - pAvgRes->count += 1; - pAvgRes->sum.dsum += plist[i]; - } - break; - } - - default: - break; } _avg_over: @@ -766,18 +774,49 @@ _avg_over: return TSDB_CODE_SUCCESS; } -#define LIST_AVG_N(sumT, T) \ - do { \ - T* plist = (T*)pCol->pData; \ - for (int32_t i = start; i < numOfRows + pInput->startRowIndex; ++i) { \ - if (pCol->hasNull && colDataIsNull_f(pCol->nullbitmap, i)) { \ - continue; \ - } \ - \ - numOfElem += 1; \ - pAvgRes->count -= 1; \ - sumT -= plist[i]; \ - } \ +static void avgTransferInfo(SAvgRes* pInput, SAvgRes* pOutput) { + pOutput->type = pInput->type; + if (IS_INTEGER_TYPE(pOutput->type)) { + pOutput->sum.isum += pInput->sum.isum; + } else { + pOutput->sum.dsum += pInput->sum.dsum; + } + + pOutput->count += pInput->count; + + return; +} + +int32_t avgFunctionMerge(SqlFunctionCtx* pCtx) { + SInputColumnInfoData* pInput = &pCtx->input; + SColumnInfoData* pCol = pInput->pData[0]; + ASSERT(pCol->info.type == TSDB_DATA_TYPE_BINARY); + + SAvgRes* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); + + int32_t start = pInput->startRowIndex; + char* data = colDataGetData(pCol, start); + SAvgRes* pInputInfo = (SAvgRes*)varDataVal(data); + + avgTransferInfo(pInputInfo, pInfo); + + SET_VAL(GET_RES_INFO(pCtx), 1, 1); + + return TSDB_CODE_SUCCESS; +} + +#define LIST_AVG_N(sumT, T) \ + do { \ + T* plist = (T*)pCol->pData; \ + for (int32_t i = start; i < numOfRows + pInput->startRowIndex; ++i) { \ + if (pCol->hasNull && colDataIsNull_f(pCol->nullbitmap, i)) { \ + continue; \ + } \ + \ + numOfElem += 1; \ + pAvgRes->count -= 1; \ + sumT -= plist[i]; \ + } \ } while (0) int32_t avgInvertFunction(SqlFunctionCtx* pCtx) { @@ -831,11 +870,11 @@ int32_t avgInvertFunction(SqlFunctionCtx* pCtx) { int32_t avgCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); - SAvgRes* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); - int32_t type = pDestCtx->input.pData[0]->info.type; + SAvgRes* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); + int32_t type = pDestCtx->input.pData[0]->info.type; SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); - SAvgRes* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); + SAvgRes* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); if (IS_INTEGER_TYPE(type)) { pDBuf->sum.isum += pSBuf->sum.isum; @@ -850,8 +889,8 @@ int32_t avgCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { int32_t avgFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SInputColumnInfoData* pInput = &pCtx->input; - int32_t type = pInput->pData[0]->info.type; SAvgRes* pAvgRes = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); + int32_t type = pAvgRes->type; if (IS_INTEGER_TYPE(type)) { pAvgRes->result = pAvgRes->sum.isum / ((double)pAvgRes->count); @@ -859,7 +898,7 @@ int32_t avgFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { pAvgRes->result = pAvgRes->sum.dsum / ((double)pAvgRes->count); } - //check for overflow + // check for overflow if (isinf(pAvgRes->result) || isnan(pAvgRes->result)) { GET_RES_INFO(pCtx)->isNullRes = 1; } @@ -867,12 +906,30 @@ int32_t avgFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { return functionFinalize(pCtx, pBlock); } +int32_t avgPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { + SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); + SAvgRes* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); + int32_t resultBytes = getAvgInfoSize(); + char* res = taosMemoryCalloc(resultBytes + VARSTR_HEADER_SIZE, sizeof(char)); + + memcpy(varDataVal(res), pInfo, resultBytes); + varDataSetLen(res, resultBytes); + + int32_t slotId = pCtx->pExpr->base.resSchema.slotId; + SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); + + colDataAppend(pCol, pBlock->info.rows, res, false); + + taosMemoryFree(res); + return pResInfo->numOfRes; +} + EFuncDataRequired statisDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow) { return FUNC_DATA_REQUIRED_STATIS_LOAD; } typedef struct SMinmaxResInfo { - bool assign; // assign the first value or not + bool assign; // assign the first value or not int64_t v; STuplePos tuplePos; } SMinmaxResInfo; @@ -906,7 +963,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { int32_t type = pCol->info.type; SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); - SMinmaxResInfo *pBuf = GET_ROWCELL_INTERBUF(pResInfo); + SMinmaxResInfo* pBuf = GET_ROWCELL_INTERBUF(pResInfo); if (IS_NULL_TYPE(type)) { GET_RES_INFO(pCtx)->isNullRes = 1; @@ -1282,7 +1339,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { numOfElems += 1; } } else if (type == TSDB_DATA_TYPE_FLOAT) { - float* pData = (float*)pCol->pData; + float* pData = (float*)pCol->pData; double* val = (double*)&pBuf->v; for (int32_t i = start; i < start + numOfRows; ++i) { @@ -1330,7 +1387,8 @@ int32_t maxFunction(SqlFunctionCtx* pCtx) { return TSDB_CODE_SUCCESS; } -static void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuplePos *pTuplePos, int32_t rowIndex); +static void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuplePos* pTuplePos, + int32_t rowIndex); int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(pCtx); @@ -1344,7 +1402,7 @@ int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { pEntryInfo->isNullRes = (pEntryInfo->numOfRes == 0); if (pCol->info.type == TSDB_DATA_TYPE_FLOAT) { - float v = *(double*) &pRes->v; + float v = *(double*)&pRes->v; colDataAppend(pCol, currentRow, (const char*)&v, pEntryInfo->isNullRes); } else { colDataAppend(pCol, currentRow, (const char*)&pRes->v, pEntryInfo->isNullRes); @@ -1357,7 +1415,7 @@ int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { return pEntryInfo->numOfRes; } -void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuplePos *pTuplePos, int32_t rowIndex) { +void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuplePos* pTuplePos, int32_t rowIndex) { int32_t pageId = pTuplePos->pageId; int32_t offset = pTuplePos->offset; if (pTuplePos->pageId != -1) { @@ -1392,7 +1450,7 @@ void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuple void releaseSource(STuplePos* pPos) { if (pPos->pageId == -1) { - return ; + return; } // Todo(liuyao) relase row } @@ -1405,18 +1463,17 @@ void replaceTupleData(STuplePos* pDestPos, STuplePos* pSourcePos) { int32_t minMaxCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx, int32_t isMinFunc) { SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); SMinmaxResInfo* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); - int32_t type = pDestCtx->input.pData[0]->info.type; + int32_t type = pDestCtx->input.pData[0]->info.type; SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); SMinmaxResInfo* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); if (IS_FLOAT_TYPE(type)) { - if (pSBuf->assign && - ( (((*(double*)&pDBuf->v) < (*(double*)&pSBuf->v)) ^ isMinFunc) || !pDBuf->assign ) ) { - *(double*) &pDBuf->v = *(double*) &pSBuf->v; + if (pSBuf->assign && ((((*(double*)&pDBuf->v) < (*(double*)&pSBuf->v)) ^ isMinFunc) || !pDBuf->assign)) { + *(double*)&pDBuf->v = *(double*)&pSBuf->v; replaceTupleData(&pDBuf->tuplePos, &pSBuf->tuplePos); } } else { - if ( pSBuf->assign && ( ((pDBuf->v < pSBuf->v) ^ isMinFunc) || !pDBuf->assign ) ) { + if (pSBuf->assign && (((pDBuf->v < pSBuf->v) ^ isMinFunc) || !pDBuf->assign)) { pDBuf->v = pSBuf->v; replaceTupleData(&pDBuf->tuplePos, &pSBuf->tuplePos); } @@ -1432,6 +1489,8 @@ int32_t maxCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { return minMaxCombine(pDestCtx, pSourceCtx, 0); } +int32_t getStddevInfoSize() { return (int32_t)sizeof(SStddevRes); } + bool getStddevFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { pEnv->calcMemSize = sizeof(SStddevRes); return true; @@ -1455,6 +1514,7 @@ int32_t stddevFunction(SqlFunctionCtx* pCtx) { int32_t type = pInput->pData[0]->info.type; SStddevRes* pStddevRes = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); + pStddevRes->type = type; // computing based on the true data block SColumnInfoData* pCol = pInput->pData[0]; @@ -1571,6 +1631,39 @@ _stddev_over: return TSDB_CODE_SUCCESS; } +static void stddevTransferInfo(SStddevRes* pInput, SStddevRes* pOutput) { + pOutput->type = pInput->type; + if (IS_INTEGER_TYPE(pOutput->type)) { + pOutput->quadraticISum += pInput->quadraticISum; + pOutput->isum += pInput->isum; + } else { + pOutput->quadraticDSum += pInput->quadraticDSum; + pOutput->dsum += pInput->dsum; + } + + pOutput->count += pInput->count; + + return; +} + +int32_t stddevFunctionMerge(SqlFunctionCtx* pCtx) { + SInputColumnInfoData* pInput = &pCtx->input; + SColumnInfoData* pCol = pInput->pData[0]; + ASSERT(pCol->info.type == TSDB_DATA_TYPE_BINARY); + + SStddevRes* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); + + int32_t start = pInput->startRowIndex; + char* data = colDataGetData(pCol, start); + SStddevRes* pInputInfo = (SStddevRes*)varDataVal(data); + + stddevTransferInfo(pInputInfo, pInfo); + + SET_VAL(GET_RES_INFO(pCtx), 1, 1); + + return TSDB_CODE_SUCCESS; +} + #define LIST_STDDEV_SUB_N(sumT, T) \ do { \ T* plist = (T*)pCol->pData; \ @@ -1584,7 +1677,7 @@ _stddev_over: pStddevRes->quadraticISum -= plist[i] * plist[i]; \ } \ } while (0) - + int32_t stddevInvertFunction(SqlFunctionCtx* pCtx) { int32_t numOfElem = 0; @@ -1636,9 +1729,10 @@ int32_t stddevInvertFunction(SqlFunctionCtx* pCtx) { int32_t stddevFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SInputColumnInfoData* pInput = &pCtx->input; - int32_t type = pInput->pData[0]->info.type; SStddevRes* pStddevRes = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); + int32_t type = pStddevRes->type; double avg; + if (IS_INTEGER_TYPE(type)) { avg = pStddevRes->isum / ((double)pStddevRes->count); pStddevRes->result = sqrt(pStddevRes->quadraticISum / ((double)pStddevRes->count) - avg * avg); @@ -1650,13 +1744,31 @@ int32_t stddevFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { return functionFinalize(pCtx, pBlock); } +int32_t stddevPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { + SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); + SStddevRes* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); + int32_t resultBytes = getStddevInfoSize(); + char* res = taosMemoryCalloc(resultBytes + VARSTR_HEADER_SIZE, sizeof(char)); + + memcpy(varDataVal(res), pInfo, resultBytes); + varDataSetLen(res, resultBytes); + + int32_t slotId = pCtx->pExpr->base.resSchema.slotId; + SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); + + colDataAppend(pCol, pBlock->info.rows, res, false); + + taosMemoryFree(res); + return pResInfo->numOfRes; +} + int32_t stddevCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); - SStddevRes* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); - int32_t type = pDestCtx->input.pData[0]->info.type; + SStddevRes* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); + int32_t type = pDestCtx->input.pData[0]->info.type; SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); - SStddevRes* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); + SStddevRes* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); if (IS_INTEGER_TYPE(type)) { pDBuf->isum += pSBuf->isum; @@ -1682,10 +1794,8 @@ bool leastSQRFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInf SLeastSQRInfo* pInfo = GET_ROWCELL_INTERBUF(pResultInfo); - pInfo->startVal = IS_FLOAT_TYPE(pCtx->param[1].param.nType) ? pCtx->param[1].param.d : - (double)pCtx->param[1].param.i; - pInfo->stepVal = IS_FLOAT_TYPE(pCtx->param[2].param.nType) ? pCtx->param[2].param.d : - (double)pCtx->param[2].param.i; + pInfo->startVal = IS_FLOAT_TYPE(pCtx->param[1].param.nType) ? pCtx->param[1].param.d : (double)pCtx->param[1].param.i; + pInfo->stepVal = IS_FLOAT_TYPE(pCtx->param[2].param.nType) ? pCtx->param[2].param.d : (double)pCtx->param[2].param.i; return true; } @@ -1812,9 +1922,9 @@ int32_t leastSQRFunction(SqlFunctionCtx* pCtx) { int32_t leastSQRFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); - SLeastSQRInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - int32_t slotId = pCtx->pExpr->base.resSchema.slotId; - SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); + SLeastSQRInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); + int32_t slotId = pCtx->pExpr->base.resSchema.slotId; + SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); int32_t currentRow = pBlock->info.rows; @@ -1836,8 +1946,9 @@ int32_t leastSQRFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { param12 /= param[1][1]; - char buf[64] = {0}; - size_t len = snprintf(varDataVal(buf), sizeof(buf) - VARSTR_HEADER_SIZE, "{slop:%.6lf, intercept:%.6lf}", param02, param12); + char buf[64] = {0}; + size_t len = + snprintf(varDataVal(buf), sizeof(buf) - VARSTR_HEADER_SIZE, "{slop:%.6lf, intercept:%.6lf}", param02, param12); varDataSetLen(buf, len); colDataAppend(pCol, currentRow, buf, pResInfo->isNullRes); @@ -1846,7 +1957,7 @@ int32_t leastSQRFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { } int32_t leastSQRInvertFunction(SqlFunctionCtx* pCtx) { - //TODO + // TODO return TSDB_CODE_SUCCESS; } @@ -1854,11 +1965,11 @@ int32_t leastSQRCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); SLeastSQRInfo* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); int32_t type = pDestCtx->input.pData[0]->info.type; - double (*pDparam)[3] = pDBuf->matrix; + double(*pDparam)[3] = pDBuf->matrix; SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); SLeastSQRInfo* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); - double (*pSparam)[3] = pSBuf->matrix; + double(*pSparam)[3] = pSBuf->matrix; for (int32_t i = 0; i < pSBuf->num; i++) { pDparam[0][0] += pDBuf->startVal * pDBuf->startVal; pDparam[0][1] += pDBuf->startVal; @@ -1996,19 +2107,21 @@ int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { } bool getApercentileFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { - int32_t bytesHist = (int32_t)(sizeof(SAPercentileInfo) + sizeof(SHistogramInfo) + sizeof(SHistBin) * (MAX_HISTOGRAM_BIN + 1)); + int32_t bytesHist = + (int32_t)(sizeof(SAPercentileInfo) + sizeof(SHistogramInfo) + sizeof(SHistBin) * (MAX_HISTOGRAM_BIN + 1)); int32_t bytesDigest = (int32_t)(sizeof(SAPercentileInfo) + TDIGEST_SIZE(COMPRESSION)); pEnv->calcMemSize = TMAX(bytesHist, bytesDigest); return true; } int32_t getApercentileMaxSize() { - int32_t bytesHist = (int32_t)(sizeof(SAPercentileInfo) + sizeof(SHistogramInfo) + sizeof(SHistBin) * (MAX_HISTOGRAM_BIN + 1)); + int32_t bytesHist = + (int32_t)(sizeof(SAPercentileInfo) + sizeof(SHistogramInfo) + sizeof(SHistBin) * (MAX_HISTOGRAM_BIN + 1)); int32_t bytesDigest = (int32_t)(sizeof(SAPercentileInfo) + TDIGEST_SIZE(COMPRESSION)); return TMAX(bytesHist, bytesDigest); } -static int8_t getApercentileAlgo(char *algoStr) { +static int8_t getApercentileAlgo(char* algoStr) { int8_t algoType; if (strcasecmp(algoStr, "default") == 0) { algoType = APERCT_ALGO_DEFAULT; @@ -2022,8 +2135,8 @@ static int8_t getApercentileAlgo(char *algoStr) { } static void buildHistogramInfo(SAPercentileInfo* pInfo) { - pInfo->pHisto = (SHistogramInfo*) ((char*)pInfo + sizeof(SAPercentileInfo)); - pInfo->pHisto->elems = (SHistBin*) ((char*)pInfo->pHisto + sizeof(SHistogramInfo)); + pInfo->pHisto = (SHistogramInfo*)((char*)pInfo + sizeof(SAPercentileInfo)); + pInfo->pHisto->elems = (SHistBin*)((char*)pInfo->pHisto + sizeof(SHistogramInfo)); } static void buildTDigestInfo(SAPercentileInfo* pInfo) { @@ -2049,7 +2162,7 @@ bool apercentileFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResult } } - char *tmp = (char *)pInfo + sizeof(SAPercentileInfo); + char* tmp = (char*)pInfo + sizeof(SAPercentileInfo); if (pInfo->algo == APERCT_ALGO_TDIGEST) { pInfo->pTDigest = tdigestNewFrom(tmp, COMPRESSION); } else { @@ -2065,7 +2178,7 @@ int32_t apercentileFunction(SqlFunctionCtx* pCtx) { SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); SInputColumnInfoData* pInput = &pCtx->input; - //SColumnDataAgg* pAgg = pInput->pColumnDataAgg[0]; + // SColumnDataAgg* pAgg = pInput->pColumnDataAgg[0]; SColumnInfoData* pCol = pInput->pData[0]; int32_t type = pCol->info.type; @@ -2081,8 +2194,8 @@ int32_t apercentileFunction(SqlFunctionCtx* pCtx) { numOfElems += 1; char* data = colDataGetData(pCol, i); - double v = 0; // value - int64_t w = 1; // weigth + double v = 0; // value + int64_t w = 1; // weigth GET_TYPED_DATA(v, double, type, data); tdigestAdd(pInfo->pTDigest, v, w); } @@ -2111,14 +2224,14 @@ static void apercentileTransferInfo(SAPercentileInfo* pInput, SAPercentileInfo* buildTDigestInfo(pInput); tdigestAutoFill(pInput->pTDigest, COMPRESSION); - if(pInput->pTDigest->num_centroids == 0 && pInput->pTDigest->num_buffered_pts == 0) { + if (pInput->pTDigest->num_centroids == 0 && pInput->pTDigest->num_buffered_pts == 0) { return; } buildTDigestInfo(pOutput); - TDigest *pTDigest = pOutput->pTDigest; + TDigest* pTDigest = pOutput->pTDigest; - if(pTDigest->num_centroids <= 0) { + if (pTDigest->num_centroids <= 0) { memcpy(pTDigest, pInput->pTDigest, (size_t)TDIGEST_SIZE(COMPRESSION)); tdigestAutoFill(pTDigest, COMPRESSION); } else { @@ -2131,16 +2244,16 @@ static void apercentileTransferInfo(SAPercentileInfo* pInput, SAPercentileInfo* } buildHistogramInfo(pOutput); - SHistogramInfo *pHisto = pOutput->pHisto; + SHistogramInfo* pHisto = pOutput->pHisto; if (pHisto->numOfElems <= 0) { memcpy(pHisto, pInput->pHisto, sizeof(SHistogramInfo) + sizeof(SHistBin) * (MAX_HISTOGRAM_BIN + 1)); - pHisto->elems = (SHistBin*) ((char *)pHisto + sizeof(SHistogramInfo)); + pHisto->elems = (SHistBin*)((char*)pHisto + sizeof(SHistogramInfo)); } else { - pHisto->elems = (SHistBin*) ((char *)pHisto + sizeof(SHistogramInfo)); - SHistogramInfo *pRes = tHistogramMerge(pHisto, pInput->pHisto, MAX_HISTOGRAM_BIN); + pHisto->elems = (SHistBin*)((char*)pHisto + sizeof(SHistogramInfo)); + SHistogramInfo* pRes = tHistogramMerge(pHisto, pInput->pHisto, MAX_HISTOGRAM_BIN); memcpy(pHisto, pRes, sizeof(SHistogramInfo) + sizeof(SHistBin) * MAX_HISTOGRAM_BIN); - pHisto->elems = (SHistBin*) ((char *)pHisto + sizeof(SHistogramInfo)); + pHisto->elems = (SHistBin*)((char*)pHisto + sizeof(SHistogramInfo)); tHistogramDestroy(&pRes); } } @@ -2156,9 +2269,9 @@ int32_t apercentileFunctionMerge(SqlFunctionCtx* pCtx) { SAPercentileInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); - int32_t start = pInput->startRowIndex; - char* data = colDataGetData(pCol, start); - SAPercentileInfo* pInputInfo = (SAPercentileInfo *)varDataVal(data); + int32_t start = pInput->startRowIndex; + char* data = colDataGetData(pCol, start); + SAPercentileInfo* pInputInfo = (SAPercentileInfo*)varDataVal(data); apercentileTransferInfo(pInputInfo, pInfo); @@ -2168,24 +2281,24 @@ int32_t apercentileFunctionMerge(SqlFunctionCtx* pCtx) { int32_t apercentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); - SAPercentileInfo* pInfo = (SAPercentileInfo*)GET_ROWCELL_INTERBUF(pResInfo); + SAPercentileInfo* pInfo = (SAPercentileInfo*)GET_ROWCELL_INTERBUF(pResInfo); if (pInfo->algo == APERCT_ALGO_TDIGEST) { if (pInfo->pTDigest->size > 0) { pInfo->result = tdigestQuantile(pInfo->pTDigest, pInfo->percent / 100); } else { // no need to free - //setNull(pCtx->pOutput, pCtx->outputType, pCtx->outputBytes); + // setNull(pCtx->pOutput, pCtx->outputType, pCtx->outputBytes); return TSDB_CODE_SUCCESS; } } else { if (pInfo->pHisto->numOfElems > 0) { - double ratio[] = {pInfo->percent}; - double *res = tHistogramUniform(pInfo->pHisto, ratio, 1); + double ratio[] = {pInfo->percent}; + double* res = tHistogramUniform(pInfo->pHisto, ratio, 1); pInfo->result = *res; - //memcpy(pCtx->pOutput, res, sizeof(double)); + // memcpy(pCtx->pOutput, res, sizeof(double)); taosMemoryFree(res); } else { // no need to free - //setNull(pCtx->pOutput, pCtx->outputType, pCtx->outputBytes); + // setNull(pCtx->pOutput, pCtx->outputType, pCtx->outputBytes); return TSDB_CODE_SUCCESS; } } @@ -2195,10 +2308,10 @@ int32_t apercentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t apercentilePartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); - SAPercentileInfo* pInfo = (SAPercentileInfo*)GET_ROWCELL_INTERBUF(pResInfo); + SAPercentileInfo* pInfo = (SAPercentileInfo*)GET_ROWCELL_INTERBUF(pResInfo); int32_t resultBytes = getApercentileMaxSize(); - char *res = taosMemoryCalloc(resultBytes + VARSTR_HEADER_SIZE, sizeof(char)); + char* res = taosMemoryCalloc(resultBytes + VARSTR_HEADER_SIZE, sizeof(char)); if (pInfo->algo == APERCT_ALGO_TDIGEST) { if (pInfo->pTDigest->size > 0) { @@ -2237,21 +2350,25 @@ int32_t apercentileCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) } else { SHistogramInfo* pTmp = tHistogramMerge(pDBuf->pHisto, pSBuf->pHisto, MAX_HISTOGRAM_BIN); memcpy(pDBuf->pHisto, pTmp, sizeof(SHistogramInfo) + sizeof(SHistBin) * (MAX_HISTOGRAM_BIN + 1)); - pDBuf->pHisto->elems = (SHistBin*) ((char *)pDBuf->pHisto + sizeof(SHistogramInfo)); + pDBuf->pHisto->elems = (SHistBin*)((char*)pDBuf->pHisto + sizeof(SHistogramInfo)); tHistogramDestroy(&pTmp); } pDResInfo->numOfRes = TMAX(pDResInfo->numOfRes, pSResInfo->numOfRes); return TSDB_CODE_SUCCESS; } +int32_t getFirstLastInfoSize(int32_t resBytes) { + return sizeof(SFirstLastRes) + resBytes + sizeof(int64_t); +} + bool getFirstLastFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { - SColumnNode* pNode = nodesListGetNode(pFunc->pParameterList, 0); - pEnv->calcMemSize = pNode->node.resType.bytes + sizeof(int64_t); + SColumnNode* pNode = (SColumnNode *)nodesListGetNode(pFunc->pParameterList, 0); + pEnv->calcMemSize = sizeof(SFirstLastRes) + pNode->node.resType.bytes + sizeof(int64_t); return true; } bool getSelectivityFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { - SColumnNode* pNode = nodesListGetNode(pFunc->pParameterList, 0); + SColumnNode* pNode = (SColumnNode*)nodesListGetNode(pFunc->pParameterList, 0); pEnv->calcMemSize = pNode->node.resType.bytes; return true; } @@ -2270,12 +2387,13 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) { int32_t numOfElems = 0; SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); - char* buf = GET_ROWCELL_INTERBUF(pResInfo); + SFirstLastRes *pInfo = GET_ROWCELL_INTERBUF(pResInfo); SInputColumnInfoData* pInput = &pCtx->input; SColumnInfoData* pInputCol = pInput->pData[0]; int32_t bytes = pInputCol->info.bytes; + pInfo->bytes = bytes; // All null data column, return directly. if (pInput->colDataAggIsSet && (pInput->pColumnDataAgg[0]->numOfNull == pInput->totalRows)) { @@ -2293,7 +2411,7 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) { if (blockDataOrder == TSDB_ORDER_ASC) { // filter according to current result firstly if (pResInfo->numOfRes > 0) { - TSKEY ts = *(TSKEY*)(buf + bytes); + TSKEY ts = *(TSKEY*)(pInfo->buf + bytes); if (ts < startKey) { return TSDB_CODE_SUCCESS; } @@ -2309,9 +2427,10 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) { char* data = colDataGetData(pInputCol, i); TSKEY cts = getRowPTs(pInput->pPTS, i); - if (pResInfo->numOfRes == 0 || *(TSKEY*)(buf + bytes) > cts) { - memcpy(buf, data, bytes); - *(TSKEY*)(buf + bytes) = cts; + if (pResInfo->numOfRes == 0 || *(TSKEY*)(pInfo->buf + bytes) > cts) { + memcpy(pInfo->buf, data, bytes); + *(TSKEY*)(pInfo->buf + bytes) = cts; + pInfo->hasResult = true; // DO_UPDATE_TAG_COLUMNS(pCtx, ts); pResInfo->numOfRes = 1; @@ -2322,7 +2441,7 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) { // in case of descending order time stamp serial, which usually happens as the results of the nest query, // all data needs to be check. if (pResInfo->numOfRes > 0) { - TSKEY ts = *(TSKEY*)(buf + bytes); + TSKEY ts = *(TSKEY*)(pInfo->buf + bytes); if (ts < endKey) { return TSDB_CODE_SUCCESS; } @@ -2338,9 +2457,10 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) { char* data = colDataGetData(pInputCol, i); TSKEY cts = getRowPTs(pInput->pPTS, i); - if (pResInfo->numOfRes == 0 || *(TSKEY*)(buf + bytes) > cts) { - memcpy(buf, data, bytes); - *(TSKEY*)(buf + bytes) = cts; + if (pResInfo->numOfRes == 0 || *(TSKEY*)(pInfo->buf + bytes) > cts) { + memcpy(pInfo->buf, data, bytes); + *(TSKEY*)(pInfo->buf + bytes) = cts; + pInfo->hasResult = true; // DO_UPDATE_TAG_COLUMNS(pCtx, ts); pResInfo->numOfRes = 1; break; @@ -2356,12 +2476,13 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { int32_t numOfElems = 0; SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); - char* buf = GET_ROWCELL_INTERBUF(pResInfo); + SFirstLastRes *pInfo = GET_ROWCELL_INTERBUF(pResInfo); SInputColumnInfoData* pInput = &pCtx->input; SColumnInfoData* pInputCol = pInput->pData[0]; int32_t bytes = pInputCol->info.bytes; + pInfo->bytes = bytes; // All null data column, return directly. if (pInput->colDataAggIsSet && (pInput->pColumnDataAgg[0]->numOfNull == pInput->totalRows)) { @@ -2386,10 +2507,11 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { char* data = colDataGetData(pInputCol, i); TSKEY cts = getRowPTs(pInput->pPTS, i); - if (pResInfo->numOfRes == 0 || *(TSKEY*)(buf + bytes) < cts) { - memcpy(buf, data, bytes); - *(TSKEY*)(buf + bytes) = cts; + if (pResInfo->numOfRes == 0 || *(TSKEY*)(pInfo->buf + bytes) < cts) { + memcpy(pInfo->buf, data, bytes); + *(TSKEY*)(pInfo->buf + bytes) = cts; // DO_UPDATE_TAG_COLUMNS(pCtx, ts); + pInfo->hasResult = true; pResInfo->numOfRes = 1; } break; @@ -2404,9 +2526,10 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { char* data = colDataGetData(pInputCol, i); TSKEY cts = getRowPTs(pInput->pPTS, i); - if (pResInfo->numOfRes == 0 || *(TSKEY*)(buf + bytes) < cts) { - memcpy(buf, data, bytes); - *(TSKEY*)(buf + bytes) = cts; + if (pResInfo->numOfRes == 0 || *(TSKEY*)(pInfo->buf + bytes) < cts) { + memcpy(pInfo->buf, data, bytes); + *(TSKEY*)(pInfo->buf + bytes) = cts; + pInfo->hasResult = true; pResInfo->numOfRes = 1; // DO_UPDATE_TAG_COLUMNS(pCtx, ts); } @@ -2418,6 +2541,56 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { return TSDB_CODE_SUCCESS; } +static void firstLastTransferInfo(SFirstLastRes* pInput, SFirstLastRes* pOutput, bool isFirst) { + if (!pInput->hasResult) { + return; + } + pOutput->bytes = pInput->bytes; + TSKEY *tsIn = (TSKEY*)(pInput->buf + pInput->bytes); + TSKEY *tsOut = (TSKEY*)(pOutput->buf + pInput->bytes); + if (pOutput->hasResult) { + if (isFirst) { + if (*tsIn > *tsOut) { + return; + } + } else { + if (*tsIn < *tsOut) { + return; + } + } + } + *tsOut = *tsIn; + memcpy(pOutput->buf, pInput->buf, pOutput->bytes); + pOutput->hasResult = true; + return; +} + +static int32_t firstLastFunctionMergeImpl(SqlFunctionCtx *pCtx, bool isFirstQuery) { + SInputColumnInfoData* pInput = &pCtx->input; + SColumnInfoData* pCol = pInput->pData[0]; + ASSERT(pCol->info.type == TSDB_DATA_TYPE_BINARY); + + SFirstLastRes* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); + + int32_t start = pInput->startRowIndex; + char* data = colDataGetData(pCol, start); + SFirstLastRes* pInputInfo = (SFirstLastRes *)varDataVal(data); + + firstLastTransferInfo(pInputInfo, pInfo, isFirstQuery); + + SET_VAL(GET_RES_INFO(pCtx), 1, 1); + + return TSDB_CODE_SUCCESS; +} + +int32_t firstFunctionMerge(SqlFunctionCtx *pCtx) { + return firstLastFunctionMergeImpl(pCtx, true); +} + +int32_t lastFunctionMerge(SqlFunctionCtx *pCtx) { + return firstLastFunctionMergeImpl(pCtx, false); +} + int32_t firstLastFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t slotId = pCtx->pExpr->base.resSchema.slotId; SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); @@ -2425,23 +2598,40 @@ int32_t firstLastFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); pResInfo->isNullRes = (pResInfo->numOfRes == 0) ? 1 : 0; - char* in = GET_ROWCELL_INTERBUF(pResInfo); - colDataAppend(pCol, pBlock->info.rows, in, pResInfo->isNullRes); + SFirstLastRes* pRes = GET_ROWCELL_INTERBUF(pResInfo); + colDataAppend(pCol, pBlock->info.rows, pRes->buf, pResInfo->isNullRes); return pResInfo->numOfRes; } +int32_t firstLastPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { + SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(pCtx); + SFirstLastRes* pRes = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); + int32_t resultBytes = getFirstLastInfoSize(pRes->bytes); + char *res = taosMemoryCalloc(resultBytes + VARSTR_HEADER_SIZE, sizeof(char)); + + memcpy(varDataVal(res), pRes, resultBytes); + varDataSetLen(res, resultBytes); + + int32_t slotId = pCtx->pExpr->base.resSchema.slotId; + SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); + + colDataAppend(pCol, pBlock->info.rows, res, false); + + taosMemoryFree(res); + return 1; +} + int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); - char* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); - int32_t type = pDestCtx->input.pData[0]->info.type; - int32_t bytes = pDestCtx->input.pData[0]->info.bytes; + char* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); + int32_t type = pDestCtx->input.pData[0]->info.type; + int32_t bytes = pDestCtx->input.pData[0]->info.bytes; SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); - char* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); + char* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); - if (pSResInfo->numOfRes != 0 && - (pDResInfo->numOfRes == 0 || *(TSKEY*)(pDBuf + bytes) < *(TSKEY*)(pSBuf + bytes)) ) { + if (pSResInfo->numOfRes != 0 && (pDResInfo->numOfRes == 0 || *(TSKEY*)(pDBuf + bytes) < *(TSKEY*)(pSBuf + bytes))) { memcpy(pDBuf, pSBuf, bytes); *(TSKEY*)(pDBuf + bytes) = *(TSKEY*)(pSBuf + bytes); pDResInfo->numOfRes = 1; @@ -2469,31 +2659,38 @@ bool diffFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) { } static void doSetPrevVal(SDiffInfo* pDiffInfo, int32_t type, const char* pv) { - switch(type) { + switch (type) { case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_TINYINT: - pDiffInfo->prev.i64 = *(int8_t*) pv; break; + pDiffInfo->prev.i64 = *(int8_t*)pv; + break; case TSDB_DATA_TYPE_INT: - pDiffInfo->prev.i64 = *(int32_t*) pv; break; + pDiffInfo->prev.i64 = *(int32_t*)pv; + break; case TSDB_DATA_TYPE_SMALLINT: - pDiffInfo->prev.i64 = *(int16_t*) pv; break; + pDiffInfo->prev.i64 = *(int16_t*)pv; + break; case TSDB_DATA_TYPE_BIGINT: - pDiffInfo->prev.i64 = *(int64_t*) pv; break; + pDiffInfo->prev.i64 = *(int64_t*)pv; + break; case TSDB_DATA_TYPE_FLOAT: - pDiffInfo->prev.d64 = *(float *) pv; break; + pDiffInfo->prev.d64 = *(float*)pv; + break; case TSDB_DATA_TYPE_DOUBLE: - pDiffInfo->prev.d64 = *(double*) pv; break; + pDiffInfo->prev.d64 = *(double*)pv; + break; default: ASSERT(0); } } -static void doHandleDiff(SDiffInfo* pDiffInfo, int32_t type, const char* pv, SColumnInfoData* pOutput, int32_t pos, int32_t order) { - int32_t factor = (order == TSDB_ORDER_ASC)? 1:-1; +static void doHandleDiff(SDiffInfo* pDiffInfo, int32_t type, const char* pv, SColumnInfoData* pOutput, int32_t pos, + int32_t order) { + int32_t factor = (order == TSDB_ORDER_ASC) ? 1 : -1; switch (type) { case TSDB_DATA_TYPE_INT: { int32_t v = *(int32_t*)pv; - int64_t delta = factor*(v - pDiffInfo->prev.i64); // direct previous may be null + int64_t delta = factor * (v - pDiffInfo->prev.i64); // direct previous may be null if (delta < 0 && pDiffInfo->ignoreNegative) { colDataSetNull_f(pOutput->nullbitmap, pos); } else { @@ -2504,8 +2701,8 @@ static void doHandleDiff(SDiffInfo* pDiffInfo, int32_t type, const char* pv, SCo } case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_TINYINT: { - int8_t v = *(int8_t*)pv; - int64_t delta = factor*(v - pDiffInfo->prev.i64); // direct previous may be null + int8_t v = *(int8_t*)pv; + int64_t delta = factor * (v - pDiffInfo->prev.i64); // direct previous may be null if (delta < 0 && pDiffInfo->ignoreNegative) { colDataSetNull_f(pOutput->nullbitmap, pos); } else { @@ -2516,7 +2713,7 @@ static void doHandleDiff(SDiffInfo* pDiffInfo, int32_t type, const char* pv, SCo } case TSDB_DATA_TYPE_SMALLINT: { int16_t v = *(int16_t*)pv; - int64_t delta = factor*(v - pDiffInfo->prev.i64); // direct previous may be null + int64_t delta = factor * (v - pDiffInfo->prev.i64); // direct previous may be null if (delta < 0 && pDiffInfo->ignoreNegative) { colDataSetNull_f(pOutput->nullbitmap, pos); } else { @@ -2527,7 +2724,7 @@ static void doHandleDiff(SDiffInfo* pDiffInfo, int32_t type, const char* pv, SCo } case TSDB_DATA_TYPE_BIGINT: { int64_t v = *(int64_t*)pv; - int64_t delta = factor*(v - pDiffInfo->prev.i64); // direct previous may be null + int64_t delta = factor * (v - pDiffInfo->prev.i64); // direct previous may be null if (delta < 0 && pDiffInfo->ignoreNegative) { colDataSetNull_f(pOutput->nullbitmap, pos); } else { @@ -2537,9 +2734,9 @@ static void doHandleDiff(SDiffInfo* pDiffInfo, int32_t type, const char* pv, SCo break; } case TSDB_DATA_TYPE_FLOAT: { - float v = *(float*)pv; - double delta = factor*(v - pDiffInfo->prev.d64); // direct previous may be null - if ((delta < 0 && pDiffInfo->ignoreNegative) || isinf(delta) || isnan(delta)) { //check for overflow + float v = *(float*)pv; + double delta = factor * (v - pDiffInfo->prev.d64); // direct previous may be null + if ((delta < 0 && pDiffInfo->ignoreNegative) || isinf(delta) || isnan(delta)) { // check for overflow colDataSetNull_f(pOutput->nullbitmap, pos); } else { colDataAppendDouble(pOutput, pos, &delta); @@ -2549,8 +2746,8 @@ static void doHandleDiff(SDiffInfo* pDiffInfo, int32_t type, const char* pv, SCo } case TSDB_DATA_TYPE_DOUBLE: { double v = *(double*)pv; - double delta = factor*(v - pDiffInfo->prev.d64); // direct previous may be null - if ((delta < 0 && pDiffInfo->ignoreNegative) || isinf(delta) || isnan(delta)) { //check for overflow + double delta = factor * (v - pDiffInfo->prev.d64); // direct previous may be null + if ((delta < 0 && pDiffInfo->ignoreNegative) || isinf(delta) || isnan(delta)) { // check for overflow colDataSetNull_f(pOutput->nullbitmap, pos); } else { colDataAppendDouble(pOutput, pos, &delta); @@ -2573,7 +2770,7 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) { SColumnInfoData* pTsOutput = pCtx->pTsOutput; int32_t numOfElems = 0; - TSKEY* tsList = (int64_t*)pInput->pPTS->pData; + TSKEY* tsList = (int64_t*)pInput->pPTS->pData; int32_t startOffset = pCtx->offset; SColumnInfoData* pOutput = (SColumnInfoData*)pCtx->pOutput; @@ -2650,9 +2847,7 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) { return numOfElems; } -int32_t getTopBotInfoSize(int64_t numOfItems) { - return sizeof(STopBotRes) + numOfItems * sizeof(STopBotResItem); -} +int32_t getTopBotInfoSize(int64_t numOfItems) { return sizeof(STopBotRes) + numOfItems * sizeof(STopBotResItem); } bool getTopBotFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { SValueNode* pkNode = (SValueNode*)nodesListGetNode(pFunc->pParameterList, 1); @@ -2661,7 +2856,7 @@ bool getTopBotFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { } bool getTopBotMergeFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { - //intermediate result is binary and length contains VAR header size + // intermediate result is binary and length contains VAR header size pEnv->calcMemSize = pFunc->node.resType.bytes; return true; } @@ -2671,7 +2866,7 @@ bool topBotFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) { return false; } - STopBotRes* pRes = GET_ROWCELL_INTERBUF(pResInfo); + STopBotRes* pRes = GET_ROWCELL_INTERBUF(pResInfo); SInputColumnInfoData* pInput = &pCtx->input; pRes->maxSize = pCtx->param[1].param.i; @@ -2747,38 +2942,37 @@ static void topBotTransferInfo(SqlFunctionCtx* pCtx, STopBotRes* pInput, bool is } int32_t topFunctionMerge(SqlFunctionCtx* pCtx) { - SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(pCtx); + SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(pCtx); SInputColumnInfoData* pInput = &pCtx->input; - SColumnInfoData* pCol = pInput->pData[0]; + SColumnInfoData* pCol = pInput->pData[0]; ASSERT(pCol->info.type == TSDB_DATA_TYPE_BINARY); - int32_t start = pInput->startRowIndex; - char* data = colDataGetData(pCol, start); - STopBotRes* pInputInfo = (STopBotRes *)varDataVal(data); + int32_t start = pInput->startRowIndex; + char* data = colDataGetData(pCol, start); + STopBotRes* pInputInfo = (STopBotRes*)varDataVal(data); STopBotRes* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); pInfo->maxSize = pInputInfo->maxSize; - pInfo->type = pInputInfo->type; + pInfo->type = pInputInfo->type; topBotTransferInfo(pCtx, pInputInfo, true); SET_VAL(GET_RES_INFO(pCtx), pEntryInfo->numOfRes, pEntryInfo->numOfRes); return TSDB_CODE_SUCCESS; } - int32_t bottomFunctionMerge(SqlFunctionCtx* pCtx) { - SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(pCtx); + SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(pCtx); SInputColumnInfoData* pInput = &pCtx->input; - SColumnInfoData* pCol = pInput->pData[0]; + SColumnInfoData* pCol = pInput->pData[0]; ASSERT(pCol->info.type == TSDB_DATA_TYPE_BINARY); - int32_t start = pInput->startRowIndex; - char* data = colDataGetData(pCol, start); - STopBotRes* pInputInfo = (STopBotRes *)varDataVal(data); + int32_t start = pInput->startRowIndex; + char* data = colDataGetData(pCol, start); + STopBotRes* pInputInfo = (STopBotRes*)varDataVal(data); STopBotRes* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); pInfo->maxSize = pInputInfo->maxSize; - pInfo->type = pInputInfo->type; + pInfo->type = pInputInfo->type; topBotTransferInfo(pCtx, pInputInfo, false); SET_VAL(GET_RES_INFO(pCtx), pEntryInfo->numOfRes, pEntryInfo->numOfRes); @@ -2838,15 +3032,12 @@ void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSData taosheapsort((void*)pItems, sizeof(STopBotResItem), pEntryInfo->numOfRes, (const void*)&type, topBotResComparFn, !isTopQuery); } else { // replace the minimum value in the result - if ((isTopQuery && ( - (IS_SIGNED_NUMERIC_TYPE(type) && val.i > pItems[0].v.i) || - (IS_UNSIGNED_NUMERIC_TYPE(type) && val.u > pItems[0].v.u) || - (IS_FLOAT_TYPE(type) && val.d > pItems[0].v.d))) - || (!isTopQuery && ( - (IS_SIGNED_NUMERIC_TYPE(type) && val.i < pItems[0].v.i) || - (IS_UNSIGNED_NUMERIC_TYPE(type) && val.u < pItems[0].v.u) || - (IS_FLOAT_TYPE(type) && val.d < pItems[0].v.d)) - )) { + if ((isTopQuery && ((IS_SIGNED_NUMERIC_TYPE(type) && val.i > pItems[0].v.i) || + (IS_UNSIGNED_NUMERIC_TYPE(type) && val.u > pItems[0].v.u) || + (IS_FLOAT_TYPE(type) && val.d > pItems[0].v.d))) || + (!isTopQuery && ((IS_SIGNED_NUMERIC_TYPE(type) && val.i < pItems[0].v.i) || + (IS_UNSIGNED_NUMERIC_TYPE(type) && val.u < pItems[0].v.u) || + (IS_FLOAT_TYPE(type) && val.d < pItems[0].v.d)))) { // replace the old data and the coresponding tuple data STopBotResItem* pItem = &pItems[0]; pItem->v = val; @@ -2965,9 +3156,7 @@ int32_t topBotFinalizeImpl(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, bool isMer return pEntryInfo->numOfRes; } -int32_t topBotFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { - return topBotFinalizeImpl(pCtx, pBlock, false); -} +int32_t topBotFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { return topBotFinalizeImpl(pCtx, pBlock, false); } int32_t topBotMergeFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { return topBotFinalizeImpl(pCtx, pBlock, true); @@ -2975,9 +3164,9 @@ int32_t topBotMergeFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t topBotPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(pCtx); - STopBotRes* pRes = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - int32_t resultBytes = getTopBotInfoSize(pRes->maxSize); - char *res = taosMemoryCalloc(resultBytes + VARSTR_HEADER_SIZE, sizeof(char)); + STopBotRes* pRes = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); + int32_t resultBytes = getTopBotInfoSize(pRes->maxSize); + char* res = taosMemoryCalloc(resultBytes + VARSTR_HEADER_SIZE, sizeof(char)); memcpy(varDataVal(res), pRes, resultBytes); varDataSetLen(res, resultBytes); @@ -2991,11 +3180,10 @@ int32_t topBotPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { return 1; } -void addResult(SqlFunctionCtx* pCtx, STopBotResItem* pSourceItem, int16_t type, - bool isTopQuery) { +void addResult(SqlFunctionCtx* pCtx, STopBotResItem* pSourceItem, int16_t type, bool isTopQuery) { SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(pCtx); - STopBotRes* pRes = getTopBotOutputInfo(pCtx); - STopBotResItem* pItems = pRes->pItems; + STopBotRes* pRes = getTopBotOutputInfo(pCtx); + STopBotResItem* pItems = pRes->pItems; assert(pItems != NULL); // not full yet @@ -3011,15 +3199,12 @@ void addResult(SqlFunctionCtx* pCtx, STopBotResItem* pSourceItem, int16_t type, taosheapsort((void*)pItems, sizeof(STopBotResItem), pEntryInfo->numOfRes, (const void*)&type, topBotResComparFn, !isTopQuery); } else { // replace the minimum value in the result - if ((isTopQuery && ( - (IS_SIGNED_NUMERIC_TYPE(type) && pSourceItem->v.i > pItems[0].v.i) || - (IS_UNSIGNED_NUMERIC_TYPE(type) && pSourceItem->v.u > pItems[0].v.u) || - (IS_FLOAT_TYPE(type) && pSourceItem->v.d > pItems[0].v.d))) - || (!isTopQuery && ( - (IS_SIGNED_NUMERIC_TYPE(type) && pSourceItem->v.i < pItems[0].v.i) || - (IS_UNSIGNED_NUMERIC_TYPE(type) && pSourceItem->v.u < pItems[0].v.u) || - (IS_FLOAT_TYPE(type) && pSourceItem->v.d < pItems[0].v.d)) - )) { + if ((isTopQuery && ((IS_SIGNED_NUMERIC_TYPE(type) && pSourceItem->v.i > pItems[0].v.i) || + (IS_UNSIGNED_NUMERIC_TYPE(type) && pSourceItem->v.u > pItems[0].v.u) || + (IS_FLOAT_TYPE(type) && pSourceItem->v.d > pItems[0].v.d))) || + (!isTopQuery && ((IS_SIGNED_NUMERIC_TYPE(type) && pSourceItem->v.i < pItems[0].v.i) || + (IS_UNSIGNED_NUMERIC_TYPE(type) && pSourceItem->v.u < pItems[0].v.u) || + (IS_FLOAT_TYPE(type) && pSourceItem->v.d < pItems[0].v.d)))) { // replace the old data and the coresponding tuple data STopBotResItem* pItem = &pItems[0]; pItem->v = pSourceItem->v; @@ -3034,7 +3219,7 @@ void addResult(SqlFunctionCtx* pCtx, STopBotResItem* pSourceItem, int16_t type, } int32_t topCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { - int32_t type = pDestCtx->input.pData[0]->info.type; + int32_t type = pDestCtx->input.pData[0]->info.type; SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); STopBotRes* pSBuf = getTopBotOutputInfo(pSourceCtx); for (int32_t i = 0; i < pSResInfo->numOfRes; i++) { @@ -3044,7 +3229,7 @@ int32_t topCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { } int32_t bottomCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { - int32_t type = pDestCtx->input.pData[0]->info.type; + int32_t type = pDestCtx->input.pData[0]->info.type; SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); STopBotRes* pSBuf = getTopBotOutputInfo(pSourceCtx); for (int32_t i = 0; i < pSResInfo->numOfRes; i++) { @@ -3053,16 +3238,14 @@ int32_t bottomCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { return TSDB_CODE_SUCCESS; } -int32_t getSpreadInfoSize() { - return (int32_t)sizeof(SSpreadInfo); -} +int32_t getSpreadInfoSize() { return (int32_t)sizeof(SSpreadInfo); } bool getSpreadFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) { pEnv->calcMemSize = sizeof(SSpreadInfo); return true; } -bool spreadFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo) { +bool spreadFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) { if (!functionSetup(pCtx, pResultInfo)) { return false; } @@ -3074,13 +3257,13 @@ bool spreadFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo) return true; } -int32_t spreadFunction(SqlFunctionCtx *pCtx) { +int32_t spreadFunction(SqlFunctionCtx* pCtx) { int32_t numOfElems = 0; // Only the pre-computing information loaded and actual data does not loaded SInputColumnInfoData* pInput = &pCtx->input; - SColumnDataAgg *pAgg = pInput->pColumnDataAgg[0]; - int32_t type = pInput->pData[0]->info.type; + SColumnDataAgg* pAgg = pInput->pColumnDataAgg[0]; + int32_t type = pInput->pData[0]->info.type; SSpreadInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); @@ -3112,7 +3295,7 @@ int32_t spreadFunction(SqlFunctionCtx *pCtx) { } else { // computing based on the true data block SColumnInfoData* pCol = pInput->pData[0]; - int32_t start = pInput->startRowIndex; + int32_t start = pInput->startRowIndex; int32_t numOfRows = pInput->numOfRows; // check the valid data one by one @@ -3121,7 +3304,7 @@ int32_t spreadFunction(SqlFunctionCtx *pCtx) { continue; } - char *data = colDataGetData(pCol, i); + char* data = colDataGetData(pCol, i); double v = 0; GET_TYPED_DATA(v, double, type, data); @@ -3158,17 +3341,16 @@ static void spreadTransferInfo(SSpreadInfo* pInput, SSpreadInfo* pOutput) { } } -int32_t spreadFunctionMerge(SqlFunctionCtx *pCtx) { +int32_t spreadFunctionMerge(SqlFunctionCtx* pCtx) { SInputColumnInfoData* pInput = &pCtx->input; - SColumnInfoData* pCol = pInput->pData[0]; + SColumnInfoData* pCol = pInput->pData[0]; ASSERT(pCol->info.type == TSDB_DATA_TYPE_BINARY); SSpreadInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - SSpreadInfo* pInputInfo; int32_t start = pInput->startRowIndex; - char* data = colDataGetData(pCol, start); - pInputInfo = (SSpreadInfo *)varDataVal(data); + char* data = colDataGetData(pCol, start); + SSpreadInfo* pInputInfo = (SSpreadInfo*)varDataVal(data); spreadTransferInfo(pInputInfo, pInfo); @@ -3188,8 +3370,8 @@ int32_t spreadFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t spreadPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); SSpreadInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - int32_t resultBytes = getSpreadInfoSize(); - char *res = taosMemoryCalloc(resultBytes + VARSTR_HEADER_SIZE, sizeof(char)); + int32_t resultBytes = getSpreadInfoSize(); + char* res = taosMemoryCalloc(resultBytes + VARSTR_HEADER_SIZE, sizeof(char)); memcpy(varDataVal(res), pInfo, resultBytes); varDataSetLen(res, resultBytes); @@ -3205,25 +3387,23 @@ int32_t spreadPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t spreadCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); - SSpreadInfo* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); + SSpreadInfo* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); - SSpreadInfo* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); + SSpreadInfo* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); spreadTransferInfo(pSBuf, pDBuf); pDResInfo->numOfRes = TMAX(pDResInfo->numOfRes, pSResInfo->numOfRes); return TSDB_CODE_SUCCESS; } -int32_t getElapsedInfoSize() { - return (int32_t)sizeof(SElapsedInfo); -} +int32_t getElapsedInfoSize() { return (int32_t)sizeof(SElapsedInfo); } bool getElapsedFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) { pEnv->calcMemSize = sizeof(SElapsedInfo); return true; } -bool elapsedFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo) { +bool elapsedFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) { if (!functionSetup(pCtx, pResultInfo)) { return false; } @@ -3242,16 +3422,16 @@ bool elapsedFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo return true; } -int32_t elapsedFunction(SqlFunctionCtx *pCtx) { +int32_t elapsedFunction(SqlFunctionCtx* pCtx) { int32_t numOfElems = 0; // Only the pre-computing information loaded and actual data does not loaded SInputColumnInfoData* pInput = &pCtx->input; - SColumnDataAgg *pAgg = pInput->pColumnDataAgg[0]; + SColumnDataAgg* pAgg = pInput->pColumnDataAgg[0]; SElapsedInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - numOfElems = pInput->numOfRows; //since this is the primary timestamp, no need to exclude NULL values + numOfElems = pInput->numOfRows; // since this is the primary timestamp, no need to exclude NULL values if (numOfElems == 0) { goto _elapsed_over; } @@ -3283,11 +3463,12 @@ int32_t elapsedFunction(SqlFunctionCtx *pCtx) { SColumnInfoData* pCol = pInput->pData[0]; - int32_t start = pInput->startRowIndex; - TSKEY* ptsList = (int64_t*)colDataGetData(pCol, start); + int32_t start = pInput->startRowIndex; + TSKEY* ptsList = (int64_t*)colDataGetData(pCol, start); if (pCtx->order == TSDB_ORDER_DESC) { if (pCtx->start.key == INT64_MIN) { - pInfo->max = (pInfo->max < ptsList[start + pInput->numOfRows - 1]) ? ptsList[start + pInput->numOfRows - 1] : pInfo->max; + pInfo->max = + (pInfo->max < ptsList[start + pInput->numOfRows - 1]) ? ptsList[start + pInput->numOfRows - 1] : pInfo->max; } else { pInfo->max = pCtx->start.key + 1; } @@ -3330,16 +3511,16 @@ static void elapsedTransferInfo(SElapsedInfo* pInput, SElapsedInfo* pOutput) { } } -int32_t elapsedFunctionMerge(SqlFunctionCtx *pCtx) { +int32_t elapsedFunctionMerge(SqlFunctionCtx* pCtx) { SInputColumnInfoData* pInput = &pCtx->input; - SColumnInfoData* pCol = pInput->pData[0]; + SColumnInfoData* pCol = pInput->pData[0]; ASSERT(pCol->info.type == TSDB_DATA_TYPE_BINARY); SElapsedInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - int32_t start = pInput->startRowIndex; - char* data = colDataGetData(pCol, start); - SElapsedInfo* pInputInfo = (SElapsedInfo *)varDataVal(data); + int32_t start = pInput->startRowIndex; + char* data = colDataGetData(pCol, start); + SElapsedInfo* pInputInfo = (SElapsedInfo*)varDataVal(data); elapsedTransferInfo(pInputInfo, pInfo); @@ -3349,7 +3530,7 @@ int32_t elapsedFunctionMerge(SqlFunctionCtx *pCtx) { int32_t elapsedFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SElapsedInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - double result = (double)pInfo->max - (double)pInfo->min; + double result = (double)pInfo->max - (double)pInfo->min; result = (result >= 0) ? result : -result; pInfo->result = result / pInfo->timeUnit; return functionFinalize(pCtx, pBlock); @@ -3357,9 +3538,9 @@ int32_t elapsedFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t elapsedPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); - SElapsedInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - int32_t resultBytes = getElapsedInfoSize(); - char *res = taosMemoryCalloc(resultBytes + VARSTR_HEADER_SIZE, sizeof(char)); + SElapsedInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); + int32_t resultBytes = getElapsedInfoSize(); + char* res = taosMemoryCalloc(resultBytes + VARSTR_HEADER_SIZE, sizeof(char)); memcpy(varDataVal(res), pInfo, resultBytes); varDataSetLen(res, resultBytes); @@ -3375,10 +3556,10 @@ int32_t elapsedPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t elapsedCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); - SElapsedInfo* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); + SElapsedInfo* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); - SElapsedInfo* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); + SElapsedInfo* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); elapsedTransferInfo(pSBuf, pDBuf); pDResInfo->numOfRes = TMAX(pDResInfo->numOfRes, pSResInfo->numOfRes); @@ -3394,7 +3575,7 @@ bool getHistogramFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) return true; } -static int8_t getHistogramBinType(char *binTypeStr) { +static int8_t getHistogramBinType(char* binTypeStr) { int8_t binType; if (strcasecmp(binTypeStr, "user_input") == 0) { binType = USER_INPUT_BIN; @@ -3409,7 +3590,7 @@ static int8_t getHistogramBinType(char *binTypeStr) { return binType; } -static bool getHistogramBinDesc(SHistoFuncInfo *pInfo, char *binDescStr, int8_t binType, bool normalized) { +static bool getHistogramBinDesc(SHistoFuncInfo* pInfo, char* binDescStr, int8_t binType, bool normalized) { cJSON* binDesc = cJSON_Parse(binDescStr); int32_t numOfBins; double* intervals; @@ -3420,17 +3601,17 @@ static bool getHistogramBinDesc(SHistoFuncInfo *pInfo, char *binDescStr, int8_t return false; } - cJSON* start = cJSON_GetObjectItem(binDesc, "start"); - cJSON* factor = cJSON_GetObjectItem(binDesc, "factor"); - cJSON* width = cJSON_GetObjectItem(binDesc, "width"); - cJSON* count = cJSON_GetObjectItem(binDesc, "count"); + cJSON* start = cJSON_GetObjectItem(binDesc, "start"); + cJSON* factor = cJSON_GetObjectItem(binDesc, "factor"); + cJSON* width = cJSON_GetObjectItem(binDesc, "width"); + cJSON* count = cJSON_GetObjectItem(binDesc, "count"); cJSON* infinity = cJSON_GetObjectItem(binDesc, "infinity"); if (!cJSON_IsNumber(start) || !cJSON_IsNumber(count) || !cJSON_IsBool(infinity)) { return false; } - if (count->valueint <= 0 || count->valueint > 1000) { // limit count to 1000 + if (count->valueint <= 0 || count->valueint > 1000) { // limit count to 1000 return false; } @@ -3524,7 +3705,7 @@ static bool getHistogramBinDesc(SHistoFuncInfo *pInfo, char *binDescStr, int8_t return false; } - pInfo->numOfBins = numOfBins - 1; + pInfo->numOfBins = numOfBins - 1; pInfo->normalized = normalized; for (int32_t i = 0; i < pInfo->numOfBins; ++i) { pInfo->bins[i].lower = intervals[i] < intervals[i + 1] ? intervals[i] : intervals[i + 1]; @@ -3536,12 +3717,12 @@ static bool getHistogramBinDesc(SHistoFuncInfo *pInfo, char *binDescStr, int8_t return true; } -bool histogramFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo *pResultInfo) { +bool histogramFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) { if (!functionSetup(pCtx, pResultInfo)) { return false; } - SHistoFuncInfo *pInfo = GET_ROWCELL_INTERBUF(pResultInfo); + SHistoFuncInfo* pInfo = GET_ROWCELL_INTERBUF(pResultInfo); pInfo->numOfBins = 0; pInfo->totalCount = 0; pInfo->normalized = 0; @@ -3550,7 +3731,7 @@ bool histogramFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo *pResultIn if (binType == UNKNOWN_BIN) { return false; } - char* binDesc = varDataVal(pCtx->param[2].param.pz); + char* binDesc = varDataVal(pCtx->param[2].param.pz); int64_t normalized = pCtx->param[3].param.i; if (normalized != 0 && normalized != 1) { return false; @@ -3562,7 +3743,7 @@ bool histogramFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo *pResultIn return true; } -int32_t histogramFunction(SqlFunctionCtx *pCtx) { +int32_t histogramFunction(SqlFunctionCtx* pCtx) { SHistoFuncInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); SInputColumnInfoData* pInput = &pCtx->input; @@ -3581,7 +3762,7 @@ int32_t histogramFunction(SqlFunctionCtx *pCtx) { numOfElems++; - char* data = colDataGetData(pCol, i); + char* data = colDataGetData(pCol, i); double v; GET_TYPED_DATA(v, double, type, data); @@ -3592,7 +3773,6 @@ int32_t histogramFunction(SqlFunctionCtx *pCtx) { break; } } - } SET_VAL(GET_RES_INFO(pCtx), numOfElems, pInfo->numOfBins); @@ -3601,7 +3781,7 @@ int32_t histogramFunction(SqlFunctionCtx *pCtx) { static void histogramTransferInfo(SHistoFuncInfo* pInput, SHistoFuncInfo* pOutput) { pOutput->normalized = pInput->normalized; - pOutput->numOfBins = pInput->numOfBins; + pOutput->numOfBins = pInput->numOfBins; pOutput->totalCount += pInput->totalCount; for (int32_t k = 0; k < pOutput->numOfBins; ++k) { pOutput->bins[k].lower = pInput->bins[k].lower; @@ -3610,16 +3790,16 @@ static void histogramTransferInfo(SHistoFuncInfo* pInput, SHistoFuncInfo* pOutpu } } -int32_t histogramFunctionMerge(SqlFunctionCtx *pCtx) { +int32_t histogramFunctionMerge(SqlFunctionCtx* pCtx) { SInputColumnInfoData* pInput = &pCtx->input; - SColumnInfoData* pCol = pInput->pData[0]; + SColumnInfoData* pCol = pInput->pData[0]; ASSERT(pCol->info.type == TSDB_DATA_TYPE_BINARY); SHistoFuncInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - int32_t start = pInput->startRowIndex; - char* data = colDataGetData(pCol, start); - SHistoFuncInfo* pInputInfo = (SHistoFuncInfo *)varDataVal(data); + int32_t start = pInput->startRowIndex; + char* data = colDataGetData(pCol, start); + SHistoFuncInfo* pInputInfo = (SHistoFuncInfo*)varDataVal(data); histogramTransferInfo(pInputInfo, pInfo); @@ -3629,15 +3809,15 @@ int32_t histogramFunctionMerge(SqlFunctionCtx *pCtx) { int32_t histogramFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); - SHistoFuncInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - int32_t slotId = pCtx->pExpr->base.resSchema.slotId; - SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); + SHistoFuncInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); + int32_t slotId = pCtx->pExpr->base.resSchema.slotId; + SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); int32_t currentRow = pBlock->info.rows; if (pInfo->normalized) { for (int32_t k = 0; k < pResInfo->numOfRes; ++k) { - if(pInfo->totalCount != 0) { + if (pInfo->totalCount != 0) { pInfo->bins[k].percentage = pInfo->bins[k].count / (double)pInfo->totalCount; } else { pInfo->bins[k].percentage = 0; @@ -3647,13 +3827,13 @@ int32_t histogramFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { for (int32_t i = 0; i < pResInfo->numOfRes; ++i) { int32_t len; - char buf[512] = {0}; + char buf[512] = {0}; if (!pInfo->normalized) { - len = sprintf(varDataVal(buf), "{\"lower_bin\":%g, \"upper_bin\":%g, \"count\":%"PRId64"}", - pInfo->bins[i].lower, pInfo->bins[i].upper, pInfo->bins[i].count); + len = sprintf(varDataVal(buf), "{\"lower_bin\":%g, \"upper_bin\":%g, \"count\":%" PRId64 "}", + pInfo->bins[i].lower, pInfo->bins[i].upper, pInfo->bins[i].count); } else { - len = sprintf(varDataVal(buf), "{\"lower_bin\":%g, \"upper_bin\":%g, \"count\":%lf}", - pInfo->bins[i].lower, pInfo->bins[i].upper, pInfo->bins[i].percentage); + len = sprintf(varDataVal(buf), "{\"lower_bin\":%g, \"upper_bin\":%g, \"count\":%lf}", pInfo->bins[i].lower, + pInfo->bins[i].upper, pInfo->bins[i].percentage); } varDataSetLen(buf, len); colDataAppend(pCol, currentRow, buf, false); @@ -3665,8 +3845,8 @@ int32_t histogramFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t histogramPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SHistoFuncInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - int32_t resultBytes = getHistogramInfoSize(); - char *res = taosMemoryCalloc(resultBytes + VARSTR_HEADER_SIZE, sizeof(char)); + int32_t resultBytes = getHistogramInfoSize(); + char* res = taosMemoryCalloc(resultBytes + VARSTR_HEADER_SIZE, sizeof(char)); memcpy(varDataVal(res), pInfo, resultBytes); varDataSetLen(res, resultBytes); @@ -3692,23 +3872,21 @@ int32_t histogramCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { return TSDB_CODE_SUCCESS; } -int32_t getHLLInfoSize() { - return (int32_t)sizeof(SHLLInfo); -} +int32_t getHLLInfoSize() { return (int32_t)sizeof(SHLLInfo); } bool getHLLFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) { pEnv->calcMemSize = sizeof(SHLLInfo); return true; } -static uint8_t hllCountNum(void* data, int32_t bytes, int32_t *buk) { +static uint8_t hllCountNum(void* data, int32_t bytes, int32_t* buk) { uint64_t hash = MurmurHash3_64(data, bytes); - int32_t index = hash & HLL_BUCKET_MASK; + int32_t index = hash & HLL_BUCKET_MASK; hash >>= HLL_BUCKET_BITS; hash |= ((uint64_t)1 << HLL_DATA_BITS); uint64_t bit = 1; - uint8_t count = 1; - while((hash & bit) == 0) { + uint8_t count = 1; + while ((hash & bit) == 0) { count++; bit <<= 1; } @@ -3716,15 +3894,15 @@ static uint8_t hllCountNum(void* data, int32_t bytes, int32_t *buk) { return count; } -static void hllBucketHisto(uint8_t *buckets, int32_t* bucketHisto) { - uint64_t *word = (uint64_t*) buckets; - uint8_t *bytes; +static void hllBucketHisto(uint8_t* buckets, int32_t* bucketHisto) { + uint64_t* word = (uint64_t*)buckets; + uint8_t* bytes; - for (int32_t j = 0; j < HLL_BUCKETS>>3; j++) { + for (int32_t j = 0; j < HLL_BUCKETS >> 3; j++) { if (*word == 0) { bucketHisto[0] += 8; } else { - bytes = (uint8_t*) word; + bytes = (uint8_t*)word; bucketHisto[bytes[0]]++; bucketHisto[bytes[1]]++; bucketHisto[bytes[2]]++; @@ -3746,8 +3924,8 @@ static double hllTau(double x) { x = sqrt(x); zPrime = z; y *= 0.5; - z -= pow(1 - x, 2)*y; - } while(zPrime != z); + z -= pow(1 - x, 2) * y; + } while (zPrime != z); return z / 3; } @@ -3761,35 +3939,36 @@ static double hllSigma(double x) { zPrime = z; z += x * y; y += y; - } while(zPrime != z); + } while (zPrime != z); return z; } -// estimate the cardinality, the algorithm refer this paper: "New cardinality estimation algorithms for HyperLogLog sketches" -static uint64_t hllCountCnt(uint8_t *buckets) { - double m = HLL_BUCKETS; +// estimate the cardinality, the algorithm refer this paper: "New cardinality estimation algorithms for HyperLogLog +// sketches" +static uint64_t hllCountCnt(uint8_t* buckets) { + double m = HLL_BUCKETS; int32_t buckethisto[64] = {0}; - hllBucketHisto(buckets,buckethisto); + hllBucketHisto(buckets, buckethisto); - double z = m * hllTau((m-buckethisto[HLL_DATA_BITS+1])/(double)m); + double z = m * hllTau((m - buckethisto[HLL_DATA_BITS + 1]) / (double)m); for (int j = HLL_DATA_BITS; j >= 1; --j) { z += buckethisto[j]; z *= 0.5; } - z += m * hllSigma(buckethisto[0]/(double)m); - double E = (double)llroundl(HLL_ALPHA_INF*m*m/z); + z += m * hllSigma(buckethisto[0] / (double)m); + double E = (double)llroundl(HLL_ALPHA_INF * m * m / z); - return (uint64_t) E; + return (uint64_t)E; } -int32_t hllFunction(SqlFunctionCtx *pCtx) { +int32_t hllFunction(SqlFunctionCtx* pCtx) { SHLLInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); SInputColumnInfoData* pInput = &pCtx->input; SColumnInfoData* pCol = pInput->pData[0]; - int32_t type = pCol->info.type; + int32_t type = pCol->info.type; int32_t bytes = pCol->info.bytes; int32_t start = pInput->startRowIndex; @@ -3829,16 +4008,16 @@ static void hllTransferInfo(SHLLInfo* pInput, SHLLInfo* pOutput) { } } -int32_t hllFunctionMerge(SqlFunctionCtx *pCtx) { +int32_t hllFunctionMerge(SqlFunctionCtx* pCtx) { SInputColumnInfoData* pInput = &pCtx->input; - SColumnInfoData* pCol = pInput->pData[0]; + SColumnInfoData* pCol = pInput->pData[0]; ASSERT(pCol->info.type == TSDB_DATA_TYPE_BINARY); SHLLInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - int32_t start = pInput->startRowIndex; - char* data = colDataGetData(pCol, start); - SHLLInfo* pInputInfo = (SHLLInfo *)varDataVal(data); + int32_t start = pInput->startRowIndex; + char* data = colDataGetData(pCol, start); + SHLLInfo* pInputInfo = (SHLLInfo*)varDataVal(data); hllTransferInfo(pInputInfo, pInfo); @@ -3847,7 +4026,7 @@ int32_t hllFunctionMerge(SqlFunctionCtx *pCtx) { } int32_t hllFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { - SResultRowEntryInfo *pInfo = GET_RES_INFO(pCtx); + SResultRowEntryInfo* pInfo = GET_RES_INFO(pCtx); SHLLInfo* pHllInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); pHllInfo->result = hllCountCnt(pHllInfo->buckets); @@ -3860,9 +4039,9 @@ int32_t hllFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t hllPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); - SHLLInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - int32_t resultBytes = getHLLInfoSize(); - char *res = taosMemoryCalloc(resultBytes + VARSTR_HEADER_SIZE, sizeof(char)); + SHLLInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); + int32_t resultBytes = getHLLInfoSize(); + char* res = taosMemoryCalloc(resultBytes + VARSTR_HEADER_SIZE, sizeof(char)); memcpy(varDataVal(res), pInfo, resultBytes); varDataSetLen(res, resultBytes); @@ -3878,10 +4057,10 @@ int32_t hllPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t hllCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); - SHLLInfo* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); + SHLLInfo* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); - SHLLInfo* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); + SHLLInfo* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); hllTransferInfo(pSBuf, pDBuf); pDResInfo->numOfRes = TMAX(pDResInfo->numOfRes, pSResInfo->numOfRes); @@ -3893,7 +4072,7 @@ bool getStateFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) { return true; } -static int8_t getStateOpType(char *opStr) { +static int8_t getStateOpType(char* opStr) { int8_t opType; if (strcasecmp(opStr, "LT") == 0) { opType = STATE_OPER_LT; @@ -3914,88 +4093,86 @@ static int8_t getStateOpType(char *opStr) { return opType; } -#define GET_STATE_VAL(param) \ - ((param.nType == TSDB_DATA_TYPE_BIGINT) ? (param.i) : (param.d)) +#define GET_STATE_VAL(param) ((param.nType == TSDB_DATA_TYPE_BIGINT) ? (param.i) : (param.d)) -#define STATE_COMP(_op, _lval, _param) \ - STATE_COMP_IMPL(_op, _lval, GET_STATE_VAL(_param)) +#define STATE_COMP(_op, _lval, _param) STATE_COMP_IMPL(_op, _lval, GET_STATE_VAL(_param)) -#define STATE_COMP_IMPL(_op, _lval, _rval) \ - do { \ - switch(_op) { \ - case STATE_OPER_LT: \ - return ((_lval) < (_rval)); \ - break; \ - case STATE_OPER_GT: \ - return ((_lval) > (_rval)); \ - break; \ - case STATE_OPER_LE: \ - return ((_lval) <= (_rval)); \ - break; \ - case STATE_OPER_GE: \ - return ((_lval) >= (_rval)); \ - break; \ - case STATE_OPER_NE: \ - return ((_lval) != (_rval)); \ - break; \ - case STATE_OPER_EQ: \ - return ((_lval) == (_rval)); \ - break; \ - default: \ - break; \ - } \ +#define STATE_COMP_IMPL(_op, _lval, _rval) \ + do { \ + switch (_op) { \ + case STATE_OPER_LT: \ + return ((_lval) < (_rval)); \ + break; \ + case STATE_OPER_GT: \ + return ((_lval) > (_rval)); \ + break; \ + case STATE_OPER_LE: \ + return ((_lval) <= (_rval)); \ + break; \ + case STATE_OPER_GE: \ + return ((_lval) >= (_rval)); \ + break; \ + case STATE_OPER_NE: \ + return ((_lval) != (_rval)); \ + break; \ + case STATE_OPER_EQ: \ + return ((_lval) == (_rval)); \ + break; \ + default: \ + break; \ + } \ } while (0) static bool checkStateOp(int8_t op, SColumnInfoData* pCol, int32_t index, SVariant param) { char* data = colDataGetData(pCol, index); - switch(pCol->info.type) { + switch (pCol->info.type) { case TSDB_DATA_TYPE_TINYINT: { - int8_t v = *(int8_t *)data; + int8_t v = *(int8_t*)data; STATE_COMP(op, v, param); break; } case TSDB_DATA_TYPE_UTINYINT: { - uint8_t v = *(uint8_t *)data; + uint8_t v = *(uint8_t*)data; STATE_COMP(op, v, param); break; } case TSDB_DATA_TYPE_SMALLINT: { - int16_t v = *(int16_t *)data; + int16_t v = *(int16_t*)data; STATE_COMP(op, v, param); break; } case TSDB_DATA_TYPE_USMALLINT: { - uint16_t v = *(uint16_t *)data; + uint16_t v = *(uint16_t*)data; STATE_COMP(op, v, param); break; } case TSDB_DATA_TYPE_INT: { - int32_t v = *(int32_t *)data; + int32_t v = *(int32_t*)data; STATE_COMP(op, v, param); break; } case TSDB_DATA_TYPE_UINT: { - uint32_t v = *(uint32_t *)data; + uint32_t v = *(uint32_t*)data; STATE_COMP(op, v, param); break; } case TSDB_DATA_TYPE_BIGINT: { - int64_t v = *(int64_t *)data; + int64_t v = *(int64_t*)data; STATE_COMP(op, v, param); break; } case TSDB_DATA_TYPE_UBIGINT: { - uint64_t v = *(uint64_t *)data; + uint64_t v = *(uint64_t*)data; STATE_COMP(op, v, param); break; } case TSDB_DATA_TYPE_FLOAT: { - float v = *(float *)data; + float v = *(float*)data; STATE_COMP(op, v, param); break; } case TSDB_DATA_TYPE_DOUBLE: { - double v = *(double *)data; + double v = *(double*)data; STATE_COMP(op, v, param); break; } @@ -4014,7 +4191,7 @@ int32_t stateCountFunction(SqlFunctionCtx* pCtx) { SColumnInfoData* pInputCol = pInput->pData[0]; - int32_t numOfElems = 0; + int32_t numOfElems = 0; SColumnInfoData* pOutput = (SColumnInfoData*)pCtx->pOutput; int8_t op = getStateOpType(varDataVal(pCtx->param[1].param.pz)); @@ -4029,14 +4206,14 @@ int32_t stateCountFunction(SqlFunctionCtx* pCtx) { continue; } - bool ret = checkStateOp(op, pInputCol, i, pCtx->param[2].param); + bool ret = checkStateOp(op, pInputCol, i, pCtx->param[2].param); int64_t output = -1; if (ret) { output = ++pInfo->count; } else { pInfo->count = 0; } - colDataAppend(pOutput, i, (char *)&output, false); + colDataAppend(pOutput, i, (char*)&output, false); } return numOfElems; @@ -4047,16 +4224,16 @@ int32_t stateDurationFunction(SqlFunctionCtx* pCtx) { SStateInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); SInputColumnInfoData* pInput = &pCtx->input; - TSKEY* tsList = (int64_t*)pInput->pPTS->pData; + TSKEY* tsList = (int64_t*)pInput->pPTS->pData; SColumnInfoData* pInputCol = pInput->pData[0]; - int32_t numOfElems = 0; + int32_t numOfElems = 0; SColumnInfoData* pOutput = (SColumnInfoData*)pCtx->pOutput; - //TODO: process timeUnit for different db precisions + // TODO: process timeUnit for different db precisions int32_t timeUnit = 1000; - if (pCtx->numOfParams == 5) { //TODO: param number incorrect + if (pCtx->numOfParams == 5) { // TODO: param number incorrect timeUnit = pCtx->param[3].param.i; } @@ -4072,7 +4249,7 @@ int32_t stateDurationFunction(SqlFunctionCtx* pCtx) { continue; } - bool ret = checkStateOp(op, pInputCol, i, pCtx->param[2].param); + bool ret = checkStateOp(op, pInputCol, i, pCtx->param[2].param); int64_t output = -1; if (ret) { if (pInfo->durationStart == 0) { @@ -4084,7 +4261,7 @@ int32_t stateDurationFunction(SqlFunctionCtx* pCtx) { } else { pInfo->durationStart = 0; } - colDataAppend(pOutput, i, (char *)&output, false); + colDataAppend(pOutput, i, (char*)&output, false); } return numOfElems; @@ -4100,7 +4277,7 @@ int32_t csumFunction(SqlFunctionCtx* pCtx) { SSumRes* pSumRes = GET_ROWCELL_INTERBUF(pResInfo); SInputColumnInfoData* pInput = &pCtx->input; - TSKEY* tsList = (int64_t*)pInput->pPTS->pData; + TSKEY* tsList = (int64_t*)pInput->pPTS->pData; SColumnInfoData* pInputCol = pInput->pData[0]; SColumnInfoData* pTsOutput = pCtx->pTsOutput; @@ -4112,7 +4289,7 @@ int32_t csumFunction(SqlFunctionCtx* pCtx) { for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; i += 1) { int32_t pos = startOffset + numOfElems; if (colDataIsNull_f(pInputCol->nullbitmap, i)) { - //colDataAppendNULL(pOutput, i); + // colDataAppendNULL(pOutput, i); continue; } @@ -4121,25 +4298,25 @@ int32_t csumFunction(SqlFunctionCtx* pCtx) { int64_t v; GET_TYPED_DATA(v, int64_t, type, data); pSumRes->isum += v; - colDataAppend(pOutput, pos, (char *)&pSumRes->isum, false); + colDataAppend(pOutput, pos, (char*)&pSumRes->isum, false); } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) { uint64_t v; GET_TYPED_DATA(v, uint64_t, type, data); pSumRes->usum += v; - colDataAppend(pOutput, pos, (char *)&pSumRes->usum, false); + colDataAppend(pOutput, pos, (char*)&pSumRes->usum, false); } else if (IS_FLOAT_TYPE(type)) { double v; GET_TYPED_DATA(v, double, type, data); pSumRes->dsum += v; - //check for overflow + // check for overflow if (isinf(pSumRes->dsum) || isnan(pSumRes->dsum)) { colDataAppendNULL(pOutput, pos); - } else { - colDataAppend(pOutput, pos, (char *)&pSumRes->dsum, false); + } else { + colDataAppend(pOutput, pos, (char*)&pSumRes->dsum, false); } } - //TODO: remove this after pTsOutput is handled + // TODO: remove this after pTsOutput is handled if (pTsOutput != NULL) { colDataAppendInt64(pTsOutput, pos, &tsList[i]); } @@ -4155,12 +4332,12 @@ bool getMavgFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) { return true; } -bool mavgFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo *pResultInfo) { +bool mavgFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) { if (!functionSetup(pCtx, pResultInfo)) { return false; } - SMavgInfo *pInfo = GET_ROWCELL_INTERBUF(pResultInfo); + SMavgInfo* pInfo = GET_ROWCELL_INTERBUF(pResultInfo); pInfo->pos = 0; pInfo->sum = 0; pInfo->numOfPoints = pCtx->param[1].param.i; @@ -4177,7 +4354,7 @@ int32_t mavgFunction(SqlFunctionCtx* pCtx) { SMavgInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); SInputColumnInfoData* pInput = &pCtx->input; - TSKEY* tsList = (int64_t*)pInput->pPTS->pData; + TSKEY* tsList = (int64_t*)pInput->pPTS->pData; SColumnInfoData* pInputCol = pInput->pData[0]; SColumnInfoData* pTsOutput = pCtx->pTsOutput; @@ -4189,11 +4366,11 @@ int32_t mavgFunction(SqlFunctionCtx* pCtx) { for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; i += 1) { int32_t pos = startOffset + numOfElems; if (colDataIsNull_f(pInputCol->nullbitmap, i)) { - //colDataAppendNULL(pOutput, i); + // colDataAppendNULL(pOutput, i); continue; } - char* data = colDataGetData(pInputCol, i); + char* data = colDataGetData(pInputCol, i); double v; GET_TYPED_DATA(v, double, type, data); @@ -4202,7 +4379,7 @@ int32_t mavgFunction(SqlFunctionCtx* pCtx) { pInfo->sum += v; } else { if (!pInfo->pointsMeet && (pInfo->pos == pInfo->numOfPoints - 1)) { - pInfo->sum +=v; + pInfo->sum += v; pInfo->pointsMeet = true; } else { pInfo->sum = pInfo->sum + v - pInfo->points[pInfo->pos]; @@ -4210,14 +4387,14 @@ int32_t mavgFunction(SqlFunctionCtx* pCtx) { pInfo->points[pInfo->pos] = v; double result = pInfo->sum / pInfo->numOfPoints; - //check for overflow + // check for overflow if (isinf(result) || isnan(result)) { colDataAppendNULL(pOutput, pos); - } else { - colDataAppend(pOutput, pos, (char *)&result, false); + } else { + colDataAppend(pOutput, pos, (char*)&result, false); } - //TODO: remove this after pTsOutput is handled + // TODO: remove this after pTsOutput is handled if (pTsOutput != NULL) { colDataAppendInt64(pTsOutput, pos, &tsList[i]); } @@ -4235,20 +4412,20 @@ int32_t mavgFunction(SqlFunctionCtx* pCtx) { bool getSampleFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { SColumnNode* pCol = (SColumnNode*)nodesListGetNode(pFunc->pParameterList, 0); - SValueNode* pVal = (SValueNode*)nodesListGetNode(pFunc->pParameterList, 1); - int32_t numOfSamples = pVal->datum.i; + SValueNode* pVal = (SValueNode*)nodesListGetNode(pFunc->pParameterList, 1); + int32_t numOfSamples = pVal->datum.i; pEnv->calcMemSize = sizeof(SSampleInfo) + numOfSamples * (pCol->node.resType.bytes + sizeof(int64_t)); return true; } -bool sampleFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo *pResultInfo) { +bool sampleFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) { if (!functionSetup(pCtx, pResultInfo)) { return false; } taosSeedRand(taosSafeRand()); - SSampleInfo *pInfo = GET_ROWCELL_INTERBUF(pResultInfo); + SSampleInfo* pInfo = GET_ROWCELL_INTERBUF(pResultInfo); pInfo->samples = pCtx->param[1].param.i; pInfo->totalPoints = 0; pInfo->numSampled = 0; @@ -4257,18 +4434,18 @@ bool sampleFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo *pResultInfo) if (pInfo->samples < 1 || pInfo->samples > SAMPLE_MAX_POINTS_NUM) { return false; } - pInfo->data = (char *)pInfo + sizeof(SSampleInfo); - pInfo->timestamp = (int64_t *)((char *)pInfo + sizeof(SSampleInfo) + pInfo->samples * pInfo->colBytes); + pInfo->data = (char*)pInfo + sizeof(SSampleInfo); + pInfo->timestamp = (int64_t*)((char*)pInfo + sizeof(SSampleInfo) + pInfo->samples * pInfo->colBytes); return true; } -static void sampleAssignResult(SSampleInfo* pInfo, char *data, TSKEY ts, int32_t index) { +static void sampleAssignResult(SSampleInfo* pInfo, char* data, TSKEY ts, int32_t index) { assignVal(pInfo->data + index * pInfo->colBytes, data, pInfo->colBytes, pInfo->colType); *(pInfo->timestamp + index) = ts; } -static void doReservoirSample(SSampleInfo* pInfo, char *data, TSKEY ts, int32_t index) { +static void doReservoirSample(SSampleInfo* pInfo, char* data, TSKEY ts, int32_t index) { pInfo->totalPoints++; if (pInfo->numSampled < pInfo->samples) { sampleAssignResult(pInfo, data, ts, pInfo->numSampled); @@ -4299,7 +4476,7 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) { } char* data = colDataGetData(pInputCol, i); - doReservoirSample(pInfo, data, /*tsList[i]*/0, i); + doReservoirSample(pInfo, data, /*tsList[i]*/ 0, i); } SET_VAL(pResInfo, pInfo->numSampled, pInfo->numSampled); @@ -4312,7 +4489,7 @@ int32_t sampleFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SSampleInfo* pInfo = GET_ROWCELL_INTERBUF(pEntryInfo); pEntryInfo->complete = true; - int32_t slotId = pCtx->pExpr->base.resSchema.slotId; + int32_t slotId = pCtx->pExpr->base.resSchema.slotId; SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); int32_t currentRow = pBlock->info.rows; @@ -4326,17 +4503,17 @@ int32_t sampleFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { bool getTailFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { SColumnNode* pCol = (SColumnNode*)nodesListGetNode(pFunc->pParameterList, 0); SValueNode* pVal = (SValueNode*)nodesListGetNode(pFunc->pParameterList, 1); - int32_t numOfPoints = pVal->datum.i; + int32_t numOfPoints = pVal->datum.i; pEnv->calcMemSize = sizeof(STailInfo) + numOfPoints * (POINTER_BYTES + sizeof(STailItem) + pCol->node.resType.bytes); return true; } -bool tailFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo *pResultInfo) { +bool tailFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) { if (!functionSetup(pCtx, pResultInfo)) { return false; } - STailInfo *pInfo = GET_ROWCELL_INTERBUF(pResultInfo); + STailInfo* pInfo = GET_ROWCELL_INTERBUF(pResultInfo); pInfo->numAdded = 0; pInfo->numOfPoints = pCtx->param[1].param.i; if (pCtx->numOfParams == 4) { @@ -4351,19 +4528,19 @@ bool tailFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo *pResultInfo) { return false; } - pInfo->pItems = (STailItem **)((char *)pInfo + sizeof(STailInfo)); - char *pItem = (char *)pInfo->pItems + pInfo->numOfPoints * POINTER_BYTES; + pInfo->pItems = (STailItem**)((char*)pInfo + sizeof(STailInfo)); + char* pItem = (char*)pInfo->pItems + pInfo->numOfPoints * POINTER_BYTES; size_t unitSize = sizeof(STailItem) + pInfo->colBytes; for (int32_t i = 0; i < pInfo->numOfPoints; ++i) { - pInfo->pItems[i] = (STailItem *)(pItem + i * unitSize); + pInfo->pItems[i] = (STailItem*)(pItem + i * unitSize); pInfo->pItems[i]->isNull = false; } return true; } -static void tailAssignResult(STailItem* pItem, char *data, int32_t colBytes, TSKEY ts, bool isNull) { +static void tailAssignResult(STailItem* pItem, char* data, int32_t colBytes, TSKEY ts, bool isNull) { pItem->timestamp = ts; if (isNull) { pItem->isNull = true; @@ -4373,30 +4550,30 @@ static void tailAssignResult(STailItem* pItem, char *data, int32_t colBytes, TSK } } -static int32_t tailCompFn(const void *p1, const void *p2, const void *param) { - STailItem *d1 = *(STailItem **)p1; - STailItem *d2 = *(STailItem **)p2; +static int32_t tailCompFn(const void* p1, const void* p2, const void* param) { + STailItem* d1 = *(STailItem**)p1; + STailItem* d2 = *(STailItem**)p2; return compareInt64Val(&d1->timestamp, &d2->timestamp); } -static void doTailAdd(STailInfo* pInfo, char *data, TSKEY ts, bool isNull) { - STailItem **pList = pInfo->pItems; +static void doTailAdd(STailInfo* pInfo, char* data, TSKEY ts, bool isNull) { + STailItem** pList = pInfo->pItems; if (pInfo->numAdded < pInfo->numOfPoints) { tailAssignResult(pList[pInfo->numAdded], data, pInfo->colBytes, ts, isNull); - taosheapsort((void *)pList, sizeof(STailItem **), pInfo->numAdded + 1, NULL, tailCompFn, 0); + taosheapsort((void*)pList, sizeof(STailItem**), pInfo->numAdded + 1, NULL, tailCompFn, 0); pInfo->numAdded++; } else if (pList[0]->timestamp < ts) { tailAssignResult(pList[0], data, pInfo->colBytes, ts, isNull); - taosheapadjust((void *)pList, sizeof(STailItem **), 0, pInfo->numOfPoints - 1, NULL, tailCompFn, NULL, 0); + taosheapadjust((void*)pList, sizeof(STailItem**), 0, pInfo->numOfPoints - 1, NULL, tailCompFn, NULL, 0); } } int32_t tailFunction(SqlFunctionCtx* pCtx) { SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); - STailInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); + STailInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); SInputColumnInfoData* pInput = &pCtx->input; - TSKEY* tsList = (int64_t*)pInput->pPTS->pData; + TSKEY* tsList = (int64_t*)pInput->pPTS->pData; SColumnInfoData* pInputCol = pInput->pData[0]; SColumnInfoData* pOutput = (SColumnInfoData*)pCtx->pOutput; @@ -4408,7 +4585,6 @@ int32_t tailFunction(SqlFunctionCtx* pCtx) { pInfo->numOfPoints = TMIN(pInfo->numOfPoints, pInput->numOfRows - pInfo->offset); } for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex - pInfo->offset; i += 1) { - char* data = colDataGetData(pInputCol, i); doTailAdd(pInfo, data, tsList[i], colDataIsNull_s(pInputCol, i)); } @@ -4416,8 +4592,8 @@ int32_t tailFunction(SqlFunctionCtx* pCtx) { taosqsort(pInfo->pItems, pInfo->numOfPoints, POINTER_BYTES, NULL, tailCompFn); for (int32_t i = 0; i < pInfo->numOfPoints; ++i) { - int32_t pos = startOffset + i; - STailItem *pItem = pInfo->pItems[i]; + int32_t pos = startOffset + i; + STailItem* pItem = pInfo->pItems[i]; if (pItem->isNull) { colDataAppendNULL(pOutput, pos); } else { @@ -4430,7 +4606,7 @@ int32_t tailFunction(SqlFunctionCtx* pCtx) { int32_t tailFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(pCtx); - STailInfo* pInfo = GET_ROWCELL_INTERBUF(pEntryInfo); + STailInfo* pInfo = GET_ROWCELL_INTERBUF(pEntryInfo); pEntryInfo->complete = true; int32_t type = pCtx->input.pData[0]->info.type; @@ -4441,10 +4617,10 @@ int32_t tailFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { // todo assign the tag value and the corresponding row data int32_t currentRow = pBlock->info.rows; for (int32_t i = 0; i < pEntryInfo->numOfRes; ++i) { - STailItem *pItem = pInfo->pItems[i]; + STailItem* pItem = pInfo->pItems[i]; colDataAppend(pCol, currentRow, pItem->data, false); - //setSelectivityValue(pCtx, pBlock, &pInfo->pItems[i].tuplePos, currentRow); + // setSelectivityValue(pCtx, pBlock, &pInfo->pItems[i].tuplePos, currentRow); currentRow += 1; } @@ -4473,11 +4649,11 @@ bool uniqueFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) { return true; } -static void doUniqueAdd(SUniqueInfo* pInfo, char *data, TSKEY ts, bool isNull) { - //handle null elements +static void doUniqueAdd(SUniqueInfo* pInfo, char* data, TSKEY ts, bool isNull) { + // handle null elements if (isNull == true) { - int32_t size = sizeof(SUniqueItem) + pInfo->colBytes; - SUniqueItem *pItem = (SUniqueItem *)(pInfo->pItems + pInfo->numOfPoints * size); + int32_t size = sizeof(SUniqueItem) + pInfo->colBytes; + SUniqueItem* pItem = (SUniqueItem*)(pInfo->pItems + pInfo->numOfPoints * size); if (pInfo->hasNull == false && pItem->isNull == false) { pItem->timestamp = ts; pItem->isNull = true; @@ -4489,15 +4665,15 @@ static void doUniqueAdd(SUniqueInfo* pInfo, char *data, TSKEY ts, bool isNull) { return; } - int32_t hashKeyBytes = IS_VAR_DATA_TYPE(pInfo->colType) ? varDataTLen(data) : pInfo->colBytes; - SUniqueItem *pHashItem = taosHashGet(pInfo->pHash, data, hashKeyBytes); + int32_t hashKeyBytes = IS_VAR_DATA_TYPE(pInfo->colType) ? varDataTLen(data) : pInfo->colBytes; + SUniqueItem* pHashItem = taosHashGet(pInfo->pHash, data, hashKeyBytes); if (pHashItem == NULL) { - int32_t size = sizeof(SUniqueItem) + pInfo->colBytes; - SUniqueItem *pItem = (SUniqueItem *)(pInfo->pItems + pInfo->numOfPoints * size); + int32_t size = sizeof(SUniqueItem) + pInfo->colBytes; + SUniqueItem* pItem = (SUniqueItem*)(pInfo->pItems + pInfo->numOfPoints * size); pItem->timestamp = ts; memcpy(pItem->data, data, pInfo->colBytes); - taosHashPut(pInfo->pHash, data, hashKeyBytes, (char *)pItem, sizeof(SUniqueItem*)); + taosHashPut(pInfo->pHash, data, hashKeyBytes, (char*)pItem, sizeof(SUniqueItem*)); pInfo->numOfPoints++; } else if (pHashItem->timestamp > ts) { pHashItem->timestamp = ts; @@ -4509,7 +4685,7 @@ int32_t uniqueFunction(SqlFunctionCtx* pCtx) { SUniqueInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); SInputColumnInfoData* pInput = &pCtx->input; - TSKEY* tsList = (int64_t*)pInput->pPTS->pData; + TSKEY* tsList = (int64_t*)pInput->pPTS->pData; SColumnInfoData* pInputCol = pInput->pData[0]; SColumnInfoData* pTsOutput = pCtx->pTsOutput; @@ -4527,7 +4703,7 @@ int32_t uniqueFunction(SqlFunctionCtx* pCtx) { } for (int32_t i = 0; i < pInfo->numOfPoints; ++i) { - SUniqueItem *pItem = (SUniqueItem *)(pInfo->pItems + i * (sizeof(SUniqueItem) + pInfo->colBytes)); + SUniqueItem* pItem = (SUniqueItem*)(pInfo->pItems + i * (sizeof(SUniqueItem) + pInfo->colBytes)); if (pItem->isNull == true) { colDataAppendNULL(pOutput, i); } else { @@ -4543,14 +4719,14 @@ int32_t uniqueFunction(SqlFunctionCtx* pCtx) { int32_t uniqueFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); - SUniqueInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); - int32_t slotId = pCtx->pExpr->base.resSchema.slotId; - SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); + SUniqueInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); + int32_t slotId = pCtx->pExpr->base.resSchema.slotId; + SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); for (int32_t i = 0; i < pResInfo->numOfRes; ++i) { - SUniqueItem *pItem = (SUniqueItem *)(pInfo->pItems + i * (sizeof(SUniqueItem) + pInfo->colBytes)); + SUniqueItem* pItem = (SUniqueItem*)(pInfo->pItems + i * (sizeof(SUniqueItem) + pInfo->colBytes)); colDataAppend(pCol, i, pItem->data, false); - //TODO: handle ts output + // TODO: handle ts output } return pResInfo->numOfRes; @@ -4567,43 +4743,43 @@ bool getTwaFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv) { return true; } -bool twaFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo) { +bool twaFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) { if (!functionSetup(pCtx, pResultInfo)) { return false; } - STwaInfo *pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - pInfo->p.key = INT64_MIN; - pInfo->win = TSWINDOW_INITIALIZER; + STwaInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); + pInfo->p.key = INT64_MIN; + pInfo->win = TSWINDOW_INITIALIZER; return true; } static double twa_get_area(SPoint1 s, SPoint1 e) { - if ((s.val >= 0 && e.val >= 0)|| (s.val <=0 && e.val <= 0)) { + if ((s.val >= 0 && e.val >= 0) || (s.val <= 0 && e.val <= 0)) { return (s.val + e.val) * (e.key - s.key) / 2; } - double x = (s.key * e.val - e.key * s.val)/(e.val - s.val); + double x = (s.key * e.val - e.key * s.val) / (e.val - s.val); double val = (s.val * (x - s.key) + e.val * (e.key - x)) / 2; return val; } #define INIT_INTP_POINT(_p, _k, _v) \ - do { \ - (_p).key = (_k); \ - (_p).val = (_v); \ + do { \ + (_p).key = (_k); \ + (_p).val = (_v); \ } while (0) int32_t twaFunction(SqlFunctionCtx* pCtx) { SInputColumnInfoData* pInput = &pCtx->input; - SColumnInfoData* pInputCol = pInput->pData[0]; + SColumnInfoData* pInputCol = pInput->pData[0]; TSKEY* tsList = (int64_t*)pInput->pPTS->pData; - SResultRowEntryInfo *pResInfo = GET_RES_INFO(pCtx); + SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); - STwaInfo *pInfo = GET_ROWCELL_INTERBUF(pResInfo); - SPoint1 *last = &pInfo->p; + STwaInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); + SPoint1* last = &pInfo->p; int32_t numOfElems = 0; int32_t i = pInput->startRowIndex; @@ -4632,9 +4808,9 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) { SPoint1 st = {0}; // calculate the value of - switch(pInputCol->info.type) { + switch (pInputCol->info.type) { case TSDB_DATA_TYPE_TINYINT: { - int8_t *val = (int8_t*) colDataGetData(pInputCol, 0); + int8_t* val = (int8_t*)colDataGetData(pInputCol, 0); for (; i < pInput->numOfRows + pInput->startRowIndex; i += 1) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { continue; @@ -4648,7 +4824,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) { } case TSDB_DATA_TYPE_SMALLINT: { - int16_t *val = (int16_t*) colDataGetData(pInputCol, 0); + int16_t* val = (int16_t*)colDataGetData(pInputCol, 0); for (; i < pInput->numOfRows + pInput->startRowIndex; i += 1) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { continue; @@ -4661,7 +4837,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) { break; } case TSDB_DATA_TYPE_INT: { - int32_t *val = (int32_t*) colDataGetData(pInputCol, 0); + int32_t* val = (int32_t*)colDataGetData(pInputCol, 0); for (; i < pInput->numOfRows + pInput->startRowIndex; i += 1) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { continue; @@ -4674,7 +4850,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) { break; } case TSDB_DATA_TYPE_BIGINT: { - int64_t *val = (int64_t*) colDataGetData(pInputCol, 0); + int64_t* val = (int64_t*)colDataGetData(pInputCol, 0); for (; i < pInput->numOfRows + pInput->startRowIndex; i += 1) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { continue; @@ -4687,7 +4863,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) { break; } case TSDB_DATA_TYPE_FLOAT: { - float *val = (float*) colDataGetData(pInputCol, 0); + float* val = (float*)colDataGetData(pInputCol, 0); for (; i < pInput->numOfRows + pInput->startRowIndex; i += 1) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { continue; @@ -4700,7 +4876,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) { break; } case TSDB_DATA_TYPE_DOUBLE: { - double *val = (double*) colDataGetData(pInputCol, 0); + double* val = (double*)colDataGetData(pInputCol, 0); for (; i < pInput->numOfRows + pInput->startRowIndex; i += 1) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { continue; @@ -4713,7 +4889,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) { break; } case TSDB_DATA_TYPE_UTINYINT: { - uint8_t *val = (uint8_t*) colDataGetData(pInputCol, 0); + uint8_t* val = (uint8_t*)colDataGetData(pInputCol, 0); for (; i < pInput->numOfRows + pInput->startRowIndex; i += 1) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { continue; @@ -4726,7 +4902,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) { break; } case TSDB_DATA_TYPE_USMALLINT: { - uint16_t *val = (uint16_t*) colDataGetData(pInputCol, 0); + uint16_t* val = (uint16_t*)colDataGetData(pInputCol, 0); for (; i < pInput->numOfRows + pInput->startRowIndex; i += 1) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { continue; @@ -4739,7 +4915,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) { break; } case TSDB_DATA_TYPE_UINT: { - uint32_t *val = (uint32_t*) colDataGetData(pInputCol, 0); + uint32_t* val = (uint32_t*)colDataGetData(pInputCol, 0); for (; i < pInput->numOfRows + pInput->startRowIndex; i += 1) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { continue; @@ -4752,7 +4928,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) { break; } case TSDB_DATA_TYPE_UBIGINT: { - uint64_t *val = (uint64_t*) colDataGetData(pInputCol, 0); + uint64_t* val = (uint64_t*)colDataGetData(pInputCol, 0); for (; i < pInput->numOfRows + pInput->startRowIndex; i += 1) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { continue; @@ -4765,16 +4941,17 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) { break; } - default: ASSERT(0); + default: + ASSERT(0); } // the last interpolated time window value if (pCtx->end.key != INT64_MIN) { - pInfo->dOutput += twa_get_area(pInfo->p, pCtx->end); + pInfo->dOutput += twa_get_area(pInfo->p, pCtx->end); pInfo->p = pCtx->end; } - pInfo->win.ekey = pInfo->p.key; + pInfo->win.ekey = pInfo->p.key; SET_VAL(pResInfo, numOfElems, 1); return TSDB_CODE_SUCCESS; @@ -4785,18 +4962,18 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) { * by next input data. The TWA function only applies to each table, so no merge procedure * is required, we simply copy to the resut ot interResBuffer. */ -//void twa_function_copy(SQLFunctionCtx *pCtx) { -// assert(pCtx->inputType == TSDB_DATA_TYPE_BINARY); -// SResultRowEntryInfo *pResInfo = GET_RES_INFO(pCtx); +// void twa_function_copy(SQLFunctionCtx *pCtx) { +// assert(pCtx->inputType == TSDB_DATA_TYPE_BINARY); +// SResultRowEntryInfo *pResInfo = GET_RES_INFO(pCtx); // -// memcpy(GET_ROWCELL_INTERBUF(pResInfo), pCtx->pInput, (size_t)pCtx->inputBytes); -// pResInfo->hasResult = ((STwaInfo *)pCtx->pInput)->hasResult; -//} +// memcpy(GET_ROWCELL_INTERBUF(pResInfo), pCtx->pInput, (size_t)pCtx->inputBytes); +// pResInfo->hasResult = ((STwaInfo *)pCtx->pInput)->hasResult; +// } -int32_t twaFinalize(struct SqlFunctionCtx *pCtx, SSDataBlock* pBlock) { - SResultRowEntryInfo *pResInfo = GET_RES_INFO(pCtx); +int32_t twaFinalize(struct SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { + SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); - STwaInfo *pInfo = (STwaInfo *)GET_ROWCELL_INTERBUF(pResInfo); + STwaInfo* pInfo = (STwaInfo*)GET_ROWCELL_INTERBUF(pResInfo); if (pResInfo->numOfRes == 0) { pResInfo->isNullRes = 1; } else { @@ -4812,11 +4989,11 @@ int32_t twaFinalize(struct SqlFunctionCtx *pCtx, SSDataBlock* pBlock) { return functionFinalize(pCtx, pBlock); } -int32_t blockDistFunction(SqlFunctionCtx *pCtx) { +int32_t blockDistFunction(SqlFunctionCtx* pCtx) { SInputColumnInfoData* pInput = &pCtx->input; - SColumnInfoData* pInputCol = pInput->pData[0]; + SColumnInfoData* pInputCol = pInput->pData[0]; - SResultRowEntryInfo *pResInfo = GET_RES_INFO(pCtx); + SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); STableBlockDistInfo* pDistInfo = GET_ROWCELL_INTERBUF(pResInfo); @@ -4837,7 +5014,7 @@ int32_t blockDistFunction(SqlFunctionCtx *pCtx) { pDistInfo->maxRows = p1.maxRows; } - for(int32_t i = 0; i < tListLen(pDistInfo->blockRowsHisto); ++i) { + for (int32_t i = 0; i < tListLen(pDistInfo->blockRowsHisto); ++i) { pDistInfo->blockRowsHisto[i] += p1.blockRowsHisto[i]; } @@ -4865,7 +5042,7 @@ int32_t tSerializeBlockDistInfo(void* buf, int32_t bufLen, const STableBlockDist if (tEncodeU32(&encoder, pInfo->numOfInmemRows) < 0) return -1; if (tEncodeU32(&encoder, pInfo->numOfSmallBlocks) < 0) return -1; - for(int32_t i = 0; i < tListLen(pInfo->blockRowsHisto); ++i) { + for (int32_t i = 0; i < tListLen(pInfo->blockRowsHisto); ++i) { if (tEncodeI32(&encoder, pInfo->blockRowsHisto[i]) < 0) return -1; } @@ -4896,7 +5073,7 @@ int32_t tDeserializeBlockDistInfo(void* buf, int32_t bufLen, STableBlockDistInfo if (tDecodeU32(&decoder, &pInfo->numOfInmemRows) < 0) return -1; if (tDecodeU32(&decoder, &pInfo->numOfSmallBlocks) < 0) return -1; - for(int32_t i = 0; i < tListLen(pInfo->blockRowsHisto); ++i) { + for (int32_t i = 0; i < tListLen(pInfo->blockRowsHisto); ++i) { if (tDecodeI32(&decoder, &pInfo->blockRowsHisto[i]) < 0) return -1; } @@ -4905,8 +5082,8 @@ int32_t tDeserializeBlockDistInfo(void* buf, int32_t bufLen, STableBlockDistInfo } int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { - SResultRowEntryInfo *pResInfo = GET_RES_INFO(pCtx); - char *pData = GET_ROWCELL_INTERBUF(pResInfo); + SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); + char* pData = GET_ROWCELL_INTERBUF(pResInfo); SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, 0); @@ -4915,41 +5092,35 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { STableBlockDistInfo info = {0}; tDeserializeBlockDistInfo(varDataVal(pData), varDataLen(pData), &info); - char st[256] = {0}; - int32_t len = sprintf(st+VARSTR_HEADER_SIZE, "Blocks=[%d] Size=[%.3fKb] Average_Block_size=[%.3fKb] Compression_Ratio=[%.3f]", info.numOfBlocks, - info.totalSize/1024.0, - info.totalSize/(info.numOfBlocks*1024.0), - info.totalSize/(info.totalRows*info.rowSize*1.0) - ); + char st[256] = {0}; + int32_t len = + sprintf(st + VARSTR_HEADER_SIZE, "Blocks=[%d] Size=[%.3fKb] Average_Block_size=[%.3fKb] Compression_Ratio=[%.3f]", + info.numOfBlocks, info.totalSize / 1024.0, info.totalSize / (info.numOfBlocks * 1024.0), + info.totalSize / (info.totalRows * info.rowSize * 1.0)); varDataSetLen(st, len); colDataAppend(pColInfo, row++, st, false); - len = sprintf(st+VARSTR_HEADER_SIZE, "Total_Rows=[%ld] MinRows=[%d] MaxRows=[%d] Averge_Rows=[%ld] Inmem_Rows=[%d]", - info.totalRows, - info.minRows, - info.maxRows, - info.totalRows/info.numOfBlocks, - info.numOfInmemRows - ); + len = sprintf(st + VARSTR_HEADER_SIZE, "Total_Rows=[%ld] MinRows=[%d] MaxRows=[%d] Averge_Rows=[%ld] Inmem_Rows=[%d]", + info.totalRows, info.minRows, info.maxRows, info.totalRows / info.numOfBlocks, info.numOfInmemRows); varDataSetLen(st, len); colDataAppend(pColInfo, row++, st, false); - len = sprintf(st + VARSTR_HEADER_SIZE, "Total_Tables=[%d] Total_Files=[%d] Total_Vgroups=[%d]", - info.numOfTables, - info.numOfFiles, 0); + len = sprintf(st + VARSTR_HEADER_SIZE, "Total_Tables=[%d] Total_Files=[%d] Total_Vgroups=[%d]", info.numOfTables, + info.numOfFiles, 0); varDataSetLen(st, len); colDataAppend(pColInfo, row++, st, false); - len = sprintf(st+VARSTR_HEADER_SIZE, "--------------------------------------------------------------------------------"); + len = sprintf(st + VARSTR_HEADER_SIZE, + "--------------------------------------------------------------------------------"); varDataSetLen(st, len); colDataAppend(pColInfo, row++, st, false); int32_t maxVal = 0; int32_t minVal = INT32_MAX; - for(int32_t i = 0; i < sizeof(info.blockRowsHisto)/sizeof(info.blockRowsHisto[0]); ++i) { + for (int32_t i = 0; i < sizeof(info.blockRowsHisto) / sizeof(info.blockRowsHisto[0]); ++i) { if (maxVal < info.blockRowsHisto[i]) { maxVal = info.blockRowsHisto[i]; } @@ -4962,10 +5133,10 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t delta = maxVal - minVal; int32_t step = delta / 50; - int32_t numOfBuckets = sizeof(info.blockRowsHisto)/sizeof(info.blockRowsHisto[0]); + int32_t numOfBuckets = sizeof(info.blockRowsHisto) / sizeof(info.blockRowsHisto[0]); int32_t bucketRange = (info.maxRows - info.minRows) / numOfBuckets; - for(int32_t i = 0; i < 20; ++i) { + for (int32_t i = 0; i < 20; ++i) { len += sprintf(st + VARSTR_HEADER_SIZE, "%04d |", info.defMinRows + bucketRange * (i + 1)); int32_t num = (info.blockRowsHisto[i] + step - 1) / step; @@ -4975,7 +5146,7 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { } double v = info.blockRowsHisto[i] * 100.0 / info.numOfBlocks; - len += sprintf(st+ VARSTR_HEADER_SIZE + len, " %d (%.3f%c)", info.blockRowsHisto[i], v, '%'); + len += sprintf(st + VARSTR_HEADER_SIZE + len, " %d (%.3f%c)", info.blockRowsHisto[i], v, '%'); printf("%s\n", st); varDataSetLen(st, len); diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index caae4c05f7..e9c916034d 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -161,6 +161,8 @@ bool fmIsUserDefinedFunc(int32_t funcId) { return funcId > FUNC_UDF_ID_START; } bool fmIsForbidFillFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_FORBID_FILL_FUNC); } +bool fmIsForbidStreamFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_FORBID_STREAM_FUNC); } + void fmFuncMgtDestroy() { void* m = gFunMgtService.pFuncNameHashTable; if (m != NULL && atomic_val_compare_exchange_ptr((void**)&gFunMgtService.pFuncNameHashTable, m, 0) == m) { @@ -239,7 +241,7 @@ static int32_t getFuncInfo(SFunctionNode* pFunc) { } static SFunctionNode* createFunction(const char* pName, SNodeList* pParameterList) { - SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION); + SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); if (NULL == pFunc) { return NULL; } @@ -247,14 +249,14 @@ static SFunctionNode* createFunction(const char* pName, SNodeList* pParameterLis pFunc->pParameterList = pParameterList; if (TSDB_CODE_SUCCESS != getFuncInfo(pFunc)) { pFunc->pParameterList = NULL; - nodesDestroyNode(pFunc); + nodesDestroyNode((SNode*)pFunc); return NULL; } return pFunc; } static SColumnNode* createColumnByFunc(const SFunctionNode* pFunc) { - SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN); + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { return NULL; } @@ -291,7 +293,7 @@ static int32_t createPartialFunction(const SFunctionNode* pSrcFunc, SFunctionNod static int32_t createMergeFunction(const SFunctionNode* pSrcFunc, const SFunctionNode* pPartialFunc, SFunctionNode** pMergeFunc) { SNodeList* pParameterList = NULL; - nodesListMakeStrictAppend(&pParameterList, createColumnByFunc(pPartialFunc)); + nodesListMakeStrictAppend(&pParameterList, (SNode*)createColumnByFunc(pPartialFunc)); *pMergeFunc = createFunction(funcMgtBuiltins[pSrcFunc->funcId].pMergeFunc, pParameterList); if (NULL == *pMergeFunc) { nodesDestroyList(pParameterList); @@ -316,8 +318,8 @@ int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc } if (TSDB_CODE_SUCCESS != code) { - nodesDestroyNode(*pPartialFunc); - nodesDestroyNode(*pMergeFunc); + nodesDestroyNode((SNode*)*pPartialFunc); + nodesDestroyNode((SNode*)*pMergeFunc); } return code; diff --git a/source/libs/index/src/indexFilter.c b/source/libs/index/src/indexFilter.c index 6197edd474..90aafb1097 100644 --- a/source/libs/index/src/indexFilter.c +++ b/source/libs/index/src/indexFilter.c @@ -97,7 +97,14 @@ static int32_t sifGetOperParamNum(EOperatorType ty) { } return 2; } -static int32_t sifValidateColumn(SColumnNode *cn) { +static int32_t sifValidOp(EOperatorType ty) { + if ((ty >= OP_TYPE_ADD && ty <= OP_TYPE_BIT_OR) || (ty == OP_TYPE_IN || ty == OP_TYPE_NOT_IN) || + (ty == OP_TYPE_LIKE || ty == OP_TYPE_NOT_LIKE || ty == OP_TYPE_MATCH || ty == OP_TYPE_NMATCH)) { + return -1; + } + return 0; +} +static int32_t sifValidColumn(SColumnNode *cn) { // add more check if (cn == NULL) { return TSDB_CODE_QRY_INVALID_INPUT; @@ -176,6 +183,7 @@ static int32_t sifInitJsonParam(SNode *node, SIFParam *param, SIFCtx *ctx) { memcpy(param->colName, r->literal, strlen(r->literal)); // sprintf(param->colName, "%s_%s", l->colName, r->literal); param->colValType = r->typeData; + param->status = SFLT_COARSE_INDEX; return 0; // memcpy(param->colName, l->colName, sizeof(l->colName)); } @@ -197,7 +205,7 @@ static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) { case QUERY_NODE_COLUMN: { SColumnNode *cn = (SColumnNode *)node; /*only support tag column*/ - SIF_ERR_RET(sifValidateColumn(cn)); + SIF_ERR_RET(sifValidColumn(cn)); param->colId = cn->colId; param->colValType = cn->node.resType.type; @@ -247,11 +255,13 @@ static int32_t sifInitOperParams(SIFParam **params, SOperatorNode *node, SIFCtx return code; } SIFParam *paramList = taosMemoryCalloc(nParam, sizeof(SIFParam)); + if (NULL == paramList) { SIF_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - if (nodeType(node->pLeft) == QUERY_NODE_OPERATOR) { + if (nodeType(node->pLeft) == QUERY_NODE_OPERATOR && + (((SOperatorNode *)(node->pLeft))->opType == OP_TYPE_JSON_GET_VALUE)) { SNode *interNode = (node->pLeft); SIF_ERR_JRET(sifInitJsonParam(interNode, ¶mList[0], ctx)); if (nParam > 1) { @@ -505,6 +515,11 @@ static int32_t sifGetOperFn(int32_t funcId, sif_func_t *func, SIdxFltStatus *sta static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) { int32_t code = 0; + if (sifValidOp(node->opType) < 0) { + output->status = SFLT_NOT_INDEX; + return code; + } + int32_t nParam = sifGetOperParamNum(node->opType); if (nParam <= 1) { output->status = SFLT_NOT_INDEX; @@ -513,9 +528,15 @@ static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) { if (node->opType == OP_TYPE_JSON_GET_VALUE) { return code; } - SIFParam *params = NULL; + SIFParam *params = NULL; SIF_ERR_RET(sifInitOperParams(¶ms, node, ctx)); + + if (params[0].status == SFLT_NOT_INDEX || (nParam > 1 && params[1].status == SFLT_NOT_INDEX)) { + output->status = SFLT_NOT_INDEX; + return code; + } + // ugly code, refactor later output->arg = ctx->arg; sif_func_t operFn = sifNullFunc; diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index 7e6a1f5e0c..1ef0ccf7f9 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -40,6 +40,10 @@ break; \ } \ (pDst)->fldname = strdup((pSrc)->fldname); \ + if (NULL == (pDst)->fldname) { \ + nodesDestroyNode((SNode*)pDst); \ + return NULL; \ + } \ } while (0) #define CLONE_NODE_FIELD(fldname) \ @@ -49,11 +53,23 @@ } \ (pDst)->fldname = nodesCloneNode((pSrc)->fldname); \ if (NULL == (pDst)->fldname) { \ - nodesDestroyNode((SNode*)(pDst)); \ + nodesDestroyNode((SNode*)pDst); \ return NULL; \ } \ } while (0) +#define CLONE_NODE_FIELD_EX(fldname, nodePtrType) \ + do { \ + if (NULL == (pSrc)->fldname) { \ + break; \ + } \ + (pDst)->fldname = (nodePtrType)nodesCloneNode((SNode*)(pSrc)->fldname); \ + if (NULL == (pDst)->fldname) { \ + nodesDestroyNode((SNode*)pDst); \ + return NULL; \ + } \ + } while (0) + #define CLONE_NODE_LIST_FIELD(fldname) \ do { \ if (NULL == (pSrc)->fldname) { \ @@ -61,7 +77,7 @@ } \ (pDst)->fldname = nodesCloneList((pSrc)->fldname); \ if (NULL == (pDst)->fldname) { \ - nodesDestroyNode((SNode*)(pDst)); \ + nodesDestroyNode((SNode*)pDst); \ return NULL; \ } \ } while (0) @@ -73,7 +89,7 @@ } \ (pDst)->fldname = cloneFunc((pSrc)->fldname); \ if (NULL == (pDst)->fldname) { \ - nodesDestroyNode((SNode*)(pDst)); \ + nodesDestroyNode((SNode*)pDst); \ return NULL; \ } \ } while (0) @@ -81,6 +97,7 @@ #define COPY_BASE_OBJECT_FIELD(fldname, copyFunc) \ do { \ if (NULL == copyFunc(&((pSrc)->fldname), &((pDst)->fldname))) { \ + nodesDestroyNode((SNode*)pDst); \ return NULL; \ } \ } while (0) @@ -147,7 +164,7 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) { int32_t len = varDataTLen(pSrc->datum.p) + 1; pDst->datum.p = taosMemoryCalloc(1, len); if (NULL == pDst->datum.p) { - nodesDestroyNode(pDst); + nodesDestroyNode((SNode*)pDst); return NULL; } memcpy(pDst->datum.p, pSrc->datum.p, len); @@ -275,8 +292,8 @@ static SNode* stateWindowNodeCopy(const SStateWindowNode* pSrc, SStateWindowNode } static SNode* sessionWindowNodeCopy(const SSessionWindowNode* pSrc, SSessionWindowNode* pDst) { - CLONE_NODE_FIELD(pCol); - CLONE_NODE_FIELD(pGap); + CLONE_NODE_FIELD_EX(pCol, SColumnNode*); + CLONE_NODE_FIELD_EX(pGap, SValueNode*); return (SNode*)pDst; } @@ -442,7 +459,7 @@ static SNode* logicIndefRowsFuncCopy(const SIndefRowsFuncLogicNode* pSrc, SIndef static SNode* logicSubplanCopy(const SLogicSubplan* pSrc, SLogicSubplan* pDst) { COPY_OBJECT_FIELD(id, sizeof(SSubplanId)); - CLONE_NODE_FIELD(pNode); + CLONE_NODE_FIELD_EX(pNode, SLogicNode*); COPY_SCALAR_FIELD(subplanType); COPY_SCALAR_FIELD(level); COPY_SCALAR_FIELD(splitFlag); @@ -450,7 +467,7 @@ static SNode* logicSubplanCopy(const SLogicSubplan* pSrc, SLogicSubplan* pDst) { } static SNode* physiNodeCopy(const SPhysiNode* pSrc, SPhysiNode* pDst) { - CLONE_NODE_FIELD(pOutputDataBlockDesc); + CLONE_NODE_FIELD_EX(pOutputDataBlockDesc, SDataBlockDescNode*); CLONE_NODE_FIELD(pConditions); CLONE_NODE_LIST_FIELD(pChildren); return (SNode*)pDst; @@ -555,8 +572,8 @@ static SNode* selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) { CLONE_NODE_LIST_FIELD(pGroupByList); CLONE_NODE_FIELD(pHaving); CLONE_NODE_LIST_FIELD(pOrderByList); - CLONE_NODE_FIELD(pLimit); - CLONE_NODE_FIELD(pLimit); + CLONE_NODE_FIELD_EX(pLimit, SLimitNode*); + CLONE_NODE_FIELD_EX(pLimit, SLimitNode*); COPY_CHAR_ARRAY_FIELD(stmtName); COPY_SCALAR_FIELD(precision); COPY_SCALAR_FIELD(isEmptyResult); @@ -566,7 +583,7 @@ static SNode* selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) { return (SNode*)pDst; } -SNodeptr nodesCloneNode(const SNodeptr pNode) { +SNode* nodesCloneNode(const SNode* pNode) { if (NULL == pNode) { return NULL; } diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index f7e65f100a..be1929d554 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -4205,7 +4205,7 @@ static int32_t jsonToNodeObject(const SJson* pJson, const char* pName, SNode** p return makeNodeByJson(pJsonNode, pNode); } -int32_t nodesNodeToString(const SNodeptr pNode, bool format, char** pStr, int32_t* pLen) { +int32_t nodesNodeToString(const SNode* pNode, bool format, char** pStr, int32_t* pLen) { if (NULL == pNode || NULL == pStr) { terrno = TSDB_CODE_FAILED; return TSDB_CODE_FAILED; diff --git a/source/libs/nodes/src/nodesEqualFuncs.c b/source/libs/nodes/src/nodesEqualFuncs.c index 9887cbdbc5..681e99a452 100644 --- a/source/libs/nodes/src/nodesEqualFuncs.c +++ b/source/libs/nodes/src/nodesEqualFuncs.c @@ -137,7 +137,7 @@ static bool functionNodeEqual(const SFunctionNode* a, const SFunctionNode* b) { return true; } -bool nodesEqualNode(const SNodeptr a, const SNodeptr b) { +bool nodesEqualNode(const SNode* a, const SNode* b) { if (a == b) { return true; } diff --git a/source/libs/nodes/src/nodesTraverseFuncs.c b/source/libs/nodes/src/nodesTraverseFuncs.c index d8130d5650..1fb2db9f23 100644 --- a/source/libs/nodes/src/nodesTraverseFuncs.c +++ b/source/libs/nodes/src/nodesTraverseFuncs.c @@ -168,7 +168,7 @@ static EDealRes walkExprs(SNodeList* pNodeList, ETraversalOrder order, FNodeWalk return DEAL_RES_CONTINUE; } -void nodesWalkExpr(SNodeptr pNode, FNodeWalker walker, void* pContext) { +void nodesWalkExpr(SNode* pNode, FNodeWalker walker, void* pContext) { (void)walkExpr(pNode, TRAVERSAL_PREORDER, walker, pContext); } @@ -176,7 +176,7 @@ void nodesWalkExprs(SNodeList* pNodeList, FNodeWalker walker, void* pContext) { (void)walkExprs(pNodeList, TRAVERSAL_PREORDER, walker, pContext); } -void nodesWalkExprPostOrder(SNodeptr pNode, FNodeWalker walker, void* pContext) { +void nodesWalkExprPostOrder(SNode* pNode, FNodeWalker walker, void* pContext) { (void)walkExpr(pNode, TRAVERSAL_POSTORDER, walker, pContext); } diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 6db824e445..0f1dbfc13a 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -30,7 +30,7 @@ static SNode* makeNode(ENodeType type, size_t size) { return p; } -SNodeptr nodesMakeNode(ENodeType type) { +SNode* nodesMakeNode(ENodeType type) { switch (type) { case QUERY_NODE_COLUMN: return makeNode(type, sizeof(SColumnNode)); @@ -216,6 +216,8 @@ SNodeptr nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SKillStmt)); case QUERY_NODE_DELETE_STMT: return makeNode(type, sizeof(SDeleteStmt)); + case QUERY_NODE_QUERY: + return makeNode(type, sizeof(SQuery)); case QUERY_NODE_LOGIC_PLAN_SCAN: return makeNode(type, sizeof(SScanLogicNode)); case QUERY_NODE_LOGIC_PLAN_JOIN: @@ -326,7 +328,7 @@ static void destroyLogicNode(SLogicNode* pNode) { static void destroyPhysiNode(SPhysiNode* pNode) { nodesDestroyList(pNode->pChildren); nodesDestroyNode(pNode->pConditions); - nodesDestroyNode(pNode->pOutputDataBlockDesc); + nodesDestroyNode((SNode*)pNode->pOutputDataBlockDesc); } static void destroyWinodwPhysiNode(SWinodwPhysiNode* pNode) { @@ -341,9 +343,9 @@ static void destroyScanPhysiNode(SScanPhysiNode* pNode) { nodesDestroyList(pNode->pScanCols); } -static void destroyDataSinkNode(SDataSinkNode* pNode) { nodesDestroyNode(pNode->pInputDataBlockDesc); } +static void destroyDataSinkNode(SDataSinkNode* pNode) { nodesDestroyNode((SNode*)pNode->pInputDataBlockDesc); } -void nodesDestroyNode(SNodeptr pNode) { +void nodesDestroyNode(SNode* pNode) { if (NULL == pNode) { return; } @@ -400,8 +402,8 @@ void nodesDestroyNode(SNodeptr pNode) { break; case QUERY_NODE_SESSION_WINDOW: { SSessionWindowNode* pSession = (SSessionWindowNode*)pNode; - nodesDestroyNode(pSession->pCol); - nodesDestroyNode(pSession->pGap); + nodesDestroyNode((SNode*)pSession->pCol); + nodesDestroyNode((SNode*)pSession->pGap); break; } case QUERY_NODE_INTERVAL_WINDOW: { @@ -437,7 +439,7 @@ void nodesDestroyNode(SNodeptr pNode) { break; case QUERY_NODE_DATABASE_OPTIONS: { SDatabaseOptions* pOptions = (SDatabaseOptions*)pNode; - nodesDestroyNode(pOptions->pDaysPerFile); + nodesDestroyNode((SNode*)pOptions->pDaysPerFile); nodesDestroyList(pOptions->pKeep); nodesDestroyList(pOptions->pRetentions); break; @@ -456,6 +458,13 @@ void nodesDestroyNode(SNodeptr pNode) { nodesDestroyNode(pOptions->pSliding); break; } + case QUERY_NODE_EXPLAIN_OPTIONS: // no pointer field + break; + case QUERY_NODE_STREAM_OPTIONS: + nodesDestroyNode(((SStreamOptions*)pNode)->pWatermark); + break; + case QUERY_NODE_LEFT_VALUE: // no pointer field + break; case QUERY_NODE_SET_OPERATOR: { SSetOperator* pStmt = (SSetOperator*)pNode; nodesDestroyNode(pStmt->pLeft); @@ -474,26 +483,26 @@ void nodesDestroyNode(SNodeptr pNode) { nodesDestroyList(pStmt->pGroupByList); nodesDestroyNode(pStmt->pHaving); nodesDestroyList(pStmt->pOrderByList); - nodesDestroyNode(pStmt->pLimit); - nodesDestroyNode(pStmt->pSlimit); + nodesDestroyNode((SNode*)pStmt->pLimit); + nodesDestroyNode((SNode*)pStmt->pSlimit); break; } case QUERY_NODE_VNODE_MODIF_STMT: destroyVgDataBlockArray(((SVnodeModifOpStmt*)pNode)->pDataBlocks); break; case QUERY_NODE_CREATE_DATABASE_STMT: - nodesDestroyNode(((SCreateDatabaseStmt*)pNode)->pOptions); + nodesDestroyNode((SNode*)((SCreateDatabaseStmt*)pNode)->pOptions); break; case QUERY_NODE_DROP_DATABASE_STMT: // no pointer field break; case QUERY_NODE_ALTER_DATABASE_STMT: - nodesDestroyNode(((SAlterDatabaseStmt*)pNode)->pOptions); + nodesDestroyNode((SNode*)((SAlterDatabaseStmt*)pNode)->pOptions); break; case QUERY_NODE_CREATE_TABLE_STMT: { SCreateTableStmt* pStmt = (SCreateTableStmt*)pNode; nodesDestroyList(pStmt->pCols); nodesDestroyList(pStmt->pTags); - nodesDestroyNode(pStmt->pOptions); + nodesDestroyNode((SNode*)pStmt->pOptions); break; } case QUERY_NODE_CREATE_SUBTABLE_CLAUSE: { @@ -508,14 +517,14 @@ void nodesDestroyNode(SNodeptr pNode) { case QUERY_NODE_DROP_TABLE_CLAUSE: // no pointer field break; case QUERY_NODE_DROP_TABLE_STMT: - nodesDestroyNode(((SDropTableStmt*)pNode)->pTables); + nodesDestroyList(((SDropTableStmt*)pNode)->pTables); break; case QUERY_NODE_DROP_SUPER_TABLE_STMT: // no pointer field break; case QUERY_NODE_ALTER_TABLE_STMT: { SAlterTableStmt* pStmt = (SAlterTableStmt*)pNode; - nodesDestroyNode(pStmt->pOptions); - nodesDestroyNode(pStmt->pVal); + nodesDestroyNode((SNode*)pStmt->pOptions); + nodesDestroyNode((SNode*)pStmt->pVal); break; } case QUERY_NODE_CREATE_USER_STMT: // no pointer field @@ -528,37 +537,107 @@ void nodesDestroyNode(SNodeptr pNode) { break; case QUERY_NODE_CREATE_INDEX_STMT: { SCreateIndexStmt* pStmt = (SCreateIndexStmt*)pNode; - nodesDestroyNode(pStmt->pOptions); + nodesDestroyNode((SNode*)pStmt->pOptions); nodesDestroyList(pStmt->pCols); break; } case QUERY_NODE_DROP_INDEX_STMT: // no pointer field case QUERY_NODE_CREATE_QNODE_STMT: // no pointer field case QUERY_NODE_DROP_QNODE_STMT: // no pointer field + case QUERY_NODE_CREATE_BNODE_STMT: // no pointer field + case QUERY_NODE_DROP_BNODE_STMT: // no pointer field + case QUERY_NODE_CREATE_SNODE_STMT: // no pointer field + case QUERY_NODE_DROP_SNODE_STMT: // no pointer field + case QUERY_NODE_CREATE_MNODE_STMT: // no pointer field + case QUERY_NODE_DROP_MNODE_STMT: // no pointer field break; case QUERY_NODE_CREATE_TOPIC_STMT: nodesDestroyNode(((SCreateTopicStmt*)pNode)->pQuery); break; case QUERY_NODE_DROP_TOPIC_STMT: // no pointer field + case QUERY_NODE_DROP_CGROUP_STMT: // no pointer field case QUERY_NODE_ALTER_LOCAL_STMT: // no pointer field break; - case QUERY_NODE_SHOW_DATABASES_STMT: - case QUERY_NODE_SHOW_TABLES_STMT: - case QUERY_NODE_SHOW_STABLES_STMT: - case QUERY_NODE_SHOW_USERS_STMT: + case QUERY_NODE_EXPLAIN_STMT: { + SExplainStmt* pStmt = (SExplainStmt*)pNode; + nodesDestroyNode((SNode*)pStmt->pOptions); + nodesDestroyNode(pStmt->pQuery); + break; + } + case QUERY_NODE_DESCRIBE_STMT: + taosMemoryFree(((SDescribeStmt*)pNode)->pMeta); + break; + case QUERY_NODE_RESET_QUERY_CACHE_STMT: // no pointer field + case QUERY_NODE_COMPACT_STMT: // no pointer field + case QUERY_NODE_CREATE_FUNCTION_STMT: // no pointer field + case QUERY_NODE_DROP_FUNCTION_STMT: // no pointer field + break; + case QUERY_NODE_CREATE_STREAM_STMT: { + SCreateStreamStmt* pStmt = (SCreateStreamStmt*)pNode; + nodesDestroyNode((SNode*)pStmt->pOptions); + nodesDestroyNode(pStmt->pQuery); + break; + } + case QUERY_NODE_DROP_STREAM_STMT: // no pointer field + case QUERY_NODE_BALANCE_VGROUP_STMT: // no pointer field + case QUERY_NODE_MERGE_VGROUP_STMT: // no pointer field + break; + case QUERY_NODE_REDISTRIBUTE_VGROUP_STMT: + nodesDestroyList(((SRedistributeVgroupStmt*)pNode)->pDnodes); + break; + case QUERY_NODE_SPLIT_VGROUP_STMT: // no pointer field + case QUERY_NODE_SYNCDB_STMT: // no pointer field + case QUERY_NODE_GRANT_STMT: // no pointer field + case QUERY_NODE_REVOKE_STMT: // no pointer field + break; case QUERY_NODE_SHOW_DNODES_STMT: - case QUERY_NODE_SHOW_VGROUPS_STMT: case QUERY_NODE_SHOW_MNODES_STMT: case QUERY_NODE_SHOW_MODULES_STMT: case QUERY_NODE_SHOW_QNODES_STMT: + case QUERY_NODE_SHOW_SNODES_STMT: + case QUERY_NODE_SHOW_BNODES_STMT: + case QUERY_NODE_SHOW_CLUSTER_STMT: + case QUERY_NODE_SHOW_DATABASES_STMT: case QUERY_NODE_SHOW_FUNCTIONS_STMT: case QUERY_NODE_SHOW_INDEXES_STMT: - case QUERY_NODE_SHOW_STREAMS_STMT: { + case QUERY_NODE_SHOW_STABLES_STMT: + case QUERY_NODE_SHOW_STREAMS_STMT: + case QUERY_NODE_SHOW_TABLES_STMT: + case QUERY_NODE_SHOW_USERS_STMT: + case QUERY_NODE_SHOW_LICENCE_STMT: + case QUERY_NODE_SHOW_VGROUPS_STMT: + case QUERY_NODE_SHOW_TOPICS_STMT: + case QUERY_NODE_SHOW_CONSUMERS_STMT: + case QUERY_NODE_SHOW_SUBSCRIBES_STMT: + case QUERY_NODE_SHOW_SMAS_STMT: + case QUERY_NODE_SHOW_CONFIGS_STMT: + case QUERY_NODE_SHOW_CONNECTIONS_STMT: + case QUERY_NODE_SHOW_QUERIES_STMT: + case QUERY_NODE_SHOW_VNODES_STMT: + case QUERY_NODE_SHOW_APPS_STMT: + case QUERY_NODE_SHOW_SCORES_STMT: + case QUERY_NODE_SHOW_VARIABLE_STMT: + case QUERY_NODE_SHOW_CREATE_DATABASE_STMT: + case QUERY_NODE_SHOW_CREATE_TABLE_STMT: + case QUERY_NODE_SHOW_CREATE_STABLE_STMT: + case QUERY_NODE_SHOW_TRANSACTIONS_STMT: { SShowStmt* pStmt = (SShowStmt*)pNode; nodesDestroyNode(pStmt->pDbName); nodesDestroyNode(pStmt->pTbNamePattern); break; } + case QUERY_NODE_KILL_CONNECTION_STMT: // no pointer field + case QUERY_NODE_KILL_QUERY_STMT: // no pointer field + case QUERY_NODE_KILL_TRANSACTION_STMT: // no pointer field + break; + case QUERY_NODE_DELETE_STMT: { + SDeleteStmt* pStmt = (SDeleteStmt*)pNode; + nodesDestroyNode(pStmt->pFromTable); + nodesDestroyNode(pStmt->pWhere); + nodesDestroyNode(pStmt->pCountFunc); + nodesDestroyNode(pStmt->pTagIndexCond); + break; + } case QUERY_NODE_QUERY: { SQuery* pQuery = (SQuery*)pNode; nodesDestroyNode(pQuery->pRoot); @@ -607,6 +686,13 @@ void nodesDestroyNode(SNodeptr pNode) { case QUERY_NODE_LOGIC_PLAN_EXCHANGE: destroyLogicNode((SLogicNode*)pNode); break; + case QUERY_NODE_LOGIC_PLAN_MERGE: { + SMergeLogicNode* pLogicNode = (SMergeLogicNode*)pNode; + destroyLogicNode((SLogicNode*)pLogicNode); + nodesDestroyList(pLogicNode->pMergeKeys); + nodesDestroyList(pLogicNode->pInputs); + break; + } case QUERY_NODE_LOGIC_PLAN_WINDOW: { SWindowLogicNode* pLogicNode = (SWindowLogicNode*)pNode; destroyLogicNode((SLogicNode*)pLogicNode); @@ -614,6 +700,13 @@ void nodesDestroyNode(SNodeptr pNode) { nodesDestroyNode(pLogicNode->pTspk); break; } + case QUERY_NODE_LOGIC_PLAN_FILL: { + SFillLogicNode* pLogicNode = (SFillLogicNode*)pNode; + destroyLogicNode((SLogicNode*)pLogicNode); + nodesDestroyNode(pLogicNode->pWStartTs); + nodesDestroyNode(pLogicNode->pValues); + break; + } case QUERY_NODE_LOGIC_PLAN_SORT: { SSortLogicNode* pLogicNode = (SSortLogicNode*)pNode; destroyLogicNode((SLogicNode*)pLogicNode); @@ -626,10 +719,16 @@ void nodesDestroyNode(SNodeptr pNode) { nodesDestroyList(pLogicNode->pPartitionKeys); break; } + case QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC: { + SIndefRowsFuncLogicNode* pLogicNode = (SIndefRowsFuncLogicNode*)pNode; + destroyLogicNode((SLogicNode*)pLogicNode); + nodesDestroyList(pLogicNode->pVectorFuncs); + break; + } case QUERY_NODE_LOGIC_SUBPLAN: { SLogicSubplan* pSubplan = (SLogicSubplan*)pNode; nodesDestroyList(pSubplan->pChildren); - nodesDestroyNode(pSubplan->pNode); + nodesDestroyNode((SNode*)pSubplan->pNode); nodesClearList(pSubplan->pParents); taosMemoryFreeClear(pSubplan->pVgroupList); break; @@ -638,17 +737,9 @@ void nodesDestroyNode(SNodeptr pNode) { nodesDestroyList(((SQueryLogicPlan*)pNode)->pTopSubplans); break; case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: - destroyScanPhysiNode((SScanPhysiNode*)pNode); - break; case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: - destroyScanPhysiNode((SScanPhysiNode*)pNode); - break; case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN: - destroyScanPhysiNode((SScanPhysiNode*)pNode); - break; case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN: - destroyScanPhysiNode((SScanPhysiNode*)pNode); - break; case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN: destroyScanPhysiNode((SScanPhysiNode*)pNode); break; @@ -679,21 +770,62 @@ void nodesDestroyNode(SNodeptr pNode) { nodesDestroyList(pPhyNode->pSrcEndPoints); break; } + case QUERY_NODE_PHYSICAL_PLAN_MERGE: { + SMergePhysiNode* pPhyNode = (SMergePhysiNode*)pNode; + destroyPhysiNode((SPhysiNode*)pPhyNode); + nodesDestroyList(pPhyNode->pMergeKeys); + nodesDestroyList(pPhyNode->pTargets); + break; + } case QUERY_NODE_PHYSICAL_PLAN_SORT: { SSortPhysiNode* pPhyNode = (SSortPhysiNode*)pNode; destroyPhysiNode((SPhysiNode*)pPhyNode); - nodesDestroyNode(pPhyNode->pExprs); - nodesDestroyNode(pPhyNode->pSortKeys); + nodesDestroyList(pPhyNode->pExprs); + nodesDestroyList(pPhyNode->pSortKeys); break; } case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL: + case QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: destroyWinodwPhysiNode((SWinodwPhysiNode*)pNode); break; + case QUERY_NODE_PHYSICAL_PLAN_FILL: { + SFillPhysiNode* pPhyNode = (SFillPhysiNode*)pNode; + destroyPhysiNode((SPhysiNode*)pPhyNode); + nodesDestroyNode(pPhyNode->pWStartTs); + nodesDestroyNode(pPhyNode->pValues); + nodesDestroyList(pPhyNode->pTargets); + break; + } case QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION: destroyWinodwPhysiNode((SWinodwPhysiNode*)pNode); break; + case QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE: { + SStateWinodwPhysiNode* pPhyNode = (SStateWinodwPhysiNode*)pNode; + destroyWinodwPhysiNode((SWinodwPhysiNode*)pPhyNode); + nodesDestroyNode(pPhyNode->pStateKey); + break; + } + case QUERY_NODE_PHYSICAL_PLAN_PARTITION: { + SPartitionPhysiNode* pPhyNode = (SPartitionPhysiNode*)pNode; + destroyPhysiNode((SPhysiNode*)pPhyNode); + nodesDestroyList(pPhyNode->pExprs); + nodesDestroyList(pPhyNode->pPartitionKeys); + nodesDestroyList(pPhyNode->pTargets); + break; + } + case QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC: { + SIndefRowsFuncPhysiNode* pPhyNode = (SIndefRowsFuncPhysiNode*)pNode; + destroyPhysiNode((SPhysiNode*)pPhyNode); + nodesDestroyList(pPhyNode->pExprs); + nodesDestroyList(pPhyNode->pVectorFuncs); + break; + } case QUERY_NODE_PHYSICAL_PLAN_DISPATCH: destroyDataSinkNode((SDataSinkNode*)pNode); break; @@ -703,11 +835,17 @@ void nodesDestroyNode(SNodeptr pNode) { taosMemoryFreeClear(pSink->pData); break; } + case QUERY_NODE_PHYSICAL_PLAN_DELETE: { + SDataDeleterNode* pSink = (SDataDeleterNode*)pNode; + destroyDataSinkNode((SDataSinkNode*)pSink); + nodesDestroyNode(pSink->pAffectedRows); + break; + } case QUERY_NODE_PHYSICAL_SUBPLAN: { SSubplan* pSubplan = (SSubplan*)pNode; nodesDestroyList(pSubplan->pChildren); - nodesDestroyNode(pSubplan->pNode); - nodesDestroyNode(pSubplan->pDataSink); + nodesDestroyNode((SNode*)pSubplan->pNode); + nodesDestroyNode((SNode*)pSubplan->pDataSink); nodesClearList(pSubplan->pParents); break; } @@ -745,7 +883,7 @@ SNodeList* nodesMakeList() { return p; } -int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode) { +int32_t nodesListAppend(SNodeList* pList, SNode* pNode) { if (NULL == pList || NULL == pNode) { return TSDB_CODE_FAILED; } @@ -767,7 +905,7 @@ int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode) { return TSDB_CODE_SUCCESS; } -int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode) { +int32_t nodesListStrictAppend(SNodeList* pList, SNode* pNode) { if (NULL == pNode) { terrno = TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY; @@ -779,7 +917,7 @@ int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode) { return code; } -int32_t nodesListMakeAppend(SNodeList** pList, SNodeptr pNode) { +int32_t nodesListMakeAppend(SNodeList** pList, SNode* pNode) { if (NULL == *pList) { *pList = nodesMakeList(); if (NULL == *pList) { @@ -790,7 +928,7 @@ int32_t nodesListMakeAppend(SNodeList** pList, SNodeptr pNode) { return nodesListAppend(*pList, pNode); } -int32_t nodesListMakeStrictAppend(SNodeList** pList, SNodeptr pNode) { +int32_t nodesListMakeStrictAppend(SNodeList** pList, SNode* pNode) { if (NULL == *pList) { *pList = nodesMakeList(); if (NULL == *pList) { @@ -832,7 +970,7 @@ int32_t nodesListStrictAppendList(SNodeList* pTarget, SNodeList* pSrc) { return code; } -int32_t nodesListPushFront(SNodeList* pList, SNodeptr pNode) { +int32_t nodesListPushFront(SNodeList* pList, SNode* pNode) { if (NULL == pList || NULL == pNode) { return TSDB_CODE_FAILED; } @@ -887,7 +1025,7 @@ void nodesListInsertList(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc) { taosMemoryFreeClear(pSrc); } -SNodeptr nodesListGetNode(SNodeList* pList, int32_t index) { +SNode* nodesListGetNode(SNodeList* pList, int32_t index) { SNode* node; FOREACH(node, pList) { if (0 == index--) { @@ -1421,7 +1559,7 @@ int32_t nodesMergeConds(SNode** pDst, SNodeList** pSrc) { *pDst = nodesListGetNode(*pSrc, 0); nodesClearList(*pSrc); } else { - SLogicConditionNode* pLogicCond = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); + SLogicConditionNode* pLogicCond = (SLogicConditionNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); if (NULL == pLogicCond) { return TSDB_CODE_OUT_OF_MEMORY; } diff --git a/source/libs/parser/inc/parInt.h b/source/libs/parser/inc/parInt.h index adedcf0fd9..b799fa9855 100644 --- a/source/libs/parser/inc/parInt.h +++ b/source/libs/parser/inc/parInt.h @@ -27,12 +27,12 @@ extern "C" { #define QUERY_SMA_OPTIMIZE_DISABLE 0 #define QUERY_SMA_OPTIMIZE_ENABLE 1 -int32_t parseInsertSyntax(SParseContext* pContext, SQuery** pQuery); -int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery); +int32_t parseInsertSyntax(SParseContext* pContext, SQuery** pQuery, SParseMetaCache* pMetaCache); +int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery, SParseMetaCache* pMetaCache); int32_t parse(SParseContext* pParseCxt, SQuery** pQuery); -int32_t collectMetaKey(SParseContext* pParseCxt, SQuery* pQuery); -int32_t authenticate(SParseContext* pParseCxt, SQuery* pQuery); -int32_t translate(SParseContext* pParseCxt, SQuery* pQuery); +int32_t collectMetaKey(SParseContext* pParseCxt, SQuery* pQuery, SParseMetaCache* pMetaCache); +int32_t authenticate(SParseContext* pParseCxt, SQuery* pQuery, SParseMetaCache* pMetaCache); +int32_t translate(SParseContext* pParseCxt, SQuery* pQuery, SParseMetaCache* pMetaCache); int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema); int32_t calculateConstant(SParseContext* pParseCxt, SQuery* pQuery); diff --git a/source/libs/parser/inc/parUtil.h b/source/libs/parser/inc/parUtil.h index fb67a35368..862e3e2cc0 100644 --- a/source/libs/parser/inc/parUtil.h +++ b/source/libs/parser/inc/parUtil.h @@ -87,6 +87,7 @@ int32_t getUserAuthFromCache(SParseMetaCache* pMetaCache, const char* pUser, con bool* pPass); int32_t getUdfInfoFromCache(SParseMetaCache* pMetaCache, const char* pFunc, SFuncInfo* pInfo); int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName, SArray** pIndexes); +void destoryParseMetaCache(SParseMetaCache* pMetaCache); #ifdef __cplusplus } diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index ed338b89e8..83ad41aac0 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -461,6 +461,7 @@ into_opt(A) ::= INTO full_table_name(B). stream_options(A) ::= . { A = createStreamOptions(pCxt); } stream_options(A) ::= stream_options(B) TRIGGER AT_ONCE. { ((SStreamOptions*)B)->triggerType = STREAM_TRIGGER_AT_ONCE; A = B; } stream_options(A) ::= stream_options(B) TRIGGER WINDOW_CLOSE. { ((SStreamOptions*)B)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; A = B; } +stream_options(A) ::= stream_options(B) TRIGGER MAX_DELAY duration_literal(C). { ((SStreamOptions*)B)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)B)->pDelay = releaseRawExprNode(pCxt, C); A = B; } stream_options(A) ::= stream_options(B) WATERMARK duration_literal(C). { ((SStreamOptions*)B)->pWatermark = releaseRawExprNode(pCxt, C); A = B; } /************************************************ kill connection/query ***********************************************/ diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index e7f4b05bc8..c75696cede 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -230,9 +230,13 @@ SNode* releaseRawExprNode(SAstCreateContext* pCxt, SNode* pNode) { SRawExprNode* pRawExpr = (SRawExprNode*)pNode; SNode* pExpr = pRawExpr->pNode; if (nodesIsExprNode(pExpr)) { - int32_t len = TMIN(sizeof(((SExprNode*)pExpr)->aliasName) - 1, pRawExpr->n); - strncpy(((SExprNode*)pExpr)->aliasName, pRawExpr->p, len); - ((SExprNode*)pExpr)->aliasName[len] = '\0'; + if (QUERY_NODE_COLUMN == nodeType(pExpr)) { + strcpy(((SExprNode*)pExpr)->aliasName, ((SColumnNode*)pExpr)->colName); + } else { + int32_t len = TMIN(sizeof(((SExprNode*)pExpr)->aliasName) - 1, pRawExpr->n); + strncpy(((SExprNode*)pExpr)->aliasName, pRawExpr->p, len); + ((SExprNode*)pExpr)->aliasName[len] = '\0'; + } } taosMemoryFreeClear(pNode); return pExpr; @@ -338,7 +342,7 @@ SNode* createPlaceholderValueNode(SAstCreateContext* pCxt, const SToken* pLitera if (NULL == pCxt->pPlaceholderValues) { pCxt->pPlaceholderValues = taosArrayInit(TARRAY_MIN_SIZE, POINTER_BYTES); if (NULL == pCxt->pPlaceholderValues) { - nodesDestroyNode(val); + nodesDestroyNode((SNode*)val); return NULL; } } @@ -368,7 +372,7 @@ SNode* createLogicConditionNode(SAstCreateContext* pCxt, ELogicConditionType typ code = addParamToLogicConditionNode(cond, pParam2); } if (TSDB_CODE_SUCCESS != code) { - nodesDestroyNode(cond); + nodesDestroyNode((SNode*)cond); return NULL; } return (SNode*)cond; @@ -399,7 +403,7 @@ SNode* createNotBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, static SNode* createPrimaryKeyCol(SAstCreateContext* pCxt) { CHECK_PARSER_STATUS(pCxt); - SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN); + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); CHECK_OUT_OF_MEM(pCol); pCol->colId = PRIMARYKEY_TIMESTAMP_COL_ID; strcpy(pCol->colName, PK_TS_COL_INTERNAL_NAME); @@ -541,7 +545,7 @@ SNode* createStateWindowNode(SAstCreateContext* pCxt, SNode* pExpr) { CHECK_OUT_OF_MEM(state); state->pCol = createPrimaryKeyCol(pCxt); if (NULL == state->pCol) { - nodesDestroyNode(state); + nodesDestroyNode((SNode*)state); CHECK_OUT_OF_MEM(state->pCol); } state->pExpr = pExpr; @@ -555,7 +559,7 @@ SNode* createIntervalWindowNode(SAstCreateContext* pCxt, SNode* pInterval, SNode CHECK_OUT_OF_MEM(interval); interval->pCol = createPrimaryKeyCol(pCxt); if (NULL == interval->pCol) { - nodesDestroyNode(interval); + nodesDestroyNode((SNode*)interval); CHECK_OUT_OF_MEM(interval->pCol); } interval->pInterval = pInterval; @@ -573,7 +577,7 @@ SNode* createFillNode(SAstCreateContext* pCxt, EFillMode mode, SNode* pValues) { fill->pValues = pValues; fill->pWStartTs = nodesMakeNode(QUERY_NODE_FUNCTION); if (NULL == fill->pWStartTs) { - nodesDestroyNode(fill); + nodesDestroyNode((SNode*)fill); CHECK_OUT_OF_MEM(fill->pWStartTs); } strcpy(((SFunctionNode*)fill->pWStartTs)->functionName, "_wstartts"); @@ -689,7 +693,7 @@ SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode* SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt) { CHECK_PARSER_STATUS(pCxt); - SDatabaseOptions* pOptions = nodesMakeNode(QUERY_NODE_DATABASE_OPTIONS); + SDatabaseOptions* pOptions = (SDatabaseOptions*)nodesMakeNode(QUERY_NODE_DATABASE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->buffer = TSDB_DEFAULT_BUFFER_PER_VNODE; pOptions->cachelast = TSDB_DEFAULT_CACHE_LAST_ROW; @@ -715,7 +719,7 @@ SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt) { SNode* createAlterDatabaseOptions(SAstCreateContext* pCxt) { CHECK_PARSER_STATUS(pCxt); - SDatabaseOptions* pOptions = nodesMakeNode(QUERY_NODE_DATABASE_OPTIONS); + SDatabaseOptions* pOptions = (SDatabaseOptions*)nodesMakeNode(QUERY_NODE_DATABASE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->buffer = -1; pOptions->cachelast = -1; @@ -800,10 +804,10 @@ SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOpti case DB_OPTION_RETENTIONS: ((SDatabaseOptions*)pOptions)->pRetentions = pVal; break; - case DB_OPTION_SCHEMALESS: +// case DB_OPTION_SCHEMALESS: // ((SDatabaseOptions*)pOptions)->schemaless = taosStr2Int8(((SToken*)pVal)->z, NULL, 10); - ((SDatabaseOptions*)pOptions)->schemaless = 1; - break; +// ((SDatabaseOptions*)pOptions)->schemaless = 0; +// break; default: break; } @@ -852,7 +856,7 @@ SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode* if (!checkDbName(pCxt, pDbName, false)) { return NULL; } - SAlterDatabaseStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_DATABASE_STMT); + SAlterDatabaseStmt* pStmt = (SAlterDatabaseStmt*)nodesMakeNode(QUERY_NODE_ALTER_DATABASE_STMT); CHECK_OUT_OF_MEM(pStmt); strncpy(pStmt->dbName, pDbName->z, pDbName->n); pStmt->pOptions = (SDatabaseOptions*)pOptions; @@ -861,7 +865,7 @@ SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode* SNode* createDefaultTableOptions(SAstCreateContext* pCxt) { CHECK_PARSER_STATUS(pCxt); - STableOptions* pOptions = nodesMakeNode(QUERY_NODE_TABLE_OPTIONS); + STableOptions* pOptions = (STableOptions*)nodesMakeNode(QUERY_NODE_TABLE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->filesFactor = TSDB_DEFAULT_ROLLUP_FILE_FACTOR; pOptions->ttl = TSDB_DEFAULT_TABLE_TTL; @@ -870,7 +874,7 @@ SNode* createDefaultTableOptions(SAstCreateContext* pCxt) { SNode* createAlterTableOptions(SAstCreateContext* pCxt) { CHECK_PARSER_STATUS(pCxt); - STableOptions* pOptions = nodesMakeNode(QUERY_NODE_TABLE_OPTIONS); + STableOptions* pOptions = (STableOptions*)nodesMakeNode(QUERY_NODE_TABLE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->filesFactor = -1; pOptions->ttl = -1; @@ -948,7 +952,7 @@ SNode* createCreateTableStmt(SAstCreateContext* pCxt, bool ignoreExists, SNode* SNode* createCreateSubTableClause(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNode* pUseRealTable, SNodeList* pSpecificTags, SNodeList* pValsOfTags, SNode* pOptions) { CHECK_PARSER_STATUS(pCxt); - SCreateSubTableClause* pStmt = nodesMakeNode(QUERY_NODE_CREATE_SUBTABLE_CLAUSE); + SCreateSubTableClause* pStmt = (SCreateSubTableClause*)nodesMakeNode(QUERY_NODE_CREATE_SUBTABLE_CLAUSE); CHECK_OUT_OF_MEM(pStmt); strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName); strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName); @@ -959,12 +963,13 @@ SNode* createCreateSubTableClause(SAstCreateContext* pCxt, bool ignoreExists, SN pStmt->pValsOfTags = pValsOfTags; nodesDestroyNode(pRealTable); nodesDestroyNode(pUseRealTable); + nodesDestroyNode(pOptions); return (SNode*)pStmt; } SNode* createCreateMultiTableStmt(SAstCreateContext* pCxt, SNodeList* pSubTables) { CHECK_PARSER_STATUS(pCxt); - SCreateMultiTableStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_MULTI_TABLE_STMT); + SCreateMultiTableStmt* pStmt = (SCreateMultiTableStmt*)nodesMakeNode(QUERY_NODE_CREATE_MULTI_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->pSubTables = pSubTables; return (SNode*)pStmt; @@ -972,7 +977,7 @@ SNode* createCreateMultiTableStmt(SAstCreateContext* pCxt, SNodeList* pSubTables SNode* createDropTableClause(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable) { CHECK_PARSER_STATUS(pCxt); - SDropTableClause* pStmt = nodesMakeNode(QUERY_NODE_DROP_TABLE_CLAUSE); + SDropTableClause* pStmt = (SDropTableClause*)nodesMakeNode(QUERY_NODE_DROP_TABLE_CLAUSE); CHECK_OUT_OF_MEM(pStmt); strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName); strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName); @@ -983,7 +988,7 @@ SNode* createDropTableClause(SAstCreateContext* pCxt, bool ignoreNotExists, SNod SNode* createDropTableStmt(SAstCreateContext* pCxt, SNodeList* pTables) { CHECK_PARSER_STATUS(pCxt); - SDropTableStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_TABLE_STMT); + SDropTableStmt* pStmt = (SDropTableStmt*)nodesMakeNode(QUERY_NODE_DROP_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->pTables = pTables; return (SNode*)pStmt; @@ -991,7 +996,7 @@ SNode* createDropTableStmt(SAstCreateContext* pCxt, SNodeList* pTables) { SNode* createDropSuperTableStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable) { CHECK_PARSER_STATUS(pCxt); - SDropSuperTableStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_SUPER_TABLE_STMT); + SDropSuperTableStmt* pStmt = (SDropSuperTableStmt*)nodesMakeNode(QUERY_NODE_DROP_SUPER_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName); strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName); @@ -1009,7 +1014,7 @@ static SNode* createAlterTableStmtFinalize(SNode* pRealTable, SAlterTableStmt* p SNode* createAlterTableModifyOptions(SAstCreateContext* pCxt, SNode* pRealTable, SNode* pOptions) { CHECK_PARSER_STATUS(pCxt); - SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); + SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->alterType = TSDB_ALTER_TABLE_UPDATE_OPTIONS; pStmt->pOptions = (STableOptions*)pOptions; @@ -1022,7 +1027,7 @@ SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable, if (!checkColumnName(pCxt, pColName)) { return NULL; } - SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); + SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->alterType = alterType; strncpy(pStmt->colName, pColName->z, pColName->n); @@ -1035,7 +1040,7 @@ SNode* createAlterTableDropCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_ if (!checkColumnName(pCxt, pColName)) { return NULL; } - SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); + SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->alterType = alterType; strncpy(pStmt->colName, pColName->z, pColName->n); @@ -1048,7 +1053,7 @@ SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int if (!checkColumnName(pCxt, pOldColName) || !checkColumnName(pCxt, pNewColName)) { return NULL; } - SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); + SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->alterType = alterType; strncpy(pStmt->colName, pOldColName->z, pOldColName->n); @@ -1061,7 +1066,7 @@ SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, SToken if (!checkColumnName(pCxt, pTagName)) { return NULL; } - SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); + SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->alterType = TSDB_ALTER_TABLE_UPDATE_TAG_VAL; strncpy(pStmt->colName, pTagName->z, pTagName->n); @@ -1092,7 +1097,7 @@ SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, S pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR; return NULL; } - SShowStmt* pStmt = nodesMakeNode(type); + SShowStmt* pStmt = (SShowStmt*)nodesMakeNode(type); CHECK_OUT_OF_MEM(pStmt); pStmt->pDbName = pDbName; pStmt->pTbNamePattern = pTbNamePattern; @@ -1137,7 +1142,7 @@ SNode* createAlterUserStmt(SAstCreateContext* pCxt, SToken* pUserName, int8_t al if (TSDB_ALTER_USER_PASSWD == alterType) { char password[TSDB_USET_PASSWORD_LEN] = {0}; if (!checkPassword(pCxt, pVal, password)) { - nodesDestroyNode(pStmt); + nodesDestroyNode((SNode*)pStmt); return NULL; } strcpy(pStmt->password, password); @@ -1187,7 +1192,7 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode) { pStmt->dnodeId = taosStr2Int32(pDnode->z, NULL, 10); } else { if (!checkAndSplitEndpoint(pCxt, pDnode, pStmt->fqdn, &pStmt->port)) { - nodesDestroyNode(pStmt); + nodesDestroyNode((SNode*)pStmt); return NULL; } } @@ -1197,7 +1202,7 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode) { SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig, const SToken* pValue) { CHECK_PARSER_STATUS(pCxt); - SAlterDnodeStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_DNODE_STMT); + SAlterDnodeStmt* pStmt = (SAlterDnodeStmt*)nodesMakeNode(QUERY_NODE_ALTER_DNODE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->dnodeId = taosStr2Int32(pDnode->z, NULL, 10); trimString(pConfig->z, pConfig->n, pStmt->config, sizeof(pStmt->config)); @@ -1213,7 +1218,7 @@ SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool igno if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName) || !checkDbName(pCxt, NULL, true)) { return NULL; } - SCreateIndexStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_INDEX_STMT); + SCreateIndexStmt* pStmt = (SCreateIndexStmt*)nodesMakeNode(QUERY_NODE_CREATE_INDEX_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->indexType = type; pStmt->ignoreExists = ignoreExists; @@ -1227,7 +1232,7 @@ SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool igno SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding) { CHECK_PARSER_STATUS(pCxt); - SIndexOptions* pOptions = nodesMakeNode(QUERY_NODE_INDEX_OPTIONS); + SIndexOptions* pOptions = (SIndexOptions*)nodesMakeNode(QUERY_NODE_INDEX_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->pFuncs = pFuncs; pOptions->pInterval = pInterval; @@ -1241,7 +1246,7 @@ SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName)) { return NULL; } - SDropIndexStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_INDEX_STMT); + SDropIndexStmt* pStmt = (SDropIndexStmt*)nodesMakeNode(QUERY_NODE_DROP_INDEX_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->ignoreNotExists = ignoreNotExists; strncpy(pStmt->indexName, pIndexName->z, pIndexName->n); @@ -1251,26 +1256,24 @@ SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken SNode* createCreateComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId) { CHECK_PARSER_STATUS(pCxt); - SCreateComponentNodeStmt* pStmt = nodesMakeNode(type); + SCreateComponentNodeStmt* pStmt = (SCreateComponentNodeStmt*)nodesMakeNode(type); CHECK_OUT_OF_MEM(pStmt); pStmt->dnodeId = taosStr2Int32(pDnodeId->z, NULL, 10); - ; return (SNode*)pStmt; } SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId) { CHECK_PARSER_STATUS(pCxt); - SDropComponentNodeStmt* pStmt = nodesMakeNode(type); + SDropComponentNodeStmt* pStmt = (SDropComponentNodeStmt*)nodesMakeNode(type); CHECK_OUT_OF_MEM(pStmt); pStmt->dnodeId = taosStr2Int32(pDnodeId->z, NULL, 10); - ; return (SNode*)pStmt; } SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, SNode* pQuery, const SToken* pSubDbName, SNode* pRealTable) { CHECK_PARSER_STATUS(pCxt); - SCreateTopicStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT); + SCreateTopicStmt* pStmt = (SCreateTopicStmt*)nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT); CHECK_OUT_OF_MEM(pStmt); strncpy(pStmt->topicName, pTopicName->z, pTopicName->n); pStmt->ignoreExists = ignoreExists; @@ -1288,7 +1291,7 @@ SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const S SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pTopicName) { CHECK_PARSER_STATUS(pCxt); - SDropTopicStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_TOPIC_STMT); + SDropTopicStmt* pStmt = (SDropTopicStmt*)nodesMakeNode(QUERY_NODE_DROP_TOPIC_STMT); CHECK_OUT_OF_MEM(pStmt); strncpy(pStmt->topicName, pTopicName->z, pTopicName->n); pStmt->ignoreNotExists = ignoreNotExists; @@ -1298,7 +1301,7 @@ SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pCGroupId, const SToken* pTopicName) { CHECK_PARSER_STATUS(pCxt); - SDropCGroupStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_CGROUP_STMT); + SDropCGroupStmt* pStmt = (SDropCGroupStmt*)nodesMakeNode(QUERY_NODE_DROP_CGROUP_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->ignoreNotExists = ignoreNotExists; strncpy(pStmt->topicName, pTopicName->z, pTopicName->n); @@ -1308,7 +1311,7 @@ SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, const SToken* pValue) { CHECK_PARSER_STATUS(pCxt); - SAlterLocalStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_LOCAL_STMT); + SAlterLocalStmt* pStmt = (SAlterLocalStmt*)nodesMakeNode(QUERY_NODE_ALTER_LOCAL_STMT); CHECK_OUT_OF_MEM(pStmt); trimString(pConfig->z, pConfig->n, pStmt->config, sizeof(pStmt->config)); if (NULL != pValue) { @@ -1319,7 +1322,7 @@ SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, cons SNode* createDefaultExplainOptions(SAstCreateContext* pCxt) { CHECK_PARSER_STATUS(pCxt); - SExplainOptions* pOptions = nodesMakeNode(QUERY_NODE_EXPLAIN_OPTIONS); + SExplainOptions* pOptions = (SExplainOptions*)nodesMakeNode(QUERY_NODE_EXPLAIN_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->verbose = TSDB_DEFAULT_EXPLAIN_VERBOSE; pOptions->ratio = TSDB_DEFAULT_EXPLAIN_RATIO; @@ -1340,7 +1343,7 @@ SNode* setExplainRatio(SAstCreateContext* pCxt, SNode* pOptions, const SToken* p SNode* createExplainStmt(SAstCreateContext* pCxt, bool analyze, SNode* pOptions, SNode* pQuery) { CHECK_PARSER_STATUS(pCxt); - SExplainStmt* pStmt = nodesMakeNode(QUERY_NODE_EXPLAIN_STMT); + SExplainStmt* pStmt = (SExplainStmt*)nodesMakeNode(QUERY_NODE_EXPLAIN_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->analyze = analyze; pStmt->pOptions = (SExplainOptions*)pOptions; @@ -1350,7 +1353,7 @@ SNode* createExplainStmt(SAstCreateContext* pCxt, bool analyze, SNode* pOptions, SNode* createDescribeStmt(SAstCreateContext* pCxt, SNode* pRealTable) { CHECK_PARSER_STATUS(pCxt); - SDescribeStmt* pStmt = nodesMakeNode(QUERY_NODE_DESCRIBE_STMT); + SDescribeStmt* pStmt = (SDescribeStmt*)nodesMakeNode(QUERY_NODE_DESCRIBE_STMT); CHECK_OUT_OF_MEM(pStmt); strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName); strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName); @@ -1379,7 +1382,7 @@ SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR; return NULL; } - SCreateFunctionStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_FUNCTION_STMT); + SCreateFunctionStmt* pStmt = (SCreateFunctionStmt*)nodesMakeNode(QUERY_NODE_CREATE_FUNCTION_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->ignoreExists = ignoreExists; strncpy(pStmt->funcName, pFuncName->z, pFuncName->n); @@ -1392,7 +1395,7 @@ SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool SNode* createDropFunctionStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pFuncName) { CHECK_PARSER_STATUS(pCxt); - SDropFunctionStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_FUNCTION_STMT); + SDropFunctionStmt* pStmt = (SDropFunctionStmt*)nodesMakeNode(QUERY_NODE_DROP_FUNCTION_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->ignoreNotExists = ignoreNotExists; strncpy(pStmt->funcName, pFuncName->z, pFuncName->n); @@ -1401,7 +1404,7 @@ SNode* createDropFunctionStmt(SAstCreateContext* pCxt, bool ignoreNotExists, con SNode* createStreamOptions(SAstCreateContext* pCxt) { CHECK_PARSER_STATUS(pCxt); - SStreamOptions* pOptions = nodesMakeNode(QUERY_NODE_STREAM_OPTIONS); + SStreamOptions* pOptions = (SStreamOptions*)nodesMakeNode(QUERY_NODE_STREAM_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->triggerType = STREAM_TRIGGER_AT_ONCE; return (SNode*)pOptions; @@ -1410,7 +1413,7 @@ SNode* createStreamOptions(SAstCreateContext* pCxt) { SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pStreamName, SNode* pRealTable, SNode* pOptions, SNode* pQuery) { CHECK_PARSER_STATUS(pCxt); - SCreateStreamStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_STREAM_STMT); + SCreateStreamStmt* pStmt = (SCreateStreamStmt*)nodesMakeNode(QUERY_NODE_CREATE_STREAM_STMT); CHECK_OUT_OF_MEM(pStmt); strncpy(pStmt->streamName, pStreamName->z, pStreamName->n); if (NULL != pRealTable) { @@ -1426,7 +1429,7 @@ SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pStreamName) { CHECK_PARSER_STATUS(pCxt); - SDropStreamStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_STREAM_STMT); + SDropStreamStmt* pStmt = (SDropStreamStmt*)nodesMakeNode(QUERY_NODE_DROP_STREAM_STMT); CHECK_OUT_OF_MEM(pStmt); strncpy(pStmt->streamName, pStreamName->z, pStreamName->n); pStmt->ignoreNotExists = ignoreNotExists; @@ -1435,7 +1438,7 @@ SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId) { CHECK_PARSER_STATUS(pCxt); - SKillStmt* pStmt = nodesMakeNode(type); + SKillStmt* pStmt = (SKillStmt*)nodesMakeNode(type); CHECK_OUT_OF_MEM(pStmt); pStmt->targetId = taosStr2Int32(pId->z, NULL, 10); return (SNode*)pStmt; @@ -1443,14 +1446,14 @@ SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId SNode* createBalanceVgroupStmt(SAstCreateContext* pCxt) { CHECK_PARSER_STATUS(pCxt); - SBalanceVgroupStmt* pStmt = nodesMakeNode(QUERY_NODE_BALANCE_VGROUP_STMT); + SBalanceVgroupStmt* pStmt = (SBalanceVgroupStmt*)nodesMakeNode(QUERY_NODE_BALANCE_VGROUP_STMT); CHECK_OUT_OF_MEM(pStmt); return (SNode*)pStmt; } SNode* createMergeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId1, const SToken* pVgId2) { CHECK_PARSER_STATUS(pCxt); - SMergeVgroupStmt* pStmt = nodesMakeNode(QUERY_NODE_MERGE_VGROUP_STMT); + SMergeVgroupStmt* pStmt = (SMergeVgroupStmt*)nodesMakeNode(QUERY_NODE_MERGE_VGROUP_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->vgId1 = taosStr2Int32(pVgId1->z, NULL, 10); pStmt->vgId2 = taosStr2Int32(pVgId2->z, NULL, 10); @@ -1459,7 +1462,7 @@ SNode* createMergeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId1, cons SNode* createRedistributeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId, SNodeList* pDnodes) { CHECK_PARSER_STATUS(pCxt); - SRedistributeVgroupStmt* pStmt = nodesMakeNode(QUERY_NODE_REDISTRIBUTE_VGROUP_STMT); + SRedistributeVgroupStmt* pStmt = (SRedistributeVgroupStmt*)nodesMakeNode(QUERY_NODE_REDISTRIBUTE_VGROUP_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->vgId = taosStr2Int32(pVgId->z, NULL, 10); pStmt->pDnodes = pDnodes; @@ -1468,7 +1471,7 @@ SNode* createRedistributeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId SNode* createSplitVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId) { CHECK_PARSER_STATUS(pCxt); - SSplitVgroupStmt* pStmt = nodesMakeNode(QUERY_NODE_SPLIT_VGROUP_STMT); + SSplitVgroupStmt* pStmt = (SSplitVgroupStmt*)nodesMakeNode(QUERY_NODE_SPLIT_VGROUP_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->vgId = taosStr2Int32(pVgId->z, NULL, 10); return (SNode*)pStmt; @@ -1486,7 +1489,7 @@ SNode* createGrantStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDbN if (!checkDbName(pCxt, pDbName, false) || !checkUserName(pCxt, pUserName)) { return NULL; } - SGrantStmt* pStmt = nodesMakeNode(QUERY_NODE_GRANT_STMT); + SGrantStmt* pStmt = (SGrantStmt*)nodesMakeNode(QUERY_NODE_GRANT_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->privileges = privileges; strncpy(pStmt->dbName, pDbName->z, pDbName->n); @@ -1499,7 +1502,7 @@ SNode* createRevokeStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDb if (!checkDbName(pCxt, pDbName, false) || !checkUserName(pCxt, pUserName)) { return NULL; } - SRevokeStmt* pStmt = nodesMakeNode(QUERY_NODE_REVOKE_STMT); + SRevokeStmt* pStmt = (SRevokeStmt*)nodesMakeNode(QUERY_NODE_REVOKE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->privileges = privileges; strncpy(pStmt->dbName, pDbName->z, pDbName->n); @@ -1508,11 +1511,11 @@ SNode* createRevokeStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDb } SNode* createCountFuncForDelete(SAstCreateContext* pCxt) { - SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION); + SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); CHECK_OUT_OF_MEM(pFunc); strcpy(pFunc->functionName, "count"); if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pFunc->pParameterList, createPrimaryKeyCol(pCxt))) { - nodesDestroyNode(pFunc); + nodesDestroyNode((SNode*)pFunc); CHECK_OUT_OF_MEM(NULL); } return (SNode*)pFunc; @@ -1520,13 +1523,13 @@ SNode* createCountFuncForDelete(SAstCreateContext* pCxt) { SNode* createDeleteStmt(SAstCreateContext* pCxt, SNode* pTable, SNode* pWhere) { CHECK_PARSER_STATUS(pCxt); - SDeleteStmt* pStmt = nodesMakeNode(QUERY_NODE_DELETE_STMT); + SDeleteStmt* pStmt = (SDeleteStmt*)nodesMakeNode(QUERY_NODE_DELETE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->pFromTable = pTable; pStmt->pWhere = pWhere; pStmt->pCountFunc = createCountFuncForDelete(pCxt); if (NULL == pStmt->pCountFunc) { - nodesDestroyNode(pStmt); + nodesDestroyNode((SNode*)pStmt); CHECK_OUT_OF_MEM(NULL); } return (SNode*)pStmt; diff --git a/source/libs/parser/src/parAstParser.c b/source/libs/parser/src/parAstParser.c index af22d8f629..1aa1320a3c 100644 --- a/source/libs/parser/src/parAstParser.c +++ b/source/libs/parser/src/parAstParser.c @@ -77,7 +77,7 @@ int32_t parse(SParseContext* pParseCxt, SQuery** pQuery) { abort_parse: ParseFree(pParser, (FFree)taosMemoryFree); if (TSDB_CODE_SUCCESS == cxt.errCode) { - *pQuery = taosMemoryCalloc(1, sizeof(SQuery)); + *pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY); if (NULL == *pQuery) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -95,12 +95,6 @@ typedef struct SCollectMetaKeyCxt { SNode* pStmt; } SCollectMetaKeyCxt; -static void destroyCollectMetaKeyCxt(SCollectMetaKeyCxt* pCxt) { - if (NULL != pCxt->pMetaCache) { - // TODO - } -} - typedef struct SCollectMetaKeyFromExprCxt { SCollectMetaKeyCxt* pComCxt; int32_t errCode; @@ -477,16 +471,7 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) { return TSDB_CODE_SUCCESS; } -int32_t collectMetaKey(SParseContext* pParseCxt, SQuery* pQuery) { - SCollectMetaKeyCxt cxt = { - .pParseCxt = pParseCxt, .pMetaCache = taosMemoryCalloc(1, sizeof(SParseMetaCache)), .pStmt = pQuery->pRoot}; - if (NULL == cxt.pMetaCache) { - return TSDB_CODE_OUT_OF_MEMORY; - } - int32_t code = collectMetaKeyFromQuery(&cxt, pQuery->pRoot); - if (TSDB_CODE_SUCCESS == code) { - TSWAP(pQuery->pMetaCache, cxt.pMetaCache); - } - destroyCollectMetaKeyCxt(&cxt); - return code; +int32_t collectMetaKey(SParseContext* pParseCxt, SQuery* pQuery, SParseMetaCache* pMetaCache) { + SCollectMetaKeyCxt cxt = {.pParseCxt = pParseCxt, .pMetaCache = pMetaCache, .pStmt = pQuery->pRoot}; + return collectMetaKeyFromQuery(&cxt, pQuery->pRoot); } diff --git a/source/libs/parser/src/parAuthenticator.c b/source/libs/parser/src/parAuthenticator.c index 858f602e1e..068ac4c94d 100644 --- a/source/libs/parser/src/parAuthenticator.c +++ b/source/libs/parser/src/parAuthenticator.c @@ -105,7 +105,7 @@ static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt) { return TSDB_CODE_SUCCESS; } -int32_t authenticate(SParseContext* pParseCxt, SQuery* pQuery) { - SAuthCxt cxt = {.pParseCxt = pParseCxt, .pMetaCache = pQuery->pMetaCache, .errCode = TSDB_CODE_SUCCESS}; +int32_t authenticate(SParseContext* pParseCxt, SQuery* pQuery, SParseMetaCache* pMetaCache) { + SAuthCxt cxt = {.pParseCxt = pParseCxt, .pMetaCache = pMetaCache, .errCode = TSDB_CODE_SUCCESS}; return authQuery(&cxt, pQuery->pRoot); } diff --git a/source/libs/parser/src/parCalcConst.c b/source/libs/parser/src/parCalcConst.c index b2cb67b1c3..22d7afd642 100644 --- a/source/libs/parser/src/parCalcConst.c +++ b/source/libs/parser/src/parCalcConst.c @@ -65,7 +65,7 @@ static bool isCondition(const SNode* pNode) { } static int32_t rewriteIsTrue(SNode* pSrc, SNode** pIsTrue) { - SOperatorNode* pOp = nodesMakeNode(QUERY_NODE_OPERATOR); + SOperatorNode* pOp = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR); if (NULL == pOp) { return TSDB_CODE_OUT_OF_MEMORY; } diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 7c0bf0de74..626960bf10 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -1301,6 +1301,8 @@ static void destroyInsertParseContextForTable(SInsertParseContext* pCxt) { destroyCreateSubTbReq(&pCxt->createTblReq); } +static void destroySubTableHashElem(void* p) { taosMemoryFree(*(STableMeta**)p); } + static void destroyInsertParseContext(SInsertParseContext* pCxt) { destroyInsertParseContextForTable(pCxt); taosHashCleanup(pCxt->pVgroupsHashObj); @@ -1458,7 +1460,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) { // [(field1_name, ...)] // VALUES (field1_value, ...) [(field1_value2, ...) ...] | FILE csv_file_path // [...]; -int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery) { +int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery, SParseMetaCache* pMetaCache) { SInsertParseContext context = { .pComCxt = pContext, .pSql = (char*)pContext->pSql, @@ -1469,7 +1471,8 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery) { .pDbFNameHashObj = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), true, HASH_NO_LOCK), .totalNum = 0, .pOutput = (SVnodeModifOpStmt*)nodesMakeNode(QUERY_NODE_VNODE_MODIF_STMT), - .pStmtCb = pContext->pStmtCb}; + .pStmtCb = pContext->pStmtCb, + .pMetaCache = pMetaCache}; if (pContext->pStmtCb && *pQuery) { (*pContext->pStmtCb->getExecInfoFn)(pContext->pStmtCb->pStmt, &context.pVgroupsHashObj, @@ -1484,18 +1487,17 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery) { NULL == context.pTableNameHashObj || NULL == context.pDbFNameHashObj || NULL == context.pOutput) { return TSDB_CODE_TSC_OUT_OF_MEMORY; } + taosHashSetFreeFp(context.pSubTableHashObj, destroySubTableHashElem); if (pContext->pStmtCb) { TSDB_QUERY_SET_TYPE(context.pOutput->insertType, TSDB_QUERY_TYPE_STMT_INSERT); } if (NULL == *pQuery) { - *pQuery = taosMemoryCalloc(1, sizeof(SQuery)); + *pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY); if (NULL == *pQuery) { return TSDB_CODE_OUT_OF_MEMORY; } - } else { - context.pMetaCache = (*pQuery)->pMetaCache; } (*pQuery)->execMode = QUERY_EXEC_MODE_SCHEDULE; (*pQuery)->haveResultSet = false; @@ -1694,24 +1696,20 @@ static int32_t parseInsertBodySyntax(SInsertParseSyntaxCxt* pCxt) { return TSDB_CODE_SUCCESS; } -int32_t parseInsertSyntax(SParseContext* pContext, SQuery** pQuery) { +int32_t parseInsertSyntax(SParseContext* pContext, SQuery** pQuery, SParseMetaCache* pMetaCache) { SInsertParseSyntaxCxt context = {.pComCxt = pContext, .pSql = (char*)pContext->pSql, .msg = {.buf = pContext->pMsg, .len = pContext->msgLen}, - .pMetaCache = taosMemoryCalloc(1, sizeof(SParseMetaCache))}; - if (NULL == context.pMetaCache) { - return TSDB_CODE_OUT_OF_MEMORY; - } - int32_t code = skipInsertInto(&context.pSql, &context.msg); + .pMetaCache = pMetaCache}; + int32_t code = skipInsertInto(&context.pSql, &context.msg); if (TSDB_CODE_SUCCESS == code) { code = parseInsertBodySyntax(&context); } if (TSDB_CODE_SUCCESS == code) { - *pQuery = taosMemoryCalloc(1, sizeof(SQuery)); + *pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY); if (NULL == *pQuery) { return TSDB_CODE_OUT_OF_MEMORY; } - TSWAP((*pQuery)->pMetaCache, context.pMetaCache); } return code; } diff --git a/source/libs/parser/src/parInsertData.c b/source/libs/parser/src/parInsertData.c index 1960073f29..2b505d4bf7 100644 --- a/source/libs/parser/src/parInsertData.c +++ b/source/libs/parser/src/parInsertData.c @@ -283,6 +283,8 @@ void sortRemoveDataBlockDupRowsRaw(STableDataBlocks* dataBuf) { if (!dataBuf->ordered) { char* pBlockData = pBlocks->data; + + // todo. qsort is unstable, if timestamp is same, should get the last one qsort(pBlockData, pBlocks->numOfRows, dataBuf->rowSize, rowDataCompar); int32_t i = 0; @@ -350,6 +352,8 @@ int sortRemoveDataBlockDupRows(STableDataBlocks* dataBuf, SBlockKeyInfo* pBlkKey if (!dataBuf->ordered) { pBlkKeyTuple = pBlkKeyInfo->pKeyTuple; + + // todo. qsort is unstable, if timestamp is same, should get the last one qsort(pBlkKeyTuple, nRows, sizeof(SBlockKeyTuple), rowDataCompar); pBlkKeyTuple = pBlkKeyInfo->pKeyTuple; diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index e1ae727b66..a9d730e1ad 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -117,6 +117,7 @@ static SKeyword keywordTable[] = { {"LOCAL", TK_LOCAL}, {"MATCH", TK_MATCH}, {"MAXROWS", TK_MAXROWS}, + {"MAX_DELAY", TK_MAX_DELAY}, {"MERGE", TK_MERGE}, {"MINROWS", TK_MINROWS}, {"MINUS", TK_MINUS}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 9e34fe6af7..f5d7c3d168 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -113,7 +113,7 @@ static int32_t getTableMetaImpl(STranslateContext* pCxt, const SName* pName, STa if (pParCxt->async) { code = getTableMetaFromCache(pCxt->pMetaCache, pName, pMeta); } else { - SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter, + SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter, .requestId = pParCxt->requestId, .requestObjRefId = pParCxt->requestRid, .mgmtEps = pParCxt->mgmtEpSet}; @@ -141,13 +141,12 @@ static int32_t refreshGetTableMeta(STranslateContext* pCxt, const char* pDbName, if (pParCxt->async) { code = getTableMetaFromCache(pCxt->pMetaCache, &name, pMeta); } else { - SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter, + SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter, .requestId = pParCxt->requestId, .requestObjRefId = pParCxt->requestRid, .mgmtEps = pParCxt->mgmtEpSet}; - - code = - catalogRefreshGetTableMeta(pParCxt->pCatalog, &conn, &name, pMeta, false); + + code = catalogRefreshGetTableMeta(pParCxt->pCatalog, &conn, &name, pMeta, false); } if (TSDB_CODE_SUCCESS != code) { parserError("catalogRefreshGetTableMeta error, code:%s, dbName:%s, tbName:%s", tstrerror(code), pDbName, @@ -165,7 +164,7 @@ static int32_t getDBVgInfoImpl(STranslateContext* pCxt, const SName* pName, SArr if (pParCxt->async) { code = getDbVgInfoFromCache(pCxt->pMetaCache, fullDbName, pVgInfo); } else { - SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter, + SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter, .requestId = pParCxt->requestId, .requestObjRefId = pParCxt->requestRid, .mgmtEps = pParCxt->mgmtEpSet}; @@ -196,7 +195,7 @@ static int32_t getTableHashVgroupImpl(STranslateContext* pCxt, const SName* pNam if (pParCxt->async) { code = getTableVgroupFromCache(pCxt->pMetaCache, pName, pInfo); } else { - SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter, + SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter, .requestId = pParCxt->requestId, .requestObjRefId = pParCxt->requestRid, .mgmtEps = pParCxt->mgmtEpSet}; @@ -244,7 +243,7 @@ static int32_t getDBCfg(STranslateContext* pCxt, const char* pDbName, SDbCfgInfo if (pParCxt->async) { code = getDbCfgFromCache(pCxt->pMetaCache, dbFname, pInfo); } else { - SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter, + SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter, .requestId = pParCxt->requestId, .requestObjRefId = pParCxt->requestRid, .mgmtEps = pParCxt->mgmtEpSet}; @@ -265,13 +264,12 @@ static int32_t getUdfInfo(STranslateContext* pCxt, SFunctionNode* pFunc) { if (pParCxt->async) { code = getUdfInfoFromCache(pCxt->pMetaCache, pFunc->functionName, &funcInfo); } else { - SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter, + SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter, .requestId = pParCxt->requestId, .requestObjRefId = pParCxt->requestRid, .mgmtEps = pParCxt->mgmtEpSet}; - code = catalogGetUdfInfo(pParCxt->pCatalog, &conn, pFunc->functionName, - &funcInfo); + code = catalogGetUdfInfo(pParCxt->pCatalog, &conn, pFunc->functionName, &funcInfo); } if (TSDB_CODE_SUCCESS == code) { pFunc->funcType = FUNCTION_TYPE_UDF; @@ -293,11 +291,11 @@ static int32_t getTableIndex(STranslateContext* pCxt, const SName* pName, SArray if (pParCxt->async) { code = getTableIndexFromCache(pCxt->pMetaCache, pName, pIndexes); } else { - SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter, + SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter, .requestId = pParCxt->requestId, .requestObjRefId = pParCxt->requestRid, .mgmtEps = pParCxt->mgmtEpSet}; - + code = catalogGetTableIndex(pParCxt->pCatalog, &conn, pName, pIndexes); } if (TSDB_CODE_SUCCESS != code) { @@ -540,13 +538,15 @@ static int32_t findAndSetColumn(STranslateContext* pCxt, SColumnNode** pColRef, SNode* pNode; FOREACH(pNode, pProjectList) { SExprNode* pExpr = (SExprNode*)pNode; - if (0 == strcmp(pCol->colName, pExpr->aliasName) || - (isPrimaryKey((STempTableNode*)pTable, pNode) && isInternalPrimaryKey(pCol))) { + if (0 == strcmp(pCol->colName, pExpr->aliasName)) { if (*pFound) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_AMBIGUOUS_COLUMN, pCol->colName); } setColumnInfoByExpr(pTable, pExpr, pColRef); *pFound = true; + } else if (isPrimaryKey((STempTableNode*)pTable, pNode) && isInternalPrimaryKey(pCol)) { + setColumnInfoByExpr(pTable, pExpr, pColRef); + *pFound = true; } } } @@ -665,9 +665,24 @@ static int32_t parseTimeFromValueNode(STranslateContext* pCxt, SValueNode* pVal) } char* pEnd = NULL; pVal->datum.i = taosStr2Int64(pVal->literal, &pEnd, 10); - return (NULL != pEnd && '\0' == *pEnd) ? TSDB_CODE_SUCCESS : TSDB_CODE_FAILED; + return (NULL != pEnd && '\0' == *pEnd) ? TSDB_CODE_SUCCESS : TSDB_CODE_PAR_WRONG_VALUE_TYPE; } else { - return TSDB_CODE_FAILED; + return TSDB_CODE_PAR_WRONG_VALUE_TYPE; + } +} + +static int32_t parseBoolFromValueNode(STranslateContext* pCxt, SValueNode* pVal) { + if (IS_VAR_DATA_TYPE(pVal->node.resType.type) || TSDB_DATA_TYPE_BOOL == pVal->node.resType.type) { + pVal->datum.b = (0 == strcasecmp(pVal->literal, "true")); + return TSDB_CODE_SUCCESS; + } else if (IS_INTEGER_TYPE(pVal->node.resType.type)) { + pVal->datum.b = (0 != taosStr2Int64(pVal->literal, NULL, 10)); + return TSDB_CODE_SUCCESS; + } else if (IS_FLOAT_TYPE(pVal->node.resType.type)) { + pVal->datum.b = (0 != taosStr2Double(pVal->literal, NULL)); + return TSDB_CODE_SUCCESS; + } else { + return TSDB_CODE_PAR_WRONG_VALUE_TYPE; } } @@ -688,7 +703,9 @@ static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SD case TSDB_DATA_TYPE_NULL: break; case TSDB_DATA_TYPE_BOOL: - pVal->datum.b = (0 == strcasecmp(pVal->literal, "true")); + if (TSDB_CODE_SUCCESS != parseBoolFromValueNode(pCxt, pVal)) { + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal); + } *(bool*)&pVal->typeData = pVal->datum.b; break; case TSDB_DATA_TYPE_TINYINT: { @@ -983,7 +1000,7 @@ static bool isCountStar(SFunctionNode* pFunc) { // count(*) is rewritten as count(ts) for scannning optimization static int32_t rewriteCountStar(STranslateContext* pCxt, SFunctionNode* pCount) { - SColumnNode* pCol = nodesListGetNode(pCount->pParameterList, 0); + SColumnNode* pCol = (SColumnNode*)nodesListGetNode(pCount->pParameterList, 0); STableNode* pTable = NULL; int32_t code = findTable(pCxt, ('\0' == pCol->tableAlias[0] ? NULL : pCol->tableAlias), &pTable); if (TSDB_CODE_SUCCESS == code && QUERY_NODE_REAL_TABLE == nodeType(pTable)) { @@ -1035,7 +1052,7 @@ static int32_t translateScanPseudoColumnFunc(STranslateContext* pCxt, SFunctionN return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TBNAME); } } else { - SValueNode* pVal = nodesListGetNode(pFunc->pParameterList, 0); + SValueNode* pVal = (SValueNode*)nodesListGetNode(pFunc->pParameterList, 0); STableNode* pTable = NULL; pCxt->errCode = findTable(pCxt, pVal->literal, &pTable); if (TSDB_CODE_SUCCESS == pCxt->errCode && (NULL == pTable || QUERY_NODE_REAL_TABLE != nodeType(pTable))) { @@ -1071,6 +1088,16 @@ static int32_t translateForbidFillFunc(STranslateContext* pCxt, SFunctionNode* p return TSDB_CODE_SUCCESS; } +static int32_t translateWindowPseudoColumnFunc(STranslateContext* pCxt, SFunctionNode* pFunc) { + if (!fmIsWindowPseudoColumnFunc(pFunc->funcId)) { + return TSDB_CODE_SUCCESS; + } + if (NULL == pCxt->pCurrSelectStmt->pWindow) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_WINDOW_PC); + } + return TSDB_CODE_SUCCESS; +} + static void setFuncClassification(SSelectStmt* pSelect, SFunctionNode* pFunc) { if (NULL != pSelect) { pSelect->hasAggFuncs = pSelect->hasAggFuncs ? true : fmIsAggFunc(pFunc->funcId); @@ -1100,6 +1127,9 @@ static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc) if (TSDB_CODE_SUCCESS == pCxt->errCode) { pCxt->errCode = translateForbidFillFunc(pCxt, pFunc); } + if (TSDB_CODE_SUCCESS == pCxt->errCode) { + pCxt->errCode = translateWindowPseudoColumnFunc(pCxt, pFunc); + } if (TSDB_CODE_SUCCESS == pCxt->errCode) { setFuncClassification(pCxt->pCurrSelectStmt, pFunc); } @@ -1176,7 +1206,7 @@ typedef struct SCheckExprForGroupByCxt { } SCheckExprForGroupByCxt; static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode) { - SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION); + SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); if (NULL == pFunc) { pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY; return DEAL_RES_ERROR; @@ -1191,7 +1221,7 @@ static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode *pNode = (SNode*)pFunc; pCxt->pCurrSelectStmt->hasSelectValFunc = true; } else { - nodesDestroyNode(pFunc); + nodesDestroyNode((SNode*)pFunc); } return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR; } @@ -1531,14 +1561,14 @@ static int32_t createAllColumns(STranslateContext* pCxt, SNodeList** pCols) { } static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) { - SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION); + SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); if (NULL == pFunc) { return NULL; } pFunc->pParameterList = nodesMakeList(); if (NULL == pFunc->pParameterList || - TSDB_CODE_SUCCESS != nodesListStrictAppend(pFunc->pParameterList, nodesCloneNode(pExpr))) { - nodesDestroyNode(pFunc); + TSDB_CODE_SUCCESS != nodesListStrictAppend(pFunc->pParameterList, nodesCloneNode((SNode*)pExpr))) { + nodesDestroyNode((SNode*)pFunc); return NULL; } @@ -2043,7 +2073,7 @@ static int32_t checkLimit(STranslateContext* pCxt, SSelectStmt* pSelect) { } static int32_t createPrimaryKeyColByTable(STranslateContext* pCxt, STableNode* pTable, SNode** pPrimaryKey) { - SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN); + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -2124,7 +2154,7 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) { } static SNode* createSetOperProject(const char* pTableAlias, SNode* pNode) { - SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN); + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { return NULL; } @@ -2136,20 +2166,20 @@ static SNode* createSetOperProject(const char* pTableAlias, SNode* pNode) { } static int32_t createCastFunc(STranslateContext* pCxt, SNode* pExpr, SDataType dt, SNode** pCast) { - SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION); + SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); if (NULL == pFunc) { return TSDB_CODE_OUT_OF_MEMORY; } strcpy(pFunc->functionName, "cast"); pFunc->node.resType = dt; if (TSDB_CODE_SUCCESS != nodesListMakeAppend(&pFunc->pParameterList, pExpr)) { - nodesDestroyNode(pFunc); + nodesDestroyNode((SNode*)pFunc); return TSDB_CODE_OUT_OF_MEMORY; } if (TSDB_CODE_SUCCESS != getFuncInfo(pCxt, pFunc)) { nodesClearList(pFunc->pParameterList); pFunc->pParameterList = NULL; - nodesDestroyNode(pFunc); + nodesDestroyNode((SNode*)pFunc); return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)pExpr)->aliasName); } *pCast = (SNode*)pFunc; @@ -2453,11 +2483,11 @@ static int32_t checkDbRetentionsOption(STranslateContext* pCxt, SNodeList* pRete static int32_t checkOptionsDependency(STranslateContext* pCxt, const char* pDbName, SDatabaseOptions* pOptions) { int32_t daysPerFile = pOptions->daysPerFile; - int32_t daysToKeep0 = pOptions->keep[0]; + int64_t daysToKeep0 = pOptions->keep[0]; if (-1 == daysPerFile && -1 == daysToKeep0) { return TSDB_CODE_SUCCESS; } else if (-1 == daysPerFile || -1 == daysToKeep0) { - SDbCfgInfo dbCfg; + SDbCfgInfo dbCfg = {0}; int32_t code = getDBCfg(pCxt, pDbName, &dbCfg); if (TSDB_CODE_SUCCESS != code) { return code; @@ -2561,16 +2591,14 @@ static int32_t buildCmdMsg(STranslateContext* pCxt, int16_t msgType, FSerializeF static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseStmt* pStmt) { SCreateDbReq createReq = {0}; - - int32_t code = checkCreateDatabase(pCxt, pStmt); + int32_t code = checkCreateDatabase(pCxt, pStmt); if (TSDB_CODE_SUCCESS == code) { code = buildCreateDbReq(pCxt, pStmt, &createReq); } - if (TSDB_CODE_SUCCESS == code) { code = buildCmdMsg(pCxt, TDMT_MND_CREATE_DB, (FSerializeFunc)tSerializeSCreateDbReq, &createReq); } - + tFreeSCreateDbReq(&createReq); return code; } @@ -2798,15 +2826,15 @@ static int32_t checkTableSchema(STranslateContext* pCxt, SCreateTableStmt* pStmt } static int32_t checkSchemalessDb(STranslateContext* pCxt, const char* pDbName) { -// if (0 != pCxt->pParseCxt->schemalessType) { -// return TSDB_CODE_SUCCESS; -// } -// SDbCfgInfo info = {0}; -// int32_t code = getDBCfg(pCxt, pDbName, &info); -// if (TSDB_CODE_SUCCESS == code) { -// code = info.schemaless ? TSDB_CODE_SML_INVALID_DB_CONF : TSDB_CODE_SUCCESS; -// } -// return code; + // if (0 != pCxt->pParseCxt->schemalessType) { + // return TSDB_CODE_SUCCESS; + // } + // SDbCfgInfo info = {0}; + // int32_t code = getDBCfg(pCxt, pDbName, &info); + // if (TSDB_CODE_SUCCESS == code) { + // code = info.schemaless ? TSDB_CODE_SML_INVALID_DB_CONF : TSDB_CODE_SUCCESS; + // } + // return code; return TSDB_CODE_SUCCESS; } @@ -2854,15 +2882,15 @@ typedef struct SSampleAstInfo { static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, char** pAst, int32_t* pLen, char** pExpr, int32_t* pExprLen) { - SSelectStmt* pSelect = nodesMakeNode(QUERY_NODE_SELECT_STMT); + SSelectStmt* pSelect = (SSelectStmt*)nodesMakeNode(QUERY_NODE_SELECT_STMT); if (NULL == pSelect) { return TSDB_CODE_OUT_OF_MEMORY; } sprintf(pSelect->stmtName, "%p", pSelect); - SRealTableNode* pTable = nodesMakeNode(QUERY_NODE_REAL_TABLE); + SRealTableNode* pTable = (SRealTableNode*)nodesMakeNode(QUERY_NODE_REAL_TABLE); if (NULL == pTable) { - nodesDestroyNode(pSelect); + nodesDestroyNode((SNode*)pSelect); return TSDB_CODE_OUT_OF_MEMORY; } strcpy(pTable->table.dbName, pInfo->pDbName); @@ -2871,19 +2899,19 @@ static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, ch pSelect->pFromTable = (SNode*)pTable; TSWAP(pSelect->pProjectionList, pInfo->pFuncs); - SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION); + SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); if (NULL == pSelect->pProjectionList || NULL == pFunc) { - nodesDestroyNode(pSelect); + nodesDestroyNode((SNode*)pSelect); return TSDB_CODE_OUT_OF_MEMORY; } strcpy(pFunc->functionName, "_wstartts"); - nodesListPushFront(pSelect->pProjectionList, pFunc); + nodesListPushFront(pSelect->pProjectionList, (SNode*)pFunc); SNode* pProject = NULL; FOREACH(pProject, pSelect->pProjectionList) { sprintf(((SExprNode*)pProject)->aliasName, "#%p", pProject); } - SIntervalWindowNode* pInterval = nodesMakeNode(QUERY_NODE_INTERVAL_WINDOW); + SIntervalWindowNode* pInterval = (SIntervalWindowNode*)nodesMakeNode(QUERY_NODE_INTERVAL_WINDOW); if (NULL == pInterval) { - nodesDestroyNode(pSelect); + nodesDestroyNode((SNode*)pSelect); return TSDB_CODE_OUT_OF_MEMORY; } pSelect->pWindow = (SNode*)pInterval; @@ -2892,7 +2920,7 @@ static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, ch TSWAP(pInterval->pSliding, pInfo->pSliding); pInterval->pCol = nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pInterval->pCol) { - nodesDestroyNode(pSelect); + nodesDestroyNode((SNode*)pSelect); return TSDB_CODE_OUT_OF_MEMORY; } ((SColumnNode*)pInterval->pCol)->colId = PRIMARYKEY_TIMESTAMP_COL_ID; @@ -2901,12 +2929,12 @@ static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, ch pCxt->createStream = true; int32_t code = translateQuery(pCxt, (SNode*)pSelect); if (TSDB_CODE_SUCCESS == code) { - code = nodesNodeToString(pSelect, false, pAst, pLen); + code = nodesNodeToString((SNode*)pSelect, false, pAst, pLen); } if (TSDB_CODE_SUCCESS == code && NULL != pExpr) { code = nodesListToString(pSelect->pProjectionList, false, pExpr, pExprLen); } - nodesDestroyNode(pSelect); + nodesDestroyNode((SNode*)pSelect); return code; } @@ -2918,7 +2946,7 @@ static void clearSampleAstInfo(SSampleAstInfo* pInfo) { } static SNode* makeIntervalVal(SRetention* pRetension, int8_t precision) { - SValueNode* pVal = nodesMakeNode(QUERY_NODE_VALUE); + SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); if (NULL == pVal) { return NULL; } @@ -2927,7 +2955,7 @@ static SNode* makeIntervalVal(SRetention* pRetension, int8_t precision) { int32_t len = snprintf(buf, sizeof(buf), "%" PRId64 "%c", timeVal, pRetension->freqUnit); pVal->literal = strndup(buf, len); if (NULL == pVal->literal) { - nodesDestroyNode(pVal); + nodesDestroyNode((SNode*)pVal); return NULL; } pVal->isDuration = true; @@ -2938,7 +2966,7 @@ static SNode* makeIntervalVal(SRetention* pRetension, int8_t precision) { } static SNode* createColumnFromDef(SColumnDefNode* pDef) { - SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN); + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { return NULL; } @@ -2947,12 +2975,12 @@ static SNode* createColumnFromDef(SColumnDefNode* pDef) { } static SNode* createRollupFunc(SNode* pSrcFunc, SColumnDefNode* pColDef) { - SFunctionNode* pFunc = nodesCloneNode(pSrcFunc); + SFunctionNode* pFunc = (SFunctionNode*)nodesCloneNode(pSrcFunc); if (NULL == pFunc) { return NULL; } if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pFunc->pParameterList, createColumnFromDef(pColDef))) { - nodesDestroyNode(pFunc); + nodesDestroyNode((SNode*)pFunc); return NULL; } return (SNode*)pFunc; @@ -3102,7 +3130,7 @@ static int32_t doTranslateDropSuperTable(STranslateContext* pCxt, const SName* p } static int32_t translateDropTable(STranslateContext* pCxt, SDropTableStmt* pStmt) { - SDropTableClause* pClause = nodesListGetNode(pStmt->pTables, 0); + SDropTableClause* pClause = (SDropTableClause*)nodesListGetNode(pStmt->pTables, 0); SName tableName; return doTranslateDropSuperTable( pCxt, toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &tableName), pClause->ignoreNotExists); @@ -3114,7 +3142,11 @@ static int32_t translateDropSuperTable(STranslateContext* pCxt, SDropSuperTableS pStmt->ignoreNotExists); } -static int32_t setAlterTableField(SAlterTableStmt* pStmt, SMAlterStbReq* pAlterReq) { +static int32_t buildAlterSuperTableReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, SMAlterStbReq* pAlterReq) { + SName tableName; + tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName), pAlterReq->name); + pAlterReq->alterType = pStmt->alterType; + if (TSDB_ALTER_TABLE_UPDATE_OPTIONS == pStmt->alterType) { pAlterReq->ttl = pStmt->pOptions->ttl; if ('\0' != pStmt->pOptions->comment[0]) { @@ -3162,18 +3194,49 @@ static int32_t setAlterTableField(SAlterTableStmt* pStmt, SMAlterStbReq* pAlterR return TSDB_CODE_SUCCESS; } -static int32_t translateAlterTable(STranslateContext* pCxt, SAlterTableStmt* pStmt) { - SMAlterStbReq alterReq = {0}; - SName tableName; - tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName), alterReq.name); - alterReq.alterType = pStmt->alterType; +static SSchema* getColSchema(STableMeta* pTableMeta, const char* pTagName) { + int32_t numOfFields = getNumOfTags(pTableMeta) + getNumOfColumns(pTableMeta); + for (int32_t i = 0; i < numOfFields; ++i) { + SSchema* pTagSchema = pTableMeta->schema + i; + if (0 == strcmp(pTagName, pTagSchema->name)) { + return pTagSchema; + } + } + return NULL; +} + +static int32_t checkAlterSuperTable(STranslateContext* pCxt, SAlterTableStmt* pStmt) { if (TSDB_ALTER_TABLE_UPDATE_TAG_VAL == pStmt->alterType || TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME == pStmt->alterType) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE); } - int32_t code = setAlterTableField(pStmt, &alterReq); + if (TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES == pStmt->alterType || + TSDB_ALTER_TABLE_UPDATE_TAG_BYTES == pStmt->alterType) { + STableMeta* pTableMeta = NULL; + int32_t code = getTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pTableMeta); + if (TSDB_CODE_SUCCESS == code) { + SSchema* pSchema = getColSchema(pTableMeta, pStmt->colName); + if (NULL == pSchema) { + code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMN, pStmt->colName); + } else if (!IS_VAR_DATA_TYPE(pSchema->type) || pSchema->type != pStmt->dataType.type || + pSchema->bytes >= calcTypeBytes(pStmt->dataType)) { + code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_MODIFY_COL); + } + } + return code; + } + return TSDB_CODE_SUCCESS; +} + +static int32_t translateAlterSuperTable(STranslateContext* pCxt, SAlterTableStmt* pStmt) { + SMAlterStbReq alterReq = {0}; + int32_t code = checkAlterSuperTable(pCxt, pStmt); + if (TSDB_CODE_SUCCESS == code) { + code = buildAlterSuperTableReq(pCxt, pStmt, &alterReq); + } if (TSDB_CODE_SUCCESS == code) { code = buildCmdMsg(pCxt, TDMT_MND_ALTER_STB, (FSerializeFunc)tSerializeSMAlterStbReq, &alterReq); } + tFreeSMAltertbReq(&alterReq); return code; } @@ -3580,6 +3643,16 @@ static int32_t translateKillTransaction(STranslateContext* pCxt, SKillStmt* pStm } static int32_t checkCreateStream(STranslateContext* pCxt, SCreateStreamStmt* pStmt) { + if (NULL != pStmt->pOptions->pWatermark && + (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pWatermark))) { + return pCxt->errCode; + } + + if (NULL != pStmt->pOptions->pDelay && + (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pDelay))) { + return pCxt->errCode; + } + if (NULL == pStmt->pQuery) { return TSDB_CODE_SUCCESS; } @@ -3627,12 +3700,9 @@ static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt* } } - if (TSDB_CODE_SUCCESS == code && NULL != pStmt->pOptions->pWatermark) { - code = (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pWatermark)) ? pCxt->errCode - : TSDB_CODE_SUCCESS; - } if (TSDB_CODE_SUCCESS == code) { pReq->triggerType = pStmt->pOptions->triggerType; + pReq->maxDelay = (NULL != pStmt->pOptions->pDelay ? ((SValueNode*)pStmt->pOptions->pDelay)->datum.i : 0); pReq->watermark = (NULL != pStmt->pOptions->pWatermark ? ((SValueNode*)pStmt->pOptions->pWatermark)->datum.i : 0); } @@ -3835,7 +3905,7 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { code = translateDropSuperTable(pCxt, (SDropSuperTableStmt*)pNode); break; case QUERY_NODE_ALTER_TABLE_STMT: - code = translateAlterTable(pCxt, (SAlterTableStmt*)pNode); + code = translateAlterSuperTable(pCxt, (SAlterTableStmt*)pNode); break; case QUERY_NODE_CREATE_USER_STMT: code = translateCreateUser(pCxt, (SCreateUserStmt*)pNode); @@ -4126,15 +4196,15 @@ static const char* getSysTableName(ENodeType type) { } static int32_t createSelectStmtForShow(ENodeType showType, SSelectStmt** pStmt) { - SSelectStmt* pSelect = nodesMakeNode(QUERY_NODE_SELECT_STMT); + SSelectStmt* pSelect = (SSelectStmt*)nodesMakeNode(QUERY_NODE_SELECT_STMT); if (NULL == pSelect) { return TSDB_CODE_OUT_OF_MEMORY; } sprintf(pSelect->stmtName, "%p", pSelect); - SRealTableNode* pTable = nodesMakeNode(QUERY_NODE_REAL_TABLE); + SRealTableNode* pTable = (SRealTableNode*)nodesMakeNode(QUERY_NODE_REAL_TABLE); if (NULL == pTable) { - nodesDestroyNode(pSelect); + nodesDestroyNode((SNode*)pSelect); return TSDB_CODE_OUT_OF_MEMORY; } strcpy(pTable->table.dbName, getSysDbName(showType)); @@ -4152,7 +4222,7 @@ static int32_t createOperatorNode(EOperatorType opType, const char* pColName, SN return TSDB_CODE_SUCCESS; } - SOperatorNode* pOper = nodesMakeNode(QUERY_NODE_OPERATOR); + SOperatorNode* pOper = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR); if (NULL == pOper) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -4161,7 +4231,7 @@ static int32_t createOperatorNode(EOperatorType opType, const char* pColName, SN pOper->pLeft = nodesMakeNode(QUERY_NODE_COLUMN); pOper->pRight = nodesCloneNode(pRight); if (NULL == pOper->pLeft || NULL == pOper->pRight) { - nodesDestroyNode(pOper); + nodesDestroyNode((SNode*)pOper); return TSDB_CODE_OUT_OF_MEMORY; } strcpy(((SColumnNode*)pOper->pLeft)->colName, pColName); @@ -4175,19 +4245,19 @@ static const char* getTbNameColName(ENodeType type) { } static int32_t createLogicCondNode(SNode* pCond1, SNode* pCond2, SNode** pCond) { - SLogicConditionNode* pCondition = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); + SLogicConditionNode* pCondition = (SLogicConditionNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); if (NULL == pCondition) { return TSDB_CODE_OUT_OF_MEMORY; } pCondition->condType = LOGIC_COND_TYPE_AND; pCondition->pParameterList = nodesMakeList(); if (NULL == pCondition->pParameterList) { - nodesDestroyNode(pCondition); + nodesDestroyNode((SNode*)pCondition); return TSDB_CODE_OUT_OF_MEMORY; } if (TSDB_CODE_SUCCESS != nodesListAppend(pCondition->pParameterList, pCond1) || TSDB_CODE_SUCCESS != nodesListAppend(pCondition->pParameterList, pCond2)) { - nodesDestroyNode(pCondition); + nodesDestroyNode((SNode*)pCondition); return TSDB_CODE_OUT_OF_MEMORY; } @@ -4335,7 +4405,7 @@ static void destroyCreateTbReqBatch(SVgroupCreateTableBatch* pTbBatch) { } static int32_t rewriteToVnodeModifyOpStmt(SQuery* pQuery, SArray* pBufArray) { - SVnodeModifOpStmt* pNewStmt = nodesMakeNode(QUERY_NODE_VNODE_MODIF_STMT); + SVnodeModifOpStmt* pNewStmt = (SVnodeModifOpStmt*)nodesMakeNode(QUERY_NODE_VNODE_MODIF_STMT); if (pNewStmt == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -4451,10 +4521,35 @@ static int32_t translateTagVal(STranslateContext* pCxt, uint8_t precision, SSche ? pCxt->errCode : TSDB_CODE_SUCCESS); } else { + // return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)pNode)->aliasName); return TSDB_CODE_FAILED; } } +static int32_t buildJsonTagVal(STranslateContext* pCxt, SSchema* pTagSchema, SValueNode* pVal, SArray* pTagArray, + STag** ppTag) { + if (pVal->literal && strlen(pVal->literal) > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) { + return buildSyntaxErrMsg(&pCxt->msgBuf, "json string too long than 4095", pVal->literal); + } + + return parseJsontoTagData(pVal->literal, pTagArray, ppTag, &pCxt->msgBuf); +} + +static int32_t buildNormalTagVal(STranslateContext* pCxt, SSchema* pTagSchema, SValueNode* pVal, SArray* pTagArray) { + if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL) { + void* nodeVal = nodesGetValueFromNode(pVal); + STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; + if (IS_VAR_DATA_TYPE(pTagSchema->type)) { + val.pData = varDataVal(nodeVal); + val.nData = varDataLen(nodeVal); + } else { + memcpy(&val.i64, nodeVal, pTagSchema->bytes); + } + taosArrayPush(pTagArray, &val); + } + return TSDB_CODE_SUCCESS; +} + static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableClause* pStmt, STableMeta* pSuperTableMeta, STag** ppTag) { int32_t numOfTags = getNumOfTags(pSuperTableMeta); @@ -4464,11 +4559,10 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla } SArray* pTagArray = taosArrayInit(LIST_LENGTH(pStmt->pValsOfTags), sizeof(STagVal)); - if (!pTagArray) { - return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_TSC_OUT_OF_MEMORY); + if (NULL == pTagArray) { + return TSDB_CODE_OUT_OF_MEMORY; } int32_t code = TSDB_CODE_SUCCESS; - int16_t nTags = 0, nBufPos = 0; SSchema* pTagSchema = getTableTagSchema(pSuperTableMeta); SNode * pTag = NULL, *pNode = NULL; bool isJson = false; @@ -4496,27 +4590,12 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla } else { REPLACE_LIST2_NODE(pVal); } - if (pTagSchema->type == TSDB_DATA_TYPE_JSON) { - if (pVal->literal && strlen(pVal->literal) > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) { - code = buildSyntaxErrMsg(&pCxt->msgBuf, "json string too long than 4095", pVal->literal); - goto end; - } + if (pSchema->type == TSDB_DATA_TYPE_JSON) { isJson = true; - code = parseJsontoTagData(pVal->literal, pTagArray, ppTag, &pCxt->msgBuf); - if (code != TSDB_CODE_SUCCESS) { - goto end; - } + code = buildJsonTagVal(pCxt, pSchema, pVal, pTagArray, ppTag); } else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL) { - void* nodeVal = nodesGetValueFromNode(pVal); - STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; - if (IS_VAR_DATA_TYPE(pTagSchema->type)) { - val.pData = varDataVal(nodeVal); - val.nData = varDataLen(nodeVal); - } else { - memcpy(&val.i64, nodeVal, pTagSchema->bytes); - } - taosArrayPush(pTagArray, &val); + code = buildNormalTagVal(pCxt, pSchema, pVal, pTagArray); } } @@ -4832,17 +4911,6 @@ static int32_t rewriteDropTable(STranslateContext* pCxt, SQuery* pQuery) { return rewriteToVnodeModifyOpStmt(pQuery, pBufArray); } -static SSchema* getColSchema(STableMeta* pTableMeta, const char* pTagName) { - int32_t numOfFields = getNumOfTags(pTableMeta) + getNumOfColumns(pTableMeta); - for (int32_t i = 0; i < numOfFields; ++i) { - SSchema* pTagSchema = pTableMeta->schema + i; - if (0 == strcmp(pTagName, pTagSchema->name)) { - return pTagSchema; - } - } - return NULL; -} - static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta, SVAlterTbReq* pReq) { SSchema* pSchema = getColSchema(pTableMeta, pStmt->colName); @@ -4860,6 +4928,10 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS return pCxt->errCode; } + if (IS_VAR_DATA_TYPE(pSchema->type) && strlen(pStmt->pVal->literal) > pSchema->bytes) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pStmt->pVal->literal); + } + pReq->isNull = (TSDB_DATA_TYPE_NULL == pStmt->pVal->node.resType.type); if (pStmt->pVal->node.resType.type == TSDB_DATA_TYPE_JSON) { if (pStmt->pVal->literal && @@ -5089,29 +5161,18 @@ static int32_t buildModifyVnodeArray(STranslateContext* pCxt, SAlterTableStmt* p return code; } -static int32_t rewriteAlterTable(STranslateContext* pCxt, SQuery* pQuery) { - SAlterTableStmt* pStmt = (SAlterTableStmt*)pQuery->pRoot; - int32_t code = checkSchemalessDb(pCxt, pStmt->dbName); - if (TSDB_CODE_SUCCESS != code) { - return code; - } - STableMeta* pTableMeta = NULL; - code = getTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pTableMeta); - if (TSDB_CODE_SUCCESS != code) { - return code; - } - - if (pStmt->dataType.type == TSDB_DATA_TYPE_JSON && pStmt->alterType == TSDB_ALTER_TABLE_ADD_TAG) { - return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_ONLY_ONE_JSON_TAG); - } - - if (pStmt->dataType.type == TSDB_DATA_TYPE_JSON && pStmt->alterType == TSDB_ALTER_TABLE_ADD_COLUMN) { - return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COL_JSON); - } +static void destoryAlterTbReq(SVAlterTbReq* pReq) { + taosMemoryFree(pReq->tbName); + taosMemoryFree(pReq->colName); + taosMemoryFree(pReq->colNewName); + taosMemoryFree(pReq->tagName); + taosMemoryFree(pReq->newComment); +} +static int32_t rewriteAlterTableImpl(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta, + SQuery* pQuery) { if (getNumOfTags(pTableMeta) == 1 && pStmt->alterType == TSDB_ALTER_TABLE_DROP_TAG) { - return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE, - "can not drop tag if there is only one tag"); + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE); } if (TSDB_SUPER_TABLE == pTableMeta->tableType) { @@ -5127,7 +5188,7 @@ static int32_t rewriteAlterTable(STranslateContext* pCxt, SQuery* pQuery) { } SVAlterTbReq req = {0}; - code = buildAlterTbReq(pCxt, pStmt, pTableMeta, &req); + int32_t code = buildAlterTbReq(pCxt, pStmt, pTableMeta, &req); SArray* pArray = NULL; if (TSDB_CODE_SUCCESS == code) { @@ -5136,7 +5197,27 @@ static int32_t rewriteAlterTable(STranslateContext* pCxt, SQuery* pQuery) { if (TSDB_CODE_SUCCESS == code) { code = rewriteToVnodeModifyOpStmt(pQuery, pArray); } + destoryAlterTbReq(&req); + return code; +} +static int32_t rewriteAlterTable(STranslateContext* pCxt, SQuery* pQuery) { + SAlterTableStmt* pStmt = (SAlterTableStmt*)pQuery->pRoot; + + if (pStmt->dataType.type == TSDB_DATA_TYPE_JSON && pStmt->alterType == TSDB_ALTER_TABLE_ADD_TAG) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_ONLY_ONE_JSON_TAG); + } + + if (pStmt->dataType.type == TSDB_DATA_TYPE_JSON && pStmt->alterType == TSDB_ALTER_TABLE_ADD_COLUMN) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COL_JSON); + } + + STableMeta* pTableMeta = NULL; + int32_t code = getTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pTableMeta); + if (TSDB_CODE_SUCCESS == code) { + code = rewriteAlterTableImpl(pCxt, pStmt, pTableMeta, pQuery); + } + taosMemoryFree(pTableMeta); return code; } @@ -5276,10 +5357,10 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) { return TSDB_CODE_SUCCESS; } -int32_t translate(SParseContext* pParseCxt, SQuery* pQuery) { +int32_t translate(SParseContext* pParseCxt, SQuery* pQuery, SParseMetaCache* pMetaCache) { STranslateContext cxt = {0}; - int32_t code = initTranslateContext(pParseCxt, pQuery->pMetaCache, &cxt); + int32_t code = initTranslateContext(pParseCxt, pMetaCache, &cxt); if (TSDB_CODE_SUCCESS == code) { code = rewriteQuery(&cxt, pQuery); } diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 716b120af5..42e887bb9d 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -19,6 +19,8 @@ #define USER_AUTH_KEY_MAX_LEN TSDB_USER_LEN + TSDB_DB_FNAME_LEN + 2 +const void* nullPointer = NULL; + static char* getSyntaxErrFormat(int32_t errCode) { switch (errCode) { case TSDB_CODE_PAR_SYNTAX_ERROR: @@ -184,6 +186,8 @@ static char* getSyntaxErrFormat(int32_t errCode) { return "The REDISTRIBUTE VGROUP statement only support 1 to 3 dnodes"; case TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC: return "%s function not allowed in fill query"; + case TSDB_CODE_PAR_INVALID_WINDOW_PC: + return "_WSTARTTS, _WENDTS and _WDURATION can only be used in window queries"; case TSDB_CODE_OUT_OF_MEMORY: return "Out of memory"; default: @@ -550,9 +554,15 @@ int32_t buildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalog return code; } -static int32_t putMetaDataToHash(const char* pKey, int32_t len, const SArray* pData, int32_t index, SHashObj* pHash) { +static int32_t putMetaDataToHash(const char* pKey, int32_t len, const SArray* pData, int32_t index, SHashObj** pHash) { + if (NULL == *pHash) { + *pHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); + if (NULL == *pHash) { + return TSDB_CODE_OUT_OF_MEMORY; + } + } SMetaRes* pRes = taosArrayGet(pData, index); - return taosHashPut(pHash, pKey, len, &pRes, POINTER_BYTES); + return taosHashPut(*pHash, pKey, len, &pRes, POINTER_BYTES); } static int32_t getMetaDataFromHash(const char* pKey, int32_t len, SHashObj* pHash, void** pOutput) { @@ -566,7 +576,7 @@ static int32_t getMetaDataFromHash(const char* pKey, int32_t len, SHashObj* pHas return (*pRes)->code; } -static int32_t putTableDataToCache(const SArray* pTableReq, const SArray* pTableData, SHashObj* pTable) { +static int32_t putTableDataToCache(const SArray* pTableReq, const SArray* pTableData, SHashObj** pTable) { int32_t ntables = taosArrayGetSize(pTableReq); for (int32_t i = 0; i < ntables; ++i) { char fullName[TSDB_TABLE_FNAME_LEN]; @@ -578,7 +588,7 @@ static int32_t putTableDataToCache(const SArray* pTableReq, const SArray* pTable return TSDB_CODE_SUCCESS; } -static int32_t putDbDataToCache(const SArray* pDbReq, const SArray* pDbData, SHashObj* pDb) { +static int32_t putDbDataToCache(const SArray* pDbReq, const SArray* pDbData, SHashObj** pDb) { int32_t nvgs = taosArrayGetSize(pDbReq); for (int32_t i = 0; i < nvgs; ++i) { char* pDbFName = taosArrayGet(pDbReq, i); @@ -589,7 +599,7 @@ static int32_t putDbDataToCache(const SArray* pDbReq, const SArray* pDbData, SHa return TSDB_CODE_SUCCESS; } -static int32_t putUserAuthToCache(const SArray* pUserAuthReq, const SArray* pUserAuthData, SHashObj* pUserAuth) { +static int32_t putUserAuthToCache(const SArray* pUserAuthReq, const SArray* pUserAuthData, SHashObj** pUserAuth) { int32_t nvgs = taosArrayGetSize(pUserAuthReq); for (int32_t i = 0; i < nvgs; ++i) { SUserAuthInfo* pUser = taosArrayGet(pUserAuthReq, i); @@ -602,7 +612,7 @@ static int32_t putUserAuthToCache(const SArray* pUserAuthReq, const SArray* pUse return TSDB_CODE_SUCCESS; } -static int32_t putUdfToCache(const SArray* pUdfReq, const SArray* pUdfData, SHashObj* pUdf) { +static int32_t putUdfToCache(const SArray* pUdfReq, const SArray* pUdfData, SHashObj** pUdf) { int32_t num = taosArrayGetSize(pUdfReq); for (int32_t i = 0; i < num; ++i) { char* pFunc = taosArrayGet(pUdfReq, i); @@ -614,27 +624,27 @@ static int32_t putUdfToCache(const SArray* pUdfReq, const SArray* pUdfData, SHas } int32_t putMetaDataToCache(const SCatalogReq* pCatalogReq, const SMetaData* pMetaData, SParseMetaCache* pMetaCache) { - int32_t code = putTableDataToCache(pCatalogReq->pTableMeta, pMetaData->pTableMeta, pMetaCache->pTableMeta); + int32_t code = putTableDataToCache(pCatalogReq->pTableMeta, pMetaData->pTableMeta, &pMetaCache->pTableMeta); if (TSDB_CODE_SUCCESS == code) { - code = putDbDataToCache(pCatalogReq->pDbVgroup, pMetaData->pDbVgroup, pMetaCache->pDbVgroup); + code = putDbDataToCache(pCatalogReq->pDbVgroup, pMetaData->pDbVgroup, &pMetaCache->pDbVgroup); } if (TSDB_CODE_SUCCESS == code) { - code = putTableDataToCache(pCatalogReq->pTableHash, pMetaData->pTableHash, pMetaCache->pTableVgroup); + code = putTableDataToCache(pCatalogReq->pTableHash, pMetaData->pTableHash, &pMetaCache->pTableVgroup); } if (TSDB_CODE_SUCCESS == code) { - code = putDbDataToCache(pCatalogReq->pDbCfg, pMetaData->pDbCfg, pMetaCache->pDbCfg); + code = putDbDataToCache(pCatalogReq->pDbCfg, pMetaData->pDbCfg, &pMetaCache->pDbCfg); } if (TSDB_CODE_SUCCESS == code) { - code = putDbDataToCache(pCatalogReq->pDbInfo, pMetaData->pDbInfo, pMetaCache->pDbInfo); + code = putDbDataToCache(pCatalogReq->pDbInfo, pMetaData->pDbInfo, &pMetaCache->pDbInfo); } if (TSDB_CODE_SUCCESS == code) { - code = putUserAuthToCache(pCatalogReq->pUser, pMetaData->pUser, pMetaCache->pUserAuth); + code = putUserAuthToCache(pCatalogReq->pUser, pMetaData->pUser, &pMetaCache->pUserAuth); } if (TSDB_CODE_SUCCESS == code) { - code = putUdfToCache(pCatalogReq->pUdf, pMetaData->pUdfList, pMetaCache->pUdf); + code = putUdfToCache(pCatalogReq->pUdf, pMetaData->pUdfList, &pMetaCache->pUdf); } if (TSDB_CODE_SUCCESS == code) { - code = putTableDataToCache(pCatalogReq->pTableIndex, pMetaData->pTableIndex, pMetaCache->pTableIndex); + code = putTableDataToCache(pCatalogReq->pTableIndex, pMetaData->pTableIndex, &pMetaCache->pTableIndex); } return code; } @@ -646,7 +656,7 @@ static int32_t reserveTableReqInCacheImpl(const char* pTbFName, int32_t len, SHa return TSDB_CODE_OUT_OF_MEMORY; } } - return taosHashPut(*pTables, pTbFName, len, &pTables, POINTER_BYTES); + return taosHashPut(*pTables, pTbFName, len, &nullPointer, POINTER_BYTES); } static int32_t reserveTableReqInCache(int32_t acctId, const char* pDb, const char* pTable, SHashObj** pTables) { @@ -688,7 +698,7 @@ static int32_t reserveDbReqInCache(int32_t acctId, const char* pDb, SHashObj** p } char fullName[TSDB_TABLE_FNAME_LEN]; int32_t len = snprintf(fullName, sizeof(fullName), "%d.%s", acctId, pDb); - return taosHashPut(*pDbs, fullName, len, &pDbs, POINTER_BYTES); + return taosHashPut(*pDbs, fullName, len, &nullPointer, POINTER_BYTES); } int32_t reserveDbVgInfoInCache(int32_t acctId, const char* pDb, SParseMetaCache* pMetaCache) { @@ -803,7 +813,7 @@ int32_t reserveUdfInCache(const char* pFunc, SParseMetaCache* pMetaCache) { return TSDB_CODE_OUT_OF_MEMORY; } } - return taosHashPut(pMetaCache->pUdf, pFunc, strlen(pFunc), &pMetaCache, POINTER_BYTES); + return taosHashPut(pMetaCache->pUdf, pFunc, strlen(pFunc), &nullPointer, POINTER_BYTES); } int32_t getUdfInfoFromCache(SParseMetaCache* pMetaCache, const char* pFunc, SFuncInfo* pInfo) { @@ -854,3 +864,14 @@ int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName, } return code; } + +void destoryParseMetaCache(SParseMetaCache* pMetaCache) { + taosHashCleanup(pMetaCache->pTableMeta); + taosHashCleanup(pMetaCache->pDbVgroup); + taosHashCleanup(pMetaCache->pTableVgroup); + taosHashCleanup(pMetaCache->pDbCfg); + taosHashCleanup(pMetaCache->pDbInfo); + taosHashCleanup(pMetaCache->pUserAuth); + taosHashCleanup(pMetaCache->pUdf); + taosHashCleanup(pMetaCache->pTableIndex); +} diff --git a/source/libs/parser/src/parser.c b/source/libs/parser/src/parser.c index edb0d79f02..538404798d 100644 --- a/source/libs/parser/src/parser.c +++ b/source/libs/parser/src/parser.c @@ -34,8 +34,8 @@ bool qIsInsertSql(const char* pStr, size_t length) { } while (1); } -static int32_t analyseSemantic(SParseContext* pCxt, SQuery* pQuery) { - int32_t code = authenticate(pCxt, pQuery); +static int32_t analyseSemantic(SParseContext* pCxt, SQuery* pQuery, SParseMetaCache* pMetaCache) { + int32_t code = authenticate(pCxt, pQuery, pMetaCache); if (TSDB_CODE_SUCCESS == code && pQuery->placeholderNum > 0) { TSWAP(pQuery->pPrepareRoot, pQuery->pRoot); @@ -43,7 +43,7 @@ static int32_t analyseSemantic(SParseContext* pCxt, SQuery* pQuery) { } if (TSDB_CODE_SUCCESS == code) { - code = translate(pCxt, pQuery); + code = translate(pCxt, pQuery, pMetaCache); } if (TSDB_CODE_SUCCESS == code) { code = calculateConstant(pCxt, pQuery); @@ -54,15 +54,15 @@ static int32_t analyseSemantic(SParseContext* pCxt, SQuery* pQuery) { static int32_t parseSqlIntoAst(SParseContext* pCxt, SQuery** pQuery) { int32_t code = parse(pCxt, pQuery); if (TSDB_CODE_SUCCESS == code) { - code = analyseSemantic(pCxt, *pQuery); + code = analyseSemantic(pCxt, *pQuery, NULL); } return code; } -static int32_t parseSqlSyntax(SParseContext* pCxt, SQuery** pQuery) { +static int32_t parseSqlSyntax(SParseContext* pCxt, SQuery** pQuery, SParseMetaCache* pMetaCache) { int32_t code = parse(pCxt, pQuery); if (TSDB_CODE_SUCCESS == code) { - code = collectMetaKey(pCxt, *pQuery); + code = collectMetaKey(pCxt, *pQuery, pMetaCache); } return code; } @@ -149,7 +149,7 @@ static void rewriteExprAlias(SNode* pRoot) { int32_t qParseSql(SParseContext* pCxt, SQuery** pQuery) { int32_t code = TSDB_CODE_SUCCESS; if (qIsInsertSql(pCxt->pSql, pCxt->sqlLen)) { - code = parseInsertSql(pCxt, pQuery); + code = parseInsertSql(pCxt, pQuery, NULL); } else { code = parseSqlIntoAst(pCxt, pQuery); } @@ -158,29 +158,38 @@ int32_t qParseSql(SParseContext* pCxt, SQuery** pQuery) { } int32_t qParseSqlSyntax(SParseContext* pCxt, SQuery** pQuery, struct SCatalogReq* pCatalogReq) { - int32_t code = TSDB_CODE_SUCCESS; + SParseMetaCache metaCache = {0}; + int32_t code = TSDB_CODE_SUCCESS; if (qIsInsertSql(pCxt->pSql, pCxt->sqlLen)) { - code = parseInsertSyntax(pCxt, pQuery); + code = parseInsertSyntax(pCxt, pQuery, &metaCache); } else { - code = parseSqlSyntax(pCxt, pQuery); + code = parseSqlSyntax(pCxt, pQuery, &metaCache); } if (TSDB_CODE_SUCCESS == code) { - code = buildCatalogReq((*pQuery)->pMetaCache, pCatalogReq); + code = buildCatalogReq(&metaCache, pCatalogReq); } + destoryParseMetaCache(&metaCache); terrno = code; return code; } int32_t qAnalyseSqlSemantic(SParseContext* pCxt, const struct SCatalogReq* pCatalogReq, const struct SMetaData* pMetaData, SQuery* pQuery) { - int32_t code = putMetaDataToCache(pCatalogReq, pMetaData, pQuery->pMetaCache); - if (NULL == pQuery->pRoot) { - return parseInsertSql(pCxt, &pQuery); + SParseMetaCache metaCache = {0}; + int32_t code = putMetaDataToCache(pCatalogReq, pMetaData, &metaCache); + if (TSDB_CODE_SUCCESS == code) { + if (NULL == pQuery->pRoot) { + code = parseInsertSql(pCxt, &pQuery, &metaCache); + } else { + code = analyseSemantic(pCxt, pQuery, &metaCache); + } } - return analyseSemantic(pCxt, pQuery); + destoryParseMetaCache(&metaCache); + terrno = code; + return code; } -void qDestroyQuery(SQuery* pQueryNode) { nodesDestroyNode(pQueryNode); } +void qDestroyQuery(SQuery* pQueryNode) { nodesDestroyNode((SNode*)pQueryNode); } int32_t qExtractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema) { return extractResultSchema(pRoot, numOfCols, pSchema); @@ -198,6 +207,8 @@ int32_t qSetSTableIdForRsma(SNode* pStmt, int64_t uid) { return TSDB_CODE_FAILED; } +void qCleanupKeywordsTable() { taosCleanupKeywordsTable(); } + int32_t qStmtBindParams(SQuery* pQuery, TAOS_MULTI_BIND* pParams, int32_t colIdx) { int32_t code = TSDB_CODE_SUCCESS; @@ -226,10 +237,9 @@ int32_t qStmtBindParams(SQuery* pQuery, TAOS_MULTI_BIND* pParams, int32_t colIdx } int32_t qStmtParseQuerySql(SParseContext* pCxt, SQuery* pQuery) { - int32_t code = translate(pCxt, pQuery); + int32_t code = translate(pCxt, pQuery, NULL); if (TSDB_CODE_SUCCESS == code) { code = calculateConstant(pCxt, pQuery); } - return code; } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 6fbee8cb11..b2de892f30 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -104,25 +104,25 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 359 +#define YYNOCODE 360 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - EOperatorType yy28; - int32_t yy42; - ENullOrder yy107; - EFillMode yy320; - SToken yy421; - SNodeList* yy530; - SAlterOption yy557; - EOrder yy610; - bool yy621; - EJoinType yy636; - int64_t yy669; - SNode* yy674; - SDataType yy690; + EFillMode yy54; + int32_t yy100; + bool yy137; + int64_t yy189; + SToken yy209; + ENullOrder yy217; + SDataType yy304; + EOperatorType yy380; + SNodeList* yy424; + EOrder yy578; + SAlterOption yy605; + EJoinType yy612; + SNode* yy632; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -138,17 +138,17 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 618 -#define YYNRULE 453 -#define YYNTOKEN 239 -#define YY_MAX_SHIFT 617 -#define YY_MIN_SHIFTREDUCE 904 -#define YY_MAX_SHIFTREDUCE 1356 -#define YY_ERROR_ACTION 1357 -#define YY_ACCEPT_ACTION 1358 -#define YY_NO_ACTION 1359 -#define YY_MIN_REDUCE 1360 -#define YY_MAX_REDUCE 1812 +#define YYNSTATE 619 +#define YYNRULE 454 +#define YYNTOKEN 240 +#define YY_MAX_SHIFT 618 +#define YY_MIN_SHIFTREDUCE 906 +#define YY_MAX_SHIFTREDUCE 1359 +#define YY_ERROR_ACTION 1360 +#define YY_ACCEPT_ACTION 1361 +#define YY_NO_ACTION 1362 +#define YY_MIN_REDUCE 1363 +#define YY_MAX_REDUCE 1816 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -215,602 +215,607 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2144) +#define YY_ACTTAB_COUNT (2152) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 28, 230, 1659, 1646, 610, 609, 296, 1646, 357, 1482, - /* 10 */ 313, 1480, 35, 33, 351, 36, 34, 32, 31, 30, - /* 20 */ 305, 24, 1170, 1643, 532, 441, 440, 1643, 79, 1643, - /* 30 */ 1675, 36, 34, 32, 31, 30, 152, 492, 516, 1639, - /* 40 */ 1645, 115, 277, 1639, 1645, 1639, 1645, 1168, 515, 1483, - /* 50 */ 535, 532, 1629, 1491, 535, 1790, 535, 496, 14, 1742, - /* 60 */ 35, 33, 1297, 355, 1176, 1659, 114, 147, 305, 1688, - /* 70 */ 1170, 1787, 82, 1660, 518, 1662, 1663, 514, 500, 535, - /* 80 */ 1491, 1, 1728, 1739, 1790, 1311, 278, 1724, 36, 34, - /* 90 */ 32, 31, 30, 1675, 531, 1168, 1789, 1647, 1790, 519, - /* 100 */ 1787, 516, 308, 614, 112, 1580, 14, 409, 35, 33, - /* 110 */ 149, 515, 1176, 1169, 1787, 1629, 305, 1643, 1170, 145, - /* 120 */ 1735, 1736, 1194, 1740, 36, 34, 32, 31, 30, 2, - /* 130 */ 381, 63, 1688, 1639, 1645, 84, 1660, 518, 1662, 1663, - /* 140 */ 514, 1361, 535, 1168, 535, 1728, 531, 1790, 56, 1727, - /* 150 */ 1724, 614, 142, 1487, 14, 391, 1171, 392, 1392, 148, - /* 160 */ 1176, 1169, 96, 1787, 1529, 95, 94, 93, 92, 91, - /* 170 */ 90, 89, 88, 87, 161, 160, 132, 2, 1372, 566, - /* 180 */ 1174, 1175, 934, 1221, 1222, 1224, 1225, 1226, 1227, 1228, - /* 190 */ 511, 533, 1236, 1237, 1238, 1239, 1240, 1241, 565, 614, - /* 200 */ 564, 563, 562, 399, 1171, 392, 1392, 38, 96, 1169, - /* 210 */ 150, 95, 94, 93, 92, 91, 90, 89, 88, 87, - /* 220 */ 938, 939, 65, 294, 1353, 55, 194, 1617, 1174, 1175, - /* 230 */ 1360, 1221, 1222, 1224, 1225, 1226, 1227, 1228, 511, 533, - /* 240 */ 1236, 1237, 1238, 1239, 1240, 1241, 36, 34, 32, 31, - /* 250 */ 30, 531, 1171, 1358, 105, 104, 103, 102, 101, 100, - /* 260 */ 99, 98, 97, 1469, 501, 35, 33, 36, 34, 32, - /* 270 */ 31, 30, 330, 305, 55, 1170, 1174, 1175, 342, 1221, - /* 280 */ 1222, 1224, 1225, 1226, 1227, 1228, 511, 533, 1236, 1237, - /* 290 */ 1238, 1239, 1240, 1241, 468, 532, 444, 443, 344, 340, - /* 300 */ 1168, 442, 486, 1659, 111, 439, 1352, 356, 438, 437, - /* 310 */ 436, 321, 39, 35, 33, 1242, 26, 1176, 133, 63, - /* 320 */ 409, 305, 1448, 1170, 1491, 72, 36, 34, 32, 31, - /* 330 */ 30, 1675, 110, 508, 8, 1790, 150, 1208, 1535, 516, - /* 340 */ 288, 1486, 55, 492, 458, 295, 1484, 147, 1168, 515, - /* 350 */ 1533, 1787, 1790, 1629, 150, 951, 614, 950, 496, 481, - /* 360 */ 1261, 35, 33, 1468, 147, 1176, 1169, 200, 1787, 305, - /* 370 */ 1688, 1170, 114, 82, 1660, 518, 1662, 1663, 514, 129, - /* 380 */ 535, 1266, 9, 1728, 952, 1790, 568, 278, 1724, 289, - /* 390 */ 1196, 287, 286, 55, 432, 66, 1168, 147, 434, 1790, - /* 400 */ 1422, 1787, 78, 150, 614, 1790, 32, 31, 30, 1171, - /* 410 */ 112, 147, 74, 1176, 1169, 1787, 350, 1788, 349, 25, - /* 420 */ 433, 1787, 396, 1467, 494, 144, 1735, 1736, 1192, 1740, - /* 430 */ 9, 487, 482, 1174, 1175, 583, 1221, 1222, 1224, 1225, - /* 440 */ 1226, 1227, 1228, 511, 533, 1236, 1237, 1238, 1239, 1240, - /* 450 */ 1241, 317, 614, 1003, 532, 1251, 566, 1171, 1571, 1573, - /* 460 */ 444, 443, 1169, 150, 1466, 442, 366, 1321, 111, 439, - /* 470 */ 1005, 150, 438, 437, 436, 565, 345, 564, 563, 562, - /* 480 */ 568, 1174, 1175, 1491, 1221, 1222, 1224, 1225, 1226, 1227, - /* 490 */ 1228, 511, 533, 1236, 1237, 1238, 1239, 1240, 1241, 157, - /* 500 */ 11, 10, 1195, 1675, 309, 1171, 478, 1319, 1320, 1322, - /* 510 */ 1323, 485, 130, 1535, 1383, 221, 584, 582, 35, 33, - /* 520 */ 310, 1493, 150, 1382, 61, 1533, 305, 60, 1170, 1174, - /* 530 */ 1175, 1193, 1221, 1222, 1224, 1225, 1226, 1227, 1228, 511, - /* 540 */ 533, 1236, 1237, 1238, 1239, 1240, 1241, 484, 390, 1572, - /* 550 */ 1573, 394, 1304, 1168, 1535, 532, 532, 566, 1194, 532, - /* 560 */ 276, 316, 1192, 1419, 1629, 975, 1533, 106, 106, 374, - /* 570 */ 1176, 367, 386, 1629, 430, 435, 565, 519, 564, 563, - /* 580 */ 562, 1273, 976, 1581, 1491, 1491, 532, 2, 1491, 131, - /* 590 */ 387, 532, 532, 532, 258, 1247, 1381, 1380, 408, 1379, - /* 600 */ 315, 1194, 1535, 1607, 1488, 466, 256, 53, 130, 614, - /* 610 */ 52, 1378, 561, 398, 1534, 1491, 394, 1493, 950, 1169, - /* 620 */ 1491, 1491, 1491, 590, 589, 588, 320, 162, 587, 586, - /* 630 */ 585, 116, 580, 579, 578, 577, 576, 575, 574, 573, - /* 640 */ 123, 569, 318, 428, 1568, 130, 1629, 1629, 1197, 1629, - /* 650 */ 130, 159, 55, 252, 1494, 572, 1521, 1463, 7, 1493, - /* 660 */ 385, 1629, 1171, 380, 379, 378, 377, 376, 373, 372, - /* 670 */ 371, 370, 369, 365, 364, 363, 362, 361, 360, 359, - /* 680 */ 358, 1377, 1376, 54, 492, 503, 1174, 1175, 81, 1221, - /* 690 */ 1222, 1224, 1225, 1226, 1227, 1228, 511, 533, 1236, 1237, - /* 700 */ 1238, 1239, 1240, 1241, 532, 1375, 36, 34, 32, 31, - /* 710 */ 30, 532, 1374, 114, 532, 1194, 529, 938, 939, 59, - /* 720 */ 58, 354, 1223, 530, 156, 1659, 243, 532, 1371, 348, - /* 730 */ 1296, 1629, 1629, 1491, 36, 34, 32, 31, 30, 319, - /* 740 */ 1491, 275, 185, 1491, 338, 183, 336, 332, 328, 153, - /* 750 */ 323, 112, 279, 1675, 1370, 1629, 1491, 1369, 1476, 1742, - /* 760 */ 571, 495, 1629, 1742, 1368, 1223, 146, 1735, 1736, 1367, - /* 770 */ 1740, 515, 1366, 206, 1478, 1629, 1208, 1365, 1629, 1409, - /* 780 */ 279, 150, 1364, 1738, 1259, 1659, 1363, 1737, 1747, 1292, - /* 790 */ 1474, 187, 1688, 434, 186, 83, 1660, 518, 1662, 1663, - /* 800 */ 514, 445, 535, 189, 1629, 1728, 188, 1629, 197, 298, - /* 810 */ 1724, 143, 1259, 1675, 1629, 433, 1404, 191, 1402, 1629, - /* 820 */ 190, 495, 1629, 222, 456, 1153, 1154, 1629, 474, 1755, - /* 830 */ 1292, 515, 1629, 1260, 449, 1629, 1629, 454, 447, 1649, - /* 840 */ 450, 510, 120, 46, 560, 209, 37, 11, 10, 457, - /* 850 */ 1355, 1356, 1688, 465, 1265, 83, 1660, 518, 1662, 1663, - /* 860 */ 514, 1260, 535, 193, 1179, 1728, 37, 37, 232, 298, - /* 870 */ 1724, 143, 1373, 504, 118, 452, 1651, 1170, 1178, 1223, - /* 880 */ 446, 1449, 1265, 470, 1318, 192, 211, 1267, 225, 1756, - /* 890 */ 459, 119, 27, 303, 1254, 1255, 1256, 1257, 1258, 1262, - /* 900 */ 1263, 1264, 1168, 1659, 120, 498, 46, 1229, 1126, 234, - /* 910 */ 51, 540, 479, 50, 216, 524, 119, 1676, 120, 1176, - /* 920 */ 27, 303, 1254, 1255, 1256, 1257, 1258, 1262, 1263, 1264, - /* 930 */ 1182, 1675, 240, 1393, 427, 1659, 1758, 1295, 121, 516, - /* 940 */ 1530, 119, 493, 224, 1181, 1034, 227, 251, 229, 515, - /* 950 */ 3, 5, 1062, 1629, 1192, 322, 325, 1066, 614, 1072, - /* 960 */ 329, 1003, 284, 1675, 285, 1137, 248, 1659, 1169, 368, - /* 970 */ 1688, 516, 1570, 83, 1660, 518, 1662, 1663, 514, 1070, - /* 980 */ 535, 515, 122, 1728, 158, 1629, 383, 298, 1724, 1803, - /* 990 */ 375, 388, 1198, 382, 384, 1675, 389, 397, 1762, 1201, - /* 1000 */ 400, 165, 1688, 516, 401, 83, 1660, 518, 1662, 1663, - /* 1010 */ 514, 1171, 535, 515, 167, 1728, 1200, 1629, 1659, 298, - /* 1020 */ 1724, 1803, 1202, 402, 170, 405, 403, 172, 406, 1199, - /* 1030 */ 1785, 175, 407, 410, 1688, 1174, 1175, 83, 1660, 518, - /* 1040 */ 1662, 1663, 514, 62, 535, 178, 1675, 1728, 1659, 1176, - /* 1050 */ 431, 298, 1724, 1803, 516, 1481, 429, 182, 1477, 86, - /* 1060 */ 184, 1611, 1746, 124, 515, 293, 125, 1479, 1629, 1475, - /* 1070 */ 126, 249, 195, 496, 460, 198, 1675, 127, 467, 469, - /* 1080 */ 461, 472, 464, 1197, 516, 1688, 201, 471, 263, 1660, - /* 1090 */ 518, 1662, 1663, 514, 515, 535, 204, 1759, 1629, 480, - /* 1100 */ 522, 1769, 1768, 496, 6, 1749, 207, 477, 489, 215, - /* 1110 */ 1292, 476, 210, 137, 1790, 1688, 297, 113, 263, 1660, - /* 1120 */ 518, 1662, 1663, 514, 483, 535, 149, 1196, 40, 217, - /* 1130 */ 1787, 505, 502, 1041, 558, 557, 556, 1045, 555, 1047, - /* 1140 */ 1048, 554, 1050, 551, 1790, 1056, 548, 1058, 1059, 545, - /* 1150 */ 542, 1743, 18, 299, 1579, 1578, 147, 180, 520, 521, - /* 1160 */ 1787, 1786, 1709, 1659, 218, 307, 223, 525, 526, 141, - /* 1170 */ 236, 527, 238, 250, 1492, 426, 422, 418, 414, 179, - /* 1180 */ 71, 73, 1659, 538, 1464, 253, 1806, 245, 47, 499, - /* 1190 */ 226, 1675, 613, 506, 228, 136, 264, 274, 255, 516, - /* 1200 */ 257, 265, 1623, 1622, 64, 57, 1621, 177, 324, 515, - /* 1210 */ 1675, 1618, 327, 1629, 326, 1163, 1164, 154, 513, 331, - /* 1220 */ 1616, 333, 334, 335, 1615, 337, 1614, 339, 515, 1613, - /* 1230 */ 1688, 341, 1629, 84, 1660, 518, 1662, 1663, 514, 1612, - /* 1240 */ 535, 1659, 343, 1728, 1597, 155, 346, 507, 1724, 1688, - /* 1250 */ 1659, 347, 272, 1660, 518, 1662, 1663, 514, 512, 535, - /* 1260 */ 509, 1700, 1140, 1591, 176, 1139, 168, 1590, 173, 1675, - /* 1270 */ 404, 352, 353, 1589, 1588, 1109, 1563, 516, 1675, 1562, - /* 1280 */ 1561, 1560, 1559, 1558, 1557, 1556, 516, 515, 166, 1555, - /* 1290 */ 1554, 1629, 1553, 1552, 1551, 1550, 515, 1549, 1548, 1547, - /* 1300 */ 1629, 1546, 117, 1545, 1544, 1543, 1542, 1541, 1688, 1540, - /* 1310 */ 1111, 134, 1660, 518, 1662, 1663, 514, 1688, 535, 1539, - /* 1320 */ 84, 1660, 518, 1662, 1663, 514, 1538, 535, 1537, 1536, - /* 1330 */ 1728, 617, 1659, 1421, 1389, 1725, 163, 108, 941, 940, - /* 1340 */ 1388, 1659, 1605, 140, 1599, 247, 1587, 171, 164, 1586, - /* 1350 */ 109, 1576, 393, 169, 497, 1804, 1470, 107, 395, 174, - /* 1360 */ 1675, 1420, 1418, 606, 602, 598, 594, 246, 516, 1675, - /* 1370 */ 969, 1416, 413, 417, 411, 412, 416, 516, 515, 415, - /* 1380 */ 1414, 1412, 1629, 420, 419, 475, 423, 515, 424, 421, - /* 1390 */ 425, 1629, 80, 1659, 1401, 241, 1400, 1387, 1472, 1688, - /* 1400 */ 1075, 1076, 273, 1660, 518, 1662, 1663, 514, 1688, 535, - /* 1410 */ 45, 268, 1660, 518, 1662, 1663, 514, 1471, 535, 1002, - /* 1420 */ 1001, 1675, 1000, 999, 581, 583, 996, 1410, 528, 516, - /* 1430 */ 290, 1405, 995, 181, 994, 291, 448, 1403, 451, 515, - /* 1440 */ 292, 1386, 453, 1629, 1385, 455, 85, 1604, 488, 1147, - /* 1450 */ 1598, 462, 1659, 473, 1585, 1584, 202, 199, 1583, 1575, - /* 1460 */ 1688, 312, 311, 134, 1660, 518, 1662, 1663, 514, 203, - /* 1470 */ 535, 1184, 208, 67, 1145, 4, 196, 37, 128, 15, - /* 1480 */ 1675, 43, 1317, 1310, 1659, 135, 49, 212, 516, 213, - /* 1490 */ 205, 22, 463, 48, 1289, 214, 1177, 1649, 515, 41, - /* 1500 */ 1659, 23, 1629, 1288, 42, 302, 68, 1805, 220, 138, - /* 1510 */ 1346, 17, 1675, 1176, 1341, 1335, 1340, 10, 300, 1688, - /* 1520 */ 513, 1345, 273, 1660, 518, 1662, 1663, 514, 1675, 535, - /* 1530 */ 515, 1344, 301, 19, 1629, 16, 516, 13, 1231, 1252, - /* 1540 */ 139, 151, 29, 1216, 1230, 517, 515, 12, 523, 20, - /* 1550 */ 1629, 1688, 536, 304, 272, 1660, 518, 1662, 1663, 514, - /* 1560 */ 1659, 535, 1180, 1701, 21, 1574, 237, 1688, 231, 1315, - /* 1570 */ 273, 1660, 518, 1662, 1663, 514, 233, 535, 239, 235, - /* 1580 */ 69, 70, 74, 1648, 242, 1691, 1186, 1233, 1675, 1063, - /* 1590 */ 534, 44, 539, 537, 314, 541, 516, 543, 1060, 544, - /* 1600 */ 1659, 1057, 546, 547, 549, 1185, 515, 1051, 550, 552, - /* 1610 */ 1629, 1659, 1049, 306, 553, 1040, 1055, 1054, 1053, 559, - /* 1620 */ 1071, 1068, 1052, 75, 76, 77, 967, 1688, 1675, 1188, - /* 1630 */ 273, 1660, 518, 1662, 1663, 514, 516, 535, 567, 1675, - /* 1640 */ 533, 1236, 1237, 991, 1069, 1009, 515, 516, 570, 244, - /* 1650 */ 1629, 1659, 989, 988, 987, 984, 986, 515, 1006, 985, - /* 1660 */ 983, 1629, 982, 1004, 1659, 492, 979, 1688, 978, 977, - /* 1670 */ 259, 1660, 518, 1662, 1663, 514, 974, 535, 1688, 1675, - /* 1680 */ 1417, 267, 1660, 518, 1662, 1663, 514, 516, 535, 973, - /* 1690 */ 972, 591, 1675, 592, 114, 593, 1415, 515, 596, 595, - /* 1700 */ 516, 1629, 597, 1413, 599, 600, 601, 1411, 603, 604, - /* 1710 */ 515, 605, 1399, 496, 1629, 607, 608, 1659, 1688, 1398, - /* 1720 */ 1384, 269, 1660, 518, 1662, 1663, 514, 611, 535, 612, - /* 1730 */ 615, 1688, 112, 1172, 260, 1660, 518, 1662, 1663, 514, - /* 1740 */ 254, 535, 616, 1359, 1359, 1675, 1359, 219, 1735, 491, - /* 1750 */ 1659, 490, 1359, 516, 1790, 1359, 1359, 1359, 1359, 1359, - /* 1760 */ 1359, 1359, 1359, 515, 1359, 1659, 149, 1629, 1359, 1359, - /* 1770 */ 1787, 1359, 1359, 1359, 1359, 1359, 1359, 1359, 1675, 1359, - /* 1780 */ 1359, 1359, 1359, 1359, 1688, 1359, 516, 270, 1660, 518, - /* 1790 */ 1662, 1663, 514, 1675, 535, 1359, 515, 1359, 1659, 1359, - /* 1800 */ 1629, 516, 1359, 1359, 1359, 1359, 1359, 1359, 1359, 1359, - /* 1810 */ 1359, 515, 1359, 1659, 1359, 1629, 1359, 1688, 1359, 1359, - /* 1820 */ 261, 1660, 518, 1662, 1663, 514, 1675, 535, 1359, 1359, - /* 1830 */ 1359, 1359, 1688, 1359, 516, 271, 1660, 518, 1662, 1663, - /* 1840 */ 514, 1675, 535, 1359, 515, 1359, 1359, 1359, 1629, 516, - /* 1850 */ 1359, 1359, 1359, 1659, 1359, 1359, 1359, 1359, 1359, 515, - /* 1860 */ 1359, 1359, 1359, 1629, 1359, 1688, 1359, 1359, 262, 1660, - /* 1870 */ 518, 1662, 1663, 514, 1359, 535, 1359, 1359, 1359, 1359, - /* 1880 */ 1688, 1675, 1359, 1671, 1660, 518, 1662, 1663, 514, 516, - /* 1890 */ 535, 1359, 1359, 1659, 1359, 1359, 1359, 1359, 1359, 515, - /* 1900 */ 1359, 1359, 1359, 1629, 1659, 1359, 1359, 1359, 1359, 1359, - /* 1910 */ 1359, 1359, 1359, 1359, 1359, 1359, 1359, 1359, 1359, 1359, - /* 1920 */ 1688, 1675, 1359, 1670, 1660, 518, 1662, 1663, 514, 516, - /* 1930 */ 535, 1359, 1675, 1359, 1359, 1359, 1359, 1359, 1359, 515, - /* 1940 */ 516, 1359, 1359, 1629, 1659, 1359, 1359, 1359, 1359, 1359, - /* 1950 */ 515, 1359, 1359, 1359, 1629, 1359, 1359, 1659, 1359, 1359, - /* 1960 */ 1688, 1359, 1359, 1669, 1660, 518, 1662, 1663, 514, 1359, - /* 1970 */ 535, 1688, 1675, 1359, 282, 1660, 518, 1662, 1663, 514, - /* 1980 */ 516, 535, 1359, 1359, 1359, 1675, 1359, 1359, 1359, 1359, - /* 1990 */ 515, 1359, 1359, 516, 1629, 1359, 1359, 1359, 1359, 1359, - /* 2000 */ 1359, 1359, 1359, 515, 1359, 1359, 1359, 1629, 1659, 1359, - /* 2010 */ 1359, 1688, 1359, 1359, 281, 1660, 518, 1662, 1663, 514, - /* 2020 */ 1359, 535, 1359, 1359, 1688, 1359, 1359, 283, 1660, 518, - /* 2030 */ 1662, 1663, 514, 1359, 535, 1359, 1675, 1359, 492, 1359, - /* 2040 */ 1359, 1659, 1359, 1359, 516, 1359, 1359, 1359, 1359, 1359, - /* 2050 */ 1359, 1359, 1359, 1359, 515, 1359, 1359, 1359, 1629, 1359, - /* 2060 */ 1359, 1359, 1359, 1359, 1359, 1359, 1359, 114, 1359, 1675, - /* 2070 */ 1359, 1359, 1359, 1359, 1359, 1688, 1359, 516, 280, 1660, - /* 2080 */ 518, 1662, 1663, 514, 1359, 535, 496, 515, 1359, 1359, - /* 2090 */ 1359, 1629, 1359, 1359, 1359, 1359, 1359, 1359, 1359, 1359, - /* 2100 */ 1359, 1359, 1359, 1359, 1359, 112, 1359, 1359, 1688, 1359, - /* 2110 */ 1359, 266, 1660, 518, 1662, 1663, 514, 1359, 535, 1359, - /* 2120 */ 219, 1735, 491, 1359, 490, 1359, 1359, 1790, 1359, 1359, - /* 2130 */ 1359, 1359, 1359, 1359, 1359, 1359, 1359, 1359, 1359, 147, - /* 2140 */ 1359, 1359, 1359, 1787, + /* 0 */ 28, 231, 1663, 1650, 611, 610, 297, 1650, 358, 1485, + /* 10 */ 314, 1483, 35, 33, 352, 36, 34, 32, 31, 30, + /* 20 */ 306, 24, 1173, 1647, 533, 442, 441, 1647, 79, 1647, + /* 30 */ 1679, 36, 34, 32, 31, 30, 152, 493, 517, 1643, + /* 40 */ 1649, 115, 278, 1643, 1649, 1643, 1649, 1171, 516, 1486, + /* 50 */ 536, 533, 1633, 1494, 536, 1794, 536, 497, 14, 1746, + /* 60 */ 35, 33, 1300, 356, 1179, 1663, 114, 147, 306, 1692, + /* 70 */ 1173, 1791, 82, 1664, 519, 1666, 1667, 515, 532, 536, + /* 80 */ 1494, 1, 1732, 1743, 1794, 1314, 280, 1728, 36, 34, + /* 90 */ 32, 31, 30, 1679, 410, 1171, 1793, 1651, 1794, 520, + /* 100 */ 1791, 517, 309, 615, 112, 1583, 14, 1746, 35, 33, + /* 110 */ 149, 516, 1179, 1172, 1791, 1633, 306, 1647, 1173, 145, + /* 120 */ 1739, 1740, 532, 1744, 36, 34, 32, 31, 30, 2, + /* 130 */ 63, 1742, 1692, 1643, 1649, 84, 1664, 519, 1666, 1667, + /* 140 */ 515, 1364, 536, 1171, 536, 1732, 953, 1794, 952, 1731, + /* 150 */ 1728, 615, 1490, 72, 14, 392, 1174, 393, 1395, 148, + /* 160 */ 1179, 1172, 96, 1791, 532, 95, 94, 93, 92, 91, + /* 170 */ 90, 89, 88, 87, 1487, 954, 56, 2, 132, 201, + /* 180 */ 1375, 1177, 1178, 39, 1224, 1225, 1227, 1228, 1229, 1230, + /* 190 */ 1231, 512, 534, 1239, 1240, 1241, 1242, 1243, 1244, 615, + /* 200 */ 400, 952, 393, 1395, 1174, 55, 1197, 66, 133, 1172, + /* 210 */ 96, 150, 1451, 95, 94, 93, 92, 91, 90, 89, + /* 220 */ 88, 87, 65, 279, 1356, 38, 429, 194, 567, 1177, + /* 230 */ 1178, 1363, 1224, 1225, 1227, 1228, 1229, 1230, 1231, 512, + /* 240 */ 534, 1239, 1240, 1241, 1242, 1243, 1244, 566, 487, 565, + /* 250 */ 564, 563, 1174, 55, 63, 105, 104, 103, 102, 101, + /* 260 */ 100, 99, 98, 97, 936, 35, 33, 110, 36, 34, + /* 270 */ 32, 31, 30, 306, 1746, 1173, 1489, 1177, 1178, 1198, + /* 280 */ 1224, 1225, 1227, 1228, 1229, 1230, 1231, 512, 534, 1239, + /* 290 */ 1240, 1241, 1242, 1243, 1244, 55, 445, 444, 1741, 1538, + /* 300 */ 1171, 443, 940, 941, 111, 440, 296, 1355, 439, 438, + /* 310 */ 437, 1536, 569, 35, 33, 1245, 1679, 1179, 26, 310, + /* 320 */ 1386, 306, 391, 1173, 486, 395, 290, 130, 36, 34, + /* 330 */ 32, 31, 30, 1196, 8, 150, 1496, 1043, 559, 558, + /* 340 */ 557, 1047, 556, 1049, 1050, 555, 1052, 552, 1171, 1058, + /* 350 */ 549, 1060, 1061, 546, 543, 150, 615, 450, 482, 618, + /* 360 */ 485, 35, 33, 585, 583, 1179, 1172, 142, 397, 306, + /* 370 */ 1633, 1173, 458, 248, 1195, 291, 1324, 289, 288, 1532, + /* 380 */ 433, 318, 9, 150, 435, 107, 193, 399, 1574, 1576, + /* 390 */ 395, 607, 603, 599, 595, 247, 1171, 1472, 453, 157, + /* 400 */ 533, 129, 1361, 447, 615, 1425, 434, 572, 192, 1174, + /* 410 */ 1794, 1385, 357, 1179, 1172, 479, 1322, 1323, 1325, 1326, + /* 420 */ 80, 1571, 1792, 242, 61, 150, 1791, 60, 159, 1494, + /* 430 */ 9, 488, 483, 51, 1177, 1178, 50, 1224, 1225, 1227, + /* 440 */ 1228, 1229, 1230, 1231, 512, 534, 1239, 1240, 1241, 1242, + /* 450 */ 1243, 1244, 615, 55, 410, 316, 529, 1174, 54, 319, + /* 460 */ 322, 1633, 1172, 130, 150, 445, 444, 130, 1538, 562, + /* 470 */ 443, 382, 1496, 111, 440, 311, 1496, 439, 438, 437, + /* 480 */ 1536, 474, 1177, 1178, 203, 1224, 1225, 1227, 1228, 1229, + /* 490 */ 1230, 1231, 512, 534, 1239, 1240, 1241, 1242, 1243, 1244, + /* 500 */ 1384, 1794, 1147, 1199, 197, 1174, 1575, 1576, 36, 34, + /* 510 */ 32, 31, 30, 147, 1307, 161, 160, 1791, 35, 33, + /* 520 */ 1197, 1663, 1155, 1156, 195, 1470, 306, 351, 1173, 350, + /* 530 */ 1177, 1178, 493, 1224, 1225, 1227, 1228, 1229, 1230, 1231, + /* 540 */ 512, 534, 1239, 1240, 1241, 1242, 1243, 1244, 253, 1679, + /* 550 */ 1633, 1524, 533, 1171, 1383, 1621, 533, 517, 1382, 1250, + /* 560 */ 277, 114, 1195, 1005, 367, 1197, 1479, 516, 106, 375, + /* 570 */ 1179, 1633, 387, 466, 533, 431, 497, 1422, 1211, 469, + /* 580 */ 1007, 1494, 569, 150, 1381, 1494, 368, 2, 1692, 343, + /* 590 */ 388, 82, 1664, 519, 1666, 1667, 515, 1481, 536, 112, + /* 600 */ 331, 1732, 1477, 1494, 1633, 280, 1728, 198, 1633, 615, + /* 610 */ 345, 341, 533, 495, 144, 1739, 1740, 1794, 1744, 1172, + /* 620 */ 1794, 940, 941, 1538, 106, 1376, 11, 10, 222, 147, + /* 630 */ 317, 436, 147, 1791, 1633, 1536, 1791, 591, 590, 589, + /* 640 */ 321, 1494, 588, 587, 586, 116, 581, 580, 579, 578, + /* 650 */ 577, 576, 575, 574, 123, 570, 32, 31, 30, 1380, + /* 660 */ 386, 1299, 1174, 381, 380, 379, 378, 377, 374, 373, + /* 670 */ 372, 371, 370, 366, 365, 364, 363, 362, 361, 360, + /* 680 */ 359, 499, 1663, 520, 1379, 1226, 1197, 1177, 1178, 1584, + /* 690 */ 1224, 1225, 1227, 1228, 1229, 1230, 1231, 512, 534, 1239, + /* 700 */ 1240, 1241, 1242, 1243, 1244, 1264, 131, 1276, 1378, 1633, + /* 710 */ 1679, 259, 573, 533, 1466, 7, 511, 533, 496, 1471, + /* 720 */ 1200, 533, 459, 257, 53, 409, 1269, 52, 516, 1491, + /* 730 */ 1226, 533, 1633, 1610, 1633, 533, 36, 34, 32, 31, + /* 740 */ 30, 1377, 1494, 244, 162, 1374, 1494, 467, 1663, 1692, + /* 750 */ 1494, 501, 83, 1664, 519, 1666, 1667, 515, 1633, 536, + /* 760 */ 1494, 1373, 1732, 1794, 1494, 25, 299, 1728, 143, 55, + /* 770 */ 36, 34, 32, 31, 30, 147, 1679, 1469, 533, 1791, + /* 780 */ 223, 533, 281, 130, 517, 475, 1759, 435, 533, 1372, + /* 790 */ 530, 1633, 1497, 531, 516, 1633, 185, 1371, 1633, 183, + /* 800 */ 320, 476, 1370, 1369, 1663, 81, 1211, 1494, 1368, 434, + /* 810 */ 1494, 1633, 567, 504, 1262, 1692, 281, 1494, 274, 1664, + /* 820 */ 519, 1666, 1667, 515, 509, 536, 1751, 1295, 493, 561, + /* 830 */ 457, 566, 1679, 565, 564, 563, 59, 58, 355, 1633, + /* 840 */ 514, 156, 1452, 455, 1538, 207, 349, 1633, 1262, 584, + /* 850 */ 516, 1226, 1633, 1633, 1633, 1367, 1537, 114, 1633, 276, + /* 860 */ 1173, 226, 339, 1263, 337, 333, 329, 153, 324, 1298, + /* 870 */ 567, 1692, 1412, 1182, 273, 1664, 519, 1666, 1667, 515, + /* 880 */ 513, 536, 510, 1704, 1268, 1171, 1366, 1407, 1295, 566, + /* 890 */ 346, 565, 564, 563, 446, 112, 120, 1263, 187, 150, + /* 900 */ 189, 186, 1179, 188, 191, 1633, 1663, 190, 46, 448, + /* 910 */ 146, 1739, 1740, 1405, 1744, 11, 10, 1653, 1268, 1358, + /* 920 */ 1359, 480, 1181, 27, 304, 1257, 1258, 1259, 1260, 1261, + /* 930 */ 1265, 1266, 1267, 210, 1679, 451, 1633, 471, 502, 1185, + /* 940 */ 78, 615, 496, 37, 37, 460, 37, 1254, 233, 1321, + /* 950 */ 74, 1172, 516, 217, 1655, 1680, 1633, 27, 304, 1257, + /* 960 */ 1258, 1259, 1260, 1261, 1265, 1266, 1267, 118, 1663, 1396, + /* 970 */ 119, 1533, 120, 1692, 212, 46, 83, 1664, 519, 1666, + /* 980 */ 1667, 515, 977, 536, 1270, 1232, 1732, 1128, 1184, 235, + /* 990 */ 299, 1728, 143, 541, 1174, 428, 1679, 1762, 494, 978, + /* 1000 */ 1663, 225, 505, 119, 517, 228, 120, 230, 525, 3, + /* 1010 */ 1760, 241, 5, 1036, 516, 121, 252, 119, 1633, 1177, + /* 1020 */ 1178, 323, 1195, 326, 330, 286, 287, 1005, 1679, 249, + /* 1030 */ 1139, 369, 1573, 376, 1064, 1692, 517, 158, 83, 1664, + /* 1040 */ 519, 1666, 1667, 515, 1068, 536, 516, 1074, 1732, 384, + /* 1050 */ 1633, 389, 299, 1728, 1807, 383, 1072, 1201, 122, 385, + /* 1060 */ 1663, 390, 1204, 1766, 401, 398, 165, 1692, 402, 167, + /* 1070 */ 83, 1664, 519, 1666, 1667, 515, 1203, 536, 1205, 404, + /* 1080 */ 1732, 403, 170, 406, 299, 1728, 1807, 172, 1679, 407, + /* 1090 */ 1202, 175, 1663, 408, 62, 1789, 517, 411, 178, 430, + /* 1100 */ 432, 1484, 182, 86, 1480, 184, 516, 295, 124, 1179, + /* 1110 */ 1633, 125, 1482, 1478, 1615, 126, 127, 1614, 196, 461, + /* 1120 */ 1679, 199, 250, 202, 465, 462, 1200, 1692, 517, 468, + /* 1130 */ 83, 1664, 519, 1666, 1667, 515, 472, 536, 516, 205, + /* 1140 */ 1732, 481, 1633, 1663, 299, 1728, 1807, 497, 470, 478, + /* 1150 */ 473, 523, 1773, 1772, 298, 1750, 490, 208, 1763, 1692, + /* 1160 */ 211, 6, 264, 1664, 519, 1666, 1667, 515, 1753, 536, + /* 1170 */ 484, 1679, 216, 1663, 477, 113, 1295, 218, 1199, 517, + /* 1180 */ 40, 300, 1747, 506, 503, 18, 527, 1582, 1794, 516, + /* 1190 */ 137, 521, 522, 1633, 219, 1581, 526, 308, 497, 237, + /* 1200 */ 149, 1679, 528, 224, 1791, 251, 1663, 1495, 1713, 517, + /* 1210 */ 1692, 1810, 1790, 264, 1664, 519, 1666, 1667, 515, 516, + /* 1220 */ 536, 239, 71, 1633, 73, 539, 246, 254, 500, 614, + /* 1230 */ 136, 227, 1467, 229, 1679, 507, 1663, 265, 47, 1794, + /* 1240 */ 1692, 256, 517, 84, 1664, 519, 1666, 1667, 515, 258, + /* 1250 */ 536, 147, 516, 1732, 275, 1791, 1633, 508, 1728, 266, + /* 1260 */ 1627, 1626, 57, 1625, 1679, 325, 1622, 327, 328, 332, + /* 1270 */ 1166, 1167, 517, 1692, 154, 1620, 134, 1664, 519, 1666, + /* 1280 */ 1667, 515, 516, 536, 334, 335, 1633, 1663, 336, 1619, + /* 1290 */ 338, 1618, 340, 1617, 342, 1616, 1663, 344, 1600, 155, + /* 1300 */ 1142, 347, 1141, 1692, 348, 1594, 84, 1664, 519, 1666, + /* 1310 */ 1667, 515, 1593, 536, 353, 1679, 1732, 354, 1592, 498, + /* 1320 */ 1808, 1729, 1591, 517, 1679, 1111, 1566, 1565, 1564, 1563, + /* 1330 */ 1562, 1561, 517, 516, 1560, 1559, 1558, 1633, 1557, 1556, + /* 1340 */ 1555, 1554, 516, 1553, 1552, 1551, 1633, 1550, 1549, 117, + /* 1350 */ 1663, 1548, 1547, 1546, 1692, 1545, 1544, 269, 1664, 519, + /* 1360 */ 1666, 1667, 515, 1692, 536, 1543, 134, 1664, 519, 1666, + /* 1370 */ 1667, 515, 1113, 536, 1542, 1541, 1540, 1539, 1679, 1424, + /* 1380 */ 1392, 943, 163, 108, 942, 1391, 517, 1608, 1602, 1590, + /* 1390 */ 1663, 171, 1589, 394, 489, 140, 516, 164, 109, 169, + /* 1400 */ 1633, 396, 1579, 303, 45, 174, 1663, 1473, 1423, 1421, + /* 1410 */ 1809, 1419, 1417, 412, 413, 414, 417, 1692, 1679, 971, + /* 1420 */ 274, 1664, 519, 1666, 1667, 515, 514, 536, 416, 420, + /* 1430 */ 418, 421, 422, 1415, 1679, 426, 516, 424, 1404, 425, + /* 1440 */ 1633, 1403, 517, 1390, 1475, 1077, 181, 1078, 1474, 1413, + /* 1450 */ 1004, 582, 516, 1003, 1663, 584, 1633, 1692, 292, 305, + /* 1460 */ 273, 1664, 519, 1666, 1667, 515, 1408, 536, 1002, 1705, + /* 1470 */ 449, 1001, 998, 1692, 997, 996, 274, 1664, 519, 1666, + /* 1480 */ 1667, 515, 1679, 536, 293, 1406, 1663, 294, 1389, 452, + /* 1490 */ 517, 180, 1388, 454, 456, 85, 1607, 1149, 1601, 463, + /* 1500 */ 516, 1588, 1587, 141, 1633, 1586, 1578, 307, 49, 427, + /* 1510 */ 423, 419, 415, 179, 1679, 67, 1663, 204, 464, 4, + /* 1520 */ 37, 1692, 517, 206, 274, 1664, 519, 1666, 1667, 515, + /* 1530 */ 15, 536, 516, 128, 209, 43, 1633, 1320, 64, 200, + /* 1540 */ 135, 177, 213, 215, 1679, 22, 48, 1653, 214, 1313, + /* 1550 */ 68, 23, 517, 1692, 42, 1292, 260, 1664, 519, 1666, + /* 1560 */ 1667, 515, 516, 536, 221, 1291, 1633, 1663, 138, 1349, + /* 1570 */ 17, 1338, 1344, 1343, 301, 1348, 10, 1347, 302, 19, + /* 1580 */ 1255, 139, 1234, 1692, 151, 29, 268, 1664, 519, 1666, + /* 1590 */ 1667, 515, 12, 536, 1233, 1679, 20, 1219, 176, 16, + /* 1600 */ 168, 518, 173, 517, 405, 41, 13, 1663, 1577, 238, + /* 1610 */ 74, 524, 1652, 516, 232, 21, 234, 1633, 1318, 1189, + /* 1620 */ 236, 240, 166, 69, 70, 243, 1695, 540, 1236, 535, + /* 1630 */ 44, 1071, 1065, 538, 1692, 1679, 315, 270, 1664, 519, + /* 1640 */ 1666, 1667, 515, 517, 536, 542, 544, 1663, 1062, 1059, + /* 1650 */ 545, 547, 548, 516, 550, 1053, 553, 1633, 551, 1057, + /* 1660 */ 1051, 1056, 1663, 554, 1055, 1054, 75, 1042, 76, 560, + /* 1670 */ 1073, 77, 1070, 568, 1692, 1679, 969, 261, 1664, 519, + /* 1680 */ 1666, 1667, 515, 517, 536, 993, 1011, 245, 991, 571, + /* 1690 */ 1679, 986, 1008, 516, 990, 989, 988, 1633, 517, 987, + /* 1700 */ 985, 984, 1006, 981, 980, 979, 976, 975, 516, 974, + /* 1710 */ 1420, 592, 1633, 1663, 1692, 593, 594, 271, 1664, 519, + /* 1720 */ 1666, 1667, 515, 1418, 536, 1663, 597, 596, 598, 1692, + /* 1730 */ 1416, 600, 262, 1664, 519, 1666, 1667, 515, 601, 536, + /* 1740 */ 602, 1679, 604, 605, 606, 1402, 608, 609, 1401, 517, + /* 1750 */ 1414, 1387, 613, 1679, 612, 1175, 255, 616, 617, 516, + /* 1760 */ 1362, 517, 1362, 1633, 1362, 1663, 1362, 1362, 1362, 1362, + /* 1770 */ 1362, 516, 1362, 1362, 1362, 1633, 1663, 1362, 1362, 1362, + /* 1780 */ 1692, 1362, 1362, 272, 1664, 519, 1666, 1667, 515, 1362, + /* 1790 */ 536, 1362, 1692, 1679, 1362, 263, 1664, 519, 1666, 1667, + /* 1800 */ 515, 517, 536, 1362, 1679, 1362, 1362, 1362, 1362, 1362, + /* 1810 */ 1362, 516, 517, 1362, 1362, 1633, 1362, 1362, 1362, 1362, + /* 1820 */ 1362, 1362, 516, 1362, 1362, 1362, 1633, 1663, 1362, 1362, + /* 1830 */ 1362, 1362, 1692, 1362, 1362, 1675, 1664, 519, 1666, 1667, + /* 1840 */ 515, 1362, 536, 1692, 1362, 1362, 1674, 1664, 519, 1666, + /* 1850 */ 1667, 515, 1362, 536, 1362, 1679, 1362, 1663, 1362, 1362, + /* 1860 */ 1362, 1362, 1362, 517, 1362, 1362, 1362, 1362, 1362, 1362, + /* 1870 */ 1362, 1362, 1362, 516, 1362, 1362, 1362, 1633, 1362, 1362, + /* 1880 */ 1362, 1362, 1362, 1362, 1362, 1679, 1362, 1663, 1362, 1362, + /* 1890 */ 1362, 1362, 1362, 517, 1692, 1362, 1362, 1673, 1664, 519, + /* 1900 */ 1666, 1667, 515, 516, 536, 1362, 1362, 1633, 1362, 1362, + /* 1910 */ 1362, 1362, 1362, 1362, 1362, 1679, 1362, 1362, 1362, 1663, + /* 1920 */ 1362, 1362, 1362, 517, 1692, 1362, 1362, 284, 1664, 519, + /* 1930 */ 1666, 1667, 515, 516, 536, 1362, 1362, 1633, 1362, 1362, + /* 1940 */ 1362, 1362, 1362, 313, 312, 1362, 1362, 1679, 1362, 1362, + /* 1950 */ 1362, 1362, 1663, 1187, 1692, 517, 1362, 283, 1664, 519, + /* 1960 */ 1666, 1667, 515, 1362, 536, 516, 1362, 1362, 1362, 1633, + /* 1970 */ 1362, 1362, 1362, 1362, 1362, 1362, 1362, 1362, 1180, 1362, + /* 1980 */ 1679, 1362, 1362, 1362, 1362, 1663, 1692, 1362, 517, 285, + /* 1990 */ 1664, 519, 1666, 1667, 515, 1179, 536, 1362, 516, 1362, + /* 2000 */ 1362, 1362, 1633, 1362, 1362, 1362, 1362, 1362, 1362, 1362, + /* 2010 */ 1362, 1362, 1362, 1679, 1362, 1362, 493, 1362, 1362, 1692, + /* 2020 */ 1362, 517, 282, 1664, 519, 1666, 1667, 515, 1362, 536, + /* 2030 */ 1362, 516, 1362, 1362, 537, 1633, 1362, 1362, 1362, 1362, + /* 2040 */ 1362, 1362, 1362, 1362, 1183, 114, 493, 1362, 1362, 1362, + /* 2050 */ 1362, 1362, 1692, 1362, 1362, 267, 1664, 519, 1666, 1667, + /* 2060 */ 515, 1362, 536, 1362, 497, 1362, 1362, 1362, 1362, 1362, + /* 2070 */ 1362, 1362, 1362, 1362, 1362, 114, 1362, 1362, 1362, 1362, + /* 2080 */ 1362, 1362, 1362, 112, 1362, 1362, 1362, 1188, 1362, 1362, + /* 2090 */ 1362, 1362, 1362, 1362, 497, 1362, 1362, 1362, 220, 1739, + /* 2100 */ 492, 1362, 491, 1362, 1362, 1794, 1362, 1362, 1362, 1362, + /* 2110 */ 1362, 1362, 1191, 112, 1362, 1362, 1362, 149, 1362, 1362, + /* 2120 */ 1362, 1791, 1362, 534, 1239, 1240, 1362, 1362, 220, 1739, + /* 2130 */ 492, 1362, 491, 1362, 1362, 1794, 1362, 1362, 1362, 1362, + /* 2140 */ 1362, 1362, 1362, 1362, 1362, 1362, 1362, 147, 1362, 1362, + /* 2150 */ 1362, 1791, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 323, 324, 242, 272, 250, 251, 275, 272, 249, 272, - /* 10 */ 275, 271, 12, 13, 297, 12, 13, 14, 15, 16, - /* 20 */ 20, 2, 22, 292, 249, 256, 257, 292, 252, 292, - /* 30 */ 270, 12, 13, 14, 15, 16, 261, 249, 278, 308, - /* 40 */ 309, 265, 283, 308, 309, 308, 309, 47, 288, 273, - /* 50 */ 319, 249, 292, 278, 319, 338, 319, 297, 58, 310, - /* 60 */ 12, 13, 14, 261, 64, 242, 278, 350, 20, 309, - /* 70 */ 22, 354, 312, 313, 314, 315, 316, 317, 41, 319, - /* 80 */ 278, 81, 322, 334, 338, 82, 326, 327, 12, 13, - /* 90 */ 14, 15, 16, 270, 20, 47, 350, 272, 338, 288, - /* 100 */ 354, 278, 291, 103, 316, 294, 58, 57, 12, 13, - /* 110 */ 350, 288, 64, 113, 354, 292, 20, 292, 22, 331, - /* 120 */ 332, 333, 20, 335, 12, 13, 14, 15, 16, 81, - /* 130 */ 75, 254, 309, 308, 309, 312, 313, 314, 315, 316, - /* 140 */ 317, 0, 319, 47, 319, 322, 20, 338, 4, 326, - /* 150 */ 327, 103, 269, 276, 58, 245, 156, 247, 248, 350, - /* 160 */ 64, 113, 21, 354, 281, 24, 25, 26, 27, 28, - /* 170 */ 29, 30, 31, 32, 119, 120, 241, 81, 243, 93, - /* 180 */ 180, 181, 4, 183, 184, 185, 186, 187, 188, 189, - /* 190 */ 190, 191, 192, 193, 194, 195, 196, 197, 112, 103, - /* 200 */ 114, 115, 116, 245, 156, 247, 248, 81, 21, 113, - /* 210 */ 210, 24, 25, 26, 27, 28, 29, 30, 31, 32, - /* 220 */ 42, 43, 165, 166, 148, 81, 169, 0, 180, 181, - /* 230 */ 0, 183, 184, 185, 186, 187, 188, 189, 190, 191, - /* 240 */ 192, 193, 194, 195, 196, 197, 12, 13, 14, 15, - /* 250 */ 16, 20, 156, 239, 24, 25, 26, 27, 28, 29, - /* 260 */ 30, 31, 32, 0, 227, 12, 13, 12, 13, 14, - /* 270 */ 15, 16, 45, 20, 81, 22, 180, 181, 151, 183, + /* 0 */ 324, 325, 243, 273, 251, 252, 276, 273, 250, 273, + /* 10 */ 276, 272, 12, 13, 298, 12, 13, 14, 15, 16, + /* 20 */ 20, 2, 22, 293, 250, 257, 258, 293, 253, 293, + /* 30 */ 271, 12, 13, 14, 15, 16, 262, 250, 279, 309, + /* 40 */ 310, 266, 284, 309, 310, 309, 310, 47, 289, 274, + /* 50 */ 320, 250, 293, 279, 320, 339, 320, 298, 58, 311, + /* 60 */ 12, 13, 14, 262, 64, 243, 279, 351, 20, 310, + /* 70 */ 22, 355, 313, 314, 315, 316, 317, 318, 20, 320, + /* 80 */ 279, 81, 323, 335, 339, 82, 327, 328, 12, 13, + /* 90 */ 14, 15, 16, 271, 57, 47, 351, 273, 339, 289, + /* 100 */ 355, 279, 292, 103, 317, 295, 58, 311, 12, 13, + /* 110 */ 351, 289, 64, 113, 355, 293, 20, 293, 22, 332, + /* 120 */ 333, 334, 20, 336, 12, 13, 14, 15, 16, 81, + /* 130 */ 255, 335, 310, 309, 310, 313, 314, 315, 316, 317, + /* 140 */ 318, 0, 320, 47, 320, 323, 20, 339, 22, 327, + /* 150 */ 328, 103, 277, 253, 58, 246, 156, 248, 249, 351, + /* 160 */ 64, 113, 21, 355, 20, 24, 25, 26, 27, 28, + /* 170 */ 29, 30, 31, 32, 274, 49, 4, 81, 242, 55, + /* 180 */ 244, 181, 182, 81, 184, 185, 186, 187, 188, 189, + /* 190 */ 190, 191, 192, 193, 194, 195, 196, 197, 198, 103, + /* 200 */ 246, 22, 248, 249, 156, 81, 20, 83, 256, 113, + /* 210 */ 21, 211, 260, 24, 25, 26, 27, 28, 29, 30, + /* 220 */ 31, 32, 165, 166, 148, 81, 47, 170, 93, 181, + /* 230 */ 182, 0, 184, 185, 186, 187, 188, 189, 190, 191, + /* 240 */ 192, 193, 194, 195, 196, 197, 198, 112, 20, 114, + /* 250 */ 115, 116, 156, 81, 255, 24, 25, 26, 27, 28, + /* 260 */ 29, 30, 31, 32, 4, 12, 13, 268, 12, 13, + /* 270 */ 14, 15, 16, 20, 311, 22, 277, 181, 182, 20, /* 280 */ 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, - /* 290 */ 194, 195, 196, 197, 297, 249, 60, 61, 171, 172, - /* 300 */ 47, 65, 20, 242, 68, 69, 230, 261, 72, 73, - /* 310 */ 74, 297, 81, 12, 13, 14, 2, 64, 255, 254, - /* 320 */ 57, 20, 259, 22, 278, 252, 12, 13, 14, 15, - /* 330 */ 16, 270, 267, 58, 81, 338, 210, 82, 270, 278, - /* 340 */ 35, 276, 81, 249, 297, 277, 273, 350, 47, 288, - /* 350 */ 282, 354, 338, 292, 210, 20, 103, 22, 297, 143, - /* 360 */ 139, 12, 13, 0, 350, 64, 113, 55, 354, 20, - /* 370 */ 309, 22, 278, 312, 313, 314, 315, 316, 317, 145, - /* 380 */ 319, 160, 81, 322, 49, 338, 57, 326, 327, 84, - /* 390 */ 20, 86, 87, 81, 89, 83, 47, 350, 93, 338, - /* 400 */ 0, 354, 81, 210, 103, 338, 14, 15, 16, 156, - /* 410 */ 316, 350, 91, 64, 113, 354, 155, 350, 157, 198, - /* 420 */ 115, 354, 14, 0, 330, 331, 332, 333, 20, 335, - /* 430 */ 81, 215, 216, 180, 181, 41, 183, 184, 185, 186, + /* 290 */ 194, 195, 196, 197, 198, 81, 60, 61, 335, 271, + /* 300 */ 47, 65, 42, 43, 68, 69, 278, 231, 72, 73, + /* 310 */ 74, 283, 57, 12, 13, 14, 271, 64, 2, 263, + /* 320 */ 243, 20, 247, 22, 279, 250, 35, 271, 12, 13, + /* 330 */ 14, 15, 16, 20, 81, 211, 280, 94, 95, 96, + /* 340 */ 97, 98, 99, 100, 101, 102, 103, 104, 47, 106, + /* 350 */ 107, 108, 109, 110, 111, 211, 103, 4, 143, 19, + /* 360 */ 315, 12, 13, 257, 258, 64, 113, 270, 14, 20, + /* 370 */ 293, 22, 19, 33, 20, 84, 181, 86, 87, 282, + /* 380 */ 89, 281, 81, 211, 93, 45, 33, 247, 288, 289, + /* 390 */ 250, 51, 52, 53, 54, 55, 47, 0, 45, 55, + /* 400 */ 250, 145, 240, 50, 103, 0, 115, 64, 55, 156, + /* 410 */ 339, 243, 262, 64, 113, 220, 221, 222, 223, 224, + /* 420 */ 80, 279, 351, 83, 80, 211, 355, 83, 286, 279, + /* 430 */ 81, 216, 217, 80, 181, 182, 83, 184, 185, 186, /* 440 */ 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, - /* 450 */ 197, 280, 103, 47, 249, 180, 93, 156, 287, 288, - /* 460 */ 60, 61, 113, 210, 0, 65, 261, 180, 68, 69, - /* 470 */ 64, 210, 72, 73, 74, 112, 82, 114, 115, 116, - /* 480 */ 57, 180, 181, 278, 183, 184, 185, 186, 187, 188, - /* 490 */ 189, 190, 191, 192, 193, 194, 195, 196, 197, 55, - /* 500 */ 1, 2, 20, 270, 262, 156, 219, 220, 221, 222, - /* 510 */ 223, 278, 270, 270, 242, 145, 256, 257, 12, 13, - /* 520 */ 277, 279, 210, 242, 80, 282, 20, 83, 22, 180, - /* 530 */ 181, 20, 183, 184, 185, 186, 187, 188, 189, 190, - /* 540 */ 191, 192, 193, 194, 195, 196, 197, 314, 246, 287, - /* 550 */ 288, 249, 14, 47, 270, 249, 249, 93, 20, 249, - /* 560 */ 18, 277, 20, 0, 292, 47, 282, 261, 261, 27, - /* 570 */ 64, 261, 30, 292, 268, 268, 112, 288, 114, 115, - /* 580 */ 116, 82, 64, 294, 278, 278, 249, 81, 278, 18, - /* 590 */ 48, 249, 249, 249, 23, 14, 242, 242, 261, 242, - /* 600 */ 262, 20, 270, 261, 261, 261, 35, 36, 270, 103, - /* 610 */ 39, 242, 92, 246, 282, 278, 249, 279, 22, 113, - /* 620 */ 278, 278, 278, 60, 61, 62, 63, 56, 65, 66, - /* 630 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - /* 640 */ 77, 78, 262, 47, 278, 270, 292, 292, 20, 292, - /* 650 */ 270, 285, 81, 263, 279, 258, 266, 260, 37, 279, - /* 660 */ 118, 292, 156, 121, 122, 123, 124, 125, 126, 127, + /* 450 */ 197, 198, 103, 81, 57, 263, 116, 156, 3, 263, + /* 460 */ 298, 293, 113, 271, 211, 60, 61, 271, 271, 92, + /* 470 */ 65, 75, 280, 68, 69, 278, 280, 72, 73, 74, + /* 480 */ 283, 141, 181, 182, 144, 184, 185, 186, 187, 188, + /* 490 */ 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, + /* 500 */ 243, 339, 162, 20, 164, 156, 288, 289, 12, 13, + /* 510 */ 14, 15, 16, 351, 14, 119, 120, 355, 12, 13, + /* 520 */ 20, 243, 167, 168, 169, 0, 20, 155, 22, 157, + /* 530 */ 181, 182, 250, 184, 185, 186, 187, 188, 189, 190, + /* 540 */ 191, 192, 193, 194, 195, 196, 197, 198, 264, 271, + /* 550 */ 293, 267, 250, 47, 243, 0, 250, 279, 243, 14, + /* 560 */ 18, 279, 20, 47, 262, 20, 272, 289, 262, 27, + /* 570 */ 64, 293, 30, 302, 250, 269, 298, 0, 82, 298, + /* 580 */ 64, 279, 57, 211, 243, 279, 262, 81, 310, 151, + /* 590 */ 48, 313, 314, 315, 316, 317, 318, 272, 320, 317, + /* 600 */ 45, 323, 272, 279, 293, 327, 328, 272, 293, 103, + /* 610 */ 172, 173, 250, 331, 332, 333, 334, 339, 336, 113, + /* 620 */ 339, 42, 43, 271, 262, 244, 1, 2, 145, 351, + /* 630 */ 278, 269, 351, 355, 293, 283, 355, 60, 61, 62, + /* 640 */ 63, 279, 65, 66, 67, 68, 69, 70, 71, 72, + /* 650 */ 73, 74, 75, 76, 77, 78, 14, 15, 16, 243, + /* 660 */ 118, 4, 156, 121, 122, 123, 124, 125, 126, 127, /* 670 */ 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, - /* 680 */ 138, 242, 242, 3, 249, 41, 180, 181, 117, 183, + /* 680 */ 138, 226, 243, 289, 243, 185, 20, 181, 182, 295, /* 690 */ 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, - /* 700 */ 194, 195, 196, 197, 249, 242, 12, 13, 14, 15, - /* 710 */ 16, 249, 242, 278, 249, 20, 261, 42, 43, 148, - /* 720 */ 149, 150, 184, 261, 153, 242, 261, 249, 242, 158, - /* 730 */ 4, 292, 292, 278, 12, 13, 14, 15, 16, 261, - /* 740 */ 278, 170, 85, 278, 173, 88, 175, 176, 177, 178, - /* 750 */ 179, 316, 58, 270, 242, 292, 278, 242, 271, 310, - /* 760 */ 64, 278, 292, 310, 242, 184, 331, 332, 333, 242, - /* 770 */ 335, 288, 242, 145, 271, 292, 82, 242, 292, 0, - /* 780 */ 58, 210, 242, 334, 90, 242, 242, 334, 208, 209, - /* 790 */ 271, 85, 309, 93, 88, 312, 313, 314, 315, 316, - /* 800 */ 317, 22, 319, 85, 292, 322, 88, 292, 271, 326, - /* 810 */ 327, 328, 90, 270, 292, 115, 0, 85, 0, 292, - /* 820 */ 88, 278, 292, 340, 21, 167, 168, 292, 345, 346, - /* 830 */ 209, 288, 292, 139, 4, 292, 292, 34, 22, 44, - /* 840 */ 22, 271, 41, 41, 271, 41, 41, 1, 2, 19, - /* 850 */ 195, 196, 309, 301, 160, 312, 313, 314, 315, 316, - /* 860 */ 317, 139, 319, 33, 47, 322, 41, 41, 41, 326, - /* 870 */ 327, 328, 243, 229, 41, 45, 81, 22, 47, 184, - /* 880 */ 50, 259, 160, 82, 82, 55, 82, 82, 357, 346, - /* 890 */ 305, 41, 198, 199, 200, 201, 202, 203, 204, 205, - /* 900 */ 206, 207, 47, 242, 41, 225, 41, 82, 82, 82, - /* 910 */ 80, 41, 348, 83, 342, 82, 41, 270, 41, 64, - /* 920 */ 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, - /* 930 */ 113, 270, 82, 248, 250, 242, 311, 211, 41, 278, - /* 940 */ 281, 41, 336, 351, 113, 82, 351, 82, 351, 288, - /* 950 */ 339, 212, 82, 292, 20, 307, 249, 82, 103, 82, - /* 960 */ 45, 47, 306, 270, 256, 154, 299, 242, 113, 249, - /* 970 */ 309, 278, 249, 312, 313, 314, 315, 316, 317, 82, - /* 980 */ 319, 288, 82, 322, 40, 292, 139, 326, 327, 328, - /* 990 */ 286, 249, 20, 284, 284, 270, 244, 244, 337, 20, - /* 1000 */ 303, 254, 309, 278, 288, 312, 313, 314, 315, 316, - /* 1010 */ 317, 156, 319, 288, 254, 322, 20, 292, 242, 326, - /* 1020 */ 327, 328, 20, 296, 254, 296, 298, 254, 278, 20, - /* 1030 */ 337, 254, 289, 249, 309, 180, 181, 312, 313, 314, - /* 1040 */ 315, 316, 317, 254, 319, 254, 270, 322, 242, 64, - /* 1050 */ 270, 326, 327, 328, 278, 270, 244, 270, 270, 249, - /* 1060 */ 270, 292, 337, 270, 288, 244, 270, 270, 292, 270, - /* 1070 */ 270, 303, 252, 297, 163, 252, 270, 270, 249, 296, - /* 1080 */ 302, 289, 288, 20, 278, 309, 252, 278, 312, 313, - /* 1090 */ 314, 315, 316, 317, 288, 319, 252, 311, 292, 218, - /* 1100 */ 217, 347, 347, 297, 224, 344, 293, 292, 147, 343, - /* 1110 */ 209, 213, 293, 341, 338, 309, 292, 278, 312, 313, - /* 1120 */ 314, 315, 316, 317, 292, 319, 350, 20, 40, 307, - /* 1130 */ 354, 228, 226, 94, 95, 96, 97, 98, 99, 100, - /* 1140 */ 101, 102, 103, 104, 338, 106, 107, 108, 109, 110, - /* 1150 */ 111, 310, 81, 231, 293, 293, 350, 33, 292, 292, - /* 1160 */ 354, 353, 325, 242, 329, 292, 352, 142, 290, 45, - /* 1170 */ 278, 289, 252, 266, 278, 51, 52, 53, 54, 55, - /* 1180 */ 252, 81, 242, 274, 260, 249, 358, 252, 300, 353, - /* 1190 */ 352, 270, 244, 353, 352, 304, 264, 264, 253, 278, - /* 1200 */ 240, 264, 0, 0, 80, 40, 0, 83, 72, 288, - /* 1210 */ 270, 0, 174, 292, 47, 47, 47, 47, 278, 174, - /* 1220 */ 0, 47, 47, 174, 0, 174, 0, 47, 288, 0, - /* 1230 */ 309, 47, 292, 312, 313, 314, 315, 316, 317, 0, - /* 1240 */ 319, 242, 47, 322, 0, 81, 160, 326, 327, 309, - /* 1250 */ 242, 159, 312, 313, 314, 315, 316, 317, 318, 319, - /* 1260 */ 320, 321, 113, 0, 140, 156, 142, 0, 144, 270, - /* 1270 */ 146, 152, 151, 0, 0, 44, 0, 278, 270, 0, - /* 1280 */ 0, 0, 0, 0, 0, 0, 278, 288, 164, 0, - /* 1290 */ 0, 292, 0, 0, 0, 0, 288, 0, 0, 0, - /* 1300 */ 292, 0, 40, 0, 0, 0, 0, 0, 309, 0, - /* 1310 */ 22, 312, 313, 314, 315, 316, 317, 309, 319, 0, - /* 1320 */ 312, 313, 314, 315, 316, 317, 0, 319, 0, 0, - /* 1330 */ 322, 19, 242, 0, 0, 327, 40, 37, 14, 14, - /* 1340 */ 0, 242, 0, 41, 0, 33, 0, 147, 38, 0, - /* 1350 */ 37, 0, 44, 37, 355, 356, 0, 45, 44, 37, - /* 1360 */ 270, 0, 0, 51, 52, 53, 54, 55, 278, 270, - /* 1370 */ 59, 0, 37, 37, 47, 45, 45, 278, 288, 47, - /* 1380 */ 0, 0, 292, 45, 47, 295, 47, 288, 45, 37, - /* 1390 */ 37, 292, 80, 242, 0, 83, 0, 0, 0, 309, - /* 1400 */ 22, 47, 312, 313, 314, 315, 316, 317, 309, 319, - /* 1410 */ 90, 312, 313, 314, 315, 316, 317, 0, 319, 47, - /* 1420 */ 47, 270, 47, 47, 41, 41, 47, 0, 116, 278, - /* 1430 */ 22, 0, 47, 88, 47, 22, 48, 0, 47, 288, - /* 1440 */ 22, 0, 22, 292, 0, 22, 20, 0, 349, 47, - /* 1450 */ 0, 22, 242, 141, 0, 0, 144, 142, 0, 0, - /* 1460 */ 309, 12, 13, 312, 313, 314, 315, 316, 317, 37, - /* 1470 */ 319, 22, 82, 81, 162, 41, 164, 41, 161, 214, - /* 1480 */ 270, 41, 82, 82, 242, 81, 145, 81, 278, 41, - /* 1490 */ 140, 81, 145, 145, 82, 44, 47, 44, 288, 208, - /* 1500 */ 242, 41, 292, 82, 41, 295, 81, 356, 44, 44, - /* 1510 */ 82, 41, 270, 64, 47, 82, 47, 2, 47, 309, - /* 1520 */ 278, 47, 312, 313, 314, 315, 316, 317, 270, 319, - /* 1530 */ 288, 47, 47, 41, 292, 214, 278, 214, 82, 180, - /* 1540 */ 44, 44, 81, 22, 82, 182, 288, 81, 143, 81, - /* 1550 */ 292, 309, 103, 295, 312, 313, 314, 315, 316, 317, - /* 1560 */ 242, 319, 113, 321, 81, 0, 37, 309, 82, 82, - /* 1570 */ 312, 313, 314, 315, 316, 317, 81, 319, 140, 81, - /* 1580 */ 81, 81, 91, 44, 44, 81, 22, 82, 270, 82, - /* 1590 */ 81, 81, 47, 92, 47, 81, 278, 47, 82, 81, - /* 1600 */ 242, 82, 47, 81, 47, 156, 288, 82, 81, 47, - /* 1610 */ 292, 242, 82, 295, 81, 22, 105, 105, 105, 93, - /* 1620 */ 47, 22, 105, 81, 81, 81, 59, 309, 270, 180, - /* 1630 */ 312, 313, 314, 315, 316, 317, 278, 319, 58, 270, - /* 1640 */ 191, 192, 193, 47, 113, 64, 288, 278, 79, 41, - /* 1650 */ 292, 242, 47, 47, 47, 22, 47, 288, 64, 47, - /* 1660 */ 47, 292, 47, 47, 242, 249, 47, 309, 47, 47, - /* 1670 */ 312, 313, 314, 315, 316, 317, 47, 319, 309, 270, - /* 1680 */ 0, 312, 313, 314, 315, 316, 317, 278, 319, 47, - /* 1690 */ 47, 47, 270, 45, 278, 37, 0, 288, 45, 47, - /* 1700 */ 278, 292, 37, 0, 47, 45, 37, 0, 47, 45, - /* 1710 */ 288, 37, 0, 297, 292, 47, 46, 242, 309, 0, - /* 1720 */ 0, 312, 313, 314, 315, 316, 317, 22, 319, 21, - /* 1730 */ 21, 309, 316, 22, 312, 313, 314, 315, 316, 317, - /* 1740 */ 22, 319, 20, 359, 359, 270, 359, 331, 332, 333, - /* 1750 */ 242, 335, 359, 278, 338, 359, 359, 359, 359, 359, - /* 1760 */ 359, 359, 359, 288, 359, 242, 350, 292, 359, 359, - /* 1770 */ 354, 359, 359, 359, 359, 359, 359, 359, 270, 359, - /* 1780 */ 359, 359, 359, 359, 309, 359, 278, 312, 313, 314, - /* 1790 */ 315, 316, 317, 270, 319, 359, 288, 359, 242, 359, - /* 1800 */ 292, 278, 359, 359, 359, 359, 359, 359, 359, 359, - /* 1810 */ 359, 288, 359, 242, 359, 292, 359, 309, 359, 359, - /* 1820 */ 312, 313, 314, 315, 316, 317, 270, 319, 359, 359, - /* 1830 */ 359, 359, 309, 359, 278, 312, 313, 314, 315, 316, - /* 1840 */ 317, 270, 319, 359, 288, 359, 359, 359, 292, 278, - /* 1850 */ 359, 359, 359, 242, 359, 359, 359, 359, 359, 288, - /* 1860 */ 359, 359, 359, 292, 359, 309, 359, 359, 312, 313, - /* 1870 */ 314, 315, 316, 317, 359, 319, 359, 359, 359, 359, - /* 1880 */ 309, 270, 359, 312, 313, 314, 315, 316, 317, 278, - /* 1890 */ 319, 359, 359, 242, 359, 359, 359, 359, 359, 288, - /* 1900 */ 359, 359, 359, 292, 242, 359, 359, 359, 359, 359, - /* 1910 */ 359, 359, 359, 359, 359, 359, 359, 359, 359, 359, - /* 1920 */ 309, 270, 359, 312, 313, 314, 315, 316, 317, 278, - /* 1930 */ 319, 359, 270, 359, 359, 359, 359, 359, 359, 288, - /* 1940 */ 278, 359, 359, 292, 242, 359, 359, 359, 359, 359, - /* 1950 */ 288, 359, 359, 359, 292, 359, 359, 242, 359, 359, - /* 1960 */ 309, 359, 359, 312, 313, 314, 315, 316, 317, 359, - /* 1970 */ 319, 309, 270, 359, 312, 313, 314, 315, 316, 317, - /* 1980 */ 278, 319, 359, 359, 359, 270, 359, 359, 359, 359, - /* 1990 */ 288, 359, 359, 278, 292, 359, 359, 359, 359, 359, - /* 2000 */ 359, 359, 359, 288, 359, 359, 359, 292, 242, 359, - /* 2010 */ 359, 309, 359, 359, 312, 313, 314, 315, 316, 317, - /* 2020 */ 359, 319, 359, 359, 309, 359, 359, 312, 313, 314, - /* 2030 */ 315, 316, 317, 359, 319, 359, 270, 359, 249, 359, - /* 2040 */ 359, 242, 359, 359, 278, 359, 359, 359, 359, 359, - /* 2050 */ 359, 359, 359, 359, 288, 359, 359, 359, 292, 359, - /* 2060 */ 359, 359, 359, 359, 359, 359, 359, 278, 359, 270, - /* 2070 */ 359, 359, 359, 359, 359, 309, 359, 278, 312, 313, - /* 2080 */ 314, 315, 316, 317, 359, 319, 297, 288, 359, 359, - /* 2090 */ 359, 292, 359, 359, 359, 359, 359, 359, 359, 359, - /* 2100 */ 359, 359, 359, 359, 359, 316, 359, 359, 309, 359, - /* 2110 */ 359, 312, 313, 314, 315, 316, 317, 359, 319, 359, - /* 2120 */ 331, 332, 333, 359, 335, 359, 359, 338, 359, 359, - /* 2130 */ 359, 359, 359, 359, 359, 359, 359, 359, 359, 350, - /* 2140 */ 359, 359, 359, 354, + /* 700 */ 194, 195, 196, 197, 198, 139, 18, 82, 243, 293, + /* 710 */ 271, 23, 259, 250, 261, 37, 272, 250, 279, 0, + /* 720 */ 20, 250, 298, 35, 36, 262, 160, 39, 289, 262, + /* 730 */ 185, 250, 293, 262, 293, 250, 12, 13, 14, 15, + /* 740 */ 16, 243, 279, 262, 56, 243, 279, 262, 243, 310, + /* 750 */ 279, 41, 313, 314, 315, 316, 317, 318, 293, 320, + /* 760 */ 279, 243, 323, 339, 279, 199, 327, 328, 329, 81, + /* 770 */ 12, 13, 14, 15, 16, 351, 271, 0, 250, 355, + /* 780 */ 341, 250, 58, 271, 279, 346, 347, 93, 250, 243, + /* 790 */ 262, 293, 280, 262, 289, 293, 85, 243, 293, 88, + /* 800 */ 262, 296, 243, 243, 243, 117, 82, 279, 243, 115, + /* 810 */ 279, 293, 93, 41, 90, 310, 58, 279, 313, 314, + /* 820 */ 315, 316, 317, 318, 58, 320, 209, 210, 250, 272, + /* 830 */ 21, 112, 271, 114, 115, 116, 148, 149, 150, 293, + /* 840 */ 279, 153, 260, 34, 271, 145, 158, 293, 90, 41, + /* 850 */ 289, 185, 293, 293, 293, 243, 283, 279, 293, 171, + /* 860 */ 22, 358, 174, 139, 176, 177, 178, 179, 180, 212, + /* 870 */ 93, 310, 0, 47, 313, 314, 315, 316, 317, 318, + /* 880 */ 319, 320, 321, 322, 160, 47, 243, 0, 210, 112, + /* 890 */ 82, 114, 115, 116, 22, 317, 41, 139, 85, 211, + /* 900 */ 85, 88, 64, 88, 85, 293, 243, 88, 41, 22, + /* 910 */ 332, 333, 334, 0, 336, 1, 2, 44, 160, 196, + /* 920 */ 197, 349, 47, 199, 200, 201, 202, 203, 204, 205, + /* 930 */ 206, 207, 208, 41, 271, 22, 293, 82, 228, 113, + /* 940 */ 81, 103, 279, 41, 41, 306, 41, 181, 41, 82, + /* 950 */ 91, 113, 289, 343, 81, 271, 293, 199, 200, 201, + /* 960 */ 202, 203, 204, 205, 206, 207, 208, 41, 243, 249, + /* 970 */ 41, 282, 41, 310, 82, 41, 313, 314, 315, 316, + /* 980 */ 317, 318, 47, 320, 82, 82, 323, 82, 113, 82, + /* 990 */ 327, 328, 329, 41, 156, 251, 271, 312, 337, 64, + /* 1000 */ 243, 352, 230, 41, 279, 352, 41, 352, 82, 340, + /* 1010 */ 347, 82, 213, 82, 289, 41, 82, 41, 293, 181, + /* 1020 */ 182, 308, 20, 250, 45, 307, 257, 47, 271, 300, + /* 1030 */ 154, 250, 250, 287, 82, 310, 279, 40, 313, 314, + /* 1040 */ 315, 316, 317, 318, 82, 320, 289, 82, 323, 139, + /* 1050 */ 293, 250, 327, 328, 329, 285, 82, 20, 82, 285, + /* 1060 */ 243, 245, 20, 338, 304, 245, 255, 310, 289, 255, + /* 1070 */ 313, 314, 315, 316, 317, 318, 20, 320, 20, 299, + /* 1080 */ 323, 297, 255, 297, 327, 328, 329, 255, 271, 279, + /* 1090 */ 20, 255, 243, 290, 255, 338, 279, 250, 255, 245, + /* 1100 */ 271, 271, 271, 250, 271, 271, 289, 245, 271, 64, + /* 1110 */ 293, 271, 271, 271, 293, 271, 271, 293, 253, 163, + /* 1120 */ 271, 253, 304, 253, 289, 303, 20, 310, 279, 250, + /* 1130 */ 313, 314, 315, 316, 317, 318, 279, 320, 289, 253, + /* 1140 */ 323, 219, 293, 243, 327, 328, 329, 298, 297, 293, + /* 1150 */ 290, 218, 348, 348, 293, 338, 147, 294, 312, 310, + /* 1160 */ 294, 225, 313, 314, 315, 316, 317, 318, 345, 320, + /* 1170 */ 293, 271, 344, 243, 214, 279, 210, 308, 20, 279, + /* 1180 */ 40, 232, 311, 229, 227, 81, 291, 294, 339, 289, + /* 1190 */ 342, 293, 293, 293, 330, 294, 142, 293, 298, 279, + /* 1200 */ 351, 271, 290, 353, 355, 267, 243, 279, 326, 279, + /* 1210 */ 310, 359, 354, 313, 314, 315, 316, 317, 318, 289, + /* 1220 */ 320, 253, 253, 293, 81, 275, 253, 250, 354, 245, + /* 1230 */ 305, 353, 261, 353, 271, 354, 243, 265, 301, 339, + /* 1240 */ 310, 254, 279, 313, 314, 315, 316, 317, 318, 241, + /* 1250 */ 320, 351, 289, 323, 265, 355, 293, 327, 328, 265, + /* 1260 */ 0, 0, 40, 0, 271, 72, 0, 47, 175, 175, + /* 1270 */ 47, 47, 279, 310, 47, 0, 313, 314, 315, 316, + /* 1280 */ 317, 318, 289, 320, 47, 47, 293, 243, 175, 0, + /* 1290 */ 175, 0, 47, 0, 47, 0, 243, 47, 0, 81, + /* 1300 */ 113, 160, 156, 310, 159, 0, 313, 314, 315, 316, + /* 1310 */ 317, 318, 0, 320, 152, 271, 323, 151, 0, 356, + /* 1320 */ 357, 328, 0, 279, 271, 44, 0, 0, 0, 0, + /* 1330 */ 0, 0, 279, 289, 0, 0, 0, 293, 0, 0, + /* 1340 */ 0, 0, 289, 0, 0, 0, 293, 0, 0, 40, + /* 1350 */ 243, 0, 0, 0, 310, 0, 0, 313, 314, 315, + /* 1360 */ 316, 317, 318, 310, 320, 0, 313, 314, 315, 316, + /* 1370 */ 317, 318, 22, 320, 0, 0, 0, 0, 271, 0, + /* 1380 */ 0, 14, 40, 37, 14, 0, 279, 0, 0, 0, + /* 1390 */ 243, 147, 0, 44, 350, 41, 289, 38, 37, 37, + /* 1400 */ 293, 44, 0, 296, 90, 37, 243, 0, 0, 0, + /* 1410 */ 357, 0, 0, 47, 45, 37, 45, 310, 271, 59, + /* 1420 */ 313, 314, 315, 316, 317, 318, 279, 320, 47, 47, + /* 1430 */ 37, 45, 37, 0, 271, 37, 289, 47, 0, 45, + /* 1440 */ 293, 0, 279, 0, 0, 22, 88, 47, 0, 0, + /* 1450 */ 47, 41, 289, 47, 243, 41, 293, 310, 22, 296, + /* 1460 */ 313, 314, 315, 316, 317, 318, 0, 320, 47, 322, + /* 1470 */ 48, 47, 47, 310, 47, 47, 313, 314, 315, 316, + /* 1480 */ 317, 318, 271, 320, 22, 0, 243, 22, 0, 47, + /* 1490 */ 279, 33, 0, 22, 22, 20, 0, 47, 0, 22, + /* 1500 */ 289, 0, 0, 45, 293, 0, 0, 296, 145, 51, + /* 1510 */ 52, 53, 54, 55, 271, 81, 243, 37, 145, 41, + /* 1520 */ 41, 310, 279, 140, 313, 314, 315, 316, 317, 318, + /* 1530 */ 215, 320, 289, 161, 82, 41, 293, 82, 80, 142, + /* 1540 */ 81, 83, 81, 44, 271, 81, 145, 44, 41, 82, + /* 1550 */ 81, 41, 279, 310, 41, 82, 313, 314, 315, 316, + /* 1560 */ 317, 318, 289, 320, 44, 82, 293, 243, 44, 82, + /* 1570 */ 41, 82, 47, 47, 47, 47, 2, 47, 47, 41, + /* 1580 */ 181, 44, 82, 310, 44, 81, 313, 314, 315, 316, + /* 1590 */ 317, 318, 81, 320, 82, 271, 81, 22, 140, 215, + /* 1600 */ 142, 183, 144, 279, 146, 209, 215, 243, 0, 37, + /* 1610 */ 91, 143, 44, 289, 82, 81, 81, 293, 82, 22, + /* 1620 */ 81, 140, 164, 81, 81, 44, 81, 47, 82, 81, + /* 1630 */ 81, 113, 82, 92, 310, 271, 47, 313, 314, 315, + /* 1640 */ 316, 317, 318, 279, 320, 81, 47, 243, 82, 82, + /* 1650 */ 81, 47, 81, 289, 47, 82, 47, 293, 81, 105, + /* 1660 */ 82, 105, 243, 81, 105, 105, 81, 22, 81, 93, + /* 1670 */ 47, 81, 22, 58, 310, 271, 59, 313, 314, 315, + /* 1680 */ 316, 317, 318, 279, 320, 47, 64, 41, 47, 79, + /* 1690 */ 271, 22, 64, 289, 47, 47, 47, 293, 279, 47, + /* 1700 */ 47, 47, 47, 47, 47, 47, 47, 47, 289, 47, + /* 1710 */ 0, 47, 293, 243, 310, 45, 37, 313, 314, 315, + /* 1720 */ 316, 317, 318, 0, 320, 243, 45, 47, 37, 310, + /* 1730 */ 0, 47, 313, 314, 315, 316, 317, 318, 45, 320, + /* 1740 */ 37, 271, 47, 45, 37, 0, 47, 46, 0, 279, + /* 1750 */ 0, 0, 21, 271, 22, 22, 22, 21, 20, 289, + /* 1760 */ 360, 279, 360, 293, 360, 243, 360, 360, 360, 360, + /* 1770 */ 360, 289, 360, 360, 360, 293, 243, 360, 360, 360, + /* 1780 */ 310, 360, 360, 313, 314, 315, 316, 317, 318, 360, + /* 1790 */ 320, 360, 310, 271, 360, 313, 314, 315, 316, 317, + /* 1800 */ 318, 279, 320, 360, 271, 360, 360, 360, 360, 360, + /* 1810 */ 360, 289, 279, 360, 360, 293, 360, 360, 360, 360, + /* 1820 */ 360, 360, 289, 360, 360, 360, 293, 243, 360, 360, + /* 1830 */ 360, 360, 310, 360, 360, 313, 314, 315, 316, 317, + /* 1840 */ 318, 360, 320, 310, 360, 360, 313, 314, 315, 316, + /* 1850 */ 317, 318, 360, 320, 360, 271, 360, 243, 360, 360, + /* 1860 */ 360, 360, 360, 279, 360, 360, 360, 360, 360, 360, + /* 1870 */ 360, 360, 360, 289, 360, 360, 360, 293, 360, 360, + /* 1880 */ 360, 360, 360, 360, 360, 271, 360, 243, 360, 360, + /* 1890 */ 360, 360, 360, 279, 310, 360, 360, 313, 314, 315, + /* 1900 */ 316, 317, 318, 289, 320, 360, 360, 293, 360, 360, + /* 1910 */ 360, 360, 360, 360, 360, 271, 360, 360, 360, 243, + /* 1920 */ 360, 360, 360, 279, 310, 360, 360, 313, 314, 315, + /* 1930 */ 316, 317, 318, 289, 320, 360, 360, 293, 360, 360, + /* 1940 */ 360, 360, 360, 12, 13, 360, 360, 271, 360, 360, + /* 1950 */ 360, 360, 243, 22, 310, 279, 360, 313, 314, 315, + /* 1960 */ 316, 317, 318, 360, 320, 289, 360, 360, 360, 293, + /* 1970 */ 360, 360, 360, 360, 360, 360, 360, 360, 47, 360, + /* 1980 */ 271, 360, 360, 360, 360, 243, 310, 360, 279, 313, + /* 1990 */ 314, 315, 316, 317, 318, 64, 320, 360, 289, 360, + /* 2000 */ 360, 360, 293, 360, 360, 360, 360, 360, 360, 360, + /* 2010 */ 360, 360, 360, 271, 360, 360, 250, 360, 360, 310, + /* 2020 */ 360, 279, 313, 314, 315, 316, 317, 318, 360, 320, + /* 2030 */ 360, 289, 360, 360, 103, 293, 360, 360, 360, 360, + /* 2040 */ 360, 360, 360, 360, 113, 279, 250, 360, 360, 360, + /* 2050 */ 360, 360, 310, 360, 360, 313, 314, 315, 316, 317, + /* 2060 */ 318, 360, 320, 360, 298, 360, 360, 360, 360, 360, + /* 2070 */ 360, 360, 360, 360, 360, 279, 360, 360, 360, 360, + /* 2080 */ 360, 360, 360, 317, 360, 360, 360, 156, 360, 360, + /* 2090 */ 360, 360, 360, 360, 298, 360, 360, 360, 332, 333, + /* 2100 */ 334, 360, 336, 360, 360, 339, 360, 360, 360, 360, + /* 2110 */ 360, 360, 181, 317, 360, 360, 360, 351, 360, 360, + /* 2120 */ 360, 355, 360, 192, 193, 194, 360, 360, 332, 333, + /* 2130 */ 334, 360, 336, 360, 360, 339, 360, 360, 360, 360, + /* 2140 */ 360, 360, 360, 360, 360, 360, 360, 351, 360, 360, + /* 2150 */ 360, 355, 360, 360, 360, 360, 360, 360, 360, 360, + /* 2160 */ 360, 360, 360, 360, 360, 360, 360, 360, 360, 360, + /* 2170 */ 360, 360, 360, 360, 360, 360, 360, 360, 360, 360, + /* 2180 */ 360, 360, 360, 360, }; -#define YY_SHIFT_COUNT (617) +#define YY_SHIFT_COUNT (618) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1722) +#define YY_SHIFT_MAX (1931) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 571, 0, 0, 48, 96, 96, 96, 96, 253, 253, + /* 0 */ 688, 0, 0, 48, 96, 96, 96, 96, 253, 253, /* 10 */ 96, 96, 301, 349, 506, 349, 349, 349, 349, 349, /* 20 */ 349, 349, 349, 349, 349, 349, 349, 349, 349, 349, - /* 30 */ 349, 349, 349, 349, 349, 349, 349, 349, 126, 126, - /* 40 */ 231, 231, 231, 1449, 1449, 1449, 1449, 261, 312, 193, - /* 50 */ 74, 74, 178, 178, 144, 193, 193, 74, 74, 74, - /* 60 */ 74, 74, 74, 74, 50, 74, 74, 102, 282, 482, - /* 70 */ 102, 74, 74, 102, 74, 102, 102, 482, 102, 74, - /* 80 */ 329, 542, 694, 722, 722, 187, 236, 855, 855, 855, - /* 90 */ 855, 855, 855, 855, 855, 855, 855, 855, 855, 855, - /* 100 */ 855, 855, 855, 855, 855, 855, 305, 335, 408, 408, - /* 110 */ 263, 406, 370, 370, 370, 423, 406, 511, 482, 102, - /* 120 */ 102, 482, 520, 696, 1039, 1039, 1039, 1039, 1039, 1039, - /* 130 */ 1039, 1312, 141, 400, 76, 287, 57, 216, 538, 581, - /* 140 */ 675, 596, 700, 628, 580, 621, 580, 680, 680, 680, - /* 150 */ 726, 695, 739, 934, 915, 914, 811, 934, 934, 944, - /* 160 */ 847, 847, 934, 972, 972, 979, 50, 482, 50, 996, - /* 170 */ 1002, 50, 996, 50, 511, 1009, 50, 50, 934, 50, - /* 180 */ 972, 102, 102, 102, 102, 102, 102, 102, 102, 102, - /* 190 */ 102, 102, 934, 972, 985, 979, 329, 911, 482, 329, - /* 200 */ 934, 996, 329, 511, 1009, 329, 1063, 881, 883, 985, - /* 210 */ 881, 883, 985, 985, 102, 880, 961, 898, 739, 901, - /* 220 */ 511, 1107, 1088, 903, 906, 922, 903, 906, 903, 906, - /* 230 */ 1071, 883, 985, 985, 883, 985, 1025, 511, 1009, 329, - /* 240 */ 520, 329, 511, 1100, 696, 934, 329, 972, 2144, 2144, - /* 250 */ 2144, 2144, 2144, 2144, 2144, 563, 1124, 230, 830, 3, - /* 260 */ 19, 314, 234, 255, 363, 464, 112, 112, 112, 112, - /* 270 */ 112, 112, 112, 112, 86, 127, 444, 55, 499, 221, - /* 280 */ 392, 392, 392, 392, 227, 394, 657, 706, 718, 732, - /* 290 */ 779, 816, 818, 803, 658, 801, 802, 804, 846, 655, - /* 300 */ 37, 644, 805, 275, 825, 795, 826, 827, 833, 850, - /* 310 */ 863, 817, 831, 865, 870, 875, 877, 897, 900, 321, - /* 320 */ 518, 1202, 1203, 1165, 1206, 1136, 1211, 1167, 1038, 1168, - /* 330 */ 1169, 1170, 1045, 1220, 1174, 1175, 1049, 1224, 1051, 1226, - /* 340 */ 1180, 1229, 1184, 1239, 1195, 1244, 1164, 1086, 1092, 1149, - /* 350 */ 1109, 1263, 1267, 1119, 1121, 1273, 1274, 1231, 1276, 1279, - /* 360 */ 1280, 1281, 1282, 1283, 1284, 1285, 1289, 1290, 1292, 1293, - /* 370 */ 1294, 1295, 1297, 1298, 1299, 1301, 1262, 1303, 1304, 1305, - /* 380 */ 1306, 1307, 1309, 1288, 1319, 1326, 1328, 1329, 1333, 1334, - /* 390 */ 1296, 1300, 1302, 1324, 1308, 1325, 1314, 1340, 1310, 1313, - /* 400 */ 1342, 1344, 1346, 1316, 1200, 1349, 1351, 1322, 1356, 1311, - /* 410 */ 1361, 1362, 1327, 1330, 1335, 1371, 1332, 1331, 1336, 1380, - /* 420 */ 1337, 1338, 1352, 1381, 1339, 1343, 1353, 1394, 1396, 1397, - /* 430 */ 1398, 1320, 1345, 1354, 1378, 1417, 1372, 1373, 1375, 1376, - /* 440 */ 1383, 1384, 1379, 1385, 1387, 1427, 1408, 1431, 1413, 1388, - /* 450 */ 1437, 1418, 1391, 1441, 1420, 1444, 1423, 1426, 1447, 1341, - /* 460 */ 1402, 1450, 1317, 1429, 1347, 1315, 1454, 1455, 1458, 1348, - /* 470 */ 1459, 1392, 1432, 1350, 1434, 1436, 1265, 1390, 1440, 1400, - /* 480 */ 1404, 1406, 1410, 1401, 1448, 1451, 1453, 1425, 1460, 1321, - /* 490 */ 1412, 1421, 1464, 1291, 1463, 1465, 1428, 1470, 1323, 1433, - /* 500 */ 1467, 1469, 1471, 1474, 1484, 1485, 1433, 1515, 1359, 1492, - /* 510 */ 1456, 1461, 1462, 1496, 1466, 1468, 1497, 1521, 1363, 1483, - /* 520 */ 1486, 1487, 1495, 1498, 1405, 1499, 1565, 1529, 1438, 1500, - /* 530 */ 1491, 1539, 1540, 1504, 1505, 1509, 1564, 1510, 1501, 1507, - /* 540 */ 1545, 1547, 1514, 1516, 1550, 1518, 1519, 1555, 1522, 1525, - /* 550 */ 1557, 1527, 1530, 1562, 1533, 1511, 1512, 1513, 1517, 1593, - /* 560 */ 1526, 1542, 1543, 1573, 1544, 1531, 1599, 1567, 1580, 1596, - /* 570 */ 1581, 1569, 1608, 1605, 1606, 1607, 1609, 1612, 1633, 1613, - /* 580 */ 1615, 1594, 1383, 1616, 1384, 1619, 1621, 1622, 1629, 1642, - /* 590 */ 1643, 1680, 1644, 1648, 1658, 1696, 1652, 1653, 1665, 1703, - /* 600 */ 1657, 1660, 1669, 1707, 1661, 1664, 1674, 1712, 1668, 1670, - /* 610 */ 1719, 1720, 1705, 1708, 1711, 1718, 1709, 1722, + /* 30 */ 349, 349, 349, 349, 349, 349, 349, 349, 144, 144, + /* 40 */ 102, 102, 102, 1931, 1931, 1931, 1931, 372, 124, 214, + /* 50 */ 58, 58, 260, 260, 172, 214, 214, 58, 58, 58, + /* 60 */ 58, 58, 58, 58, 37, 58, 58, 186, 228, 259, + /* 70 */ 186, 58, 58, 186, 58, 186, 186, 259, 186, 58, + /* 80 */ 255, 542, 724, 758, 758, 189, 236, 838, 838, 838, + /* 90 */ 838, 838, 838, 838, 838, 838, 838, 838, 838, 838, + /* 100 */ 838, 838, 838, 838, 838, 838, 291, 126, 354, 354, + /* 110 */ 397, 516, 483, 483, 483, 525, 516, 313, 259, 186, + /* 120 */ 186, 259, 377, 343, 243, 243, 243, 243, 243, 243, + /* 130 */ 243, 340, 141, 405, 76, 195, 57, 215, 500, 545, + /* 140 */ 579, 179, 694, 700, 617, 678, 617, 455, 455, 455, + /* 150 */ 657, 666, 799, 1002, 979, 980, 876, 1002, 1002, 997, + /* 160 */ 910, 910, 1002, 1037, 1037, 1042, 37, 259, 37, 1056, + /* 170 */ 1058, 37, 1056, 37, 313, 1070, 37, 37, 1002, 37, + /* 180 */ 1037, 186, 186, 186, 186, 186, 186, 186, 186, 186, + /* 190 */ 186, 186, 1002, 1037, 1045, 1045, 1042, 255, 956, 259, + /* 200 */ 255, 1002, 1056, 255, 313, 1070, 255, 1106, 922, 933, + /* 210 */ 1045, 922, 933, 1045, 1045, 186, 936, 1009, 960, 799, + /* 220 */ 966, 313, 1158, 1140, 954, 957, 949, 954, 957, 954, + /* 230 */ 957, 1104, 933, 1045, 1045, 933, 1045, 1054, 313, 1070, + /* 240 */ 255, 377, 255, 313, 1143, 343, 1002, 255, 1037, 2152, + /* 250 */ 2152, 2152, 2152, 2152, 2152, 2152, 577, 1458, 231, 353, + /* 260 */ 3, 19, 316, 256, 496, 719, 777, 112, 112, 112, + /* 270 */ 112, 112, 112, 112, 112, 135, 438, 344, 396, 355, + /* 280 */ 625, 566, 642, 642, 642, 642, 555, 808, 711, 813, + /* 290 */ 815, 819, 872, 887, 913, 809, 855, 867, 892, 914, + /* 300 */ 723, 710, 772, 902, 766, 903, 873, 905, 907, 926, + /* 310 */ 929, 931, 826, 875, 934, 952, 962, 965, 974, 976, + /* 320 */ 859, 935, 1260, 1261, 1222, 1263, 1193, 1266, 1220, 1093, + /* 330 */ 1223, 1224, 1227, 1094, 1275, 1237, 1238, 1113, 1289, 1115, + /* 340 */ 1291, 1245, 1293, 1247, 1295, 1250, 1298, 1218, 1141, 1145, + /* 350 */ 1187, 1146, 1305, 1312, 1162, 1166, 1318, 1322, 1281, 1326, + /* 360 */ 1327, 1328, 1329, 1330, 1331, 1334, 1335, 1336, 1338, 1339, + /* 370 */ 1340, 1341, 1343, 1344, 1345, 1347, 1348, 1309, 1351, 1352, + /* 380 */ 1353, 1355, 1356, 1365, 1350, 1374, 1375, 1376, 1377, 1379, + /* 390 */ 1380, 1342, 1346, 1354, 1367, 1349, 1370, 1357, 1385, 1359, + /* 400 */ 1361, 1387, 1388, 1389, 1362, 1244, 1392, 1402, 1368, 1407, + /* 410 */ 1360, 1408, 1409, 1366, 1369, 1378, 1411, 1381, 1371, 1393, + /* 420 */ 1412, 1382, 1386, 1395, 1433, 1390, 1394, 1398, 1438, 1441, + /* 430 */ 1443, 1444, 1314, 1358, 1400, 1423, 1448, 1403, 1406, 1421, + /* 440 */ 1424, 1410, 1414, 1425, 1427, 1428, 1449, 1436, 1466, 1462, + /* 450 */ 1422, 1485, 1465, 1442, 1488, 1471, 1492, 1472, 1475, 1496, + /* 460 */ 1363, 1450, 1498, 1372, 1477, 1373, 1397, 1501, 1502, 1505, + /* 470 */ 1401, 1506, 1434, 1480, 1383, 1478, 1479, 1315, 1452, 1494, + /* 480 */ 1455, 1459, 1461, 1464, 1467, 1507, 1499, 1503, 1469, 1510, + /* 490 */ 1384, 1473, 1483, 1520, 1396, 1513, 1524, 1487, 1529, 1391, + /* 500 */ 1489, 1525, 1526, 1527, 1528, 1530, 1531, 1489, 1574, 1399, + /* 510 */ 1538, 1500, 1504, 1512, 1537, 1511, 1515, 1540, 1575, 1418, + /* 520 */ 1534, 1532, 1536, 1535, 1539, 1468, 1542, 1608, 1572, 1481, + /* 530 */ 1543, 1519, 1568, 1581, 1545, 1546, 1548, 1597, 1549, 1541, + /* 540 */ 1550, 1580, 1589, 1564, 1566, 1599, 1569, 1567, 1604, 1571, + /* 550 */ 1573, 1607, 1577, 1578, 1609, 1582, 1554, 1556, 1559, 1560, + /* 560 */ 1645, 1576, 1585, 1587, 1623, 1590, 1518, 1650, 1617, 1615, + /* 570 */ 1638, 1622, 1610, 1646, 1641, 1647, 1648, 1649, 1652, 1669, + /* 580 */ 1653, 1654, 1628, 1410, 1655, 1414, 1656, 1657, 1658, 1659, + /* 590 */ 1660, 1662, 1710, 1664, 1670, 1679, 1723, 1680, 1681, 1691, + /* 600 */ 1730, 1684, 1693, 1703, 1750, 1695, 1698, 1707, 1745, 1699, + /* 610 */ 1701, 1748, 1751, 1732, 1731, 1733, 1734, 1736, 1738, }; -#define YY_REDUCE_COUNT (254) -#define YY_REDUCE_MIN (-323) -#define YY_REDUCE_MAX (1799) +#define YY_REDUCE_COUNT (255) +#define YY_REDUCE_MIN (-324) +#define YY_REDUCE_MAX (1796) static const short yy_reduce_ofst[] = { - /* 0 */ 14, -240, 61, 483, 543, 661, 693, 725, 776, 806, - /* 10 */ -177, 921, 940, 999, 1008, 1090, 1099, 1151, 1210, 1242, - /* 20 */ 1258, 1318, 1358, 1369, 1409, 1422, 1475, 1508, 1523, 1556, - /* 30 */ 1571, 1611, 1651, 1662, 1702, 1715, 1766, 1799, 1416, 1789, - /* 40 */ 94, -212, 435, -269, -265, -263, -175, -283, -3, 47, - /* 50 */ 306, 307, -90, -42, -254, -191, 67, -225, -198, 46, - /* 60 */ 205, 310, 337, 343, 65, 342, 344, 68, 233, -189, - /* 70 */ 242, 455, 462, 243, 465, 338, 284, 171, 380, 478, - /* 80 */ -224, -241, -323, -323, -323, -65, 63, 272, 281, 354, - /* 90 */ 355, 357, 369, 439, 440, 463, 470, 486, 512, 515, - /* 100 */ 522, 527, 530, 535, 540, 544, -117, -246, 302, 367, - /* 110 */ -123, -231, -251, 449, 453, 73, 260, 366, 289, 375, - /* 120 */ 332, 262, 390, 397, -260, 487, 503, 519, 537, 570, - /* 130 */ 573, 552, 629, 622, 531, 564, 585, 572, 647, 647, - /* 140 */ 685, 684, 659, 625, 606, 606, 606, 592, 595, 597, - /* 150 */ 611, 647, 648, 707, 656, 708, 667, 720, 723, 704, - /* 160 */ 709, 710, 742, 752, 753, 697, 747, 716, 760, 727, - /* 170 */ 728, 770, 729, 773, 750, 743, 777, 789, 784, 791, - /* 180 */ 812, 780, 785, 787, 788, 790, 793, 796, 797, 799, - /* 190 */ 800, 807, 810, 821, 769, 768, 820, 778, 794, 823, - /* 200 */ 829, 783, 834, 809, 792, 844, 786, 754, 813, 815, - /* 210 */ 755, 819, 824, 832, 647, 761, 766, 772, 822, 606, - /* 220 */ 839, 841, 835, 808, 814, 828, 836, 838, 840, 842, - /* 230 */ 837, 861, 866, 867, 862, 873, 878, 892, 882, 920, - /* 240 */ 907, 928, 896, 909, 924, 936, 935, 948, 888, 891, - /* 250 */ 932, 933, 937, 945, 960, + /* 0 */ 162, -241, 278, 439, 663, 725, 757, 817, 849, 900, + /* 10 */ -178, 930, 561, 963, 993, 505, 1044, 1053, 1107, 1147, + /* 20 */ 1163, 1211, 1243, 1273, 1324, 1364, 1404, 1419, 1470, 1482, + /* 30 */ 1522, 1533, 1584, 1614, 1644, 1676, 1709, 1742, 1766, 1796, + /* 40 */ 282, -213, 578, -270, -266, -264, -176, -284, 281, 424, + /* 50 */ 306, 362, -91, -46, -255, -192, 71, -226, -199, 150, + /* 60 */ 302, 324, 463, 467, -1, 471, 485, 28, 45, -190, + /* 70 */ 56, 528, 531, 197, 481, 192, 352, 100, 196, 538, + /* 80 */ -225, -242, -324, -324, -324, -64, -48, 77, 168, 257, + /* 90 */ 311, 315, 341, 416, 441, 465, 498, 502, 518, 546, + /* 100 */ 554, 559, 560, 565, 612, 643, 97, -247, 75, 140, + /* 110 */ -125, -232, -252, -204, -37, -100, 106, 142, 394, 512, + /* 120 */ 573, 218, 284, 453, -261, 294, 325, 330, 335, 444, + /* 130 */ 557, 271, 381, 582, 503, 572, 639, 610, 684, 684, + /* 140 */ 720, 744, 689, 685, 661, 661, 661, 649, 653, 655, + /* 150 */ 669, 684, 713, 773, 718, 769, 729, 781, 782, 746, + /* 160 */ 770, 774, 801, 816, 820, 760, 811, 779, 814, 784, + /* 170 */ 780, 827, 786, 832, 810, 803, 836, 839, 847, 843, + /* 180 */ 854, 829, 830, 831, 833, 834, 837, 840, 841, 842, + /* 190 */ 844, 845, 853, 862, 821, 824, 818, 865, 822, 835, + /* 200 */ 868, 879, 851, 870, 857, 860, 886, 846, 804, 863, + /* 210 */ 856, 805, 866, 861, 877, 684, 823, 828, 848, 869, + /* 220 */ 661, 896, 871, 864, 858, 850, 852, 874, 878, 881, + /* 230 */ 880, 882, 893, 898, 899, 901, 904, 895, 920, 912, + /* 240 */ 968, 938, 969, 928, 950, 971, 977, 973, 984, 937, + /* 250 */ 925, 972, 989, 994, 987, 1008, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 10 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 20 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 30 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 40 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 50 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 60 */ 1357, 1357, 1357, 1357, 1426, 1357, 1357, 1357, 1357, 1357, - /* 70 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 80 */ 1424, 1564, 1357, 1730, 1357, 1357, 1357, 1357, 1357, 1357, - /* 90 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 100 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 110 */ 1426, 1357, 1741, 1741, 1741, 1424, 1357, 1357, 1357, 1357, - /* 120 */ 1357, 1357, 1520, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 130 */ 1357, 1600, 1357, 1357, 1807, 1357, 1606, 1765, 1357, 1357, - /* 140 */ 1357, 1357, 1473, 1757, 1733, 1747, 1734, 1792, 1792, 1792, - /* 150 */ 1750, 1357, 1761, 1357, 1357, 1357, 1592, 1357, 1357, 1569, - /* 160 */ 1566, 1566, 1357, 1357, 1357, 1357, 1426, 1357, 1426, 1357, - /* 170 */ 1357, 1426, 1357, 1426, 1357, 1357, 1426, 1426, 1357, 1426, - /* 180 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 190 */ 1357, 1357, 1357, 1357, 1357, 1357, 1424, 1602, 1357, 1424, - /* 200 */ 1357, 1357, 1424, 1357, 1357, 1424, 1357, 1772, 1770, 1357, - /* 210 */ 1772, 1770, 1357, 1357, 1357, 1784, 1780, 1763, 1761, 1747, - /* 220 */ 1357, 1357, 1357, 1798, 1794, 1810, 1798, 1794, 1798, 1794, - /* 230 */ 1357, 1770, 1357, 1357, 1770, 1357, 1577, 1357, 1357, 1424, - /* 240 */ 1357, 1424, 1357, 1489, 1357, 1357, 1424, 1357, 1594, 1608, - /* 250 */ 1523, 1523, 1523, 1427, 1362, 1357, 1357, 1357, 1357, 1357, - /* 260 */ 1357, 1357, 1357, 1357, 1357, 1357, 1674, 1783, 1782, 1706, - /* 270 */ 1705, 1704, 1702, 1673, 1485, 1357, 1357, 1357, 1357, 1357, - /* 280 */ 1667, 1668, 1666, 1665, 1357, 1357, 1357, 1357, 1357, 1357, - /* 290 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1731, 1357, - /* 300 */ 1795, 1799, 1357, 1357, 1357, 1650, 1357, 1357, 1357, 1357, - /* 310 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 320 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 330 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 340 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 350 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 360 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 370 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 380 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 390 */ 1357, 1357, 1391, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 400 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 410 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 420 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 430 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 440 */ 1454, 1453, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 450 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 460 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 470 */ 1357, 1357, 1357, 1357, 1754, 1764, 1357, 1357, 1357, 1357, - /* 480 */ 1357, 1357, 1357, 1357, 1357, 1357, 1650, 1357, 1781, 1357, - /* 490 */ 1740, 1736, 1357, 1357, 1732, 1357, 1357, 1793, 1357, 1357, - /* 500 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1726, 1357, 1699, - /* 510 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1661, 1357, - /* 520 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 530 */ 1357, 1649, 1357, 1690, 1357, 1357, 1357, 1357, 1357, 1357, - /* 540 */ 1357, 1357, 1517, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 550 */ 1357, 1357, 1357, 1357, 1357, 1502, 1500, 1499, 1498, 1357, - /* 560 */ 1495, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 570 */ 1357, 1357, 1446, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 580 */ 1357, 1357, 1437, 1357, 1436, 1357, 1357, 1357, 1357, 1357, - /* 590 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 600 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, - /* 610 */ 1357, 1357, 1357, 1357, 1357, 1357, 1357, 1357, + /* 0 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 10 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 20 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 30 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 40 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 50 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 60 */ 1360, 1360, 1360, 1360, 1429, 1360, 1360, 1360, 1360, 1360, + /* 70 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 80 */ 1427, 1567, 1360, 1734, 1360, 1360, 1360, 1360, 1360, 1360, + /* 90 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 100 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 110 */ 1429, 1360, 1745, 1745, 1745, 1427, 1360, 1360, 1360, 1360, + /* 120 */ 1360, 1360, 1523, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 130 */ 1360, 1603, 1360, 1360, 1811, 1360, 1609, 1769, 1360, 1360, + /* 140 */ 1360, 1360, 1476, 1761, 1737, 1751, 1738, 1796, 1796, 1796, + /* 150 */ 1754, 1360, 1765, 1360, 1360, 1360, 1595, 1360, 1360, 1572, + /* 160 */ 1569, 1569, 1360, 1360, 1360, 1360, 1429, 1360, 1429, 1360, + /* 170 */ 1360, 1429, 1360, 1429, 1360, 1360, 1429, 1429, 1360, 1429, + /* 180 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 190 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1427, 1605, 1360, + /* 200 */ 1427, 1360, 1360, 1427, 1360, 1360, 1427, 1360, 1776, 1774, + /* 210 */ 1360, 1776, 1774, 1360, 1360, 1360, 1788, 1784, 1767, 1765, + /* 220 */ 1751, 1360, 1360, 1360, 1802, 1798, 1814, 1802, 1798, 1802, + /* 230 */ 1798, 1360, 1774, 1360, 1360, 1774, 1360, 1580, 1360, 1360, + /* 240 */ 1427, 1360, 1427, 1360, 1492, 1360, 1360, 1427, 1360, 1597, + /* 250 */ 1611, 1526, 1526, 1526, 1430, 1365, 1360, 1360, 1360, 1360, + /* 260 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1678, 1787, 1786, + /* 270 */ 1710, 1709, 1708, 1706, 1677, 1488, 1360, 1360, 1360, 1360, + /* 280 */ 1360, 1360, 1671, 1672, 1670, 1669, 1360, 1360, 1360, 1360, + /* 290 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1735, + /* 300 */ 1360, 1799, 1803, 1360, 1360, 1360, 1654, 1360, 1360, 1360, + /* 310 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 320 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 330 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 340 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 350 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 360 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 370 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 380 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 390 */ 1360, 1360, 1360, 1394, 1360, 1360, 1360, 1360, 1360, 1360, + /* 400 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 410 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 420 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 430 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 440 */ 1360, 1457, 1456, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 450 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 460 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 470 */ 1360, 1360, 1360, 1360, 1360, 1758, 1768, 1360, 1360, 1360, + /* 480 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1654, 1360, 1785, + /* 490 */ 1360, 1744, 1740, 1360, 1360, 1736, 1360, 1360, 1797, 1360, + /* 500 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1730, 1360, + /* 510 */ 1703, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1665, + /* 520 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 530 */ 1360, 1360, 1653, 1360, 1694, 1360, 1360, 1360, 1360, 1360, + /* 540 */ 1360, 1360, 1360, 1520, 1360, 1360, 1360, 1360, 1360, 1360, + /* 550 */ 1360, 1360, 1360, 1360, 1360, 1360, 1505, 1503, 1502, 1501, + /* 560 */ 1360, 1498, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 570 */ 1360, 1360, 1360, 1449, 1360, 1360, 1360, 1360, 1360, 1360, + /* 580 */ 1360, 1360, 1360, 1440, 1360, 1439, 1360, 1360, 1360, 1360, + /* 590 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 600 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, + /* 610 */ 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, 1360, }; /********** End of lemon-generated parsing tables *****************************/ @@ -999,6 +1004,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* TRIGGER => nothing */ 0, /* AT_ONCE => nothing */ 0, /* WINDOW_CLOSE => nothing */ + 0, /* MAX_DELAY => nothing */ 0, /* WATERMARK => nothing */ 0, /* KILL => nothing */ 0, /* CONNECTION => nothing */ @@ -1063,12 +1069,12 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ID => nothing */ - 232, /* NK_BITNOT => ID */ - 232, /* INSERT => ID */ - 232, /* VALUES => ID */ - 232, /* IMPORT => ID */ - 232, /* NK_SEMI => ID */ - 232, /* FILE => ID */ + 233, /* NK_BITNOT => ID */ + 233, /* INSERT => ID */ + 233, /* VALUES => ID */ + 233, /* IMPORT => ID */ + 233, /* NK_SEMI => ID */ + 233, /* FILE => ID */ }; #endif /* YYFALLBACK */ @@ -1325,196 +1331,197 @@ static const char *const yyTokenName[] = { /* 166 */ "TRIGGER", /* 167 */ "AT_ONCE", /* 168 */ "WINDOW_CLOSE", - /* 169 */ "WATERMARK", - /* 170 */ "KILL", - /* 171 */ "CONNECTION", - /* 172 */ "TRANSACTION", - /* 173 */ "BALANCE", - /* 174 */ "VGROUP", - /* 175 */ "MERGE", - /* 176 */ "REDISTRIBUTE", - /* 177 */ "SPLIT", - /* 178 */ "SYNCDB", - /* 179 */ "DELETE", - /* 180 */ "NULL", - /* 181 */ "NK_QUESTION", - /* 182 */ "NK_ARROW", - /* 183 */ "ROWTS", - /* 184 */ "TBNAME", - /* 185 */ "QSTARTTS", - /* 186 */ "QENDTS", - /* 187 */ "WSTARTTS", - /* 188 */ "WENDTS", - /* 189 */ "WDURATION", - /* 190 */ "CAST", - /* 191 */ "NOW", - /* 192 */ "TODAY", - /* 193 */ "TIMEZONE", - /* 194 */ "COUNT", - /* 195 */ "FIRST", - /* 196 */ "LAST", - /* 197 */ "LAST_ROW", - /* 198 */ "BETWEEN", - /* 199 */ "IS", - /* 200 */ "NK_LT", - /* 201 */ "NK_GT", - /* 202 */ "NK_LE", - /* 203 */ "NK_GE", - /* 204 */ "NK_NE", - /* 205 */ "MATCH", - /* 206 */ "NMATCH", - /* 207 */ "CONTAINS", - /* 208 */ "JOIN", - /* 209 */ "INNER", - /* 210 */ "SELECT", - /* 211 */ "DISTINCT", - /* 212 */ "WHERE", - /* 213 */ "PARTITION", - /* 214 */ "BY", - /* 215 */ "SESSION", - /* 216 */ "STATE_WINDOW", - /* 217 */ "SLIDING", - /* 218 */ "FILL", - /* 219 */ "VALUE", - /* 220 */ "NONE", - /* 221 */ "PREV", - /* 222 */ "LINEAR", - /* 223 */ "NEXT", - /* 224 */ "HAVING", - /* 225 */ "ORDER", - /* 226 */ "SLIMIT", - /* 227 */ "SOFFSET", - /* 228 */ "LIMIT", - /* 229 */ "OFFSET", - /* 230 */ "ASC", - /* 231 */ "NULLS", - /* 232 */ "ID", - /* 233 */ "NK_BITNOT", - /* 234 */ "INSERT", - /* 235 */ "VALUES", - /* 236 */ "IMPORT", - /* 237 */ "NK_SEMI", - /* 238 */ "FILE", - /* 239 */ "cmd", - /* 240 */ "account_options", - /* 241 */ "alter_account_options", - /* 242 */ "literal", - /* 243 */ "alter_account_option", - /* 244 */ "user_name", - /* 245 */ "privileges", - /* 246 */ "priv_level", - /* 247 */ "priv_type_list", - /* 248 */ "priv_type", - /* 249 */ "db_name", - /* 250 */ "dnode_endpoint", - /* 251 */ "dnode_host_name", - /* 252 */ "not_exists_opt", - /* 253 */ "db_options", - /* 254 */ "exists_opt", - /* 255 */ "alter_db_options", - /* 256 */ "integer_list", - /* 257 */ "variable_list", - /* 258 */ "retention_list", - /* 259 */ "alter_db_option", - /* 260 */ "retention", - /* 261 */ "full_table_name", - /* 262 */ "column_def_list", - /* 263 */ "tags_def_opt", - /* 264 */ "table_options", - /* 265 */ "multi_create_clause", - /* 266 */ "tags_def", - /* 267 */ "multi_drop_clause", - /* 268 */ "alter_table_clause", - /* 269 */ "alter_table_options", - /* 270 */ "column_name", - /* 271 */ "type_name", - /* 272 */ "signed_literal", - /* 273 */ "create_subtable_clause", - /* 274 */ "specific_tags_opt", - /* 275 */ "literal_list", - /* 276 */ "drop_table_clause", - /* 277 */ "col_name_list", - /* 278 */ "table_name", - /* 279 */ "column_def", - /* 280 */ "func_name_list", - /* 281 */ "alter_table_option", - /* 282 */ "col_name", - /* 283 */ "db_name_cond_opt", - /* 284 */ "like_pattern_opt", - /* 285 */ "table_name_cond", - /* 286 */ "from_db_opt", - /* 287 */ "func_name", - /* 288 */ "function_name", - /* 289 */ "index_name", - /* 290 */ "index_options", - /* 291 */ "func_list", - /* 292 */ "duration_literal", - /* 293 */ "sliding_opt", - /* 294 */ "func", - /* 295 */ "expression_list", - /* 296 */ "topic_name", - /* 297 */ "query_expression", - /* 298 */ "cgroup_name", - /* 299 */ "analyze_opt", - /* 300 */ "explain_options", - /* 301 */ "agg_func_opt", - /* 302 */ "bufsize_opt", - /* 303 */ "stream_name", - /* 304 */ "stream_options", - /* 305 */ "into_opt", - /* 306 */ "dnode_list", - /* 307 */ "where_clause_opt", - /* 308 */ "signed", - /* 309 */ "literal_func", - /* 310 */ "table_alias", - /* 311 */ "column_alias", - /* 312 */ "expression", - /* 313 */ "pseudo_column", - /* 314 */ "column_reference", - /* 315 */ "function_expression", - /* 316 */ "subquery", - /* 317 */ "star_func", - /* 318 */ "star_func_para_list", - /* 319 */ "noarg_func", - /* 320 */ "other_para_list", - /* 321 */ "star_func_para", - /* 322 */ "predicate", - /* 323 */ "compare_op", - /* 324 */ "in_op", - /* 325 */ "in_predicate_value", - /* 326 */ "boolean_value_expression", - /* 327 */ "boolean_primary", - /* 328 */ "common_expression", - /* 329 */ "from_clause", - /* 330 */ "table_reference_list", - /* 331 */ "table_reference", - /* 332 */ "table_primary", - /* 333 */ "joined_table", - /* 334 */ "alias_opt", - /* 335 */ "parenthesized_joined_table", - /* 336 */ "join_type", - /* 337 */ "search_condition", - /* 338 */ "query_specification", - /* 339 */ "set_quantifier_opt", - /* 340 */ "select_list", - /* 341 */ "partition_by_clause_opt", - /* 342 */ "twindow_clause_opt", - /* 343 */ "group_by_clause_opt", - /* 344 */ "having_clause_opt", - /* 345 */ "select_sublist", - /* 346 */ "select_item", - /* 347 */ "fill_opt", - /* 348 */ "fill_mode", - /* 349 */ "group_by_list", - /* 350 */ "query_expression_body", - /* 351 */ "order_by_clause_opt", - /* 352 */ "slimit_clause_opt", - /* 353 */ "limit_clause_opt", - /* 354 */ "query_primary", - /* 355 */ "sort_specification_list", - /* 356 */ "sort_specification", - /* 357 */ "ordering_specification_opt", - /* 358 */ "null_ordering_opt", + /* 169 */ "MAX_DELAY", + /* 170 */ "WATERMARK", + /* 171 */ "KILL", + /* 172 */ "CONNECTION", + /* 173 */ "TRANSACTION", + /* 174 */ "BALANCE", + /* 175 */ "VGROUP", + /* 176 */ "MERGE", + /* 177 */ "REDISTRIBUTE", + /* 178 */ "SPLIT", + /* 179 */ "SYNCDB", + /* 180 */ "DELETE", + /* 181 */ "NULL", + /* 182 */ "NK_QUESTION", + /* 183 */ "NK_ARROW", + /* 184 */ "ROWTS", + /* 185 */ "TBNAME", + /* 186 */ "QSTARTTS", + /* 187 */ "QENDTS", + /* 188 */ "WSTARTTS", + /* 189 */ "WENDTS", + /* 190 */ "WDURATION", + /* 191 */ "CAST", + /* 192 */ "NOW", + /* 193 */ "TODAY", + /* 194 */ "TIMEZONE", + /* 195 */ "COUNT", + /* 196 */ "FIRST", + /* 197 */ "LAST", + /* 198 */ "LAST_ROW", + /* 199 */ "BETWEEN", + /* 200 */ "IS", + /* 201 */ "NK_LT", + /* 202 */ "NK_GT", + /* 203 */ "NK_LE", + /* 204 */ "NK_GE", + /* 205 */ "NK_NE", + /* 206 */ "MATCH", + /* 207 */ "NMATCH", + /* 208 */ "CONTAINS", + /* 209 */ "JOIN", + /* 210 */ "INNER", + /* 211 */ "SELECT", + /* 212 */ "DISTINCT", + /* 213 */ "WHERE", + /* 214 */ "PARTITION", + /* 215 */ "BY", + /* 216 */ "SESSION", + /* 217 */ "STATE_WINDOW", + /* 218 */ "SLIDING", + /* 219 */ "FILL", + /* 220 */ "VALUE", + /* 221 */ "NONE", + /* 222 */ "PREV", + /* 223 */ "LINEAR", + /* 224 */ "NEXT", + /* 225 */ "HAVING", + /* 226 */ "ORDER", + /* 227 */ "SLIMIT", + /* 228 */ "SOFFSET", + /* 229 */ "LIMIT", + /* 230 */ "OFFSET", + /* 231 */ "ASC", + /* 232 */ "NULLS", + /* 233 */ "ID", + /* 234 */ "NK_BITNOT", + /* 235 */ "INSERT", + /* 236 */ "VALUES", + /* 237 */ "IMPORT", + /* 238 */ "NK_SEMI", + /* 239 */ "FILE", + /* 240 */ "cmd", + /* 241 */ "account_options", + /* 242 */ "alter_account_options", + /* 243 */ "literal", + /* 244 */ "alter_account_option", + /* 245 */ "user_name", + /* 246 */ "privileges", + /* 247 */ "priv_level", + /* 248 */ "priv_type_list", + /* 249 */ "priv_type", + /* 250 */ "db_name", + /* 251 */ "dnode_endpoint", + /* 252 */ "dnode_host_name", + /* 253 */ "not_exists_opt", + /* 254 */ "db_options", + /* 255 */ "exists_opt", + /* 256 */ "alter_db_options", + /* 257 */ "integer_list", + /* 258 */ "variable_list", + /* 259 */ "retention_list", + /* 260 */ "alter_db_option", + /* 261 */ "retention", + /* 262 */ "full_table_name", + /* 263 */ "column_def_list", + /* 264 */ "tags_def_opt", + /* 265 */ "table_options", + /* 266 */ "multi_create_clause", + /* 267 */ "tags_def", + /* 268 */ "multi_drop_clause", + /* 269 */ "alter_table_clause", + /* 270 */ "alter_table_options", + /* 271 */ "column_name", + /* 272 */ "type_name", + /* 273 */ "signed_literal", + /* 274 */ "create_subtable_clause", + /* 275 */ "specific_tags_opt", + /* 276 */ "literal_list", + /* 277 */ "drop_table_clause", + /* 278 */ "col_name_list", + /* 279 */ "table_name", + /* 280 */ "column_def", + /* 281 */ "func_name_list", + /* 282 */ "alter_table_option", + /* 283 */ "col_name", + /* 284 */ "db_name_cond_opt", + /* 285 */ "like_pattern_opt", + /* 286 */ "table_name_cond", + /* 287 */ "from_db_opt", + /* 288 */ "func_name", + /* 289 */ "function_name", + /* 290 */ "index_name", + /* 291 */ "index_options", + /* 292 */ "func_list", + /* 293 */ "duration_literal", + /* 294 */ "sliding_opt", + /* 295 */ "func", + /* 296 */ "expression_list", + /* 297 */ "topic_name", + /* 298 */ "query_expression", + /* 299 */ "cgroup_name", + /* 300 */ "analyze_opt", + /* 301 */ "explain_options", + /* 302 */ "agg_func_opt", + /* 303 */ "bufsize_opt", + /* 304 */ "stream_name", + /* 305 */ "stream_options", + /* 306 */ "into_opt", + /* 307 */ "dnode_list", + /* 308 */ "where_clause_opt", + /* 309 */ "signed", + /* 310 */ "literal_func", + /* 311 */ "table_alias", + /* 312 */ "column_alias", + /* 313 */ "expression", + /* 314 */ "pseudo_column", + /* 315 */ "column_reference", + /* 316 */ "function_expression", + /* 317 */ "subquery", + /* 318 */ "star_func", + /* 319 */ "star_func_para_list", + /* 320 */ "noarg_func", + /* 321 */ "other_para_list", + /* 322 */ "star_func_para", + /* 323 */ "predicate", + /* 324 */ "compare_op", + /* 325 */ "in_op", + /* 326 */ "in_predicate_value", + /* 327 */ "boolean_value_expression", + /* 328 */ "boolean_primary", + /* 329 */ "common_expression", + /* 330 */ "from_clause", + /* 331 */ "table_reference_list", + /* 332 */ "table_reference", + /* 333 */ "table_primary", + /* 334 */ "joined_table", + /* 335 */ "alias_opt", + /* 336 */ "parenthesized_joined_table", + /* 337 */ "join_type", + /* 338 */ "search_condition", + /* 339 */ "query_specification", + /* 340 */ "set_quantifier_opt", + /* 341 */ "select_list", + /* 342 */ "partition_by_clause_opt", + /* 343 */ "twindow_clause_opt", + /* 344 */ "group_by_clause_opt", + /* 345 */ "having_clause_opt", + /* 346 */ "select_sublist", + /* 347 */ "select_item", + /* 348 */ "fill_opt", + /* 349 */ "fill_mode", + /* 350 */ "group_by_list", + /* 351 */ "query_expression_body", + /* 352 */ "order_by_clause_opt", + /* 353 */ "slimit_clause_opt", + /* 354 */ "limit_clause_opt", + /* 355 */ "query_primary", + /* 356 */ "sort_specification_list", + /* 357 */ "sort_specification", + /* 358 */ "ordering_specification_opt", + /* 359 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1773,208 +1780,209 @@ static const char *const yyRuleName[] = { /* 248 */ "stream_options ::=", /* 249 */ "stream_options ::= stream_options TRIGGER AT_ONCE", /* 250 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 251 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 252 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 253 */ "cmd ::= KILL QUERY NK_INTEGER", - /* 254 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 255 */ "cmd ::= BALANCE VGROUP", - /* 256 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 257 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 258 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 259 */ "dnode_list ::= DNODE NK_INTEGER", - /* 260 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 261 */ "cmd ::= SYNCDB db_name REPLICA", - /* 262 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 263 */ "cmd ::= query_expression", - /* 264 */ "literal ::= NK_INTEGER", - /* 265 */ "literal ::= NK_FLOAT", - /* 266 */ "literal ::= NK_STRING", - /* 267 */ "literal ::= NK_BOOL", - /* 268 */ "literal ::= TIMESTAMP NK_STRING", - /* 269 */ "literal ::= duration_literal", - /* 270 */ "literal ::= NULL", - /* 271 */ "literal ::= NK_QUESTION", - /* 272 */ "duration_literal ::= NK_VARIABLE", - /* 273 */ "signed ::= NK_INTEGER", - /* 274 */ "signed ::= NK_PLUS NK_INTEGER", - /* 275 */ "signed ::= NK_MINUS NK_INTEGER", - /* 276 */ "signed ::= NK_FLOAT", - /* 277 */ "signed ::= NK_PLUS NK_FLOAT", - /* 278 */ "signed ::= NK_MINUS NK_FLOAT", - /* 279 */ "signed_literal ::= signed", - /* 280 */ "signed_literal ::= NK_STRING", - /* 281 */ "signed_literal ::= NK_BOOL", - /* 282 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 283 */ "signed_literal ::= duration_literal", - /* 284 */ "signed_literal ::= NULL", - /* 285 */ "signed_literal ::= literal_func", - /* 286 */ "literal_list ::= signed_literal", - /* 287 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 288 */ "db_name ::= NK_ID", - /* 289 */ "table_name ::= NK_ID", - /* 290 */ "column_name ::= NK_ID", - /* 291 */ "function_name ::= NK_ID", - /* 292 */ "table_alias ::= NK_ID", - /* 293 */ "column_alias ::= NK_ID", - /* 294 */ "user_name ::= NK_ID", - /* 295 */ "index_name ::= NK_ID", - /* 296 */ "topic_name ::= NK_ID", - /* 297 */ "stream_name ::= NK_ID", - /* 298 */ "cgroup_name ::= NK_ID", - /* 299 */ "expression ::= literal", - /* 300 */ "expression ::= pseudo_column", - /* 301 */ "expression ::= column_reference", - /* 302 */ "expression ::= function_expression", - /* 303 */ "expression ::= subquery", - /* 304 */ "expression ::= NK_LP expression NK_RP", - /* 305 */ "expression ::= NK_PLUS expression", - /* 306 */ "expression ::= NK_MINUS expression", - /* 307 */ "expression ::= expression NK_PLUS expression", - /* 308 */ "expression ::= expression NK_MINUS expression", - /* 309 */ "expression ::= expression NK_STAR expression", - /* 310 */ "expression ::= expression NK_SLASH expression", - /* 311 */ "expression ::= expression NK_REM expression", - /* 312 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 313 */ "expression_list ::= expression", - /* 314 */ "expression_list ::= expression_list NK_COMMA expression", - /* 315 */ "column_reference ::= column_name", - /* 316 */ "column_reference ::= table_name NK_DOT column_name", - /* 317 */ "pseudo_column ::= ROWTS", - /* 318 */ "pseudo_column ::= TBNAME", - /* 319 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 320 */ "pseudo_column ::= QSTARTTS", - /* 321 */ "pseudo_column ::= QENDTS", - /* 322 */ "pseudo_column ::= WSTARTTS", - /* 323 */ "pseudo_column ::= WENDTS", - /* 324 */ "pseudo_column ::= WDURATION", - /* 325 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 326 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 327 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP", - /* 328 */ "function_expression ::= literal_func", - /* 329 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 330 */ "literal_func ::= NOW", - /* 331 */ "noarg_func ::= NOW", - /* 332 */ "noarg_func ::= TODAY", - /* 333 */ "noarg_func ::= TIMEZONE", - /* 334 */ "star_func ::= COUNT", - /* 335 */ "star_func ::= FIRST", - /* 336 */ "star_func ::= LAST", - /* 337 */ "star_func ::= LAST_ROW", - /* 338 */ "star_func_para_list ::= NK_STAR", - /* 339 */ "star_func_para_list ::= other_para_list", - /* 340 */ "other_para_list ::= star_func_para", - /* 341 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 342 */ "star_func_para ::= expression", - /* 343 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 344 */ "predicate ::= expression compare_op expression", - /* 345 */ "predicate ::= expression BETWEEN expression AND expression", - /* 346 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 347 */ "predicate ::= expression IS NULL", - /* 348 */ "predicate ::= expression IS NOT NULL", - /* 349 */ "predicate ::= expression in_op in_predicate_value", - /* 350 */ "compare_op ::= NK_LT", - /* 351 */ "compare_op ::= NK_GT", - /* 352 */ "compare_op ::= NK_LE", - /* 353 */ "compare_op ::= NK_GE", - /* 354 */ "compare_op ::= NK_NE", - /* 355 */ "compare_op ::= NK_EQ", - /* 356 */ "compare_op ::= LIKE", - /* 357 */ "compare_op ::= NOT LIKE", - /* 358 */ "compare_op ::= MATCH", - /* 359 */ "compare_op ::= NMATCH", - /* 360 */ "compare_op ::= CONTAINS", - /* 361 */ "in_op ::= IN", - /* 362 */ "in_op ::= NOT IN", - /* 363 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 364 */ "boolean_value_expression ::= boolean_primary", - /* 365 */ "boolean_value_expression ::= NOT boolean_primary", - /* 366 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 367 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 368 */ "boolean_primary ::= predicate", - /* 369 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 370 */ "common_expression ::= expression", - /* 371 */ "common_expression ::= boolean_value_expression", - /* 372 */ "from_clause ::= FROM table_reference_list", - /* 373 */ "table_reference_list ::= table_reference", - /* 374 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 375 */ "table_reference ::= table_primary", - /* 376 */ "table_reference ::= joined_table", - /* 377 */ "table_primary ::= table_name alias_opt", - /* 378 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 379 */ "table_primary ::= subquery alias_opt", - /* 380 */ "table_primary ::= parenthesized_joined_table", - /* 381 */ "alias_opt ::=", - /* 382 */ "alias_opt ::= table_alias", - /* 383 */ "alias_opt ::= AS table_alias", - /* 384 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 385 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 386 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 387 */ "join_type ::=", - /* 388 */ "join_type ::= INNER", - /* 389 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 390 */ "set_quantifier_opt ::=", - /* 391 */ "set_quantifier_opt ::= DISTINCT", - /* 392 */ "set_quantifier_opt ::= ALL", - /* 393 */ "select_list ::= NK_STAR", - /* 394 */ "select_list ::= select_sublist", - /* 395 */ "select_sublist ::= select_item", - /* 396 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 397 */ "select_item ::= common_expression", - /* 398 */ "select_item ::= common_expression column_alias", - /* 399 */ "select_item ::= common_expression AS column_alias", - /* 400 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 401 */ "where_clause_opt ::=", - /* 402 */ "where_clause_opt ::= WHERE search_condition", - /* 403 */ "partition_by_clause_opt ::=", - /* 404 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 405 */ "twindow_clause_opt ::=", - /* 406 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 407 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", - /* 408 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 409 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 410 */ "sliding_opt ::=", - /* 411 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 412 */ "fill_opt ::=", - /* 413 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 414 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 415 */ "fill_mode ::= NONE", - /* 416 */ "fill_mode ::= PREV", - /* 417 */ "fill_mode ::= NULL", - /* 418 */ "fill_mode ::= LINEAR", - /* 419 */ "fill_mode ::= NEXT", - /* 420 */ "group_by_clause_opt ::=", - /* 421 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 422 */ "group_by_list ::= expression", - /* 423 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 424 */ "having_clause_opt ::=", - /* 425 */ "having_clause_opt ::= HAVING search_condition", - /* 426 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 427 */ "query_expression_body ::= query_primary", - /* 428 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 429 */ "query_expression_body ::= query_expression_body UNION query_expression_body", - /* 430 */ "query_primary ::= query_specification", - /* 431 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP", - /* 432 */ "order_by_clause_opt ::=", - /* 433 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 434 */ "slimit_clause_opt ::=", - /* 435 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 436 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 437 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 438 */ "limit_clause_opt ::=", - /* 439 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 440 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 441 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 442 */ "subquery ::= NK_LP query_expression NK_RP", - /* 443 */ "search_condition ::= common_expression", - /* 444 */ "sort_specification_list ::= sort_specification", - /* 445 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 446 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 447 */ "ordering_specification_opt ::=", - /* 448 */ "ordering_specification_opt ::= ASC", - /* 449 */ "ordering_specification_opt ::= DESC", - /* 450 */ "null_ordering_opt ::=", - /* 451 */ "null_ordering_opt ::= NULLS FIRST", - /* 452 */ "null_ordering_opt ::= NULLS LAST", + /* 251 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", + /* 252 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 253 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 254 */ "cmd ::= KILL QUERY NK_INTEGER", + /* 255 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 256 */ "cmd ::= BALANCE VGROUP", + /* 257 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 258 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 259 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 260 */ "dnode_list ::= DNODE NK_INTEGER", + /* 261 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 262 */ "cmd ::= SYNCDB db_name REPLICA", + /* 263 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 264 */ "cmd ::= query_expression", + /* 265 */ "literal ::= NK_INTEGER", + /* 266 */ "literal ::= NK_FLOAT", + /* 267 */ "literal ::= NK_STRING", + /* 268 */ "literal ::= NK_BOOL", + /* 269 */ "literal ::= TIMESTAMP NK_STRING", + /* 270 */ "literal ::= duration_literal", + /* 271 */ "literal ::= NULL", + /* 272 */ "literal ::= NK_QUESTION", + /* 273 */ "duration_literal ::= NK_VARIABLE", + /* 274 */ "signed ::= NK_INTEGER", + /* 275 */ "signed ::= NK_PLUS NK_INTEGER", + /* 276 */ "signed ::= NK_MINUS NK_INTEGER", + /* 277 */ "signed ::= NK_FLOAT", + /* 278 */ "signed ::= NK_PLUS NK_FLOAT", + /* 279 */ "signed ::= NK_MINUS NK_FLOAT", + /* 280 */ "signed_literal ::= signed", + /* 281 */ "signed_literal ::= NK_STRING", + /* 282 */ "signed_literal ::= NK_BOOL", + /* 283 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 284 */ "signed_literal ::= duration_literal", + /* 285 */ "signed_literal ::= NULL", + /* 286 */ "signed_literal ::= literal_func", + /* 287 */ "literal_list ::= signed_literal", + /* 288 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 289 */ "db_name ::= NK_ID", + /* 290 */ "table_name ::= NK_ID", + /* 291 */ "column_name ::= NK_ID", + /* 292 */ "function_name ::= NK_ID", + /* 293 */ "table_alias ::= NK_ID", + /* 294 */ "column_alias ::= NK_ID", + /* 295 */ "user_name ::= NK_ID", + /* 296 */ "index_name ::= NK_ID", + /* 297 */ "topic_name ::= NK_ID", + /* 298 */ "stream_name ::= NK_ID", + /* 299 */ "cgroup_name ::= NK_ID", + /* 300 */ "expression ::= literal", + /* 301 */ "expression ::= pseudo_column", + /* 302 */ "expression ::= column_reference", + /* 303 */ "expression ::= function_expression", + /* 304 */ "expression ::= subquery", + /* 305 */ "expression ::= NK_LP expression NK_RP", + /* 306 */ "expression ::= NK_PLUS expression", + /* 307 */ "expression ::= NK_MINUS expression", + /* 308 */ "expression ::= expression NK_PLUS expression", + /* 309 */ "expression ::= expression NK_MINUS expression", + /* 310 */ "expression ::= expression NK_STAR expression", + /* 311 */ "expression ::= expression NK_SLASH expression", + /* 312 */ "expression ::= expression NK_REM expression", + /* 313 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 314 */ "expression_list ::= expression", + /* 315 */ "expression_list ::= expression_list NK_COMMA expression", + /* 316 */ "column_reference ::= column_name", + /* 317 */ "column_reference ::= table_name NK_DOT column_name", + /* 318 */ "pseudo_column ::= ROWTS", + /* 319 */ "pseudo_column ::= TBNAME", + /* 320 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 321 */ "pseudo_column ::= QSTARTTS", + /* 322 */ "pseudo_column ::= QENDTS", + /* 323 */ "pseudo_column ::= WSTARTTS", + /* 324 */ "pseudo_column ::= WENDTS", + /* 325 */ "pseudo_column ::= WDURATION", + /* 326 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 327 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 328 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP", + /* 329 */ "function_expression ::= literal_func", + /* 330 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 331 */ "literal_func ::= NOW", + /* 332 */ "noarg_func ::= NOW", + /* 333 */ "noarg_func ::= TODAY", + /* 334 */ "noarg_func ::= TIMEZONE", + /* 335 */ "star_func ::= COUNT", + /* 336 */ "star_func ::= FIRST", + /* 337 */ "star_func ::= LAST", + /* 338 */ "star_func ::= LAST_ROW", + /* 339 */ "star_func_para_list ::= NK_STAR", + /* 340 */ "star_func_para_list ::= other_para_list", + /* 341 */ "other_para_list ::= star_func_para", + /* 342 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 343 */ "star_func_para ::= expression", + /* 344 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 345 */ "predicate ::= expression compare_op expression", + /* 346 */ "predicate ::= expression BETWEEN expression AND expression", + /* 347 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 348 */ "predicate ::= expression IS NULL", + /* 349 */ "predicate ::= expression IS NOT NULL", + /* 350 */ "predicate ::= expression in_op in_predicate_value", + /* 351 */ "compare_op ::= NK_LT", + /* 352 */ "compare_op ::= NK_GT", + /* 353 */ "compare_op ::= NK_LE", + /* 354 */ "compare_op ::= NK_GE", + /* 355 */ "compare_op ::= NK_NE", + /* 356 */ "compare_op ::= NK_EQ", + /* 357 */ "compare_op ::= LIKE", + /* 358 */ "compare_op ::= NOT LIKE", + /* 359 */ "compare_op ::= MATCH", + /* 360 */ "compare_op ::= NMATCH", + /* 361 */ "compare_op ::= CONTAINS", + /* 362 */ "in_op ::= IN", + /* 363 */ "in_op ::= NOT IN", + /* 364 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 365 */ "boolean_value_expression ::= boolean_primary", + /* 366 */ "boolean_value_expression ::= NOT boolean_primary", + /* 367 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 368 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 369 */ "boolean_primary ::= predicate", + /* 370 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 371 */ "common_expression ::= expression", + /* 372 */ "common_expression ::= boolean_value_expression", + /* 373 */ "from_clause ::= FROM table_reference_list", + /* 374 */ "table_reference_list ::= table_reference", + /* 375 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 376 */ "table_reference ::= table_primary", + /* 377 */ "table_reference ::= joined_table", + /* 378 */ "table_primary ::= table_name alias_opt", + /* 379 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 380 */ "table_primary ::= subquery alias_opt", + /* 381 */ "table_primary ::= parenthesized_joined_table", + /* 382 */ "alias_opt ::=", + /* 383 */ "alias_opt ::= table_alias", + /* 384 */ "alias_opt ::= AS table_alias", + /* 385 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 386 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 387 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 388 */ "join_type ::=", + /* 389 */ "join_type ::= INNER", + /* 390 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 391 */ "set_quantifier_opt ::=", + /* 392 */ "set_quantifier_opt ::= DISTINCT", + /* 393 */ "set_quantifier_opt ::= ALL", + /* 394 */ "select_list ::= NK_STAR", + /* 395 */ "select_list ::= select_sublist", + /* 396 */ "select_sublist ::= select_item", + /* 397 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 398 */ "select_item ::= common_expression", + /* 399 */ "select_item ::= common_expression column_alias", + /* 400 */ "select_item ::= common_expression AS column_alias", + /* 401 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 402 */ "where_clause_opt ::=", + /* 403 */ "where_clause_opt ::= WHERE search_condition", + /* 404 */ "partition_by_clause_opt ::=", + /* 405 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 406 */ "twindow_clause_opt ::=", + /* 407 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 408 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", + /* 409 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 410 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 411 */ "sliding_opt ::=", + /* 412 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 413 */ "fill_opt ::=", + /* 414 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 415 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 416 */ "fill_mode ::= NONE", + /* 417 */ "fill_mode ::= PREV", + /* 418 */ "fill_mode ::= NULL", + /* 419 */ "fill_mode ::= LINEAR", + /* 420 */ "fill_mode ::= NEXT", + /* 421 */ "group_by_clause_opt ::=", + /* 422 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 423 */ "group_by_list ::= expression", + /* 424 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 425 */ "having_clause_opt ::=", + /* 426 */ "having_clause_opt ::= HAVING search_condition", + /* 427 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 428 */ "query_expression_body ::= query_primary", + /* 429 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 430 */ "query_expression_body ::= query_expression_body UNION query_expression_body", + /* 431 */ "query_primary ::= query_specification", + /* 432 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP", + /* 433 */ "order_by_clause_opt ::=", + /* 434 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 435 */ "slimit_clause_opt ::=", + /* 436 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 437 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 438 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 439 */ "limit_clause_opt ::=", + /* 440 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 441 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 442 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 443 */ "subquery ::= NK_LP query_expression NK_RP", + /* 444 */ "search_condition ::= common_expression", + /* 445 */ "sort_specification_list ::= sort_specification", + /* 446 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 447 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 448 */ "ordering_specification_opt ::=", + /* 449 */ "ordering_specification_opt ::= ASC", + /* 450 */ "ordering_specification_opt ::= DESC", + /* 451 */ "null_ordering_opt ::=", + /* 452 */ "null_ordering_opt ::= NULLS FIRST", + /* 453 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -2101,174 +2109,174 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 239: /* cmd */ - case 242: /* literal */ - case 253: /* db_options */ - case 255: /* alter_db_options */ - case 260: /* retention */ - case 261: /* full_table_name */ - case 264: /* table_options */ - case 268: /* alter_table_clause */ - case 269: /* alter_table_options */ - case 272: /* signed_literal */ - case 273: /* create_subtable_clause */ - case 276: /* drop_table_clause */ - case 279: /* column_def */ - case 282: /* col_name */ - case 283: /* db_name_cond_opt */ - case 284: /* like_pattern_opt */ - case 285: /* table_name_cond */ - case 286: /* from_db_opt */ - case 287: /* func_name */ - case 290: /* index_options */ - case 292: /* duration_literal */ - case 293: /* sliding_opt */ - case 294: /* func */ - case 297: /* query_expression */ - case 300: /* explain_options */ - case 304: /* stream_options */ - case 305: /* into_opt */ - case 307: /* where_clause_opt */ - case 308: /* signed */ - case 309: /* literal_func */ - case 312: /* expression */ - case 313: /* pseudo_column */ - case 314: /* column_reference */ - case 315: /* function_expression */ - case 316: /* subquery */ - case 321: /* star_func_para */ - case 322: /* predicate */ - case 325: /* in_predicate_value */ - case 326: /* boolean_value_expression */ - case 327: /* boolean_primary */ - case 328: /* common_expression */ - case 329: /* from_clause */ - case 330: /* table_reference_list */ - case 331: /* table_reference */ - case 332: /* table_primary */ - case 333: /* joined_table */ - case 335: /* parenthesized_joined_table */ - case 337: /* search_condition */ - case 338: /* query_specification */ - case 342: /* twindow_clause_opt */ - case 344: /* having_clause_opt */ - case 346: /* select_item */ - case 347: /* fill_opt */ - case 350: /* query_expression_body */ - case 352: /* slimit_clause_opt */ - case 353: /* limit_clause_opt */ - case 354: /* query_primary */ - case 356: /* sort_specification */ + case 240: /* cmd */ + case 243: /* literal */ + case 254: /* db_options */ + case 256: /* alter_db_options */ + case 261: /* retention */ + case 262: /* full_table_name */ + case 265: /* table_options */ + case 269: /* alter_table_clause */ + case 270: /* alter_table_options */ + case 273: /* signed_literal */ + case 274: /* create_subtable_clause */ + case 277: /* drop_table_clause */ + case 280: /* column_def */ + case 283: /* col_name */ + case 284: /* db_name_cond_opt */ + case 285: /* like_pattern_opt */ + case 286: /* table_name_cond */ + case 287: /* from_db_opt */ + case 288: /* func_name */ + case 291: /* index_options */ + case 293: /* duration_literal */ + case 294: /* sliding_opt */ + case 295: /* func */ + case 298: /* query_expression */ + case 301: /* explain_options */ + case 305: /* stream_options */ + case 306: /* into_opt */ + case 308: /* where_clause_opt */ + case 309: /* signed */ + case 310: /* literal_func */ + case 313: /* expression */ + case 314: /* pseudo_column */ + case 315: /* column_reference */ + case 316: /* function_expression */ + case 317: /* subquery */ + case 322: /* star_func_para */ + case 323: /* predicate */ + case 326: /* in_predicate_value */ + case 327: /* boolean_value_expression */ + case 328: /* boolean_primary */ + case 329: /* common_expression */ + case 330: /* from_clause */ + case 331: /* table_reference_list */ + case 332: /* table_reference */ + case 333: /* table_primary */ + case 334: /* joined_table */ + case 336: /* parenthesized_joined_table */ + case 338: /* search_condition */ + case 339: /* query_specification */ + case 343: /* twindow_clause_opt */ + case 345: /* having_clause_opt */ + case 347: /* select_item */ + case 348: /* fill_opt */ + case 351: /* query_expression_body */ + case 353: /* slimit_clause_opt */ + case 354: /* limit_clause_opt */ + case 355: /* query_primary */ + case 357: /* sort_specification */ { - nodesDestroyNode((yypminor->yy674)); + nodesDestroyNode((yypminor->yy632)); } break; - case 240: /* account_options */ - case 241: /* alter_account_options */ - case 243: /* alter_account_option */ - case 302: /* bufsize_opt */ + case 241: /* account_options */ + case 242: /* alter_account_options */ + case 244: /* alter_account_option */ + case 303: /* bufsize_opt */ { } break; - case 244: /* user_name */ - case 246: /* priv_level */ - case 249: /* db_name */ - case 250: /* dnode_endpoint */ - case 251: /* dnode_host_name */ - case 270: /* column_name */ - case 278: /* table_name */ - case 288: /* function_name */ - case 289: /* index_name */ - case 296: /* topic_name */ - case 298: /* cgroup_name */ - case 303: /* stream_name */ - case 310: /* table_alias */ - case 311: /* column_alias */ - case 317: /* star_func */ - case 319: /* noarg_func */ - case 334: /* alias_opt */ + case 245: /* user_name */ + case 247: /* priv_level */ + case 250: /* db_name */ + case 251: /* dnode_endpoint */ + case 252: /* dnode_host_name */ + case 271: /* column_name */ + case 279: /* table_name */ + case 289: /* function_name */ + case 290: /* index_name */ + case 297: /* topic_name */ + case 299: /* cgroup_name */ + case 304: /* stream_name */ + case 311: /* table_alias */ + case 312: /* column_alias */ + case 318: /* star_func */ + case 320: /* noarg_func */ + case 335: /* alias_opt */ { } break; - case 245: /* privileges */ - case 247: /* priv_type_list */ - case 248: /* priv_type */ + case 246: /* privileges */ + case 248: /* priv_type_list */ + case 249: /* priv_type */ { } break; - case 252: /* not_exists_opt */ - case 254: /* exists_opt */ - case 299: /* analyze_opt */ - case 301: /* agg_func_opt */ - case 339: /* set_quantifier_opt */ + case 253: /* not_exists_opt */ + case 255: /* exists_opt */ + case 300: /* analyze_opt */ + case 302: /* agg_func_opt */ + case 340: /* set_quantifier_opt */ { } break; - case 256: /* integer_list */ - case 257: /* variable_list */ - case 258: /* retention_list */ - case 262: /* column_def_list */ - case 263: /* tags_def_opt */ - case 265: /* multi_create_clause */ - case 266: /* tags_def */ - case 267: /* multi_drop_clause */ - case 274: /* specific_tags_opt */ - case 275: /* literal_list */ - case 277: /* col_name_list */ - case 280: /* func_name_list */ - case 291: /* func_list */ - case 295: /* expression_list */ - case 306: /* dnode_list */ - case 318: /* star_func_para_list */ - case 320: /* other_para_list */ - case 340: /* select_list */ - case 341: /* partition_by_clause_opt */ - case 343: /* group_by_clause_opt */ - case 345: /* select_sublist */ - case 349: /* group_by_list */ - case 351: /* order_by_clause_opt */ - case 355: /* sort_specification_list */ + case 257: /* integer_list */ + case 258: /* variable_list */ + case 259: /* retention_list */ + case 263: /* column_def_list */ + case 264: /* tags_def_opt */ + case 266: /* multi_create_clause */ + case 267: /* tags_def */ + case 268: /* multi_drop_clause */ + case 275: /* specific_tags_opt */ + case 276: /* literal_list */ + case 278: /* col_name_list */ + case 281: /* func_name_list */ + case 292: /* func_list */ + case 296: /* expression_list */ + case 307: /* dnode_list */ + case 319: /* star_func_para_list */ + case 321: /* other_para_list */ + case 341: /* select_list */ + case 342: /* partition_by_clause_opt */ + case 344: /* group_by_clause_opt */ + case 346: /* select_sublist */ + case 350: /* group_by_list */ + case 352: /* order_by_clause_opt */ + case 356: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy530)); + nodesDestroyList((yypminor->yy424)); } break; - case 259: /* alter_db_option */ - case 281: /* alter_table_option */ + case 260: /* alter_db_option */ + case 282: /* alter_table_option */ { } break; - case 271: /* type_name */ + case 272: /* type_name */ { } break; - case 323: /* compare_op */ - case 324: /* in_op */ + case 324: /* compare_op */ + case 325: /* in_op */ { } break; - case 336: /* join_type */ + case 337: /* join_type */ { } break; - case 348: /* fill_mode */ + case 349: /* fill_mode */ { } break; - case 357: /* ordering_specification_opt */ + case 358: /* ordering_specification_opt */ { } break; - case 358: /* null_ordering_opt */ + case 359: /* null_ordering_opt */ { } @@ -2567,459 +2575,460 @@ static const struct { YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ signed char nrhs; /* Negative of the number of RHS symbols in the rule */ } yyRuleInfo[] = { - { 239, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - { 239, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - { 240, 0 }, /* (2) account_options ::= */ - { 240, -3 }, /* (3) account_options ::= account_options PPS literal */ - { 240, -3 }, /* (4) account_options ::= account_options TSERIES literal */ - { 240, -3 }, /* (5) account_options ::= account_options STORAGE literal */ - { 240, -3 }, /* (6) account_options ::= account_options STREAMS literal */ - { 240, -3 }, /* (7) account_options ::= account_options QTIME literal */ - { 240, -3 }, /* (8) account_options ::= account_options DBS literal */ - { 240, -3 }, /* (9) account_options ::= account_options USERS literal */ - { 240, -3 }, /* (10) account_options ::= account_options CONNS literal */ - { 240, -3 }, /* (11) account_options ::= account_options STATE literal */ - { 241, -1 }, /* (12) alter_account_options ::= alter_account_option */ - { 241, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - { 243, -2 }, /* (14) alter_account_option ::= PASS literal */ - { 243, -2 }, /* (15) alter_account_option ::= PPS literal */ - { 243, -2 }, /* (16) alter_account_option ::= TSERIES literal */ - { 243, -2 }, /* (17) alter_account_option ::= STORAGE literal */ - { 243, -2 }, /* (18) alter_account_option ::= STREAMS literal */ - { 243, -2 }, /* (19) alter_account_option ::= QTIME literal */ - { 243, -2 }, /* (20) alter_account_option ::= DBS literal */ - { 243, -2 }, /* (21) alter_account_option ::= USERS literal */ - { 243, -2 }, /* (22) alter_account_option ::= CONNS literal */ - { 243, -2 }, /* (23) alter_account_option ::= STATE literal */ - { 239, -5 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING */ - { 239, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 239, -5 }, /* (26) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ - { 239, -3 }, /* (27) cmd ::= DROP USER user_name */ - { 239, -6 }, /* (28) cmd ::= GRANT privileges ON priv_level TO user_name */ - { 239, -6 }, /* (29) cmd ::= REVOKE privileges ON priv_level FROM user_name */ - { 245, -1 }, /* (30) privileges ::= ALL */ - { 245, -1 }, /* (31) privileges ::= priv_type_list */ - { 247, -1 }, /* (32) priv_type_list ::= priv_type */ - { 247, -3 }, /* (33) priv_type_list ::= priv_type_list NK_COMMA priv_type */ - { 248, -1 }, /* (34) priv_type ::= READ */ - { 248, -1 }, /* (35) priv_type ::= WRITE */ - { 246, -3 }, /* (36) priv_level ::= NK_STAR NK_DOT NK_STAR */ - { 246, -3 }, /* (37) priv_level ::= db_name NK_DOT NK_STAR */ - { 239, -3 }, /* (38) cmd ::= CREATE DNODE dnode_endpoint */ - { 239, -5 }, /* (39) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ - { 239, -3 }, /* (40) cmd ::= DROP DNODE NK_INTEGER */ - { 239, -3 }, /* (41) cmd ::= DROP DNODE dnode_endpoint */ - { 239, -4 }, /* (42) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - { 239, -5 }, /* (43) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - { 239, -4 }, /* (44) cmd ::= ALTER ALL DNODES NK_STRING */ - { 239, -5 }, /* (45) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - { 250, -1 }, /* (46) dnode_endpoint ::= NK_STRING */ - { 251, -1 }, /* (47) dnode_host_name ::= NK_ID */ - { 251, -1 }, /* (48) dnode_host_name ::= NK_IPTOKEN */ - { 239, -3 }, /* (49) cmd ::= ALTER LOCAL NK_STRING */ - { 239, -4 }, /* (50) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - { 239, -5 }, /* (51) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 239, -5 }, /* (52) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - { 239, -5 }, /* (53) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - { 239, -5 }, /* (54) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - { 239, -5 }, /* (55) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - { 239, -5 }, /* (56) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - { 239, -5 }, /* (57) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - { 239, -5 }, /* (58) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - { 239, -5 }, /* (59) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 239, -4 }, /* (60) cmd ::= DROP DATABASE exists_opt db_name */ - { 239, -2 }, /* (61) cmd ::= USE db_name */ - { 239, -4 }, /* (62) cmd ::= ALTER DATABASE db_name alter_db_options */ - { 252, -3 }, /* (63) not_exists_opt ::= IF NOT EXISTS */ - { 252, 0 }, /* (64) not_exists_opt ::= */ - { 254, -2 }, /* (65) exists_opt ::= IF EXISTS */ - { 254, 0 }, /* (66) exists_opt ::= */ - { 253, 0 }, /* (67) db_options ::= */ - { 253, -3 }, /* (68) db_options ::= db_options BUFFER NK_INTEGER */ - { 253, -3 }, /* (69) db_options ::= db_options CACHELAST NK_INTEGER */ - { 253, -3 }, /* (70) db_options ::= db_options COMP NK_INTEGER */ - { 253, -3 }, /* (71) db_options ::= db_options DAYS NK_INTEGER */ - { 253, -3 }, /* (72) db_options ::= db_options DAYS NK_VARIABLE */ - { 253, -3 }, /* (73) db_options ::= db_options FSYNC NK_INTEGER */ - { 253, -3 }, /* (74) db_options ::= db_options MAXROWS NK_INTEGER */ - { 253, -3 }, /* (75) db_options ::= db_options MINROWS NK_INTEGER */ - { 253, -3 }, /* (76) db_options ::= db_options KEEP integer_list */ - { 253, -3 }, /* (77) db_options ::= db_options KEEP variable_list */ - { 253, -3 }, /* (78) db_options ::= db_options PAGES NK_INTEGER */ - { 253, -3 }, /* (79) db_options ::= db_options PAGESIZE NK_INTEGER */ - { 253, -3 }, /* (80) db_options ::= db_options PRECISION NK_STRING */ - { 253, -3 }, /* (81) db_options ::= db_options REPLICA NK_INTEGER */ - { 253, -3 }, /* (82) db_options ::= db_options STRICT NK_INTEGER */ - { 253, -3 }, /* (83) db_options ::= db_options WAL NK_INTEGER */ - { 253, -3 }, /* (84) db_options ::= db_options VGROUPS NK_INTEGER */ - { 253, -3 }, /* (85) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 253, -3 }, /* (86) db_options ::= db_options RETENTIONS retention_list */ - { 253, -3 }, /* (87) db_options ::= db_options SCHEMALESS NK_INTEGER */ - { 255, -1 }, /* (88) alter_db_options ::= alter_db_option */ - { 255, -2 }, /* (89) alter_db_options ::= alter_db_options alter_db_option */ - { 259, -2 }, /* (90) alter_db_option ::= BUFFER NK_INTEGER */ - { 259, -2 }, /* (91) alter_db_option ::= CACHELAST NK_INTEGER */ - { 259, -2 }, /* (92) alter_db_option ::= FSYNC NK_INTEGER */ - { 259, -2 }, /* (93) alter_db_option ::= KEEP integer_list */ - { 259, -2 }, /* (94) alter_db_option ::= KEEP variable_list */ - { 259, -2 }, /* (95) alter_db_option ::= PAGES NK_INTEGER */ - { 259, -2 }, /* (96) alter_db_option ::= REPLICA NK_INTEGER */ - { 259, -2 }, /* (97) alter_db_option ::= STRICT NK_INTEGER */ - { 259, -2 }, /* (98) alter_db_option ::= WAL NK_INTEGER */ - { 256, -1 }, /* (99) integer_list ::= NK_INTEGER */ - { 256, -3 }, /* (100) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - { 257, -1 }, /* (101) variable_list ::= NK_VARIABLE */ - { 257, -3 }, /* (102) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - { 258, -1 }, /* (103) retention_list ::= retention */ - { 258, -3 }, /* (104) retention_list ::= retention_list NK_COMMA retention */ - { 260, -3 }, /* (105) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - { 239, -9 }, /* (106) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 239, -3 }, /* (107) cmd ::= CREATE TABLE multi_create_clause */ - { 239, -9 }, /* (108) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 239, -3 }, /* (109) cmd ::= DROP TABLE multi_drop_clause */ - { 239, -4 }, /* (110) cmd ::= DROP STABLE exists_opt full_table_name */ - { 239, -3 }, /* (111) cmd ::= ALTER TABLE alter_table_clause */ - { 239, -3 }, /* (112) cmd ::= ALTER STABLE alter_table_clause */ - { 268, -2 }, /* (113) alter_table_clause ::= full_table_name alter_table_options */ - { 268, -5 }, /* (114) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - { 268, -4 }, /* (115) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - { 268, -5 }, /* (116) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - { 268, -5 }, /* (117) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - { 268, -5 }, /* (118) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - { 268, -4 }, /* (119) alter_table_clause ::= full_table_name DROP TAG column_name */ - { 268, -5 }, /* (120) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - { 268, -5 }, /* (121) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - { 268, -6 }, /* (122) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ - { 265, -1 }, /* (123) multi_create_clause ::= create_subtable_clause */ - { 265, -2 }, /* (124) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 273, -10 }, /* (125) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options */ - { 267, -1 }, /* (126) multi_drop_clause ::= drop_table_clause */ - { 267, -2 }, /* (127) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 276, -2 }, /* (128) drop_table_clause ::= exists_opt full_table_name */ - { 274, 0 }, /* (129) specific_tags_opt ::= */ - { 274, -3 }, /* (130) specific_tags_opt ::= NK_LP col_name_list NK_RP */ - { 261, -1 }, /* (131) full_table_name ::= table_name */ - { 261, -3 }, /* (132) full_table_name ::= db_name NK_DOT table_name */ - { 262, -1 }, /* (133) column_def_list ::= column_def */ - { 262, -3 }, /* (134) column_def_list ::= column_def_list NK_COMMA column_def */ - { 279, -2 }, /* (135) column_def ::= column_name type_name */ - { 279, -4 }, /* (136) column_def ::= column_name type_name COMMENT NK_STRING */ - { 271, -1 }, /* (137) type_name ::= BOOL */ - { 271, -1 }, /* (138) type_name ::= TINYINT */ - { 271, -1 }, /* (139) type_name ::= SMALLINT */ - { 271, -1 }, /* (140) type_name ::= INT */ - { 271, -1 }, /* (141) type_name ::= INTEGER */ - { 271, -1 }, /* (142) type_name ::= BIGINT */ - { 271, -1 }, /* (143) type_name ::= FLOAT */ - { 271, -1 }, /* (144) type_name ::= DOUBLE */ - { 271, -4 }, /* (145) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 271, -1 }, /* (146) type_name ::= TIMESTAMP */ - { 271, -4 }, /* (147) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 271, -2 }, /* (148) type_name ::= TINYINT UNSIGNED */ - { 271, -2 }, /* (149) type_name ::= SMALLINT UNSIGNED */ - { 271, -2 }, /* (150) type_name ::= INT UNSIGNED */ - { 271, -2 }, /* (151) type_name ::= BIGINT UNSIGNED */ - { 271, -1 }, /* (152) type_name ::= JSON */ - { 271, -4 }, /* (153) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 271, -1 }, /* (154) type_name ::= MEDIUMBLOB */ - { 271, -1 }, /* (155) type_name ::= BLOB */ - { 271, -4 }, /* (156) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 271, -1 }, /* (157) type_name ::= DECIMAL */ - { 271, -4 }, /* (158) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 271, -6 }, /* (159) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 263, 0 }, /* (160) tags_def_opt ::= */ - { 263, -1 }, /* (161) tags_def_opt ::= tags_def */ - { 266, -4 }, /* (162) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 264, 0 }, /* (163) table_options ::= */ - { 264, -3 }, /* (164) table_options ::= table_options COMMENT NK_STRING */ - { 264, -3 }, /* (165) table_options ::= table_options FILE_FACTOR NK_FLOAT */ - { 264, -5 }, /* (166) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ - { 264, -3 }, /* (167) table_options ::= table_options TTL NK_INTEGER */ - { 264, -5 }, /* (168) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 269, -1 }, /* (169) alter_table_options ::= alter_table_option */ - { 269, -2 }, /* (170) alter_table_options ::= alter_table_options alter_table_option */ - { 281, -2 }, /* (171) alter_table_option ::= COMMENT NK_STRING */ - { 281, -2 }, /* (172) alter_table_option ::= TTL NK_INTEGER */ - { 277, -1 }, /* (173) col_name_list ::= col_name */ - { 277, -3 }, /* (174) col_name_list ::= col_name_list NK_COMMA col_name */ - { 282, -1 }, /* (175) col_name ::= column_name */ - { 239, -2 }, /* (176) cmd ::= SHOW DNODES */ - { 239, -2 }, /* (177) cmd ::= SHOW USERS */ - { 239, -2 }, /* (178) cmd ::= SHOW DATABASES */ - { 239, -4 }, /* (179) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - { 239, -4 }, /* (180) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - { 239, -3 }, /* (181) cmd ::= SHOW db_name_cond_opt VGROUPS */ - { 239, -2 }, /* (182) cmd ::= SHOW MNODES */ - { 239, -2 }, /* (183) cmd ::= SHOW MODULES */ - { 239, -2 }, /* (184) cmd ::= SHOW QNODES */ - { 239, -2 }, /* (185) cmd ::= SHOW FUNCTIONS */ - { 239, -5 }, /* (186) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - { 239, -2 }, /* (187) cmd ::= SHOW STREAMS */ - { 239, -2 }, /* (188) cmd ::= SHOW ACCOUNTS */ - { 239, -2 }, /* (189) cmd ::= SHOW APPS */ - { 239, -2 }, /* (190) cmd ::= SHOW CONNECTIONS */ - { 239, -2 }, /* (191) cmd ::= SHOW LICENCE */ - { 239, -2 }, /* (192) cmd ::= SHOW GRANTS */ - { 239, -4 }, /* (193) cmd ::= SHOW CREATE DATABASE db_name */ - { 239, -4 }, /* (194) cmd ::= SHOW CREATE TABLE full_table_name */ - { 239, -4 }, /* (195) cmd ::= SHOW CREATE STABLE full_table_name */ - { 239, -2 }, /* (196) cmd ::= SHOW QUERIES */ - { 239, -2 }, /* (197) cmd ::= SHOW SCORES */ - { 239, -2 }, /* (198) cmd ::= SHOW TOPICS */ - { 239, -2 }, /* (199) cmd ::= SHOW VARIABLES */ - { 239, -2 }, /* (200) cmd ::= SHOW BNODES */ - { 239, -2 }, /* (201) cmd ::= SHOW SNODES */ - { 239, -2 }, /* (202) cmd ::= SHOW CLUSTER */ - { 239, -2 }, /* (203) cmd ::= SHOW TRANSACTIONS */ - { 283, 0 }, /* (204) db_name_cond_opt ::= */ - { 283, -2 }, /* (205) db_name_cond_opt ::= db_name NK_DOT */ - { 284, 0 }, /* (206) like_pattern_opt ::= */ - { 284, -2 }, /* (207) like_pattern_opt ::= LIKE NK_STRING */ - { 285, -1 }, /* (208) table_name_cond ::= table_name */ - { 286, 0 }, /* (209) from_db_opt ::= */ - { 286, -2 }, /* (210) from_db_opt ::= FROM db_name */ - { 280, -1 }, /* (211) func_name_list ::= func_name */ - { 280, -3 }, /* (212) func_name_list ::= func_name_list NK_COMMA func_name */ - { 287, -1 }, /* (213) func_name ::= function_name */ - { 239, -8 }, /* (214) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ - { 239, -10 }, /* (215) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ - { 239, -6 }, /* (216) cmd ::= DROP INDEX exists_opt index_name ON table_name */ - { 290, 0 }, /* (217) index_options ::= */ - { 290, -9 }, /* (218) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ - { 290, -11 }, /* (219) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ - { 291, -1 }, /* (220) func_list ::= func */ - { 291, -3 }, /* (221) func_list ::= func_list NK_COMMA func */ - { 294, -4 }, /* (222) func ::= function_name NK_LP expression_list NK_RP */ - { 239, -6 }, /* (223) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ - { 239, -7 }, /* (224) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ - { 239, -7 }, /* (225) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ - { 239, -4 }, /* (226) cmd ::= DROP TOPIC exists_opt topic_name */ - { 239, -7 }, /* (227) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - { 239, -2 }, /* (228) cmd ::= DESC full_table_name */ - { 239, -2 }, /* (229) cmd ::= DESCRIBE full_table_name */ - { 239, -3 }, /* (230) cmd ::= RESET QUERY CACHE */ - { 239, -4 }, /* (231) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ - { 299, 0 }, /* (232) analyze_opt ::= */ - { 299, -1 }, /* (233) analyze_opt ::= ANALYZE */ - { 300, 0 }, /* (234) explain_options ::= */ - { 300, -3 }, /* (235) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 300, -3 }, /* (236) explain_options ::= explain_options RATIO NK_FLOAT */ - { 239, -6 }, /* (237) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ - { 239, -10 }, /* (238) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ - { 239, -4 }, /* (239) cmd ::= DROP FUNCTION exists_opt function_name */ - { 301, 0 }, /* (240) agg_func_opt ::= */ - { 301, -1 }, /* (241) agg_func_opt ::= AGGREGATE */ - { 302, 0 }, /* (242) bufsize_opt ::= */ - { 302, -2 }, /* (243) bufsize_opt ::= BUFSIZE NK_INTEGER */ - { 239, -8 }, /* (244) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ - { 239, -4 }, /* (245) cmd ::= DROP STREAM exists_opt stream_name */ - { 305, 0 }, /* (246) into_opt ::= */ - { 305, -2 }, /* (247) into_opt ::= INTO full_table_name */ - { 304, 0 }, /* (248) stream_options ::= */ - { 304, -3 }, /* (249) stream_options ::= stream_options TRIGGER AT_ONCE */ - { 304, -3 }, /* (250) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - { 304, -3 }, /* (251) stream_options ::= stream_options WATERMARK duration_literal */ - { 239, -3 }, /* (252) cmd ::= KILL CONNECTION NK_INTEGER */ - { 239, -3 }, /* (253) cmd ::= KILL QUERY NK_INTEGER */ - { 239, -3 }, /* (254) cmd ::= KILL TRANSACTION NK_INTEGER */ - { 239, -2 }, /* (255) cmd ::= BALANCE VGROUP */ - { 239, -4 }, /* (256) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - { 239, -4 }, /* (257) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - { 239, -3 }, /* (258) cmd ::= SPLIT VGROUP NK_INTEGER */ - { 306, -2 }, /* (259) dnode_list ::= DNODE NK_INTEGER */ - { 306, -3 }, /* (260) dnode_list ::= dnode_list DNODE NK_INTEGER */ - { 239, -3 }, /* (261) cmd ::= SYNCDB db_name REPLICA */ - { 239, -4 }, /* (262) cmd ::= DELETE FROM full_table_name where_clause_opt */ - { 239, -1 }, /* (263) cmd ::= query_expression */ - { 242, -1 }, /* (264) literal ::= NK_INTEGER */ - { 242, -1 }, /* (265) literal ::= NK_FLOAT */ - { 242, -1 }, /* (266) literal ::= NK_STRING */ - { 242, -1 }, /* (267) literal ::= NK_BOOL */ - { 242, -2 }, /* (268) literal ::= TIMESTAMP NK_STRING */ - { 242, -1 }, /* (269) literal ::= duration_literal */ - { 242, -1 }, /* (270) literal ::= NULL */ - { 242, -1 }, /* (271) literal ::= NK_QUESTION */ - { 292, -1 }, /* (272) duration_literal ::= NK_VARIABLE */ - { 308, -1 }, /* (273) signed ::= NK_INTEGER */ - { 308, -2 }, /* (274) signed ::= NK_PLUS NK_INTEGER */ - { 308, -2 }, /* (275) signed ::= NK_MINUS NK_INTEGER */ - { 308, -1 }, /* (276) signed ::= NK_FLOAT */ - { 308, -2 }, /* (277) signed ::= NK_PLUS NK_FLOAT */ - { 308, -2 }, /* (278) signed ::= NK_MINUS NK_FLOAT */ - { 272, -1 }, /* (279) signed_literal ::= signed */ - { 272, -1 }, /* (280) signed_literal ::= NK_STRING */ - { 272, -1 }, /* (281) signed_literal ::= NK_BOOL */ - { 272, -2 }, /* (282) signed_literal ::= TIMESTAMP NK_STRING */ - { 272, -1 }, /* (283) signed_literal ::= duration_literal */ - { 272, -1 }, /* (284) signed_literal ::= NULL */ - { 272, -1 }, /* (285) signed_literal ::= literal_func */ - { 275, -1 }, /* (286) literal_list ::= signed_literal */ - { 275, -3 }, /* (287) literal_list ::= literal_list NK_COMMA signed_literal */ - { 249, -1 }, /* (288) db_name ::= NK_ID */ - { 278, -1 }, /* (289) table_name ::= NK_ID */ - { 270, -1 }, /* (290) column_name ::= NK_ID */ - { 288, -1 }, /* (291) function_name ::= NK_ID */ - { 310, -1 }, /* (292) table_alias ::= NK_ID */ - { 311, -1 }, /* (293) column_alias ::= NK_ID */ - { 244, -1 }, /* (294) user_name ::= NK_ID */ - { 289, -1 }, /* (295) index_name ::= NK_ID */ - { 296, -1 }, /* (296) topic_name ::= NK_ID */ - { 303, -1 }, /* (297) stream_name ::= NK_ID */ - { 298, -1 }, /* (298) cgroup_name ::= NK_ID */ - { 312, -1 }, /* (299) expression ::= literal */ - { 312, -1 }, /* (300) expression ::= pseudo_column */ - { 312, -1 }, /* (301) expression ::= column_reference */ - { 312, -1 }, /* (302) expression ::= function_expression */ - { 312, -1 }, /* (303) expression ::= subquery */ - { 312, -3 }, /* (304) expression ::= NK_LP expression NK_RP */ - { 312, -2 }, /* (305) expression ::= NK_PLUS expression */ - { 312, -2 }, /* (306) expression ::= NK_MINUS expression */ - { 312, -3 }, /* (307) expression ::= expression NK_PLUS expression */ - { 312, -3 }, /* (308) expression ::= expression NK_MINUS expression */ - { 312, -3 }, /* (309) expression ::= expression NK_STAR expression */ - { 312, -3 }, /* (310) expression ::= expression NK_SLASH expression */ - { 312, -3 }, /* (311) expression ::= expression NK_REM expression */ - { 312, -3 }, /* (312) expression ::= column_reference NK_ARROW NK_STRING */ - { 295, -1 }, /* (313) expression_list ::= expression */ - { 295, -3 }, /* (314) expression_list ::= expression_list NK_COMMA expression */ - { 314, -1 }, /* (315) column_reference ::= column_name */ - { 314, -3 }, /* (316) column_reference ::= table_name NK_DOT column_name */ - { 313, -1 }, /* (317) pseudo_column ::= ROWTS */ - { 313, -1 }, /* (318) pseudo_column ::= TBNAME */ - { 313, -3 }, /* (319) pseudo_column ::= table_name NK_DOT TBNAME */ - { 313, -1 }, /* (320) pseudo_column ::= QSTARTTS */ - { 313, -1 }, /* (321) pseudo_column ::= QENDTS */ - { 313, -1 }, /* (322) pseudo_column ::= WSTARTTS */ - { 313, -1 }, /* (323) pseudo_column ::= WENDTS */ - { 313, -1 }, /* (324) pseudo_column ::= WDURATION */ - { 315, -4 }, /* (325) function_expression ::= function_name NK_LP expression_list NK_RP */ - { 315, -4 }, /* (326) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - { 315, -6 }, /* (327) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ - { 315, -1 }, /* (328) function_expression ::= literal_func */ - { 309, -3 }, /* (329) literal_func ::= noarg_func NK_LP NK_RP */ - { 309, -1 }, /* (330) literal_func ::= NOW */ - { 319, -1 }, /* (331) noarg_func ::= NOW */ - { 319, -1 }, /* (332) noarg_func ::= TODAY */ - { 319, -1 }, /* (333) noarg_func ::= TIMEZONE */ - { 317, -1 }, /* (334) star_func ::= COUNT */ - { 317, -1 }, /* (335) star_func ::= FIRST */ - { 317, -1 }, /* (336) star_func ::= LAST */ - { 317, -1 }, /* (337) star_func ::= LAST_ROW */ - { 318, -1 }, /* (338) star_func_para_list ::= NK_STAR */ - { 318, -1 }, /* (339) star_func_para_list ::= other_para_list */ - { 320, -1 }, /* (340) other_para_list ::= star_func_para */ - { 320, -3 }, /* (341) other_para_list ::= other_para_list NK_COMMA star_func_para */ - { 321, -1 }, /* (342) star_func_para ::= expression */ - { 321, -3 }, /* (343) star_func_para ::= table_name NK_DOT NK_STAR */ - { 322, -3 }, /* (344) predicate ::= expression compare_op expression */ - { 322, -5 }, /* (345) predicate ::= expression BETWEEN expression AND expression */ - { 322, -6 }, /* (346) predicate ::= expression NOT BETWEEN expression AND expression */ - { 322, -3 }, /* (347) predicate ::= expression IS NULL */ - { 322, -4 }, /* (348) predicate ::= expression IS NOT NULL */ - { 322, -3 }, /* (349) predicate ::= expression in_op in_predicate_value */ - { 323, -1 }, /* (350) compare_op ::= NK_LT */ - { 323, -1 }, /* (351) compare_op ::= NK_GT */ - { 323, -1 }, /* (352) compare_op ::= NK_LE */ - { 323, -1 }, /* (353) compare_op ::= NK_GE */ - { 323, -1 }, /* (354) compare_op ::= NK_NE */ - { 323, -1 }, /* (355) compare_op ::= NK_EQ */ - { 323, -1 }, /* (356) compare_op ::= LIKE */ - { 323, -2 }, /* (357) compare_op ::= NOT LIKE */ - { 323, -1 }, /* (358) compare_op ::= MATCH */ - { 323, -1 }, /* (359) compare_op ::= NMATCH */ - { 323, -1 }, /* (360) compare_op ::= CONTAINS */ - { 324, -1 }, /* (361) in_op ::= IN */ - { 324, -2 }, /* (362) in_op ::= NOT IN */ - { 325, -3 }, /* (363) in_predicate_value ::= NK_LP expression_list NK_RP */ - { 326, -1 }, /* (364) boolean_value_expression ::= boolean_primary */ - { 326, -2 }, /* (365) boolean_value_expression ::= NOT boolean_primary */ - { 326, -3 }, /* (366) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 326, -3 }, /* (367) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 327, -1 }, /* (368) boolean_primary ::= predicate */ - { 327, -3 }, /* (369) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 328, -1 }, /* (370) common_expression ::= expression */ - { 328, -1 }, /* (371) common_expression ::= boolean_value_expression */ - { 329, -2 }, /* (372) from_clause ::= FROM table_reference_list */ - { 330, -1 }, /* (373) table_reference_list ::= table_reference */ - { 330, -3 }, /* (374) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 331, -1 }, /* (375) table_reference ::= table_primary */ - { 331, -1 }, /* (376) table_reference ::= joined_table */ - { 332, -2 }, /* (377) table_primary ::= table_name alias_opt */ - { 332, -4 }, /* (378) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 332, -2 }, /* (379) table_primary ::= subquery alias_opt */ - { 332, -1 }, /* (380) table_primary ::= parenthesized_joined_table */ - { 334, 0 }, /* (381) alias_opt ::= */ - { 334, -1 }, /* (382) alias_opt ::= table_alias */ - { 334, -2 }, /* (383) alias_opt ::= AS table_alias */ - { 335, -3 }, /* (384) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 335, -3 }, /* (385) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 333, -6 }, /* (386) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 336, 0 }, /* (387) join_type ::= */ - { 336, -1 }, /* (388) join_type ::= INNER */ - { 338, -9 }, /* (389) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - { 339, 0 }, /* (390) set_quantifier_opt ::= */ - { 339, -1 }, /* (391) set_quantifier_opt ::= DISTINCT */ - { 339, -1 }, /* (392) set_quantifier_opt ::= ALL */ - { 340, -1 }, /* (393) select_list ::= NK_STAR */ - { 340, -1 }, /* (394) select_list ::= select_sublist */ - { 345, -1 }, /* (395) select_sublist ::= select_item */ - { 345, -3 }, /* (396) select_sublist ::= select_sublist NK_COMMA select_item */ - { 346, -1 }, /* (397) select_item ::= common_expression */ - { 346, -2 }, /* (398) select_item ::= common_expression column_alias */ - { 346, -3 }, /* (399) select_item ::= common_expression AS column_alias */ - { 346, -3 }, /* (400) select_item ::= table_name NK_DOT NK_STAR */ - { 307, 0 }, /* (401) where_clause_opt ::= */ - { 307, -2 }, /* (402) where_clause_opt ::= WHERE search_condition */ - { 341, 0 }, /* (403) partition_by_clause_opt ::= */ - { 341, -3 }, /* (404) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 342, 0 }, /* (405) twindow_clause_opt ::= */ - { 342, -6 }, /* (406) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 342, -4 }, /* (407) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ - { 342, -6 }, /* (408) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 342, -8 }, /* (409) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 293, 0 }, /* (410) sliding_opt ::= */ - { 293, -4 }, /* (411) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 347, 0 }, /* (412) fill_opt ::= */ - { 347, -4 }, /* (413) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 347, -6 }, /* (414) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 348, -1 }, /* (415) fill_mode ::= NONE */ - { 348, -1 }, /* (416) fill_mode ::= PREV */ - { 348, -1 }, /* (417) fill_mode ::= NULL */ - { 348, -1 }, /* (418) fill_mode ::= LINEAR */ - { 348, -1 }, /* (419) fill_mode ::= NEXT */ - { 343, 0 }, /* (420) group_by_clause_opt ::= */ - { 343, -3 }, /* (421) group_by_clause_opt ::= GROUP BY group_by_list */ - { 349, -1 }, /* (422) group_by_list ::= expression */ - { 349, -3 }, /* (423) group_by_list ::= group_by_list NK_COMMA expression */ - { 344, 0 }, /* (424) having_clause_opt ::= */ - { 344, -2 }, /* (425) having_clause_opt ::= HAVING search_condition */ - { 297, -4 }, /* (426) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 350, -1 }, /* (427) query_expression_body ::= query_primary */ - { 350, -4 }, /* (428) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 350, -3 }, /* (429) query_expression_body ::= query_expression_body UNION query_expression_body */ - { 354, -1 }, /* (430) query_primary ::= query_specification */ - { 354, -6 }, /* (431) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ - { 351, 0 }, /* (432) order_by_clause_opt ::= */ - { 351, -3 }, /* (433) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 352, 0 }, /* (434) slimit_clause_opt ::= */ - { 352, -2 }, /* (435) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 352, -4 }, /* (436) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 352, -4 }, /* (437) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 353, 0 }, /* (438) limit_clause_opt ::= */ - { 353, -2 }, /* (439) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 353, -4 }, /* (440) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 353, -4 }, /* (441) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 316, -3 }, /* (442) subquery ::= NK_LP query_expression NK_RP */ - { 337, -1 }, /* (443) search_condition ::= common_expression */ - { 355, -1 }, /* (444) sort_specification_list ::= sort_specification */ - { 355, -3 }, /* (445) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 356, -3 }, /* (446) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 357, 0 }, /* (447) ordering_specification_opt ::= */ - { 357, -1 }, /* (448) ordering_specification_opt ::= ASC */ - { 357, -1 }, /* (449) ordering_specification_opt ::= DESC */ - { 358, 0 }, /* (450) null_ordering_opt ::= */ - { 358, -2 }, /* (451) null_ordering_opt ::= NULLS FIRST */ - { 358, -2 }, /* (452) null_ordering_opt ::= NULLS LAST */ + { 240, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + { 240, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + { 241, 0 }, /* (2) account_options ::= */ + { 241, -3 }, /* (3) account_options ::= account_options PPS literal */ + { 241, -3 }, /* (4) account_options ::= account_options TSERIES literal */ + { 241, -3 }, /* (5) account_options ::= account_options STORAGE literal */ + { 241, -3 }, /* (6) account_options ::= account_options STREAMS literal */ + { 241, -3 }, /* (7) account_options ::= account_options QTIME literal */ + { 241, -3 }, /* (8) account_options ::= account_options DBS literal */ + { 241, -3 }, /* (9) account_options ::= account_options USERS literal */ + { 241, -3 }, /* (10) account_options ::= account_options CONNS literal */ + { 241, -3 }, /* (11) account_options ::= account_options STATE literal */ + { 242, -1 }, /* (12) alter_account_options ::= alter_account_option */ + { 242, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + { 244, -2 }, /* (14) alter_account_option ::= PASS literal */ + { 244, -2 }, /* (15) alter_account_option ::= PPS literal */ + { 244, -2 }, /* (16) alter_account_option ::= TSERIES literal */ + { 244, -2 }, /* (17) alter_account_option ::= STORAGE literal */ + { 244, -2 }, /* (18) alter_account_option ::= STREAMS literal */ + { 244, -2 }, /* (19) alter_account_option ::= QTIME literal */ + { 244, -2 }, /* (20) alter_account_option ::= DBS literal */ + { 244, -2 }, /* (21) alter_account_option ::= USERS literal */ + { 244, -2 }, /* (22) alter_account_option ::= CONNS literal */ + { 244, -2 }, /* (23) alter_account_option ::= STATE literal */ + { 240, -5 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING */ + { 240, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 240, -5 }, /* (26) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ + { 240, -3 }, /* (27) cmd ::= DROP USER user_name */ + { 240, -6 }, /* (28) cmd ::= GRANT privileges ON priv_level TO user_name */ + { 240, -6 }, /* (29) cmd ::= REVOKE privileges ON priv_level FROM user_name */ + { 246, -1 }, /* (30) privileges ::= ALL */ + { 246, -1 }, /* (31) privileges ::= priv_type_list */ + { 248, -1 }, /* (32) priv_type_list ::= priv_type */ + { 248, -3 }, /* (33) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + { 249, -1 }, /* (34) priv_type ::= READ */ + { 249, -1 }, /* (35) priv_type ::= WRITE */ + { 247, -3 }, /* (36) priv_level ::= NK_STAR NK_DOT NK_STAR */ + { 247, -3 }, /* (37) priv_level ::= db_name NK_DOT NK_STAR */ + { 240, -3 }, /* (38) cmd ::= CREATE DNODE dnode_endpoint */ + { 240, -5 }, /* (39) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ + { 240, -3 }, /* (40) cmd ::= DROP DNODE NK_INTEGER */ + { 240, -3 }, /* (41) cmd ::= DROP DNODE dnode_endpoint */ + { 240, -4 }, /* (42) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + { 240, -5 }, /* (43) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + { 240, -4 }, /* (44) cmd ::= ALTER ALL DNODES NK_STRING */ + { 240, -5 }, /* (45) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + { 251, -1 }, /* (46) dnode_endpoint ::= NK_STRING */ + { 252, -1 }, /* (47) dnode_host_name ::= NK_ID */ + { 252, -1 }, /* (48) dnode_host_name ::= NK_IPTOKEN */ + { 240, -3 }, /* (49) cmd ::= ALTER LOCAL NK_STRING */ + { 240, -4 }, /* (50) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + { 240, -5 }, /* (51) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (52) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (53) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (54) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (55) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (56) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (57) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (58) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (59) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 240, -4 }, /* (60) cmd ::= DROP DATABASE exists_opt db_name */ + { 240, -2 }, /* (61) cmd ::= USE db_name */ + { 240, -4 }, /* (62) cmd ::= ALTER DATABASE db_name alter_db_options */ + { 253, -3 }, /* (63) not_exists_opt ::= IF NOT EXISTS */ + { 253, 0 }, /* (64) not_exists_opt ::= */ + { 255, -2 }, /* (65) exists_opt ::= IF EXISTS */ + { 255, 0 }, /* (66) exists_opt ::= */ + { 254, 0 }, /* (67) db_options ::= */ + { 254, -3 }, /* (68) db_options ::= db_options BUFFER NK_INTEGER */ + { 254, -3 }, /* (69) db_options ::= db_options CACHELAST NK_INTEGER */ + { 254, -3 }, /* (70) db_options ::= db_options COMP NK_INTEGER */ + { 254, -3 }, /* (71) db_options ::= db_options DAYS NK_INTEGER */ + { 254, -3 }, /* (72) db_options ::= db_options DAYS NK_VARIABLE */ + { 254, -3 }, /* (73) db_options ::= db_options FSYNC NK_INTEGER */ + { 254, -3 }, /* (74) db_options ::= db_options MAXROWS NK_INTEGER */ + { 254, -3 }, /* (75) db_options ::= db_options MINROWS NK_INTEGER */ + { 254, -3 }, /* (76) db_options ::= db_options KEEP integer_list */ + { 254, -3 }, /* (77) db_options ::= db_options KEEP variable_list */ + { 254, -3 }, /* (78) db_options ::= db_options PAGES NK_INTEGER */ + { 254, -3 }, /* (79) db_options ::= db_options PAGESIZE NK_INTEGER */ + { 254, -3 }, /* (80) db_options ::= db_options PRECISION NK_STRING */ + { 254, -3 }, /* (81) db_options ::= db_options REPLICA NK_INTEGER */ + { 254, -3 }, /* (82) db_options ::= db_options STRICT NK_INTEGER */ + { 254, -3 }, /* (83) db_options ::= db_options WAL NK_INTEGER */ + { 254, -3 }, /* (84) db_options ::= db_options VGROUPS NK_INTEGER */ + { 254, -3 }, /* (85) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 254, -3 }, /* (86) db_options ::= db_options RETENTIONS retention_list */ + { 254, -3 }, /* (87) db_options ::= db_options SCHEMALESS NK_INTEGER */ + { 256, -1 }, /* (88) alter_db_options ::= alter_db_option */ + { 256, -2 }, /* (89) alter_db_options ::= alter_db_options alter_db_option */ + { 260, -2 }, /* (90) alter_db_option ::= BUFFER NK_INTEGER */ + { 260, -2 }, /* (91) alter_db_option ::= CACHELAST NK_INTEGER */ + { 260, -2 }, /* (92) alter_db_option ::= FSYNC NK_INTEGER */ + { 260, -2 }, /* (93) alter_db_option ::= KEEP integer_list */ + { 260, -2 }, /* (94) alter_db_option ::= KEEP variable_list */ + { 260, -2 }, /* (95) alter_db_option ::= PAGES NK_INTEGER */ + { 260, -2 }, /* (96) alter_db_option ::= REPLICA NK_INTEGER */ + { 260, -2 }, /* (97) alter_db_option ::= STRICT NK_INTEGER */ + { 260, -2 }, /* (98) alter_db_option ::= WAL NK_INTEGER */ + { 257, -1 }, /* (99) integer_list ::= NK_INTEGER */ + { 257, -3 }, /* (100) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + { 258, -1 }, /* (101) variable_list ::= NK_VARIABLE */ + { 258, -3 }, /* (102) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + { 259, -1 }, /* (103) retention_list ::= retention */ + { 259, -3 }, /* (104) retention_list ::= retention_list NK_COMMA retention */ + { 261, -3 }, /* (105) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + { 240, -9 }, /* (106) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 240, -3 }, /* (107) cmd ::= CREATE TABLE multi_create_clause */ + { 240, -9 }, /* (108) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 240, -3 }, /* (109) cmd ::= DROP TABLE multi_drop_clause */ + { 240, -4 }, /* (110) cmd ::= DROP STABLE exists_opt full_table_name */ + { 240, -3 }, /* (111) cmd ::= ALTER TABLE alter_table_clause */ + { 240, -3 }, /* (112) cmd ::= ALTER STABLE alter_table_clause */ + { 269, -2 }, /* (113) alter_table_clause ::= full_table_name alter_table_options */ + { 269, -5 }, /* (114) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 269, -4 }, /* (115) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 269, -5 }, /* (116) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 269, -5 }, /* (117) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 269, -5 }, /* (118) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 269, -4 }, /* (119) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 269, -5 }, /* (120) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 269, -5 }, /* (121) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 269, -6 }, /* (122) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + { 266, -1 }, /* (123) multi_create_clause ::= create_subtable_clause */ + { 266, -2 }, /* (124) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 274, -10 }, /* (125) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options */ + { 268, -1 }, /* (126) multi_drop_clause ::= drop_table_clause */ + { 268, -2 }, /* (127) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 277, -2 }, /* (128) drop_table_clause ::= exists_opt full_table_name */ + { 275, 0 }, /* (129) specific_tags_opt ::= */ + { 275, -3 }, /* (130) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + { 262, -1 }, /* (131) full_table_name ::= table_name */ + { 262, -3 }, /* (132) full_table_name ::= db_name NK_DOT table_name */ + { 263, -1 }, /* (133) column_def_list ::= column_def */ + { 263, -3 }, /* (134) column_def_list ::= column_def_list NK_COMMA column_def */ + { 280, -2 }, /* (135) column_def ::= column_name type_name */ + { 280, -4 }, /* (136) column_def ::= column_name type_name COMMENT NK_STRING */ + { 272, -1 }, /* (137) type_name ::= BOOL */ + { 272, -1 }, /* (138) type_name ::= TINYINT */ + { 272, -1 }, /* (139) type_name ::= SMALLINT */ + { 272, -1 }, /* (140) type_name ::= INT */ + { 272, -1 }, /* (141) type_name ::= INTEGER */ + { 272, -1 }, /* (142) type_name ::= BIGINT */ + { 272, -1 }, /* (143) type_name ::= FLOAT */ + { 272, -1 }, /* (144) type_name ::= DOUBLE */ + { 272, -4 }, /* (145) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 272, -1 }, /* (146) type_name ::= TIMESTAMP */ + { 272, -4 }, /* (147) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 272, -2 }, /* (148) type_name ::= TINYINT UNSIGNED */ + { 272, -2 }, /* (149) type_name ::= SMALLINT UNSIGNED */ + { 272, -2 }, /* (150) type_name ::= INT UNSIGNED */ + { 272, -2 }, /* (151) type_name ::= BIGINT UNSIGNED */ + { 272, -1 }, /* (152) type_name ::= JSON */ + { 272, -4 }, /* (153) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 272, -1 }, /* (154) type_name ::= MEDIUMBLOB */ + { 272, -1 }, /* (155) type_name ::= BLOB */ + { 272, -4 }, /* (156) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 272, -1 }, /* (157) type_name ::= DECIMAL */ + { 272, -4 }, /* (158) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 272, -6 }, /* (159) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 264, 0 }, /* (160) tags_def_opt ::= */ + { 264, -1 }, /* (161) tags_def_opt ::= tags_def */ + { 267, -4 }, /* (162) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 265, 0 }, /* (163) table_options ::= */ + { 265, -3 }, /* (164) table_options ::= table_options COMMENT NK_STRING */ + { 265, -3 }, /* (165) table_options ::= table_options FILE_FACTOR NK_FLOAT */ + { 265, -5 }, /* (166) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ + { 265, -3 }, /* (167) table_options ::= table_options TTL NK_INTEGER */ + { 265, -5 }, /* (168) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 270, -1 }, /* (169) alter_table_options ::= alter_table_option */ + { 270, -2 }, /* (170) alter_table_options ::= alter_table_options alter_table_option */ + { 282, -2 }, /* (171) alter_table_option ::= COMMENT NK_STRING */ + { 282, -2 }, /* (172) alter_table_option ::= TTL NK_INTEGER */ + { 278, -1 }, /* (173) col_name_list ::= col_name */ + { 278, -3 }, /* (174) col_name_list ::= col_name_list NK_COMMA col_name */ + { 283, -1 }, /* (175) col_name ::= column_name */ + { 240, -2 }, /* (176) cmd ::= SHOW DNODES */ + { 240, -2 }, /* (177) cmd ::= SHOW USERS */ + { 240, -2 }, /* (178) cmd ::= SHOW DATABASES */ + { 240, -4 }, /* (179) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + { 240, -4 }, /* (180) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + { 240, -3 }, /* (181) cmd ::= SHOW db_name_cond_opt VGROUPS */ + { 240, -2 }, /* (182) cmd ::= SHOW MNODES */ + { 240, -2 }, /* (183) cmd ::= SHOW MODULES */ + { 240, -2 }, /* (184) cmd ::= SHOW QNODES */ + { 240, -2 }, /* (185) cmd ::= SHOW FUNCTIONS */ + { 240, -5 }, /* (186) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 240, -2 }, /* (187) cmd ::= SHOW STREAMS */ + { 240, -2 }, /* (188) cmd ::= SHOW ACCOUNTS */ + { 240, -2 }, /* (189) cmd ::= SHOW APPS */ + { 240, -2 }, /* (190) cmd ::= SHOW CONNECTIONS */ + { 240, -2 }, /* (191) cmd ::= SHOW LICENCE */ + { 240, -2 }, /* (192) cmd ::= SHOW GRANTS */ + { 240, -4 }, /* (193) cmd ::= SHOW CREATE DATABASE db_name */ + { 240, -4 }, /* (194) cmd ::= SHOW CREATE TABLE full_table_name */ + { 240, -4 }, /* (195) cmd ::= SHOW CREATE STABLE full_table_name */ + { 240, -2 }, /* (196) cmd ::= SHOW QUERIES */ + { 240, -2 }, /* (197) cmd ::= SHOW SCORES */ + { 240, -2 }, /* (198) cmd ::= SHOW TOPICS */ + { 240, -2 }, /* (199) cmd ::= SHOW VARIABLES */ + { 240, -2 }, /* (200) cmd ::= SHOW BNODES */ + { 240, -2 }, /* (201) cmd ::= SHOW SNODES */ + { 240, -2 }, /* (202) cmd ::= SHOW CLUSTER */ + { 240, -2 }, /* (203) cmd ::= SHOW TRANSACTIONS */ + { 284, 0 }, /* (204) db_name_cond_opt ::= */ + { 284, -2 }, /* (205) db_name_cond_opt ::= db_name NK_DOT */ + { 285, 0 }, /* (206) like_pattern_opt ::= */ + { 285, -2 }, /* (207) like_pattern_opt ::= LIKE NK_STRING */ + { 286, -1 }, /* (208) table_name_cond ::= table_name */ + { 287, 0 }, /* (209) from_db_opt ::= */ + { 287, -2 }, /* (210) from_db_opt ::= FROM db_name */ + { 281, -1 }, /* (211) func_name_list ::= func_name */ + { 281, -3 }, /* (212) func_name_list ::= func_name_list NK_COMMA func_name */ + { 288, -1 }, /* (213) func_name ::= function_name */ + { 240, -8 }, /* (214) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ + { 240, -10 }, /* (215) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ + { 240, -6 }, /* (216) cmd ::= DROP INDEX exists_opt index_name ON table_name */ + { 291, 0 }, /* (217) index_options ::= */ + { 291, -9 }, /* (218) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ + { 291, -11 }, /* (219) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ + { 292, -1 }, /* (220) func_list ::= func */ + { 292, -3 }, /* (221) func_list ::= func_list NK_COMMA func */ + { 295, -4 }, /* (222) func ::= function_name NK_LP expression_list NK_RP */ + { 240, -6 }, /* (223) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ + { 240, -7 }, /* (224) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ + { 240, -7 }, /* (225) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ + { 240, -4 }, /* (226) cmd ::= DROP TOPIC exists_opt topic_name */ + { 240, -7 }, /* (227) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + { 240, -2 }, /* (228) cmd ::= DESC full_table_name */ + { 240, -2 }, /* (229) cmd ::= DESCRIBE full_table_name */ + { 240, -3 }, /* (230) cmd ::= RESET QUERY CACHE */ + { 240, -4 }, /* (231) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ + { 300, 0 }, /* (232) analyze_opt ::= */ + { 300, -1 }, /* (233) analyze_opt ::= ANALYZE */ + { 301, 0 }, /* (234) explain_options ::= */ + { 301, -3 }, /* (235) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 301, -3 }, /* (236) explain_options ::= explain_options RATIO NK_FLOAT */ + { 240, -6 }, /* (237) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ + { 240, -10 }, /* (238) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + { 240, -4 }, /* (239) cmd ::= DROP FUNCTION exists_opt function_name */ + { 302, 0 }, /* (240) agg_func_opt ::= */ + { 302, -1 }, /* (241) agg_func_opt ::= AGGREGATE */ + { 303, 0 }, /* (242) bufsize_opt ::= */ + { 303, -2 }, /* (243) bufsize_opt ::= BUFSIZE NK_INTEGER */ + { 240, -8 }, /* (244) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ + { 240, -4 }, /* (245) cmd ::= DROP STREAM exists_opt stream_name */ + { 306, 0 }, /* (246) into_opt ::= */ + { 306, -2 }, /* (247) into_opt ::= INTO full_table_name */ + { 305, 0 }, /* (248) stream_options ::= */ + { 305, -3 }, /* (249) stream_options ::= stream_options TRIGGER AT_ONCE */ + { 305, -3 }, /* (250) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + { 305, -4 }, /* (251) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + { 305, -3 }, /* (252) stream_options ::= stream_options WATERMARK duration_literal */ + { 240, -3 }, /* (253) cmd ::= KILL CONNECTION NK_INTEGER */ + { 240, -3 }, /* (254) cmd ::= KILL QUERY NK_INTEGER */ + { 240, -3 }, /* (255) cmd ::= KILL TRANSACTION NK_INTEGER */ + { 240, -2 }, /* (256) cmd ::= BALANCE VGROUP */ + { 240, -4 }, /* (257) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + { 240, -4 }, /* (258) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + { 240, -3 }, /* (259) cmd ::= SPLIT VGROUP NK_INTEGER */ + { 307, -2 }, /* (260) dnode_list ::= DNODE NK_INTEGER */ + { 307, -3 }, /* (261) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 240, -3 }, /* (262) cmd ::= SYNCDB db_name REPLICA */ + { 240, -4 }, /* (263) cmd ::= DELETE FROM full_table_name where_clause_opt */ + { 240, -1 }, /* (264) cmd ::= query_expression */ + { 243, -1 }, /* (265) literal ::= NK_INTEGER */ + { 243, -1 }, /* (266) literal ::= NK_FLOAT */ + { 243, -1 }, /* (267) literal ::= NK_STRING */ + { 243, -1 }, /* (268) literal ::= NK_BOOL */ + { 243, -2 }, /* (269) literal ::= TIMESTAMP NK_STRING */ + { 243, -1 }, /* (270) literal ::= duration_literal */ + { 243, -1 }, /* (271) literal ::= NULL */ + { 243, -1 }, /* (272) literal ::= NK_QUESTION */ + { 293, -1 }, /* (273) duration_literal ::= NK_VARIABLE */ + { 309, -1 }, /* (274) signed ::= NK_INTEGER */ + { 309, -2 }, /* (275) signed ::= NK_PLUS NK_INTEGER */ + { 309, -2 }, /* (276) signed ::= NK_MINUS NK_INTEGER */ + { 309, -1 }, /* (277) signed ::= NK_FLOAT */ + { 309, -2 }, /* (278) signed ::= NK_PLUS NK_FLOAT */ + { 309, -2 }, /* (279) signed ::= NK_MINUS NK_FLOAT */ + { 273, -1 }, /* (280) signed_literal ::= signed */ + { 273, -1 }, /* (281) signed_literal ::= NK_STRING */ + { 273, -1 }, /* (282) signed_literal ::= NK_BOOL */ + { 273, -2 }, /* (283) signed_literal ::= TIMESTAMP NK_STRING */ + { 273, -1 }, /* (284) signed_literal ::= duration_literal */ + { 273, -1 }, /* (285) signed_literal ::= NULL */ + { 273, -1 }, /* (286) signed_literal ::= literal_func */ + { 276, -1 }, /* (287) literal_list ::= signed_literal */ + { 276, -3 }, /* (288) literal_list ::= literal_list NK_COMMA signed_literal */ + { 250, -1 }, /* (289) db_name ::= NK_ID */ + { 279, -1 }, /* (290) table_name ::= NK_ID */ + { 271, -1 }, /* (291) column_name ::= NK_ID */ + { 289, -1 }, /* (292) function_name ::= NK_ID */ + { 311, -1 }, /* (293) table_alias ::= NK_ID */ + { 312, -1 }, /* (294) column_alias ::= NK_ID */ + { 245, -1 }, /* (295) user_name ::= NK_ID */ + { 290, -1 }, /* (296) index_name ::= NK_ID */ + { 297, -1 }, /* (297) topic_name ::= NK_ID */ + { 304, -1 }, /* (298) stream_name ::= NK_ID */ + { 299, -1 }, /* (299) cgroup_name ::= NK_ID */ + { 313, -1 }, /* (300) expression ::= literal */ + { 313, -1 }, /* (301) expression ::= pseudo_column */ + { 313, -1 }, /* (302) expression ::= column_reference */ + { 313, -1 }, /* (303) expression ::= function_expression */ + { 313, -1 }, /* (304) expression ::= subquery */ + { 313, -3 }, /* (305) expression ::= NK_LP expression NK_RP */ + { 313, -2 }, /* (306) expression ::= NK_PLUS expression */ + { 313, -2 }, /* (307) expression ::= NK_MINUS expression */ + { 313, -3 }, /* (308) expression ::= expression NK_PLUS expression */ + { 313, -3 }, /* (309) expression ::= expression NK_MINUS expression */ + { 313, -3 }, /* (310) expression ::= expression NK_STAR expression */ + { 313, -3 }, /* (311) expression ::= expression NK_SLASH expression */ + { 313, -3 }, /* (312) expression ::= expression NK_REM expression */ + { 313, -3 }, /* (313) expression ::= column_reference NK_ARROW NK_STRING */ + { 296, -1 }, /* (314) expression_list ::= expression */ + { 296, -3 }, /* (315) expression_list ::= expression_list NK_COMMA expression */ + { 315, -1 }, /* (316) column_reference ::= column_name */ + { 315, -3 }, /* (317) column_reference ::= table_name NK_DOT column_name */ + { 314, -1 }, /* (318) pseudo_column ::= ROWTS */ + { 314, -1 }, /* (319) pseudo_column ::= TBNAME */ + { 314, -3 }, /* (320) pseudo_column ::= table_name NK_DOT TBNAME */ + { 314, -1 }, /* (321) pseudo_column ::= QSTARTTS */ + { 314, -1 }, /* (322) pseudo_column ::= QENDTS */ + { 314, -1 }, /* (323) pseudo_column ::= WSTARTTS */ + { 314, -1 }, /* (324) pseudo_column ::= WENDTS */ + { 314, -1 }, /* (325) pseudo_column ::= WDURATION */ + { 316, -4 }, /* (326) function_expression ::= function_name NK_LP expression_list NK_RP */ + { 316, -4 }, /* (327) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + { 316, -6 }, /* (328) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ + { 316, -1 }, /* (329) function_expression ::= literal_func */ + { 310, -3 }, /* (330) literal_func ::= noarg_func NK_LP NK_RP */ + { 310, -1 }, /* (331) literal_func ::= NOW */ + { 320, -1 }, /* (332) noarg_func ::= NOW */ + { 320, -1 }, /* (333) noarg_func ::= TODAY */ + { 320, -1 }, /* (334) noarg_func ::= TIMEZONE */ + { 318, -1 }, /* (335) star_func ::= COUNT */ + { 318, -1 }, /* (336) star_func ::= FIRST */ + { 318, -1 }, /* (337) star_func ::= LAST */ + { 318, -1 }, /* (338) star_func ::= LAST_ROW */ + { 319, -1 }, /* (339) star_func_para_list ::= NK_STAR */ + { 319, -1 }, /* (340) star_func_para_list ::= other_para_list */ + { 321, -1 }, /* (341) other_para_list ::= star_func_para */ + { 321, -3 }, /* (342) other_para_list ::= other_para_list NK_COMMA star_func_para */ + { 322, -1 }, /* (343) star_func_para ::= expression */ + { 322, -3 }, /* (344) star_func_para ::= table_name NK_DOT NK_STAR */ + { 323, -3 }, /* (345) predicate ::= expression compare_op expression */ + { 323, -5 }, /* (346) predicate ::= expression BETWEEN expression AND expression */ + { 323, -6 }, /* (347) predicate ::= expression NOT BETWEEN expression AND expression */ + { 323, -3 }, /* (348) predicate ::= expression IS NULL */ + { 323, -4 }, /* (349) predicate ::= expression IS NOT NULL */ + { 323, -3 }, /* (350) predicate ::= expression in_op in_predicate_value */ + { 324, -1 }, /* (351) compare_op ::= NK_LT */ + { 324, -1 }, /* (352) compare_op ::= NK_GT */ + { 324, -1 }, /* (353) compare_op ::= NK_LE */ + { 324, -1 }, /* (354) compare_op ::= NK_GE */ + { 324, -1 }, /* (355) compare_op ::= NK_NE */ + { 324, -1 }, /* (356) compare_op ::= NK_EQ */ + { 324, -1 }, /* (357) compare_op ::= LIKE */ + { 324, -2 }, /* (358) compare_op ::= NOT LIKE */ + { 324, -1 }, /* (359) compare_op ::= MATCH */ + { 324, -1 }, /* (360) compare_op ::= NMATCH */ + { 324, -1 }, /* (361) compare_op ::= CONTAINS */ + { 325, -1 }, /* (362) in_op ::= IN */ + { 325, -2 }, /* (363) in_op ::= NOT IN */ + { 326, -3 }, /* (364) in_predicate_value ::= NK_LP expression_list NK_RP */ + { 327, -1 }, /* (365) boolean_value_expression ::= boolean_primary */ + { 327, -2 }, /* (366) boolean_value_expression ::= NOT boolean_primary */ + { 327, -3 }, /* (367) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 327, -3 }, /* (368) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 328, -1 }, /* (369) boolean_primary ::= predicate */ + { 328, -3 }, /* (370) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 329, -1 }, /* (371) common_expression ::= expression */ + { 329, -1 }, /* (372) common_expression ::= boolean_value_expression */ + { 330, -2 }, /* (373) from_clause ::= FROM table_reference_list */ + { 331, -1 }, /* (374) table_reference_list ::= table_reference */ + { 331, -3 }, /* (375) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 332, -1 }, /* (376) table_reference ::= table_primary */ + { 332, -1 }, /* (377) table_reference ::= joined_table */ + { 333, -2 }, /* (378) table_primary ::= table_name alias_opt */ + { 333, -4 }, /* (379) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 333, -2 }, /* (380) table_primary ::= subquery alias_opt */ + { 333, -1 }, /* (381) table_primary ::= parenthesized_joined_table */ + { 335, 0 }, /* (382) alias_opt ::= */ + { 335, -1 }, /* (383) alias_opt ::= table_alias */ + { 335, -2 }, /* (384) alias_opt ::= AS table_alias */ + { 336, -3 }, /* (385) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 336, -3 }, /* (386) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 334, -6 }, /* (387) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 337, 0 }, /* (388) join_type ::= */ + { 337, -1 }, /* (389) join_type ::= INNER */ + { 339, -9 }, /* (390) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + { 340, 0 }, /* (391) set_quantifier_opt ::= */ + { 340, -1 }, /* (392) set_quantifier_opt ::= DISTINCT */ + { 340, -1 }, /* (393) set_quantifier_opt ::= ALL */ + { 341, -1 }, /* (394) select_list ::= NK_STAR */ + { 341, -1 }, /* (395) select_list ::= select_sublist */ + { 346, -1 }, /* (396) select_sublist ::= select_item */ + { 346, -3 }, /* (397) select_sublist ::= select_sublist NK_COMMA select_item */ + { 347, -1 }, /* (398) select_item ::= common_expression */ + { 347, -2 }, /* (399) select_item ::= common_expression column_alias */ + { 347, -3 }, /* (400) select_item ::= common_expression AS column_alias */ + { 347, -3 }, /* (401) select_item ::= table_name NK_DOT NK_STAR */ + { 308, 0 }, /* (402) where_clause_opt ::= */ + { 308, -2 }, /* (403) where_clause_opt ::= WHERE search_condition */ + { 342, 0 }, /* (404) partition_by_clause_opt ::= */ + { 342, -3 }, /* (405) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 343, 0 }, /* (406) twindow_clause_opt ::= */ + { 343, -6 }, /* (407) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 343, -4 }, /* (408) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ + { 343, -6 }, /* (409) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 343, -8 }, /* (410) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 294, 0 }, /* (411) sliding_opt ::= */ + { 294, -4 }, /* (412) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 348, 0 }, /* (413) fill_opt ::= */ + { 348, -4 }, /* (414) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 348, -6 }, /* (415) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 349, -1 }, /* (416) fill_mode ::= NONE */ + { 349, -1 }, /* (417) fill_mode ::= PREV */ + { 349, -1 }, /* (418) fill_mode ::= NULL */ + { 349, -1 }, /* (419) fill_mode ::= LINEAR */ + { 349, -1 }, /* (420) fill_mode ::= NEXT */ + { 344, 0 }, /* (421) group_by_clause_opt ::= */ + { 344, -3 }, /* (422) group_by_clause_opt ::= GROUP BY group_by_list */ + { 350, -1 }, /* (423) group_by_list ::= expression */ + { 350, -3 }, /* (424) group_by_list ::= group_by_list NK_COMMA expression */ + { 345, 0 }, /* (425) having_clause_opt ::= */ + { 345, -2 }, /* (426) having_clause_opt ::= HAVING search_condition */ + { 298, -4 }, /* (427) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 351, -1 }, /* (428) query_expression_body ::= query_primary */ + { 351, -4 }, /* (429) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 351, -3 }, /* (430) query_expression_body ::= query_expression_body UNION query_expression_body */ + { 355, -1 }, /* (431) query_primary ::= query_specification */ + { 355, -6 }, /* (432) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ + { 352, 0 }, /* (433) order_by_clause_opt ::= */ + { 352, -3 }, /* (434) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 353, 0 }, /* (435) slimit_clause_opt ::= */ + { 353, -2 }, /* (436) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 353, -4 }, /* (437) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 353, -4 }, /* (438) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 354, 0 }, /* (439) limit_clause_opt ::= */ + { 354, -2 }, /* (440) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 354, -4 }, /* (441) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 354, -4 }, /* (442) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 317, -3 }, /* (443) subquery ::= NK_LP query_expression NK_RP */ + { 338, -1 }, /* (444) search_condition ::= common_expression */ + { 356, -1 }, /* (445) sort_specification_list ::= sort_specification */ + { 356, -3 }, /* (446) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 357, -3 }, /* (447) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 358, 0 }, /* (448) ordering_specification_opt ::= */ + { 358, -1 }, /* (449) ordering_specification_opt ::= ASC */ + { 358, -1 }, /* (450) ordering_specification_opt ::= DESC */ + { 359, 0 }, /* (451) null_ordering_opt ::= */ + { 359, -2 }, /* (452) null_ordering_opt ::= NULLS FIRST */ + { 359, -2 }, /* (453) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3108,11 +3117,11 @@ static YYACTIONTYPE yy_reduce( YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,240,&yymsp[0].minor); + yy_destructor(yypParser,241,&yymsp[0].minor); break; case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,241,&yymsp[0].minor); + yy_destructor(yypParser,242,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -3126,20 +3135,20 @@ static YYACTIONTYPE yy_reduce( case 9: /* account_options ::= account_options USERS literal */ yytestcase(yyruleno==9); case 10: /* account_options ::= account_options CONNS literal */ yytestcase(yyruleno==10); case 11: /* account_options ::= account_options STATE literal */ yytestcase(yyruleno==11); -{ yy_destructor(yypParser,240,&yymsp[-2].minor); +{ yy_destructor(yypParser,241,&yymsp[-2].minor); { } - yy_destructor(yypParser,242,&yymsp[0].minor); + yy_destructor(yypParser,243,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,243,&yymsp[0].minor); +{ yy_destructor(yypParser,244,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,241,&yymsp[-1].minor); +{ yy_destructor(yypParser,242,&yymsp[-1].minor); { } - yy_destructor(yypParser,243,&yymsp[0].minor); + yy_destructor(yypParser,244,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -3153,63 +3162,63 @@ static YYACTIONTYPE yy_reduce( case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22); case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); { } - yy_destructor(yypParser,242,&yymsp[0].minor); + yy_destructor(yypParser,243,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy421, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy209, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; case 26: /* cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy421, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy209, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } break; case 27: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy209); } break; case 28: /* cmd ::= GRANT privileges ON priv_level TO user_name */ -{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy669, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy189, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209); } break; case 29: /* cmd ::= REVOKE privileges ON priv_level FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy669, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy189, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209); } break; case 30: /* privileges ::= ALL */ -{ yymsp[0].minor.yy669 = PRIVILEGE_TYPE_ALL; } +{ yymsp[0].minor.yy189 = PRIVILEGE_TYPE_ALL; } break; case 31: /* privileges ::= priv_type_list */ case 32: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==32); -{ yylhsminor.yy669 = yymsp[0].minor.yy669; } - yymsp[0].minor.yy669 = yylhsminor.yy669; +{ yylhsminor.yy189 = yymsp[0].minor.yy189; } + yymsp[0].minor.yy189 = yylhsminor.yy189; break; case 33: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy669 = yymsp[-2].minor.yy669 | yymsp[0].minor.yy669; } - yymsp[-2].minor.yy669 = yylhsminor.yy669; +{ yylhsminor.yy189 = yymsp[-2].minor.yy189 | yymsp[0].minor.yy189; } + yymsp[-2].minor.yy189 = yylhsminor.yy189; break; case 34: /* priv_type ::= READ */ -{ yymsp[0].minor.yy669 = PRIVILEGE_TYPE_READ; } +{ yymsp[0].minor.yy189 = PRIVILEGE_TYPE_READ; } break; case 35: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy669 = PRIVILEGE_TYPE_WRITE; } +{ yymsp[0].minor.yy189 = PRIVILEGE_TYPE_WRITE; } break; case 36: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy421 = yymsp[-2].minor.yy0; } - yymsp[-2].minor.yy421 = yylhsminor.yy421; +{ yylhsminor.yy209 = yymsp[-2].minor.yy0; } + yymsp[-2].minor.yy209 = yylhsminor.yy209; break; case 37: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy421 = yymsp[-2].minor.yy421; } - yymsp[-2].minor.yy421 = yylhsminor.yy421; +{ yylhsminor.yy209 = yymsp[-2].minor.yy209; } + yymsp[-2].minor.yy209 = yylhsminor.yy209; break; case 38: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy421, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy209, NULL); } break; case 39: /* cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0); } break; case 40: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; case 41: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy209); } break; case 42: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -3226,26 +3235,26 @@ static YYACTIONTYPE yy_reduce( case 46: /* dnode_endpoint ::= NK_STRING */ case 47: /* dnode_host_name ::= NK_ID */ yytestcase(yyruleno==47); case 48: /* dnode_host_name ::= NK_IPTOKEN */ yytestcase(yyruleno==48); - case 288: /* db_name ::= NK_ID */ yytestcase(yyruleno==288); - case 289: /* table_name ::= NK_ID */ yytestcase(yyruleno==289); - case 290: /* column_name ::= NK_ID */ yytestcase(yyruleno==290); - case 291: /* function_name ::= NK_ID */ yytestcase(yyruleno==291); - case 292: /* table_alias ::= NK_ID */ yytestcase(yyruleno==292); - case 293: /* column_alias ::= NK_ID */ yytestcase(yyruleno==293); - case 294: /* user_name ::= NK_ID */ yytestcase(yyruleno==294); - case 295: /* index_name ::= NK_ID */ yytestcase(yyruleno==295); - case 296: /* topic_name ::= NK_ID */ yytestcase(yyruleno==296); - case 297: /* stream_name ::= NK_ID */ yytestcase(yyruleno==297); - case 298: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==298); - case 331: /* noarg_func ::= NOW */ yytestcase(yyruleno==331); - case 332: /* noarg_func ::= TODAY */ yytestcase(yyruleno==332); - case 333: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==333); - case 334: /* star_func ::= COUNT */ yytestcase(yyruleno==334); - case 335: /* star_func ::= FIRST */ yytestcase(yyruleno==335); - case 336: /* star_func ::= LAST */ yytestcase(yyruleno==336); - case 337: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==337); -{ yylhsminor.yy421 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy421 = yylhsminor.yy421; + case 289: /* db_name ::= NK_ID */ yytestcase(yyruleno==289); + case 290: /* table_name ::= NK_ID */ yytestcase(yyruleno==290); + case 291: /* column_name ::= NK_ID */ yytestcase(yyruleno==291); + case 292: /* function_name ::= NK_ID */ yytestcase(yyruleno==292); + case 293: /* table_alias ::= NK_ID */ yytestcase(yyruleno==293); + case 294: /* column_alias ::= NK_ID */ yytestcase(yyruleno==294); + case 295: /* user_name ::= NK_ID */ yytestcase(yyruleno==295); + case 296: /* index_name ::= NK_ID */ yytestcase(yyruleno==296); + case 297: /* topic_name ::= NK_ID */ yytestcase(yyruleno==297); + case 298: /* stream_name ::= NK_ID */ yytestcase(yyruleno==298); + case 299: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==299); + case 332: /* noarg_func ::= NOW */ yytestcase(yyruleno==332); + case 333: /* noarg_func ::= TODAY */ yytestcase(yyruleno==333); + case 334: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==334); + case 335: /* star_func ::= COUNT */ yytestcase(yyruleno==335); + case 336: /* star_func ::= FIRST */ yytestcase(yyruleno==336); + case 337: /* star_func ::= LAST */ yytestcase(yyruleno==337); + case 338: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==338); +{ yylhsminor.yy209 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy209 = yylhsminor.yy209; break; case 49: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -3278,156 +3287,156 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } break; case 59: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy621, &yymsp[-1].minor.yy421, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy137, &yymsp[-1].minor.yy209, yymsp[0].minor.yy632); } break; case 60: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy621, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy137, &yymsp[0].minor.yy209); } break; case 61: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy209); } break; case 62: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy421, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy209, yymsp[0].minor.yy632); } break; case 63: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy621 = true; } +{ yymsp[-2].minor.yy137 = true; } break; case 64: /* not_exists_opt ::= */ case 66: /* exists_opt ::= */ yytestcase(yyruleno==66); case 232: /* analyze_opt ::= */ yytestcase(yyruleno==232); case 240: /* agg_func_opt ::= */ yytestcase(yyruleno==240); - case 390: /* set_quantifier_opt ::= */ yytestcase(yyruleno==390); -{ yymsp[1].minor.yy621 = false; } + case 391: /* set_quantifier_opt ::= */ yytestcase(yyruleno==391); +{ yymsp[1].minor.yy137 = false; } break; case 65: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy621 = true; } +{ yymsp[-1].minor.yy137 = true; } break; case 67: /* db_options ::= */ -{ yymsp[1].minor.yy674 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy632 = createDefaultDatabaseOptions(pCxt); } break; case 68: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 69: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 70: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 71: /* db_options ::= db_options DAYS NK_INTEGER */ case 72: /* db_options ::= db_options DAYS NK_VARIABLE */ yytestcase(yyruleno==72); -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 73: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 74: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 75: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 76: /* db_options ::= db_options KEEP integer_list */ case 77: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==77); -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_KEEP, yymsp[0].minor.yy530); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_KEEP, yymsp[0].minor.yy424); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 78: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 79: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 80: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 81: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 82: /* db_options ::= db_options STRICT NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 83: /* db_options ::= db_options WAL NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 84: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 85: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 86: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_RETENTIONS, yymsp[0].minor.yy530); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_RETENTIONS, yymsp[0].minor.yy424); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 87: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy674 = setDatabaseOption(pCxt, yymsp[-2].minor.yy674, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setDatabaseOption(pCxt, yymsp[-2].minor.yy632, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 88: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy674 = createAlterDatabaseOptions(pCxt); yylhsminor.yy674 = setAlterDatabaseOption(pCxt, yylhsminor.yy674, &yymsp[0].minor.yy557); } - yymsp[0].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterDatabaseOptions(pCxt); yylhsminor.yy632 = setAlterDatabaseOption(pCxt, yylhsminor.yy632, &yymsp[0].minor.yy605); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; case 89: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy674 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy674, &yymsp[0].minor.yy557); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy632, &yymsp[0].minor.yy605); } + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; case 90: /* alter_db_option ::= BUFFER NK_INTEGER */ -{ yymsp[-1].minor.yy557.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy605.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy605.val = yymsp[0].minor.yy0; } break; case 91: /* alter_db_option ::= CACHELAST NK_INTEGER */ -{ yymsp[-1].minor.yy557.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy605.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy605.val = yymsp[0].minor.yy0; } break; case 92: /* alter_db_option ::= FSYNC NK_INTEGER */ -{ yymsp[-1].minor.yy557.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy605.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy605.val = yymsp[0].minor.yy0; } break; case 93: /* alter_db_option ::= KEEP integer_list */ case 94: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==94); -{ yymsp[-1].minor.yy557.type = DB_OPTION_KEEP; yymsp[-1].minor.yy557.pList = yymsp[0].minor.yy530; } +{ yymsp[-1].minor.yy605.type = DB_OPTION_KEEP; yymsp[-1].minor.yy605.pList = yymsp[0].minor.yy424; } break; case 95: /* alter_db_option ::= PAGES NK_INTEGER */ -{ yymsp[-1].minor.yy557.type = DB_OPTION_PAGES; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy605.type = DB_OPTION_PAGES; yymsp[-1].minor.yy605.val = yymsp[0].minor.yy0; } break; case 96: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy557.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy605.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy605.val = yymsp[0].minor.yy0; } break; case 97: /* alter_db_option ::= STRICT NK_INTEGER */ -{ yymsp[-1].minor.yy557.type = DB_OPTION_STRICT; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy605.type = DB_OPTION_STRICT; yymsp[-1].minor.yy605.val = yymsp[0].minor.yy0; } break; case 98: /* alter_db_option ::= WAL NK_INTEGER */ -{ yymsp[-1].minor.yy557.type = DB_OPTION_WAL; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy605.type = DB_OPTION_WAL; yymsp[-1].minor.yy605.val = yymsp[0].minor.yy0; } break; case 99: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy530 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy530 = yylhsminor.yy530; +{ yylhsminor.yy424 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy424 = yylhsminor.yy424; break; case 100: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 260: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==260); -{ yylhsminor.yy530 = addNodeToList(pCxt, yymsp[-2].minor.yy530, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy530 = yylhsminor.yy530; + case 261: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==261); +{ yylhsminor.yy424 = addNodeToList(pCxt, yymsp[-2].minor.yy424, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy424 = yylhsminor.yy424; break; case 101: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy530 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy530 = yylhsminor.yy530; +{ yylhsminor.yy424 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy424 = yylhsminor.yy424; break; case 102: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy530 = addNodeToList(pCxt, yymsp[-2].minor.yy530, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy530 = yylhsminor.yy530; +{ yylhsminor.yy424 = addNodeToList(pCxt, yymsp[-2].minor.yy424, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy424 = yylhsminor.yy424; break; case 103: /* retention_list ::= retention */ case 123: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==123); @@ -3436,242 +3445,242 @@ static YYACTIONTYPE yy_reduce( case 173: /* col_name_list ::= col_name */ yytestcase(yyruleno==173); case 211: /* func_name_list ::= func_name */ yytestcase(yyruleno==211); case 220: /* func_list ::= func */ yytestcase(yyruleno==220); - case 286: /* literal_list ::= signed_literal */ yytestcase(yyruleno==286); - case 340: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==340); - case 395: /* select_sublist ::= select_item */ yytestcase(yyruleno==395); - case 444: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==444); -{ yylhsminor.yy530 = createNodeList(pCxt, yymsp[0].minor.yy674); } - yymsp[0].minor.yy530 = yylhsminor.yy530; + case 287: /* literal_list ::= signed_literal */ yytestcase(yyruleno==287); + case 341: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==341); + case 396: /* select_sublist ::= select_item */ yytestcase(yyruleno==396); + case 445: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==445); +{ yylhsminor.yy424 = createNodeList(pCxt, yymsp[0].minor.yy632); } + yymsp[0].minor.yy424 = yylhsminor.yy424; break; case 104: /* retention_list ::= retention_list NK_COMMA retention */ case 134: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==134); case 174: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==174); case 212: /* func_name_list ::= func_name_list NK_COMMA func_name */ yytestcase(yyruleno==212); case 221: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==221); - case 287: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==287); - case 341: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==341); - case 396: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==396); - case 445: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==445); -{ yylhsminor.yy530 = addNodeToList(pCxt, yymsp[-2].minor.yy530, yymsp[0].minor.yy674); } - yymsp[-2].minor.yy530 = yylhsminor.yy530; + case 288: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==288); + case 342: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==342); + case 397: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==397); + case 446: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==446); +{ yylhsminor.yy424 = addNodeToList(pCxt, yymsp[-2].minor.yy424, yymsp[0].minor.yy632); } + yymsp[-2].minor.yy424 = yylhsminor.yy424; break; case 105: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -{ yylhsminor.yy674 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 106: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ case 108: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==108); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy621, yymsp[-5].minor.yy674, yymsp[-3].minor.yy530, yymsp[-1].minor.yy530, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy137, yymsp[-5].minor.yy632, yymsp[-3].minor.yy424, yymsp[-1].minor.yy424, yymsp[0].minor.yy632); } break; case 107: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy530); } +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy424); } break; case 109: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy530); } +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy424); } break; case 110: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy621, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy137, yymsp[0].minor.yy632); } break; case 111: /* cmd ::= ALTER TABLE alter_table_clause */ case 112: /* cmd ::= ALTER STABLE alter_table_clause */ yytestcase(yyruleno==112); - case 263: /* cmd ::= query_expression */ yytestcase(yyruleno==263); -{ pCxt->pRootNode = yymsp[0].minor.yy674; } + case 264: /* cmd ::= query_expression */ yytestcase(yyruleno==264); +{ pCxt->pRootNode = yymsp[0].minor.yy632; } break; case 113: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy674 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy674, yymsp[0].minor.yy674); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy632, yymsp[0].minor.yy632); } + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; case 114: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy674 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy674, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy421, yymsp[0].minor.yy690); } - yymsp[-4].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy632, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy209, yymsp[0].minor.yy304); } + yymsp[-4].minor.yy632 = yylhsminor.yy632; break; case 115: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy674 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy674, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy421); } - yymsp[-3].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy632, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy209); } + yymsp[-3].minor.yy632 = yylhsminor.yy632; break; case 116: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy674 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy674, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy421, yymsp[0].minor.yy690); } - yymsp[-4].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy632, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy209, yymsp[0].minor.yy304); } + yymsp[-4].minor.yy632 = yylhsminor.yy632; break; case 117: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy674 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy674, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy421, &yymsp[0].minor.yy421); } - yymsp[-4].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy632, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy209, &yymsp[0].minor.yy209); } + yymsp[-4].minor.yy632 = yylhsminor.yy632; break; case 118: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy674 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy674, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy421, yymsp[0].minor.yy690); } - yymsp[-4].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy632, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy209, yymsp[0].minor.yy304); } + yymsp[-4].minor.yy632 = yylhsminor.yy632; break; case 119: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy674 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy674, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy421); } - yymsp[-3].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy632, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy209); } + yymsp[-3].minor.yy632 = yylhsminor.yy632; break; case 120: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy674 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy674, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy421, yymsp[0].minor.yy690); } - yymsp[-4].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy632, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy209, yymsp[0].minor.yy304); } + yymsp[-4].minor.yy632 = yylhsminor.yy632; break; case 121: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy674 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy674, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy421, &yymsp[0].minor.yy421); } - yymsp[-4].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy632, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy209, &yymsp[0].minor.yy209); } + yymsp[-4].minor.yy632 = yylhsminor.yy632; break; case 122: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy674 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy674, &yymsp[-2].minor.yy421, yymsp[0].minor.yy674); } - yymsp[-5].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy632, &yymsp[-2].minor.yy209, yymsp[0].minor.yy632); } + yymsp[-5].minor.yy632 = yylhsminor.yy632; break; case 124: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ case 127: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==127); -{ yylhsminor.yy530 = addNodeToList(pCxt, yymsp[-1].minor.yy530, yymsp[0].minor.yy674); } - yymsp[-1].minor.yy530 = yylhsminor.yy530; +{ yylhsminor.yy424 = addNodeToList(pCxt, yymsp[-1].minor.yy424, yymsp[0].minor.yy632); } + yymsp[-1].minor.yy424 = yylhsminor.yy424; break; case 125: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options */ -{ yylhsminor.yy674 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy621, yymsp[-8].minor.yy674, yymsp[-6].minor.yy674, yymsp[-5].minor.yy530, yymsp[-2].minor.yy530, yymsp[0].minor.yy674); } - yymsp[-9].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy137, yymsp[-8].minor.yy632, yymsp[-6].minor.yy632, yymsp[-5].minor.yy424, yymsp[-2].minor.yy424, yymsp[0].minor.yy632); } + yymsp[-9].minor.yy632 = yylhsminor.yy632; break; case 128: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy674 = createDropTableClause(pCxt, yymsp[-1].minor.yy621, yymsp[0].minor.yy674); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createDropTableClause(pCxt, yymsp[-1].minor.yy137, yymsp[0].minor.yy632); } + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; case 129: /* specific_tags_opt ::= */ case 160: /* tags_def_opt ::= */ yytestcase(yyruleno==160); - case 403: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==403); - case 420: /* group_by_clause_opt ::= */ yytestcase(yyruleno==420); - case 432: /* order_by_clause_opt ::= */ yytestcase(yyruleno==432); -{ yymsp[1].minor.yy530 = NULL; } + case 404: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==404); + case 421: /* group_by_clause_opt ::= */ yytestcase(yyruleno==421); + case 433: /* order_by_clause_opt ::= */ yytestcase(yyruleno==433); +{ yymsp[1].minor.yy424 = NULL; } break; case 130: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy530 = yymsp[-1].minor.yy530; } +{ yymsp[-2].minor.yy424 = yymsp[-1].minor.yy424; } break; case 131: /* full_table_name ::= table_name */ -{ yylhsminor.yy674 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy421, NULL); } - yymsp[0].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy209, NULL); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; case 132: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy674 = createRealTableNode(pCxt, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy421, NULL); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createRealTableNode(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209, NULL); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 135: /* column_def ::= column_name type_name */ -{ yylhsminor.yy674 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy421, yymsp[0].minor.yy690, NULL); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy209, yymsp[0].minor.yy304, NULL); } + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; case 136: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy674 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy421, yymsp[-2].minor.yy690, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-2].minor.yy304, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy632 = yylhsminor.yy632; break; case 137: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_BOOL); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_BOOL); } break; case 138: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_TINYINT); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; case 139: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; case 140: /* type_name ::= INT */ case 141: /* type_name ::= INTEGER */ yytestcase(yyruleno==141); -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_INT); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_INT); } break; case 142: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_BIGINT); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; case 143: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_FLOAT); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; case 144: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; case 145: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy690 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; case 146: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; case 147: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy690 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; case 148: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy690 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; case 149: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy690 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; case 150: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy690 = createDataType(TSDB_DATA_TYPE_UINT); } +{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_UINT); } break; case 151: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy690 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; case 152: /* type_name ::= JSON */ -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_JSON); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_JSON); } break; case 153: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy690 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; case 154: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; case 155: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_BLOB); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_BLOB); } break; case 156: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy690 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; case 157: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy690 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 158: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy690 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-3].minor.yy304 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 159: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy690 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-5].minor.yy304 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 161: /* tags_def_opt ::= tags_def */ - case 339: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==339); - case 394: /* select_list ::= select_sublist */ yytestcase(yyruleno==394); -{ yylhsminor.yy530 = yymsp[0].minor.yy530; } - yymsp[0].minor.yy530 = yylhsminor.yy530; + case 340: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==340); + case 395: /* select_list ::= select_sublist */ yytestcase(yyruleno==395); +{ yylhsminor.yy424 = yymsp[0].minor.yy424; } + yymsp[0].minor.yy424 = yylhsminor.yy424; break; case 162: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy530 = yymsp[-1].minor.yy530; } +{ yymsp[-3].minor.yy424 = yymsp[-1].minor.yy424; } break; case 163: /* table_options ::= */ -{ yymsp[1].minor.yy674 = createDefaultTableOptions(pCxt); } +{ yymsp[1].minor.yy632 = createDefaultTableOptions(pCxt); } break; case 164: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy674 = setTableOption(pCxt, yymsp[-2].minor.yy674, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setTableOption(pCxt, yymsp[-2].minor.yy632, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 165: /* table_options ::= table_options FILE_FACTOR NK_FLOAT */ -{ yylhsminor.yy674 = setTableOption(pCxt, yymsp[-2].minor.yy674, TABLE_OPTION_FILE_FACTOR, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setTableOption(pCxt, yymsp[-2].minor.yy632, TABLE_OPTION_FILE_FACTOR, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 166: /* table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ -{ yylhsminor.yy674 = setTableOption(pCxt, yymsp[-4].minor.yy674, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy530); } - yymsp[-4].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setTableOption(pCxt, yymsp[-4].minor.yy632, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy424); } + yymsp[-4].minor.yy632 = yylhsminor.yy632; break; case 167: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy674 = setTableOption(pCxt, yymsp[-2].minor.yy674, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setTableOption(pCxt, yymsp[-2].minor.yy632, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 168: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy674 = setTableOption(pCxt, yymsp[-4].minor.yy674, TABLE_OPTION_SMA, yymsp[-1].minor.yy530); } - yymsp[-4].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setTableOption(pCxt, yymsp[-4].minor.yy632, TABLE_OPTION_SMA, yymsp[-1].minor.yy424); } + yymsp[-4].minor.yy632 = yylhsminor.yy632; break; case 169: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy674 = createAlterTableOptions(pCxt); yylhsminor.yy674 = setTableOption(pCxt, yylhsminor.yy674, yymsp[0].minor.yy557.type, &yymsp[0].minor.yy557.val); } - yymsp[0].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createAlterTableOptions(pCxt); yylhsminor.yy632 = setTableOption(pCxt, yylhsminor.yy632, yymsp[0].minor.yy605.type, &yymsp[0].minor.yy605.val); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; case 170: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy674 = setTableOption(pCxt, yymsp[-1].minor.yy674, yymsp[0].minor.yy557.type, &yymsp[0].minor.yy557.val); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setTableOption(pCxt, yymsp[-1].minor.yy632, yymsp[0].minor.yy605.type, &yymsp[0].minor.yy605.val); } + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; case 171: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy557.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy605.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy605.val = yymsp[0].minor.yy0; } break; case 172: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy557.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy605.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy605.val = yymsp[0].minor.yy0; } break; case 175: /* col_name ::= column_name */ -{ yylhsminor.yy674 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy421); } - yymsp[0].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy209); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; case 176: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL, NULL); } @@ -3683,13 +3692,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL, NULL); } break; case 179: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy674, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy632, yymsp[0].minor.yy632); } break; case 180: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy674, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy632, yymsp[0].minor.yy632); } break; case 181: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy674, NULL); } +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy632, NULL); } break; case 182: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT, NULL, NULL); } @@ -3704,7 +3713,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT, NULL, NULL); } break; case 186: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[-1].minor.yy674, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[-1].minor.yy632, yymsp[0].minor.yy632); } break; case 187: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT, NULL, NULL); } @@ -3723,13 +3732,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE_STMT, NULL, NULL); } break; case 193: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy209); } break; case 194: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy632); } break; case 195: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy632); } break; case 196: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT, NULL, NULL); } @@ -3757,672 +3766,676 @@ static YYACTIONTYPE yy_reduce( break; case 204: /* db_name_cond_opt ::= */ case 209: /* from_db_opt ::= */ yytestcase(yyruleno==209); -{ yymsp[1].minor.yy674 = createDefaultDatabaseCondValue(pCxt); } +{ yymsp[1].minor.yy632 = createDefaultDatabaseCondValue(pCxt); } break; case 205: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy421); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy209); } + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; case 206: /* like_pattern_opt ::= */ case 217: /* index_options ::= */ yytestcase(yyruleno==217); case 246: /* into_opt ::= */ yytestcase(yyruleno==246); - case 401: /* where_clause_opt ::= */ yytestcase(yyruleno==401); - case 405: /* twindow_clause_opt ::= */ yytestcase(yyruleno==405); - case 410: /* sliding_opt ::= */ yytestcase(yyruleno==410); - case 412: /* fill_opt ::= */ yytestcase(yyruleno==412); - case 424: /* having_clause_opt ::= */ yytestcase(yyruleno==424); - case 434: /* slimit_clause_opt ::= */ yytestcase(yyruleno==434); - case 438: /* limit_clause_opt ::= */ yytestcase(yyruleno==438); -{ yymsp[1].minor.yy674 = NULL; } + case 402: /* where_clause_opt ::= */ yytestcase(yyruleno==402); + case 406: /* twindow_clause_opt ::= */ yytestcase(yyruleno==406); + case 411: /* sliding_opt ::= */ yytestcase(yyruleno==411); + case 413: /* fill_opt ::= */ yytestcase(yyruleno==413); + case 425: /* having_clause_opt ::= */ yytestcase(yyruleno==425); + case 435: /* slimit_clause_opt ::= */ yytestcase(yyruleno==435); + case 439: /* limit_clause_opt ::= */ yytestcase(yyruleno==439); +{ yymsp[1].minor.yy632 = NULL; } break; case 207: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; case 208: /* table_name_cond ::= table_name */ -{ yylhsminor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy421); } - yymsp[0].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy209); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; case 210: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy421); } +{ yymsp[-1].minor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy209); } break; case 213: /* func_name ::= function_name */ -{ yylhsminor.yy674 = createFunctionNode(pCxt, &yymsp[0].minor.yy421, NULL); } - yymsp[0].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createFunctionNode(pCxt, &yymsp[0].minor.yy209, NULL); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; case 214: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy621, &yymsp[-3].minor.yy421, &yymsp[-1].minor.yy421, NULL, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy137, &yymsp[-3].minor.yy209, &yymsp[-1].minor.yy209, NULL, yymsp[0].minor.yy632); } break; case 215: /* cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, yymsp[-6].minor.yy621, &yymsp[-5].minor.yy421, &yymsp[-3].minor.yy421, yymsp[-1].minor.yy530, NULL); } +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, yymsp[-6].minor.yy137, &yymsp[-5].minor.yy209, &yymsp[-3].minor.yy209, yymsp[-1].minor.yy424, NULL); } break; case 216: /* cmd ::= DROP INDEX exists_opt index_name ON table_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-3].minor.yy621, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-3].minor.yy137, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209); } break; case 218: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ -{ yymsp[-8].minor.yy674 = createIndexOption(pCxt, yymsp[-6].minor.yy530, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), NULL, yymsp[0].minor.yy674); } +{ yymsp[-8].minor.yy632 = createIndexOption(pCxt, yymsp[-6].minor.yy424, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), NULL, yymsp[0].minor.yy632); } break; case 219: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ -{ yymsp[-10].minor.yy674 = createIndexOption(pCxt, yymsp[-8].minor.yy530, releaseRawExprNode(pCxt, yymsp[-4].minor.yy674), releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), yymsp[0].minor.yy674); } +{ yymsp[-10].minor.yy632 = createIndexOption(pCxt, yymsp[-8].minor.yy424, releaseRawExprNode(pCxt, yymsp[-4].minor.yy632), releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), yymsp[0].minor.yy632); } break; case 222: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy674 = createFunctionNode(pCxt, &yymsp[-3].minor.yy421, yymsp[-1].minor.yy530); } - yymsp[-3].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = createFunctionNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-1].minor.yy424); } + yymsp[-3].minor.yy632 = yylhsminor.yy632; break; case 223: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy621, &yymsp[-2].minor.yy421, yymsp[0].minor.yy674, NULL, NULL); } +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy137, &yymsp[-2].minor.yy209, yymsp[0].minor.yy632, NULL, NULL); } break; case 224: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-4].minor.yy621, &yymsp[-3].minor.yy421, NULL, &yymsp[0].minor.yy421, NULL); } +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-4].minor.yy137, &yymsp[-3].minor.yy209, NULL, &yymsp[0].minor.yy209, NULL); } break; case 225: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-4].minor.yy621, &yymsp[-3].minor.yy421, NULL, NULL, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-4].minor.yy137, &yymsp[-3].minor.yy209, NULL, NULL, yymsp[0].minor.yy632); } break; case 226: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy621, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy137, &yymsp[0].minor.yy209); } break; case 227: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy621, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy137, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209); } break; case 228: /* cmd ::= DESC full_table_name */ case 229: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==229); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy632); } break; case 230: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; case 231: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy621, yymsp[-1].minor.yy674, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy137, yymsp[-1].minor.yy632, yymsp[0].minor.yy632); } break; case 233: /* analyze_opt ::= ANALYZE */ case 241: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==241); - case 391: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==391); -{ yymsp[0].minor.yy621 = true; } + case 392: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==392); +{ yymsp[0].minor.yy137 = true; } break; case 234: /* explain_options ::= */ -{ yymsp[1].minor.yy674 = createDefaultExplainOptions(pCxt); } +{ yymsp[1].minor.yy632 = createDefaultExplainOptions(pCxt); } break; case 235: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy674 = setExplainVerbose(pCxt, yymsp[-2].minor.yy674, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setExplainVerbose(pCxt, yymsp[-2].minor.yy632, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 236: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy674 = setExplainRatio(pCxt, yymsp[-2].minor.yy674, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ yylhsminor.yy632 = setExplainRatio(pCxt, yymsp[-2].minor.yy632, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 237: /* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ -{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy530); } +{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy424); } break; case 238: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ -{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy621, yymsp[-8].minor.yy621, &yymsp[-5].minor.yy421, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy690, yymsp[0].minor.yy42); } +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy137, yymsp[-8].minor.yy137, &yymsp[-5].minor.yy209, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy304, yymsp[0].minor.yy100); } break; case 239: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy621, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy137, &yymsp[0].minor.yy209); } break; case 242: /* bufsize_opt ::= */ -{ yymsp[1].minor.yy42 = 0; } +{ yymsp[1].minor.yy100 = 0; } break; case 243: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ -{ yymsp[-1].minor.yy42 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy100 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } break; case 244: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-5].minor.yy621, &yymsp[-4].minor.yy421, yymsp[-2].minor.yy674, yymsp[-3].minor.yy674, yymsp[0].minor.yy674); } +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-5].minor.yy137, &yymsp[-4].minor.yy209, yymsp[-2].minor.yy632, yymsp[-3].minor.yy632, yymsp[0].minor.yy632); } break; case 245: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy621, &yymsp[0].minor.yy421); } +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy137, &yymsp[0].minor.yy209); } break; case 247: /* into_opt ::= INTO full_table_name */ - case 372: /* from_clause ::= FROM table_reference_list */ yytestcase(yyruleno==372); - case 402: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==402); - case 425: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==425); -{ yymsp[-1].minor.yy674 = yymsp[0].minor.yy674; } + case 373: /* from_clause ::= FROM table_reference_list */ yytestcase(yyruleno==373); + case 403: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==403); + case 426: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==426); +{ yymsp[-1].minor.yy632 = yymsp[0].minor.yy632; } break; case 248: /* stream_options ::= */ -{ yymsp[1].minor.yy674 = createStreamOptions(pCxt); } +{ yymsp[1].minor.yy632 = createStreamOptions(pCxt); } break; case 249: /* stream_options ::= stream_options TRIGGER AT_ONCE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy674)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy674 = yymsp[-2].minor.yy674; } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ ((SStreamOptions*)yymsp[-2].minor.yy632)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy632 = yymsp[-2].minor.yy632; } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; case 250: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy674)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy674 = yymsp[-2].minor.yy674; } - yymsp[-2].minor.yy674 = yylhsminor.yy674; +{ ((SStreamOptions*)yymsp[-2].minor.yy632)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy632 = yymsp[-2].minor.yy632; } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 251: /* stream_options ::= stream_options WATERMARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy674)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy674); yylhsminor.yy674 = yymsp[-2].minor.yy674; } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 251: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-3].minor.yy632)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy632)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy632); yylhsminor.yy632 = yymsp[-3].minor.yy632; } + yymsp[-3].minor.yy632 = yylhsminor.yy632; break; - case 252: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 252: /* stream_options ::= stream_options WATERMARK duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy632)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy632); yylhsminor.yy632 = yymsp[-2].minor.yy632; } + yymsp[-2].minor.yy632 = yylhsminor.yy632; + break; + case 253: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 253: /* cmd ::= KILL QUERY NK_INTEGER */ + case 254: /* cmd ::= KILL QUERY NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_QUERY_STMT, &yymsp[0].minor.yy0); } break; - case 254: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 255: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } break; - case 255: /* cmd ::= BALANCE VGROUP */ + case 256: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } break; - case 256: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 257: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 257: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy530); } + case 258: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy424); } break; - case 258: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 259: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 259: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy530 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + case 260: /* dnode_list ::= DNODE NK_INTEGER */ +{ yymsp[-1].minor.yy424 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; - case 261: /* cmd ::= SYNCDB db_name REPLICA */ -{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy421); } + case 262: /* cmd ::= SYNCDB db_name REPLICA */ +{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy209); } break; - case 262: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy674, yymsp[0].minor.yy674); } + case 263: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy632, yymsp[0].minor.yy632); } break; - case 264: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy674 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 265: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy632 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 265: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy674 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 266: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy632 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 266: /* literal ::= NK_STRING */ -{ yylhsminor.yy674 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 267: /* literal ::= NK_STRING */ +{ yylhsminor.yy632 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 267: /* literal ::= NK_BOOL */ -{ yylhsminor.yy674 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 268: /* literal ::= NK_BOOL */ +{ yylhsminor.yy632 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 268: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; + case 269: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; - case 269: /* literal ::= duration_literal */ - case 279: /* signed_literal ::= signed */ yytestcase(yyruleno==279); - case 299: /* expression ::= literal */ yytestcase(yyruleno==299); - case 300: /* expression ::= pseudo_column */ yytestcase(yyruleno==300); - case 301: /* expression ::= column_reference */ yytestcase(yyruleno==301); - case 302: /* expression ::= function_expression */ yytestcase(yyruleno==302); - case 303: /* expression ::= subquery */ yytestcase(yyruleno==303); - case 328: /* function_expression ::= literal_func */ yytestcase(yyruleno==328); - case 364: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==364); - case 368: /* boolean_primary ::= predicate */ yytestcase(yyruleno==368); - case 370: /* common_expression ::= expression */ yytestcase(yyruleno==370); - case 371: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==371); - case 373: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==373); - case 375: /* table_reference ::= table_primary */ yytestcase(yyruleno==375); - case 376: /* table_reference ::= joined_table */ yytestcase(yyruleno==376); - case 380: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==380); - case 427: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==427); - case 430: /* query_primary ::= query_specification */ yytestcase(yyruleno==430); -{ yylhsminor.yy674 = yymsp[0].minor.yy674; } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 270: /* literal ::= duration_literal */ + case 280: /* signed_literal ::= signed */ yytestcase(yyruleno==280); + case 300: /* expression ::= literal */ yytestcase(yyruleno==300); + case 301: /* expression ::= pseudo_column */ yytestcase(yyruleno==301); + case 302: /* expression ::= column_reference */ yytestcase(yyruleno==302); + case 303: /* expression ::= function_expression */ yytestcase(yyruleno==303); + case 304: /* expression ::= subquery */ yytestcase(yyruleno==304); + case 329: /* function_expression ::= literal_func */ yytestcase(yyruleno==329); + case 365: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==365); + case 369: /* boolean_primary ::= predicate */ yytestcase(yyruleno==369); + case 371: /* common_expression ::= expression */ yytestcase(yyruleno==371); + case 372: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==372); + case 374: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==374); + case 376: /* table_reference ::= table_primary */ yytestcase(yyruleno==376); + case 377: /* table_reference ::= joined_table */ yytestcase(yyruleno==377); + case 381: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==381); + case 428: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==428); + case 431: /* query_primary ::= query_specification */ yytestcase(yyruleno==431); +{ yylhsminor.yy632 = yymsp[0].minor.yy632; } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 270: /* literal ::= NULL */ -{ yylhsminor.yy674 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 271: /* literal ::= NULL */ +{ yylhsminor.yy632 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 271: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy674 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 272: /* literal ::= NK_QUESTION */ +{ yylhsminor.yy632 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 272: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy674 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 273: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy632 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 273: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 274: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 274: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + case 275: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; - case 275: /* signed ::= NK_MINUS NK_INTEGER */ + case 276: /* signed ::= NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; - case 276: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 277: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 277: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 278: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 278: /* signed ::= NK_MINUS NK_FLOAT */ + case 279: /* signed ::= NK_MINUS NK_FLOAT */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; - case 280: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 281: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 281: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 282: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 282: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 283: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 283: /* signed_literal ::= duration_literal */ - case 285: /* signed_literal ::= literal_func */ yytestcase(yyruleno==285); - case 342: /* star_func_para ::= expression */ yytestcase(yyruleno==342); - case 397: /* select_item ::= common_expression */ yytestcase(yyruleno==397); - case 443: /* search_condition ::= common_expression */ yytestcase(yyruleno==443); -{ yylhsminor.yy674 = releaseRawExprNode(pCxt, yymsp[0].minor.yy674); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 284: /* signed_literal ::= duration_literal */ + case 286: /* signed_literal ::= literal_func */ yytestcase(yyruleno==286); + case 343: /* star_func_para ::= expression */ yytestcase(yyruleno==343); + case 398: /* select_item ::= common_expression */ yytestcase(yyruleno==398); + case 444: /* search_condition ::= common_expression */ yytestcase(yyruleno==444); +{ yylhsminor.yy632 = releaseRawExprNode(pCxt, yymsp[0].minor.yy632); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 284: /* signed_literal ::= NULL */ -{ yylhsminor.yy674 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 285: /* signed_literal ::= NULL */ +{ yylhsminor.yy632 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 304: /* expression ::= NK_LP expression NK_RP */ - case 369: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==369); -{ yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy674)); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 305: /* expression ::= NK_LP expression NK_RP */ + case 370: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==370); +{ yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy632)); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 305: /* expression ::= NK_PLUS expression */ + case 306: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy674)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy632)); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; - case 306: /* expression ::= NK_MINUS expression */ + case 307: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy674), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy632), NULL)); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; - case 307: /* expression ::= expression NK_PLUS expression */ + case 308: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy674); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy632); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 308: /* expression ::= expression NK_MINUS expression */ + case 309: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy674); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy632); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 309: /* expression ::= expression NK_STAR expression */ + case 310: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy674); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy632); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 310: /* expression ::= expression NK_SLASH expression */ + case 311: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy674); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy632); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 311: /* expression ::= expression NK_REM expression */ + case 312: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy674); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy632); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 312: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 313: /* expression ::= column_reference NK_ARROW NK_STRING */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 313: /* expression_list ::= expression */ -{ yylhsminor.yy530 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy674)); } - yymsp[0].minor.yy530 = yylhsminor.yy530; + case 314: /* expression_list ::= expression */ +{ yylhsminor.yy424 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy632)); } + yymsp[0].minor.yy424 = yylhsminor.yy424; break; - case 314: /* expression_list ::= expression_list NK_COMMA expression */ -{ yylhsminor.yy530 = addNodeToList(pCxt, yymsp[-2].minor.yy530, releaseRawExprNode(pCxt, yymsp[0].minor.yy674)); } - yymsp[-2].minor.yy530 = yylhsminor.yy530; + case 315: /* expression_list ::= expression_list NK_COMMA expression */ +{ yylhsminor.yy424 = addNodeToList(pCxt, yymsp[-2].minor.yy424, releaseRawExprNode(pCxt, yymsp[0].minor.yy632)); } + yymsp[-2].minor.yy424 = yylhsminor.yy424; break; - case 315: /* column_reference ::= column_name */ -{ yylhsminor.yy674 = createRawExprNode(pCxt, &yymsp[0].minor.yy421, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy421)); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 316: /* column_reference ::= column_name */ +{ yylhsminor.yy632 = createRawExprNode(pCxt, &yymsp[0].minor.yy209, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy209)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 316: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy421, createColumnNode(pCxt, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy421)); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 317: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209, createColumnNode(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209)); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 317: /* pseudo_column ::= ROWTS */ - case 318: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==318); - case 320: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==320); - case 321: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==321); - case 322: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==322); - case 323: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==323); - case 324: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==324); - case 330: /* literal_func ::= NOW */ yytestcase(yyruleno==330); -{ yylhsminor.yy674 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy674 = yylhsminor.yy674; + case 318: /* pseudo_column ::= ROWTS */ + case 319: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==319); + case 321: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==321); + case 322: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==322); + case 323: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==323); + case 324: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==324); + case 325: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==325); + case 331: /* literal_func ::= NOW */ yytestcase(yyruleno==331); +{ yylhsminor.yy632 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy632 = yylhsminor.yy632; break; - case 319: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy421)))); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 320: /* pseudo_column ::= table_name NK_DOT TBNAME */ +{ yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy209)))); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 325: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 326: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==326); -{ yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy421, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy421, yymsp[-1].minor.yy530)); } - yymsp[-3].minor.yy674 = yylhsminor.yy674; + case 326: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 327: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==327); +{ yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy209, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-1].minor.yy424)); } + yymsp[-3].minor.yy632 = yylhsminor.yy632; break; - case 327: /* function_expression ::= CAST NK_LP expression AS type_name NK_RP */ -{ yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy674), yymsp[-1].minor.yy690)); } - yymsp[-5].minor.yy674 = yylhsminor.yy674; + case 328: /* function_expression ::= CAST NK_LP expression AS type_name NK_RP */ +{ yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy632), yymsp[-1].minor.yy304)); } + yymsp[-5].minor.yy632 = yylhsminor.yy632; break; - case 329: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy421, NULL)); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 330: /* literal_func ::= noarg_func NK_LP NK_RP */ +{ yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy209, NULL)); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 338: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy530 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy530 = yylhsminor.yy530; + case 339: /* star_func_para_list ::= NK_STAR */ +{ yylhsminor.yy424 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy424 = yylhsminor.yy424; break; - case 343: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 400: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==400); -{ yylhsminor.yy674 = createColumnNode(pCxt, &yymsp[-2].minor.yy421, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 344: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 401: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==401); +{ yylhsminor.yy632 = createColumnNode(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 344: /* predicate ::= expression compare_op expression */ - case 349: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==349); + case 345: /* predicate ::= expression compare_op expression */ + case 350: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==350); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy674); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy28, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy632); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy380, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 345: /* predicate ::= expression BETWEEN expression AND expression */ + case 346: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy674); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy674), releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy632); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy632), releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } - yymsp[-4].minor.yy674 = yylhsminor.yy674; + yymsp[-4].minor.yy632 = yylhsminor.yy632; break; - case 346: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 347: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy674); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy674), releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy632); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy632), releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } - yymsp[-5].minor.yy674 = yylhsminor.yy674; + yymsp[-5].minor.yy632 = yylhsminor.yy632; break; - case 347: /* predicate ::= expression IS NULL */ + case 348: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), NULL)); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 348: /* predicate ::= expression IS NOT NULL */ + case 349: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy674), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy632), NULL)); } - yymsp[-3].minor.yy674 = yylhsminor.yy674; + yymsp[-3].minor.yy632 = yylhsminor.yy632; break; - case 350: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy28 = OP_TYPE_LOWER_THAN; } + case 351: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy380 = OP_TYPE_LOWER_THAN; } break; - case 351: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy28 = OP_TYPE_GREATER_THAN; } + case 352: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy380 = OP_TYPE_GREATER_THAN; } break; - case 352: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy28 = OP_TYPE_LOWER_EQUAL; } + case 353: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy380 = OP_TYPE_LOWER_EQUAL; } break; - case 353: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy28 = OP_TYPE_GREATER_EQUAL; } + case 354: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy380 = OP_TYPE_GREATER_EQUAL; } break; - case 354: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy28 = OP_TYPE_NOT_EQUAL; } + case 355: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy380 = OP_TYPE_NOT_EQUAL; } break; - case 355: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy28 = OP_TYPE_EQUAL; } + case 356: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy380 = OP_TYPE_EQUAL; } break; - case 356: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy28 = OP_TYPE_LIKE; } + case 357: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy380 = OP_TYPE_LIKE; } break; - case 357: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy28 = OP_TYPE_NOT_LIKE; } + case 358: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy380 = OP_TYPE_NOT_LIKE; } break; - case 358: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy28 = OP_TYPE_MATCH; } + case 359: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy380 = OP_TYPE_MATCH; } break; - case 359: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy28 = OP_TYPE_NMATCH; } + case 360: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy380 = OP_TYPE_NMATCH; } break; - case 360: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy28 = OP_TYPE_JSON_CONTAINS; } + case 361: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy380 = OP_TYPE_JSON_CONTAINS; } break; - case 361: /* in_op ::= IN */ -{ yymsp[0].minor.yy28 = OP_TYPE_IN; } + case 362: /* in_op ::= IN */ +{ yymsp[0].minor.yy380 = OP_TYPE_IN; } break; - case 362: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy28 = OP_TYPE_NOT_IN; } + case 363: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy380 = OP_TYPE_NOT_IN; } break; - case 363: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy530)); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 364: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy424)); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 365: /* boolean_value_expression ::= NOT boolean_primary */ + case 366: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy674), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy632), NULL)); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; - case 366: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 367: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy674); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy632); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 367: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 368: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy674); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy674); - yylhsminor.yy674 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy632); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy632); + yylhsminor.yy632 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 374: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy674 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy674, yymsp[0].minor.yy674, NULL); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 375: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy632 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy632, yymsp[0].minor.yy632, NULL); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 377: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy674 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy421, &yymsp[0].minor.yy421); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; + case 378: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy632 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy209, &yymsp[0].minor.yy209); } + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; - case 378: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy674 = createRealTableNode(pCxt, &yymsp[-3].minor.yy421, &yymsp[-1].minor.yy421, &yymsp[0].minor.yy421); } - yymsp[-3].minor.yy674 = yylhsminor.yy674; + case 379: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy632 = createRealTableNode(pCxt, &yymsp[-3].minor.yy209, &yymsp[-1].minor.yy209, &yymsp[0].minor.yy209); } + yymsp[-3].minor.yy632 = yylhsminor.yy632; break; - case 379: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy674 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy674), &yymsp[0].minor.yy421); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; + case 380: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy632 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy632), &yymsp[0].minor.yy209); } + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; - case 381: /* alias_opt ::= */ -{ yymsp[1].minor.yy421 = nil_token; } + case 382: /* alias_opt ::= */ +{ yymsp[1].minor.yy209 = nil_token; } break; - case 382: /* alias_opt ::= table_alias */ -{ yylhsminor.yy421 = yymsp[0].minor.yy421; } - yymsp[0].minor.yy421 = yylhsminor.yy421; + case 383: /* alias_opt ::= table_alias */ +{ yylhsminor.yy209 = yymsp[0].minor.yy209; } + yymsp[0].minor.yy209 = yylhsminor.yy209; break; - case 383: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy421 = yymsp[0].minor.yy421; } + case 384: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy209 = yymsp[0].minor.yy209; } break; - case 384: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 385: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==385); -{ yymsp[-2].minor.yy674 = yymsp[-1].minor.yy674; } + case 385: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 386: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==386); +{ yymsp[-2].minor.yy632 = yymsp[-1].minor.yy632; } break; - case 386: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy674 = createJoinTableNode(pCxt, yymsp[-4].minor.yy636, yymsp[-5].minor.yy674, yymsp[-2].minor.yy674, yymsp[0].minor.yy674); } - yymsp[-5].minor.yy674 = yylhsminor.yy674; + case 387: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy632 = createJoinTableNode(pCxt, yymsp[-4].minor.yy612, yymsp[-5].minor.yy632, yymsp[-2].minor.yy632, yymsp[0].minor.yy632); } + yymsp[-5].minor.yy632 = yylhsminor.yy632; break; - case 387: /* join_type ::= */ -{ yymsp[1].minor.yy636 = JOIN_TYPE_INNER; } + case 388: /* join_type ::= */ +{ yymsp[1].minor.yy612 = JOIN_TYPE_INNER; } break; - case 388: /* join_type ::= INNER */ -{ yymsp[0].minor.yy636 = JOIN_TYPE_INNER; } + case 389: /* join_type ::= INNER */ +{ yymsp[0].minor.yy612 = JOIN_TYPE_INNER; } break; - case 389: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 390: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { - yymsp[-8].minor.yy674 = createSelectStmt(pCxt, yymsp[-7].minor.yy621, yymsp[-6].minor.yy530, yymsp[-5].minor.yy674); - yymsp[-8].minor.yy674 = addWhereClause(pCxt, yymsp[-8].minor.yy674, yymsp[-4].minor.yy674); - yymsp[-8].minor.yy674 = addPartitionByClause(pCxt, yymsp[-8].minor.yy674, yymsp[-3].minor.yy530); - yymsp[-8].minor.yy674 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy674, yymsp[-2].minor.yy674); - yymsp[-8].minor.yy674 = addGroupByClause(pCxt, yymsp[-8].minor.yy674, yymsp[-1].minor.yy530); - yymsp[-8].minor.yy674 = addHavingClause(pCxt, yymsp[-8].minor.yy674, yymsp[0].minor.yy674); + yymsp[-8].minor.yy632 = createSelectStmt(pCxt, yymsp[-7].minor.yy137, yymsp[-6].minor.yy424, yymsp[-5].minor.yy632); + yymsp[-8].minor.yy632 = addWhereClause(pCxt, yymsp[-8].minor.yy632, yymsp[-4].minor.yy632); + yymsp[-8].minor.yy632 = addPartitionByClause(pCxt, yymsp[-8].minor.yy632, yymsp[-3].minor.yy424); + yymsp[-8].minor.yy632 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy632, yymsp[-2].minor.yy632); + yymsp[-8].minor.yy632 = addGroupByClause(pCxt, yymsp[-8].minor.yy632, yymsp[-1].minor.yy424); + yymsp[-8].minor.yy632 = addHavingClause(pCxt, yymsp[-8].minor.yy632, yymsp[0].minor.yy632); } break; - case 392: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy621 = false; } + case 393: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy137 = false; } break; - case 393: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy530 = NULL; } + case 394: /* select_list ::= NK_STAR */ +{ yymsp[0].minor.yy424 = NULL; } break; - case 398: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy674 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy674), &yymsp[0].minor.yy421); } - yymsp[-1].minor.yy674 = yylhsminor.yy674; + case 399: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy632 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy632), &yymsp[0].minor.yy209); } + yymsp[-1].minor.yy632 = yylhsminor.yy632; break; - case 399: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy674 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), &yymsp[0].minor.yy421); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 400: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy632 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), &yymsp[0].minor.yy209); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 404: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 421: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==421); - case 433: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==433); -{ yymsp[-2].minor.yy530 = yymsp[0].minor.yy530; } + case 405: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 422: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==422); + case 434: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==434); +{ yymsp[-2].minor.yy424 = yymsp[0].minor.yy424; } break; - case 406: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy674 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy674), releaseRawExprNode(pCxt, yymsp[-1].minor.yy674)); } + case 407: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ +{ yymsp[-5].minor.yy632 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy632), releaseRawExprNode(pCxt, yymsp[-1].minor.yy632)); } break; - case 407: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ -{ yymsp[-3].minor.yy674 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy674)); } + case 408: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ +{ yymsp[-3].minor.yy632 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy632)); } break; - case 408: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy674 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy674), NULL, yymsp[-1].minor.yy674, yymsp[0].minor.yy674); } + case 409: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy632 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy632), NULL, yymsp[-1].minor.yy632, yymsp[0].minor.yy632); } break; - case 409: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy674 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy674), releaseRawExprNode(pCxt, yymsp[-3].minor.yy674), yymsp[-1].minor.yy674, yymsp[0].minor.yy674); } + case 410: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy632 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy632), releaseRawExprNode(pCxt, yymsp[-3].minor.yy632), yymsp[-1].minor.yy632, yymsp[0].minor.yy632); } break; - case 411: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ -{ yymsp[-3].minor.yy674 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy674); } + case 412: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ +{ yymsp[-3].minor.yy632 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy632); } break; - case 413: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy674 = createFillNode(pCxt, yymsp[-1].minor.yy320, NULL); } + case 414: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy632 = createFillNode(pCxt, yymsp[-1].minor.yy54, NULL); } break; - case 414: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy674 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy530)); } + case 415: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy632 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy424)); } break; - case 415: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy320 = FILL_MODE_NONE; } + case 416: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy54 = FILL_MODE_NONE; } break; - case 416: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy320 = FILL_MODE_PREV; } + case 417: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy54 = FILL_MODE_PREV; } break; - case 417: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy320 = FILL_MODE_NULL; } + case 418: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy54 = FILL_MODE_NULL; } break; - case 418: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy320 = FILL_MODE_LINEAR; } + case 419: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy54 = FILL_MODE_LINEAR; } break; - case 419: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy320 = FILL_MODE_NEXT; } + case 420: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy54 = FILL_MODE_NEXT; } break; - case 422: /* group_by_list ::= expression */ -{ yylhsminor.yy530 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); } - yymsp[0].minor.yy530 = yylhsminor.yy530; + case 423: /* group_by_list ::= expression */ +{ yylhsminor.yy424 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } + yymsp[0].minor.yy424 = yylhsminor.yy424; break; - case 423: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy530 = addNodeToList(pCxt, yymsp[-2].minor.yy530, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy674))); } - yymsp[-2].minor.yy530 = yylhsminor.yy530; + case 424: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy424 = addNodeToList(pCxt, yymsp[-2].minor.yy424, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy632))); } + yymsp[-2].minor.yy424 = yylhsminor.yy424; break; - case 426: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 427: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy674 = addOrderByClause(pCxt, yymsp[-3].minor.yy674, yymsp[-2].minor.yy530); - yylhsminor.yy674 = addSlimitClause(pCxt, yylhsminor.yy674, yymsp[-1].minor.yy674); - yylhsminor.yy674 = addLimitClause(pCxt, yylhsminor.yy674, yymsp[0].minor.yy674); + yylhsminor.yy632 = addOrderByClause(pCxt, yymsp[-3].minor.yy632, yymsp[-2].minor.yy424); + yylhsminor.yy632 = addSlimitClause(pCxt, yylhsminor.yy632, yymsp[-1].minor.yy632); + yylhsminor.yy632 = addLimitClause(pCxt, yylhsminor.yy632, yymsp[0].minor.yy632); } - yymsp[-3].minor.yy674 = yylhsminor.yy674; + yymsp[-3].minor.yy632 = yylhsminor.yy632; break; - case 428: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy674 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy674, yymsp[0].minor.yy674); } - yymsp[-3].minor.yy674 = yylhsminor.yy674; + case 429: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy632 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy632, yymsp[0].minor.yy632); } + yymsp[-3].minor.yy632 = yylhsminor.yy632; break; - case 429: /* query_expression_body ::= query_expression_body UNION query_expression_body */ -{ yylhsminor.yy674 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy674, yymsp[0].minor.yy674); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 430: /* query_expression_body ::= query_expression_body UNION query_expression_body */ +{ yylhsminor.yy632 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy632, yymsp[0].minor.yy632); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 431: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ -{ yymsp[-5].minor.yy674 = yymsp[-4].minor.yy674; } - yy_destructor(yypParser,351,&yymsp[-3].minor); - yy_destructor(yypParser,352,&yymsp[-2].minor); - yy_destructor(yypParser,353,&yymsp[-1].minor); + case 432: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ +{ yymsp[-5].minor.yy632 = yymsp[-4].minor.yy632; } + yy_destructor(yypParser,352,&yymsp[-3].minor); + yy_destructor(yypParser,353,&yymsp[-2].minor); + yy_destructor(yypParser,354,&yymsp[-1].minor); break; - case 435: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 439: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==439); -{ yymsp[-1].minor.yy674 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 436: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 440: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==440); +{ yymsp[-1].minor.yy632 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 436: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 440: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==440); -{ yymsp[-3].minor.yy674 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 437: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 441: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==441); +{ yymsp[-3].minor.yy632 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 437: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 441: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==441); -{ yymsp[-3].minor.yy674 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 438: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 442: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==442); +{ yymsp[-3].minor.yy632 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 442: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy674 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy674); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 443: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy632 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy632); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 446: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy674 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy674), yymsp[-1].minor.yy610, yymsp[0].minor.yy107); } - yymsp[-2].minor.yy674 = yylhsminor.yy674; + case 447: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy632 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy632), yymsp[-1].minor.yy578, yymsp[0].minor.yy217); } + yymsp[-2].minor.yy632 = yylhsminor.yy632; break; - case 447: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy610 = ORDER_ASC; } + case 448: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy578 = ORDER_ASC; } break; - case 448: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy610 = ORDER_ASC; } + case 449: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy578 = ORDER_ASC; } break; - case 449: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy610 = ORDER_DESC; } + case 450: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy578 = ORDER_DESC; } break; - case 450: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy107 = NULL_ORDER_DEFAULT; } + case 451: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy217 = NULL_ORDER_DEFAULT; } break; - case 451: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy107 = NULL_ORDER_FIRST; } + case 452: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy217 = NULL_ORDER_FIRST; } break; - case 452: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy107 = NULL_ORDER_LAST; } + case 453: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy217 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/mockCatalog.cpp b/source/libs/parser/test/mockCatalog.cpp index 2ba5b97062..b0c6181264 100644 --- a/source/libs/parser/test/mockCatalog.cpp +++ b/source/libs/parser/test/mockCatalog.cpp @@ -141,22 +141,46 @@ void generateTestT1(MockCatalogService* mcs) { * c2 | column | VARCHAR | 20 | * tag1 | tag | INT | 4 | * tag2 | tag | VARCHAR | 20 | + * tag3 | tag | TIMESTAMP | 8 | * Child Table: st1s1, st1s2 */ void generateTestST1(MockCatalogService* mcs) { - ITableBuilder& builder = mcs->createTableBuilder("test", "st1", TSDB_SUPER_TABLE, 3, 2) + ITableBuilder& builder = mcs->createTableBuilder("test", "st1", TSDB_SUPER_TABLE, 3, 3) .setPrecision(TSDB_TIME_PRECISION_MILLI) .addColumn("ts", TSDB_DATA_TYPE_TIMESTAMP) .addColumn("c1", TSDB_DATA_TYPE_INT) .addColumn("c2", TSDB_DATA_TYPE_BINARY, 20) .addTag("tag1", TSDB_DATA_TYPE_INT) - .addTag("tag2", TSDB_DATA_TYPE_BINARY, 20); + .addTag("tag2", TSDB_DATA_TYPE_BINARY, 20) + .addTag("tag3", TSDB_DATA_TYPE_TIMESTAMP); builder.done(); mcs->createSubTable("test", "st1", "st1s1", 1); mcs->createSubTable("test", "st1", "st1s2", 2); mcs->createSubTable("test", "st1", "st1s3", 1); } +/* + * Super Table: st2 + * Field | Type | DataType | Bytes | + * ========================================================================== + * ts | column | TIMESTAMP | 8 | + * c1 | column | INT | 4 | + * c2 | column | VARCHAR | 20 | + * jtag | tag | json | -- | + * Child Table: st2s1, st2s2 + */ +void generateTestST2(MockCatalogService* mcs) { + ITableBuilder& builder = mcs->createTableBuilder("test", "st2", TSDB_SUPER_TABLE, 3, 1) + .setPrecision(TSDB_TIME_PRECISION_MILLI) + .addColumn("ts", TSDB_DATA_TYPE_TIMESTAMP) + .addColumn("c1", TSDB_DATA_TYPE_INT) + .addColumn("c2", TSDB_DATA_TYPE_BINARY, 20) + .addTag("jtag", TSDB_DATA_TYPE_JSON); + builder.done(); + mcs->createSubTable("test", "st2", "st2s1", 1); + mcs->createSubTable("test", "st2", "st2s2", 2); +} + void generateFunctions(MockCatalogService* mcs) { mcs->createFunction("udf1", TSDB_FUNC_TYPE_SCALAR, TSDB_DATA_TYPE_INT, tDataTypes[TSDB_DATA_TYPE_INT].bytes, 0); mcs->createFunction("udf2", TSDB_FUNC_TYPE_AGGREGATE, TSDB_DATA_TYPE_DOUBLE, tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, @@ -167,17 +191,17 @@ void generateFunctions(MockCatalogService* mcs) { int32_t __catalogGetHandle(const char* clusterId, struct SCatalog** catalogHandle) { return 0; } -int32_t __catalogGetTableMeta(struct SCatalog* pCatalog, SRequestConnInfo *pConn, const SName* pTableName, +int32_t __catalogGetTableMeta(struct SCatalog* pCatalog, SRequestConnInfo* pConn, const SName* pTableName, STableMeta** pTableMeta) { return g_mockCatalogService->catalogGetTableMeta(pTableName, pTableMeta); } -int32_t __catalogGetTableHashVgroup(struct SCatalog* pCatalog, SRequestConnInfo *pConn, - const SName* pTableName, SVgroupInfo* vgInfo) { +int32_t __catalogGetTableHashVgroup(struct SCatalog* pCatalog, SRequestConnInfo* pConn, const SName* pTableName, + SVgroupInfo* vgInfo) { return g_mockCatalogService->catalogGetTableHashVgroup(pTableName, vgInfo); } -int32_t __catalogGetTableDistVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, +int32_t __catalogGetTableDistVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SArray** pVgList) { return g_mockCatalogService->catalogGetTableDistVgInfo(pTableName, pVgList); } @@ -187,28 +211,26 @@ int32_t __catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* ve return 0; } -int32_t __catalogGetDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char* dbFName, - SArray** pVgList) { +int32_t __catalogGetDBVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const char* dbFName, SArray** pVgList) { return g_mockCatalogService->catalogGetDBVgInfo(dbFName, pVgList); } -int32_t __catalogGetDBCfg(SCatalog* pCtg, SRequestConnInfo *pConn, const char* dbFName, SDbCfgInfo* pDbCfg) { +int32_t __catalogGetDBCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const char* dbFName, SDbCfgInfo* pDbCfg) { return 0; } -int32_t __catalogChkAuth(SCatalog* pCtg, SRequestConnInfo *pConn, const char* user, const char* dbFName, - AUTH_TYPE type, bool* pass) { +int32_t __catalogChkAuth(SCatalog* pCtg, SRequestConnInfo* pConn, const char* user, const char* dbFName, AUTH_TYPE type, + bool* pass) { *pass = true; return 0; } -int32_t __catalogGetUdfInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char* funcName, - SFuncInfo* pInfo) { +int32_t __catalogGetUdfInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const char* funcName, SFuncInfo* pInfo) { return g_mockCatalogService->catalogGetUdfInfo(funcName, pInfo); } -int32_t __catalogRefreshGetTableMeta(SCatalog* pCatalog, SRequestConnInfo *pConn, - const SName* pTableName, STableMeta** pTableMeta, int32_t isSTable) { +int32_t __catalogRefreshGetTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const SName* pTableName, + STableMeta** pTableMeta, int32_t isSTable) { return g_mockCatalogService->catalogGetTableMeta(pTableName, pTableMeta); } @@ -283,6 +305,7 @@ void generateMetaData() { generatePerformanceSchema(g_mockCatalogService.get()); generateTestT1(g_mockCatalogService.get()); generateTestST1(g_mockCatalogService.get()); + generateTestST2(g_mockCatalogService.get()); generateFunctions(g_mockCatalogService.get()); g_mockCatalogService->showTables(); } diff --git a/source/libs/parser/test/mockCatalogService.cpp b/source/libs/parser/test/mockCatalogService.cpp index 010d4a2f72..68f9e9d36d 100644 --- a/source/libs/parser/test/mockCatalogService.cpp +++ b/source/libs/parser/test/mockCatalogService.cpp @@ -584,3 +584,35 @@ int32_t MockCatalogService::catalogGetTableIndex(const SName* pTableName, SArray int32_t MockCatalogService::catalogGetAllMeta(const SCatalogReq* pCatalogReq, SMetaData* pMetaData) const { return impl_->catalogGetAllMeta(pCatalogReq, pMetaData); } + +void MockCatalogService::destoryCatalogReq(SCatalogReq* pReq) { + taosArrayDestroy(pReq->pDbVgroup); + taosArrayDestroy(pReq->pDbCfg); + taosArrayDestroy(pReq->pDbInfo); + taosArrayDestroy(pReq->pTableMeta); + taosArrayDestroy(pReq->pTableHash); + taosArrayDestroy(pReq->pUdf); + taosArrayDestroy(pReq->pIndex); + taosArrayDestroy(pReq->pUser); + taosArrayDestroy(pReq->pTableIndex); + delete pReq; +} + +void MockCatalogService::destoryMetaRes(void* p) { + SMetaRes* pRes = (SMetaRes*)p; + taosMemoryFree(pRes->pRes); +} + +void MockCatalogService::destoryMetaData(SMetaData* pData) { + taosArrayDestroyEx(pData->pDbVgroup, destoryMetaRes); + taosArrayDestroyEx(pData->pDbCfg, destoryMetaRes); + taosArrayDestroyEx(pData->pDbInfo, destoryMetaRes); + taosArrayDestroyEx(pData->pTableMeta, destoryMetaRes); + taosArrayDestroyEx(pData->pTableHash, destoryMetaRes); + taosArrayDestroyEx(pData->pTableIndex, destoryMetaRes); + taosArrayDestroyEx(pData->pUdfList, destoryMetaRes); + taosArrayDestroyEx(pData->pIndex, destoryMetaRes); + taosArrayDestroyEx(pData->pUser, destoryMetaRes); + taosArrayDestroyEx(pData->pQnodeList, destoryMetaRes); + delete pData; +} diff --git a/source/libs/parser/test/mockCatalogService.h b/source/libs/parser/test/mockCatalogService.h index c4ab091b7a..1c98a7d9d5 100644 --- a/source/libs/parser/test/mockCatalogService.h +++ b/source/libs/parser/test/mockCatalogService.h @@ -50,6 +50,10 @@ struct MockTableMeta { class MockCatalogServiceImpl; class MockCatalogService { public: + static void destoryCatalogReq(SCatalogReq* pReq); + static void destoryMetaRes(void* p); + static void destoryMetaData(SMetaData* pData); + MockCatalogService(); ~MockCatalogService(); ITableBuilder& createTableBuilder(const std::string& db, const std::string& tbname, int8_t tableType, diff --git a/source/libs/parser/test/parInitialATest.cpp b/source/libs/parser/test/parInitialATest.cpp index f554651b90..cc23fbbc60 100644 --- a/source/libs/parser/test/parInitialATest.cpp +++ b/source/libs/parser/test/parInitialATest.cpp @@ -76,6 +76,11 @@ TEST_F(ParserInitialATest, alterSTable) { SMAlterStbReq expect = {0}; + auto clearAlterStbReq = [&]() { + tFreeSMAltertbReq(&expect); + memset(&expect, 0, sizeof(SMAlterStbReq)); + }; + auto setAlterStbReqFunc = [&](const char* pTbname, int8_t alterType, int32_t numOfFields = 0, const char* pField1Name = nullptr, int8_t field1Type = 0, int32_t field1Bytes = 0, const char* pField2Name = nullptr, const char* pComment = nullptr, @@ -139,39 +144,49 @@ TEST_F(ParserInitialATest, alterSTable) { ASSERT_EQ(pField->type, pExpectField->type); ASSERT_EQ(pField->bytes, pExpectField->bytes); } + tFreeSMAltertbReq(&req); }); setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_OPTIONS, 0, nullptr, 0, 0, nullptr, nullptr, 10); run("ALTER TABLE st1 TTL 10"); + clearAlterStbReq(); setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_OPTIONS, 0, nullptr, 0, 0, nullptr, "test"); run("ALTER TABLE st1 COMMENT 'test'"); + clearAlterStbReq(); setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_ADD_COLUMN, 1, "cc1", TSDB_DATA_TYPE_BIGINT); run("ALTER TABLE st1 ADD COLUMN cc1 BIGINT"); + clearAlterStbReq(); setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_DROP_COLUMN, 1, "c1"); run("ALTER TABLE st1 DROP COLUMN c1"); + clearAlterStbReq(); - setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, 1, "c1", TSDB_DATA_TYPE_VARCHAR, - 20 + VARSTR_HEADER_SIZE); - run("ALTER TABLE st1 MODIFY COLUMN c1 VARCHAR(20)"); + setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, 1, "c2", TSDB_DATA_TYPE_VARCHAR, + 30 + VARSTR_HEADER_SIZE); + run("ALTER TABLE st1 MODIFY COLUMN c2 VARCHAR(30)"); + clearAlterStbReq(); // setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, 2, "c1", 0, 0, "cc1"); // run("ALTER TABLE st1 RENAME COLUMN c1 cc1"); setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_ADD_TAG, 1, "tag11", TSDB_DATA_TYPE_BIGINT); run("ALTER TABLE st1 ADD TAG tag11 BIGINT"); + clearAlterStbReq(); setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_DROP_TAG, 1, "tag1"); run("ALTER TABLE st1 DROP TAG tag1"); + clearAlterStbReq(); - setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, 1, "tag1", TSDB_DATA_TYPE_VARCHAR, - 20 + VARSTR_HEADER_SIZE); - run("ALTER TABLE st1 MODIFY TAG tag1 VARCHAR(20)"); + setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, 1, "tag2", TSDB_DATA_TYPE_VARCHAR, + 30 + VARSTR_HEADER_SIZE); + run("ALTER TABLE st1 MODIFY TAG tag2 VARCHAR(30)"); + clearAlterStbReq(); setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_TAG_NAME, 2, "tag1", 0, 0, "tag11"); run("ALTER TABLE st1 RENAME TAG tag1 tag11"); + clearAlterStbReq(); // todo // ADD {FULLTEXT | SMA} INDEX index_name (col_name [, col_name] ...) [index_option] @@ -181,6 +196,10 @@ TEST_F(ParserInitialATest, alterSTableSemanticCheck) { useDb("root", "test"); run("ALTER TABLE st1 RENAME COLUMN c1 cc1", TSDB_CODE_PAR_INVALID_ALTER_TABLE); + + run("ALTER TABLE st1 MODIFY COLUMN c2 NCHAR(10)", TSDB_CODE_PAR_INVALID_MODIFY_COL); + + run("ALTER TABLE st1 MODIFY TAG tag2 NCHAR(10)", TSDB_CODE_PAR_INVALID_MODIFY_COL); } TEST_F(ParserInitialATest, alterTable) { @@ -188,9 +207,16 @@ TEST_F(ParserInitialATest, alterTable) { SVAlterTbReq expect = {0}; + auto clearAlterTbReq = [&]() { + free(expect.tbName); + free(expect.colName); + free(expect.colNewName); + free(expect.tagName); + memset(&expect, 0, sizeof(SVAlterTbReq)); + }; + auto setAlterColFunc = [&](const char* pTbname, int8_t alterType, const char* pColName, int8_t dataType = 0, int32_t dataBytes = 0, const char* pNewColName = nullptr) { - memset(&expect, 0, sizeof(SVAlterTbReq)); expect.tbName = strdup(pTbname); expect.action = alterType; expect.colName = strdup(pColName); @@ -213,7 +239,6 @@ TEST_F(ParserInitialATest, alterTable) { }; auto setAlterTagFunc = [&](const char* pTbname, const char* pTagName, uint8_t* pNewVal, uint32_t bytes) { - memset(&expect, 0, sizeof(SVAlterTbReq)); expect.tbName = strdup(pTbname); expect.action = TSDB_ALTER_TABLE_UPDATE_TAG_VAL; expect.tagName = strdup(pTagName); @@ -224,7 +249,6 @@ TEST_F(ParserInitialATest, alterTable) { }; auto setAlterOptionsFunc = [&](const char* pTbname, int32_t ttl, char* pComment = nullptr) { - memset(&expect, 0, sizeof(SVAlterTbReq)); expect.tbName = strdup(pTbname); expect.action = TSDB_ALTER_TABLE_UPDATE_OPTIONS; if (-1 != ttl) { @@ -281,25 +305,32 @@ TEST_F(ParserInitialATest, alterTable) { setAlterOptionsFunc("t1", 10, nullptr); run("ALTER TABLE t1 TTL 10"); + clearAlterTbReq(); setAlterOptionsFunc("t1", -1, (char*)"test"); run("ALTER TABLE t1 COMMENT 'test'"); + clearAlterTbReq(); setAlterColFunc("t1", TSDB_ALTER_TABLE_ADD_COLUMN, "cc1", TSDB_DATA_TYPE_BIGINT); run("ALTER TABLE t1 ADD COLUMN cc1 BIGINT"); + clearAlterTbReq(); setAlterColFunc("t1", TSDB_ALTER_TABLE_DROP_COLUMN, "c1"); run("ALTER TABLE t1 DROP COLUMN c1"); + clearAlterTbReq(); setAlterColFunc("t1", TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, "c2", TSDB_DATA_TYPE_VARCHAR, 30 + VARSTR_HEADER_SIZE); run("ALTER TABLE t1 MODIFY COLUMN c2 VARCHAR(30)"); + clearAlterTbReq(); setAlterColFunc("t1", TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, "c1", 0, 0, "cc1"); run("ALTER TABLE t1 RENAME COLUMN c1 cc1"); + clearAlterTbReq(); int32_t val = 10; setAlterTagFunc("st1s1", "tag1", (uint8_t*)&val, sizeof(val)); run("ALTER TABLE st1s1 SET TAG tag1=10"); + clearAlterTbReq(); // todo // ADD {FULLTEXT | SMA} INDEX index_name (col_name [, col_name] ...) [index_option] @@ -309,6 +340,8 @@ TEST_F(ParserInitialATest, alterTableSemanticCheck) { useDb("root", "test"); run("ALTER TABLE st1s1 RENAME COLUMN c1 cc1", TSDB_CODE_PAR_INVALID_ALTER_TABLE); + + run("ALTER TABLE st1s1 SET TAG tag2 = '123456789012345678901'", TSDB_CODE_PAR_WRONG_VALUE_TYPE); } TEST_F(ParserInitialATest, alterUser) { diff --git a/source/libs/parser/test/parInitialCTest.cpp b/source/libs/parser/test/parInitialCTest.cpp index f306947f76..3a6c78d808 100644 --- a/source/libs/parser/test/parInitialCTest.cpp +++ b/source/libs/parser/test/parInitialCTest.cpp @@ -67,8 +67,12 @@ TEST_F(ParserInitialCTest, createDatabase) { SCreateDbReq expect = {0}; - auto setCreateDbReqFunc = [&](const char* pDbname, int8_t igExists = 0) { + auto clearCreateDbReq = [&]() { + tFreeSCreateDbReq(&expect); memset(&expect, 0, sizeof(SCreateDbReq)); + }; + + auto setCreateDbReqFunc = [&](const char* pDbname, int8_t igExists = 0) { int32_t len = snprintf(expect.db, sizeof(expect.db), "0.%s", pDbname); expect.db[len] = '\0'; expect.ignoreExist = igExists; @@ -151,7 +155,7 @@ TEST_F(ParserInitialCTest, createDatabase) { ASSERT_EQ(req.replications, expect.replications); ASSERT_EQ(req.strict, expect.strict); ASSERT_EQ(req.cacheLastRow, expect.cacheLastRow); - ASSERT_EQ(req.schemaless, expect.schemaless); + //ASSERT_EQ(req.schemaless, expect.schemaless); ASSERT_EQ(req.ignoreExist, expect.ignoreExist); ASSERT_EQ(req.numOfRetensions, expect.numOfRetensions); if (expect.numOfRetensions > 0) { @@ -166,10 +170,12 @@ TEST_F(ParserInitialCTest, createDatabase) { ASSERT_EQ(pReten->keepUnit, pExpectReten->keepUnit); } } + tFreeSCreateDbReq(&req); }); setCreateDbReqFunc("wxy_db"); run("CREATE DATABASE wxy_db"); + clearCreateDbReq(); setCreateDbReqFunc("wxy_db", 1); setDbBufferFunc(64); @@ -211,6 +217,7 @@ TEST_F(ParserInitialCTest, createDatabase) { "VGROUPS 100 " "SINGLE_STABLE 1 " "SCHEMALESS 1"); + clearCreateDbReq(); setCreateDbReqFunc("wxy_db", 1); setDbDaysFunc(100); @@ -218,6 +225,7 @@ TEST_F(ParserInitialCTest, createDatabase) { run("CREATE DATABASE IF NOT EXISTS wxy_db " "DAYS 100m " "KEEP 1440m,300h,400d "); + clearCreateDbReq(); } TEST_F(ParserInitialCTest, createDatabaseSemanticCheck) { @@ -309,10 +317,14 @@ TEST_F(ParserInitialCTest, createStable) { SMCreateStbReq expect = {0}; + auto clearCreateStbReq = [&]() { + tFreeSMCreateStbReq(&expect); + memset(&expect, 0, sizeof(SMCreateStbReq)); + }; + auto setCreateStbReqFunc = [&](const char* pTbname, int8_t igExists = 0, float xFilesFactor = TSDB_DEFAULT_ROLLUP_FILE_FACTOR, int32_t ttl = TSDB_DEFAULT_TABLE_TTL, const char* pComment = nullptr) { - memset(&expect, 0, sizeof(SMCreateStbReq)); int32_t len = snprintf(expect.name, sizeof(expect.name), "0.test.%s", pTbname); expect.name[len] = '\0'; expect.igExists = igExists; @@ -396,6 +408,7 @@ TEST_F(ParserInitialCTest, createStable) { if (expect.ast2Len > 0) { ASSERT_EQ(std::string(req.pAst2), std::string(expect.pAst2)); } + tFreeSMCreateStbReq(&req); }); setCreateStbReqFunc("t1"); @@ -403,6 +416,7 @@ TEST_F(ParserInitialCTest, createStable) { addFieldToCreateStbReqFunc(true, "c1", TSDB_DATA_TYPE_INT); addFieldToCreateStbReqFunc(false, "id", TSDB_DATA_TYPE_INT); run("CREATE STABLE t1(ts TIMESTAMP, c1 INT) TAGS(id INT)"); + clearCreateStbReq(); setCreateStbReqFunc("t1", 1, 0.1, 100, "test create table"); addFieldToCreateStbReqFunc(true, "ts", TSDB_DATA_TYPE_TIMESTAMP, 0, 0); @@ -443,6 +457,7 @@ TEST_F(ParserInitialCTest, createStable) { "a8 BINARY(20), a9 SMALLINT, a10 SMALLINT UNSIGNED COMMENT 'test column comment', a11 TINYINT, " "a12 TINYINT UNSIGNED, a13 BOOL, a14 NCHAR(30), a15 VARCHAR(50)) " "TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (MIN) FILE_FACTOR 0.1"); + clearCreateStbReq(); } TEST_F(ParserInitialCTest, createStableSemanticCheck) { @@ -455,13 +470,62 @@ TEST_F(ParserInitialCTest, createStableSemanticCheck) { TEST_F(ParserInitialCTest, createStream) { useDb("root", "test"); + SCMCreateStreamReq expect = {0}; + + auto clearCreateStreamReq = [&]() { + tFreeSCMCreateStreamReq(&expect); + memset(&expect, 0, sizeof(SCMCreateStreamReq)); + }; + + auto setCreateStbReqFunc = + [&](const char* pStream, const char* pSrcDb, const char* pSql, const char* pDstStb = nullptr, int8_t igExists = 0, + int8_t triggerType = STREAM_TRIGGER_AT_ONCE, int64_t maxDelay = 0, int64_t watermark = 0) { + snprintf(expect.name, sizeof(expect.name), "0.%s", pStream); + snprintf(expect.sourceDB, sizeof(expect.sourceDB), "0.%s", pSrcDb); + if (NULL != pDstStb) { + snprintf(expect.targetStbFullName, sizeof(expect.targetStbFullName), "0.test.%s", pDstStb); + } + expect.igExists = igExists; + expect.sql = strdup(pSql); + expect.triggerType = triggerType; + expect.maxDelay = maxDelay; + expect.watermark = watermark; + }; + + setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) { + ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_CREATE_STREAM_STMT); + SCMCreateStreamReq req = {0}; + ASSERT_TRUE(TSDB_CODE_SUCCESS == + tDeserializeSCMCreateStreamReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req)); + + ASSERT_EQ(std::string(req.name), std::string(expect.name)); + ASSERT_EQ(std::string(req.sourceDB), std::string(expect.sourceDB)); + ASSERT_EQ(std::string(req.targetStbFullName), std::string(expect.targetStbFullName)); + ASSERT_EQ(req.igExists, expect.igExists); + ASSERT_EQ(std::string(req.sql), std::string(expect.sql)); + ASSERT_EQ(req.triggerType, expect.triggerType); + ASSERT_EQ(req.maxDelay, expect.maxDelay); + ASSERT_EQ(req.watermark, expect.watermark); + tFreeSCMCreateStreamReq(&req); + }); + + setCreateStbReqFunc("s1", "test", "create stream s1 as select * from t1"); run("CREATE STREAM s1 AS SELECT * FROM t1"); + clearCreateStreamReq(); + setCreateStbReqFunc("s1", "test", "create stream if not exists s1 as select * from t1", nullptr, 1); run("CREATE STREAM IF NOT EXISTS s1 AS SELECT * FROM t1"); + clearCreateStreamReq(); + setCreateStbReqFunc("s1", "test", "create stream s1 into st1 as select * from t1", "st1"); run("CREATE STREAM s1 INTO st1 AS SELECT * FROM t1"); + clearCreateStreamReq(); - run("CREATE STREAM IF NOT EXISTS s1 TRIGGER WINDOW_CLOSE WATERMARK 10s INTO st1 AS SELECT * FROM t1"); + setCreateStbReqFunc("s1", "test", + "create stream if not exists s1 trigger max_delay 20s watermark 10s into st1 as select * from t1", + "st1", 1, STREAM_TRIGGER_MAX_DELAY, 20 * MILLISECOND_PER_SECOND, 10 * MILLISECOND_PER_SECOND); + run("CREATE STREAM IF NOT EXISTS s1 TRIGGER MAX_DELAY 20s WATERMARK 10s INTO st1 AS SELECT * FROM t1"); + clearCreateStreamReq(); } TEST_F(ParserInitialCTest, createTable) { @@ -484,12 +548,14 @@ TEST_F(ParserInitialCTest, createTable) { "a14 NCHAR(30), a15 VARCHAR(50)) " "TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (MIN) FILE_FACTOR 0.1"); - run("CREATE TABLE IF NOT EXISTS t1 USING st1 TAGS(1, 'wxy')"); + run("CREATE TABLE IF NOT EXISTS t1 USING st1 TAGS(1, 'wxy', NOW)"); run("CREATE TABLE " "IF NOT EXISTS test.t1 USING test.st1 (tag1, tag2) TAGS(1, 'abc') " "IF NOT EXISTS test.t2 USING test.st1 (tag1, tag2) TAGS(2, 'abc') " "IF NOT EXISTS test.t3 USING test.st1 (tag1, tag2) TAGS(3, 'abc') "); + + // run("CREATE TABLE IF NOT EXISTS t1 USING st1 TAGS(1, 'wxy', NOW + 1S)"); } TEST_F(ParserInitialCTest, createTopic) { @@ -497,9 +563,10 @@ TEST_F(ParserInitialCTest, createTopic) { SCMCreateTopicReq expect = {0}; + auto clearCreateTopicReq = [&]() { memset(&expect, 0, sizeof(SCMCreateTopicReq)); }; + auto setCreateTopicReqFunc = [&](const char* pTopicName, int8_t igExists, const char* pSql, const char* pAst, const char* pDbName = nullptr, const char* pTbname = nullptr) { - memset(&expect, 0, sizeof(SMCreateStbReq)); snprintf(expect.name, sizeof(expect.name), "0.%s", pTopicName); expect.igExists = igExists; expect.sql = (char*)pSql; @@ -538,19 +605,24 @@ TEST_F(ParserInitialCTest, createTopic) { default: ASSERT_TRUE(false); } + tFreeSCMCreateTopicReq(&req); }); setCreateTopicReqFunc("tp1", 0, "create topic tp1 as select * from t1", "ast"); run("CREATE TOPIC tp1 AS SELECT * FROM t1"); + clearCreateTopicReq(); setCreateTopicReqFunc("tp1", 1, "create topic if not exists tp1 as select ts, ceil(c1) from t1", "ast"); run("CREATE TOPIC IF NOT EXISTS tp1 AS SELECT ts, CEIL(c1) FROM t1"); + clearCreateTopicReq(); setCreateTopicReqFunc("tp1", 0, "create topic tp1 as database test", nullptr, "test"); run("CREATE TOPIC tp1 AS DATABASE test"); + clearCreateTopicReq(); setCreateTopicReqFunc("tp1", 1, "create topic if not exists tp1 as stable st1", nullptr, "test", "st1"); run("CREATE TOPIC IF NOT EXISTS tp1 AS STABLE st1"); + clearCreateTopicReq(); } TEST_F(ParserInitialCTest, createUser) { diff --git a/source/libs/parser/test/parInsertTest.cpp b/source/libs/parser/test/parInsertTest.cpp index eae83e2223..3ebf9a417b 100644 --- a/source/libs/parser/test/parInsertTest.cpp +++ b/source/libs/parser/test/parInsertTest.cpp @@ -35,6 +35,9 @@ string toString(int32_t code) { return tstrerror(code); } // [...]; class InsertTest : public Test { protected: + InsertTest() : res_(nullptr) {} + ~InsertTest() { reset(); } + void setDatabase(const string& acctId, const string& db) { acctId_ = acctId; db_ = db; @@ -51,7 +54,7 @@ class InsertTest : public Test { } int32_t run() { - code_ = parseInsertSql(&cxt_, &res_); + code_ = parseInsertSql(&cxt_, &res_, nullptr); if (code_ != TSDB_CODE_SUCCESS) { cout << "code:" << toString(code_) << ", msg:" << errMagBuf_ << endl; } @@ -60,29 +63,31 @@ class InsertTest : public Test { int32_t runAsync() { cxt_.async = true; - code_ = parseInsertSyntax(&cxt_, &res_); + unique_ptr metaCache(new SParseMetaCache(), _destoryParseMetaCache); + code_ = parseInsertSyntax(&cxt_, &res_, metaCache.get()); if (code_ != TSDB_CODE_SUCCESS) { cout << "parseInsertSyntax code:" << toString(code_) << ", msg:" << errMagBuf_ << endl; return code_; } - SCatalogReq catalogReq = {0}; - code_ = buildCatalogReq(res_->pMetaCache, &catalogReq); + unique_ptr catalogReq(new SCatalogReq(), + MockCatalogService::destoryCatalogReq); + code_ = buildCatalogReq(metaCache.get(), catalogReq.get()); if (code_ != TSDB_CODE_SUCCESS) { cout << "buildCatalogReq code:" << toString(code_) << ", msg:" << errMagBuf_ << endl; return code_; } - SMetaData metaData = {0}; - g_mockCatalogService->catalogGetAllMeta(&catalogReq, &metaData); + unique_ptr metaData(new SMetaData(), MockCatalogService::destoryMetaData); + g_mockCatalogService->catalogGetAllMeta(catalogReq.get(), metaData.get()); - code_ = putMetaDataToCache(&catalogReq, &metaData, res_->pMetaCache); + code_ = putMetaDataToCache(catalogReq.get(), metaData.get(), metaCache.get()); if (code_ != TSDB_CODE_SUCCESS) { cout << "putMetaDataToCache code:" << toString(code_) << ", msg:" << errMagBuf_ << endl; return code_; } - code_ = parseInsertSql(&cxt_, &res_); + code_ = parseInsertSql(&cxt_, &res_, metaCache.get()); if (code_ != TSDB_CODE_SUCCESS) { cout << "parseInsertSql code:" << toString(code_) << ", msg:" << errMagBuf_ << endl; return code_; @@ -139,12 +144,18 @@ class InsertTest : public Test { static const int max_err_len = 1024; static const int max_sql_len = 1024 * 1024; + static void _destoryParseMetaCache(SParseMetaCache* pMetaCache) { + destoryParseMetaCache(pMetaCache); + delete pMetaCache; + } + void reset() { memset(&cxt_, 0, sizeof(cxt_)); memset(errMagBuf_, 0, max_err_len); cxt_.pMsg = errMagBuf_; cxt_.msgLen = max_err_len; code_ = TSDB_CODE_SUCCESS; + qDestroyQuery(res_); res_ = nullptr; } @@ -234,8 +245,8 @@ TEST_F(InsertTest, autoCreateTableTest) { setDatabase("root", "test"); bind( - "insert into st1s1 using st1 tags(1, 'wxy') values (now, 1, \"beijing\")(now+1s, 2, \"shanghai\")(now+2s, 3, " - "\"guangzhou\")"); + "insert into st1s1 using st1 tags(1, 'wxy', now) " + "values (now, 1, \"beijing\")(now+1s, 2, \"shanghai\")(now+2s, 3, \"guangzhou\")"); ASSERT_EQ(run(), TSDB_CODE_SUCCESS); dumpReslut(); checkReslut(1, 3); @@ -246,8 +257,8 @@ TEST_F(InsertTest, autoCreateTableTest) { ASSERT_EQ(run(), TSDB_CODE_SUCCESS); bind( - "insert into st1s1 using st1 tags(1, 'wxy') values (now, 1, \"beijing\")(now+1s, 2, \"shanghai\")(now+2s, 3, " - "\"guangzhou\")"); + "insert into st1s1 using st1 tags(1, 'wxy', now) " + "values (now, 1, \"beijing\")(now+1s, 2, \"shanghai\")(now+2s, 3, \"guangzhou\")"); ASSERT_EQ(runAsync(), TSDB_CODE_SUCCESS); bind( diff --git a/source/libs/parser/test/parSelectTest.cpp b/source/libs/parser/test/parSelectTest.cpp index 51d302fe12..c87520e262 100644 --- a/source/libs/parser/test/parSelectTest.cpp +++ b/source/libs/parser/test/parSelectTest.cpp @@ -219,6 +219,7 @@ TEST_F(ParserSelectTest, intervalSemanticCheck) { run("SELECT HISTOGRAM(c1, 'log_bin', '{\"start\": -33,\"factor\": 55,\"count\": 5,\"infinity\": false}', 1) FROM t1 " "WHERE ts > TIMESTAMP '2022-04-01 00:00:00' and ts < TIMESTAMP '2022-04-30 23:59:59' INTERVAL(10s) FILL(NULL)", TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC); + run("SELECT _WSTARTTS, _WENDTS, _WDURATION, sum(c1) FROM t1", TSDB_CODE_PAR_INVALID_WINDOW_PC); } TEST_F(ParserSelectTest, subquery) { @@ -231,13 +232,22 @@ TEST_F(ParserSelectTest, subquery) { run("SELECT SUM(a) FROM (SELECT MAX(c1) a, ts FROM st1s1 PARTITION BY TBNAME INTERVAL(1m)) INTERVAL(1n)"); run("SELECT SUM(a) FROM (SELECT MAX(c1) a, _wstartts FROM st1s1 PARTITION BY TBNAME INTERVAL(1m)) INTERVAL(1n)"); + + run("SELECT _C0 FROM (SELECT _ROWTS, ts FROM st1s1)"); + + run("SELECT ts FROM (SELECT t1.ts FROM st1s1 t1)"); } TEST_F(ParserSelectTest, subquerySemanticCheck) { useDb("root", "test"); - run("SELECT SUM(a) FROM (SELECT MAX(c1) a FROM st1s1 INTERVAL(1m)) INTERVAL(1n)", TSDB_CODE_PAR_NOT_ALLOWED_WIN_QUERY, - PARSER_STAGE_TRANSLATE); + run("SELECT SUM(a) FROM (SELECT MAX(c1) a FROM st1s1 INTERVAL(1m)) INTERVAL(1n)", + TSDB_CODE_PAR_NOT_ALLOWED_WIN_QUERY); + + run("SELECT ts FROM (SELECT t1.ts AS ts, t2.ts FROM st1s1 t1, st1s2 t2 WHERE t1.ts = t2.ts)", + TSDB_CODE_PAR_AMBIGUOUS_COLUMN); + + run("SELECT ts FROM (SELECT ts AS c1 FROM st1s1 t1)", TSDB_CODE_PAR_INVALID_COLUMN); } TEST_F(ParserSelectTest, semanticCheck) { diff --git a/source/libs/parser/test/parTestMain.cpp b/source/libs/parser/test/parTestMain.cpp index ecc535feb0..bcaccbab07 100644 --- a/source/libs/parser/test/parTestMain.cpp +++ b/source/libs/parser/test/parTestMain.cpp @@ -45,6 +45,7 @@ class ParserEnv : public testing::Environment { destroyMetaDataEnv(); taosCleanupKeywordsTable(); fmFuncMgtDestroy(); + taosCloseLog(); } ParserEnv() {} diff --git a/source/libs/parser/test/parTestUtil.cpp b/source/libs/parser/test/parTestUtil.cpp index fab7ed35b1..663f456cb8 100644 --- a/source/libs/parser/test/parTestUtil.cpp +++ b/source/libs/parser/test/parTestUtil.cpp @@ -62,7 +62,7 @@ int32_t getLogLevel() { return g_logLevel; } class ParserTestBaseImpl { public: - ParserTestBaseImpl(ParserTestBase* pBase) : pBase_(pBase) {} + ParserTestBaseImpl(ParserTestBase* pBase) : pBase_(pBase), sqlNo_(0) {} void login(const std::string& user) { caseEnv_.user_ = user; } @@ -73,38 +73,18 @@ class ParserTestBaseImpl { } void run(const string& sql, int32_t expect, ParserStage checkStage) { + ++sqlNo_; if (caseEnv_.nsql_ > 0) { --(caseEnv_.nsql_); return; } - reset(expect, checkStage); - try { - SParseContext cxt = {0}; - setParseContext(sql, &cxt); - - SQuery* pQuery = nullptr; - doParse(&cxt, &pQuery); - - doAuthenticate(&cxt, pQuery); - - doTranslate(&cxt, pQuery); - - doCalculateConstant(&cxt, pQuery); - - if (g_dump) { - dump(); - } - } catch (const TerminateFlag& e) { - // success and terminate - return; - } catch (...) { - dump(); - throw; - } + runInternalFuncs(sql, expect, checkStage); + runApis(sql, expect, checkStage); if (g_testAsyncApis) { - runAsync(sql, expect, checkStage); + runAsyncInternalFuncs(sql, expect, checkStage); + runAsyncApis(sql, expect, checkStage); } } @@ -131,34 +111,63 @@ class ParserTestBaseImpl { string calcConstAst_; }; + enum TestInterfaceType { + TEST_INTERFACE_INTERNAL = 1, + TEST_INTERFACE_API, + TEST_INTERFACE_ASYNC_INTERNAL, + TEST_INTERFACE_ASYNC_API + }; + + static void _destoryParseMetaCache(SParseMetaCache* pMetaCache) { + destoryParseMetaCache(pMetaCache); + delete pMetaCache; + } + bool checkResultCode(const string& pFunc, int32_t resultCode) { return !(stmtEnv_.checkFunc_.empty()) - ? (("*" == stmtEnv_.checkFunc_ || stmtEnv_.checkFunc_ == pFunc) ? stmtEnv_.expect_ == resultCode - : TSDB_CODE_SUCCESS == resultCode) + ? ((stmtEnv_.checkFunc_ == pFunc) ? stmtEnv_.expect_ == resultCode : TSDB_CODE_SUCCESS == resultCode) : true; } - string stageFunc(ParserStage stage) { - switch (stage) { - case PARSER_STAGE_PARSE: - return "parse"; - case PARSER_STAGE_TRANSLATE: - return "translate"; - case PARSER_STAGE_CALC_CONST: - return "calculateConstant"; - case PARSER_STAGE_ALL: - return "*"; + string stageFunc(ParserStage stage, TestInterfaceType type) { + switch (type) { + case TEST_INTERFACE_INTERNAL: + case TEST_INTERFACE_ASYNC_INTERNAL: + switch (stage) { + case PARSER_STAGE_PARSE: + return "parse"; + case PARSER_STAGE_TRANSLATE: + return "translate"; + case PARSER_STAGE_CALC_CONST: + return "calculateConstant"; + default: + break; + } + break; + case TEST_INTERFACE_API: + return "qParseSql"; + case TEST_INTERFACE_ASYNC_API: + switch (stage) { + case PARSER_STAGE_PARSE: + return "qParseSqlSyntax"; + case PARSER_STAGE_TRANSLATE: + case PARSER_STAGE_CALC_CONST: + return "qAnalyseSqlSemantic"; + default: + break; + } + break; default: break; } return "unknown"; } - void reset(int32_t expect, ParserStage checkStage) { + void reset(int32_t expect, ParserStage checkStage, TestInterfaceType type) { stmtEnv_.sql_.clear(); stmtEnv_.msgBuf_.fill(0); stmtEnv_.expect_ = expect; - stmtEnv_.checkFunc_ = stageFunc(checkStage); + stmtEnv_.checkFunc_ = stageFunc(checkStage, type); res_.parsedAst_.clear(); res_.translatedAst_.clear(); @@ -166,13 +175,19 @@ class ParserTestBaseImpl { } void dump() { - cout << "==========================================sql : [" << stmtEnv_.sql_ << "]" << endl; - cout << "raw syntax tree : " << endl; - cout << res_.parsedAst_ << endl; - cout << "translated syntax tree : " << endl; - cout << res_.translatedAst_ << endl; - cout << "optimized syntax tree : " << endl; - cout << res_.calcConstAst_ << endl; + cout << "========================================== " << sqlNo_ << " sql : [" << stmtEnv_.sql_ << "]" << endl; + if (!res_.parsedAst_.empty()) { + cout << "raw syntax tree : " << endl; + cout << res_.parsedAst_ << endl; + } + if (!res_.translatedAst_.empty()) { + cout << "translated syntax tree : " << endl; + cout << res_.translatedAst_ << endl; + } + if (!res_.calcConstAst_.empty()) { + cout << "optimized syntax tree : " << endl; + cout << res_.calcConstAst_ << endl; + } } void setParseContext(const string& sql, SParseContext* pCxt, bool async = false) { @@ -196,9 +211,8 @@ class ParserTestBaseImpl { res_.parsedAst_ = toString((*pQuery)->pRoot); } - void doCollectMetaKey(SParseContext* pCxt, SQuery* pQuery) { - DO_WITH_THROW(collectMetaKey, pCxt, pQuery); - ASSERT_NE(pQuery->pMetaCache, nullptr); + void doCollectMetaKey(SParseContext* pCxt, SQuery* pQuery, SParseMetaCache* pMetaCache) { + DO_WITH_THROW(collectMetaKey, pCxt, pQuery, pMetaCache); } void doBuildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalogReq) { @@ -213,10 +227,12 @@ class ParserTestBaseImpl { DO_WITH_THROW(putMetaDataToCache, pCatalogReq, pMetaData, pMetaCache); } - void doAuthenticate(SParseContext* pCxt, SQuery* pQuery) { DO_WITH_THROW(authenticate, pCxt, pQuery); } + void doAuthenticate(SParseContext* pCxt, SQuery* pQuery, SParseMetaCache* pMetaCache) { + DO_WITH_THROW(authenticate, pCxt, pQuery, pMetaCache); + } - void doTranslate(SParseContext* pCxt, SQuery* pQuery) { - DO_WITH_THROW(translate, pCxt, pQuery); + void doTranslate(SParseContext* pCxt, SQuery* pQuery, SParseMetaCache* pMetaCache) { + DO_WITH_THROW(translate, pCxt, pQuery, pMetaCache); checkQuery(pQuery, PARSER_STAGE_TRANSLATE); res_.translatedAst_ = toString(pQuery->pRoot); } @@ -226,6 +242,24 @@ class ParserTestBaseImpl { res_.calcConstAst_ = toString(pQuery->pRoot); } + void doParseSql(SParseContext* pCxt, SQuery** pQuery) { + DO_WITH_THROW(qParseSql, pCxt, pQuery); + ASSERT_NE(*pQuery, nullptr); + res_.calcConstAst_ = toString((*pQuery)->pRoot); + } + + void doParseSqlSyntax(SParseContext* pCxt, SQuery** pQuery, SCatalogReq* pCatalogReq) { + DO_WITH_THROW(qParseSqlSyntax, pCxt, pQuery, pCatalogReq); + ASSERT_NE(*pQuery, nullptr); + res_.parsedAst_ = toString((*pQuery)->pRoot); + } + + void doAnalyseSqlSemantic(SParseContext* pCxt, const SCatalogReq* pCatalogReq, const SMetaData* pMetaData, + SQuery* pQuery) { + DO_WITH_THROW(qAnalyseSqlSemantic, pCxt, pCatalogReq, pMetaData, pQuery); + res_.calcConstAst_ = toString(pQuery->pRoot); + } + string toString(const SNode* pRoot) { char* pStr = NULL; int32_t len = 0; @@ -237,31 +271,84 @@ class ParserTestBaseImpl { void checkQuery(const SQuery* pQuery, ParserStage stage) { pBase_->checkDdl(pQuery, stage); } - void runAsync(const string& sql, int32_t expect, ParserStage checkStage) { - reset(expect, checkStage); + void runInternalFuncs(const string& sql, int32_t expect, ParserStage checkStage) { + reset(expect, checkStage, TEST_INTERFACE_INTERNAL); + try { + SParseContext cxt = {0}; + setParseContext(sql, &cxt); + + SQuery* pQuery = nullptr; + doParse(&cxt, &pQuery); + unique_ptr query(pQuery, qDestroyQuery); + + doAuthenticate(&cxt, pQuery, nullptr); + + doTranslate(&cxt, pQuery, nullptr); + + doCalculateConstant(&cxt, pQuery); + + if (g_dump) { + dump(); + } + } catch (const TerminateFlag& e) { + // success and terminate + return; + } catch (...) { + dump(); + throw; + } + } + + void runApis(const string& sql, int32_t expect, ParserStage checkStage) { + reset(expect, checkStage, TEST_INTERFACE_API); + try { + SParseContext cxt = {0}; + setParseContext(sql, &cxt); + + SQuery* pQuery = nullptr; + doParseSql(&cxt, &pQuery); + unique_ptr query(pQuery, qDestroyQuery); + + if (g_dump) { + dump(); + } + } catch (const TerminateFlag& e) { + // success and terminate + return; + } catch (...) { + dump(); + throw; + } + } + + void runAsyncInternalFuncs(const string& sql, int32_t expect, ParserStage checkStage) { + reset(expect, checkStage, TEST_INTERFACE_ASYNC_INTERNAL); try { SParseContext cxt = {0}; setParseContext(sql, &cxt, true); SQuery* pQuery = nullptr; doParse(&cxt, &pQuery); + unique_ptr query(pQuery, qDestroyQuery); - doCollectMetaKey(&cxt, pQuery); + unique_ptr metaCache(new SParseMetaCache(), _destoryParseMetaCache); + doCollectMetaKey(&cxt, pQuery, metaCache.get()); - SCatalogReq catalogReq = {0}; - doBuildCatalogReq(pQuery->pMetaCache, &catalogReq); + unique_ptr catalogReq(new SCatalogReq(), + MockCatalogService::destoryCatalogReq); + doBuildCatalogReq(metaCache.get(), catalogReq.get()); string err; thread t1([&]() { try { - SMetaData metaData = {0}; - doGetAllMeta(&catalogReq, &metaData); + unique_ptr metaData(new SMetaData(), MockCatalogService::destoryMetaData); + doGetAllMeta(catalogReq.get(), metaData.get()); - doPutMetaDataToCache(&catalogReq, &metaData, pQuery->pMetaCache); + doPutMetaDataToCache(catalogReq.get(), metaData.get(), metaCache.get()); - doAuthenticate(&cxt, pQuery); + doAuthenticate(&cxt, pQuery, metaCache.get()); - doTranslate(&cxt, pQuery); + doTranslate(&cxt, pQuery, metaCache.get()); doCalculateConstant(&cxt, pQuery); } catch (const TerminateFlag& e) { @@ -290,10 +377,56 @@ class ParserTestBaseImpl { } } + void runAsyncApis(const string& sql, int32_t expect, ParserStage checkStage) { + reset(expect, checkStage, TEST_INTERFACE_ASYNC_API); + try { + SParseContext cxt = {0}; + setParseContext(sql, &cxt); + + unique_ptr catalogReq(new SCatalogReq(), + MockCatalogService::destoryCatalogReq); + SQuery* pQuery = nullptr; + doParseSqlSyntax(&cxt, &pQuery, catalogReq.get()); + unique_ptr query(pQuery, qDestroyQuery); + + string err; + thread t1([&]() { + try { + unique_ptr metaData(new SMetaData(), MockCatalogService::destoryMetaData); + doGetAllMeta(catalogReq.get(), metaData.get()); + + doAnalyseSqlSemantic(&cxt, catalogReq.get(), metaData.get(), pQuery); + } catch (const TerminateFlag& e) { + // success and terminate + } catch (const runtime_error& e) { + err = e.what(); + } catch (...) { + err = "unknown error"; + } + }); + + t1.join(); + if (!err.empty()) { + throw runtime_error(err); + } + + if (g_dump) { + dump(); + } + } catch (const TerminateFlag& e) { + // success and terminate + return; + } catch (...) { + dump(); + throw; + } + } + caseEnv caseEnv_; stmtEnv stmtEnv_; stmtRes res_; ParserTestBase* pBase_; + int32_t sqlNo_; }; ParserTestBase::ParserTestBase() : impl_(new ParserTestBaseImpl(this)) {} diff --git a/source/libs/parser/test/parTestUtil.h b/source/libs/parser/test/parTestUtil.h index ad21252c2b..afdb763448 100644 --- a/source/libs/parser/test/parTestUtil.h +++ b/source/libs/parser/test/parTestUtil.h @@ -27,7 +27,7 @@ namespace ParserTest { class ParserTestBaseImpl; -enum ParserStage { PARSER_STAGE_PARSE, PARSER_STAGE_TRANSLATE, PARSER_STAGE_CALC_CONST, PARSER_STAGE_ALL }; +enum ParserStage { PARSER_STAGE_PARSE = 1, PARSER_STAGE_TRANSLATE, PARSER_STAGE_CALC_CONST }; class ParserTestBase : public testing::Test { public: diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index d67b194192..17ab06cac9 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -138,7 +138,7 @@ static int32_t createRootLogicNode(SLogicPlanContext* pCxt, void* pStmt, uint8_t code = pushLogicNode(pCxt, pRoot, pNode); } if (TSDB_CODE_SUCCESS != code) { - nodesDestroyNode(pNode); + nodesDestroyNode((SNode*)pNode); } return code; } @@ -173,8 +173,8 @@ static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols return SCAN_TYPE_TAG; } -static SNodeptr createPrimaryKeyCol(uint64_t tableId) { - SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN); +static SNode* createPrimaryKeyCol(uint64_t tableId) { + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { return NULL; } @@ -184,7 +184,7 @@ static SNodeptr createPrimaryKeyCol(uint64_t tableId) { pCol->colId = PRIMARYKEY_TIMESTAMP_COL_ID; pCol->colType = COLUMN_TYPE_COLUMN; strcpy(pCol->colName, "#primarykey"); - return pCol; + return (SNode*)pCol; } static int32_t addPrimaryKeyCol(uint64_t tableId, SNodeList** pCols) { @@ -282,7 +282,7 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pScan; } else { - nodesDestroyNode(pScan); + nodesDestroyNode((SNode*)pScan); } return code; @@ -349,7 +349,7 @@ static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pJoin; } else { - nodesDestroyNode(pJoin); + nodesDestroyNode((SNode*)pJoin); } return code; @@ -377,7 +377,7 @@ static int32_t createLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSel if (TSDB_CODE_SUCCESS == code) { pNode->pConditions = nodesCloneNode(pSelect->pWhere); if (NULL != pSelect->pWhere && NULL == pNode->pConditions) { - nodesDestroyNode(pNode); + nodesDestroyNode((SNode*)pNode); return TSDB_CODE_OUT_OF_MEMORY; } pNode->precision = pSelect->precision; @@ -387,7 +387,7 @@ static int32_t createLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSel } static SColumnNode* createColumnByExpr(const char* pStmtName, SExprNode* pExpr) { - SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN); + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { return NULL; } @@ -451,7 +451,7 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pAgg; } else { - nodesDestroyNode(pAgg); + nodesDestroyNode((SNode*)pAgg); } return code; @@ -482,7 +482,7 @@ static int32_t createIndefRowsFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pIdfRowsFunc; } else { - nodesDestroyNode(pIdfRowsFunc); + nodesDestroyNode((SNode*)pIdfRowsFunc); } return code; @@ -514,7 +514,7 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pWindow; } else { - nodesDestroyNode(pWindow); + nodesDestroyNode((SNode*)pWindow); } return code; @@ -522,7 +522,7 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm static int32_t createWindowLogicNodeByState(SLogicPlanContext* pCxt, SStateWindowNode* pState, SSelectStmt* pSelect, SLogicNode** pLogicNode) { - SWindowLogicNode* pWindow = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW); + SWindowLogicNode* pWindow = (SWindowLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW); if (NULL == pWindow) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -532,7 +532,7 @@ static int32_t createWindowLogicNodeByState(SLogicPlanContext* pCxt, SStateWindo pWindow->pTspk = nodesCloneNode(pState->pCol); if (NULL == pWindow->pTspk) { - nodesDestroyNode(pWindow); + nodesDestroyNode((SNode*)pWindow); return TSDB_CODE_OUT_OF_MEMORY; } @@ -541,7 +541,7 @@ static int32_t createWindowLogicNodeByState(SLogicPlanContext* pCxt, SStateWindo static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionWindowNode* pSession, SSelectStmt* pSelect, SLogicNode** pLogicNode) { - SWindowLogicNode* pWindow = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW); + SWindowLogicNode* pWindow = (SWindowLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW); if (NULL == pWindow) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -549,9 +549,9 @@ static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionW pWindow->winType = WINDOW_TYPE_SESSION; pWindow->sessionGap = ((SValueNode*)pSession->pGap)->datum.i; - pWindow->pTspk = nodesCloneNode(pSession->pCol); + pWindow->pTspk = nodesCloneNode((SNode*)pSession->pCol); if (NULL == pWindow->pTspk) { - nodesDestroyNode(pWindow); + nodesDestroyNode((SNode*)pWindow); return TSDB_CODE_OUT_OF_MEMORY; } @@ -560,7 +560,7 @@ static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionW static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SIntervalWindowNode* pInterval, SSelectStmt* pSelect, SLogicNode** pLogicNode) { - SWindowLogicNode* pWindow = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW); + SWindowLogicNode* pWindow = (SWindowLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW); if (NULL == pWindow) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -576,7 +576,7 @@ static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SInterva pWindow->pTspk = nodesCloneNode(pInterval->pCol); if (NULL == pWindow->pTspk) { - nodesDestroyNode(pWindow); + nodesDestroyNode((SNode*)pWindow); return TSDB_CODE_OUT_OF_MEMORY; } @@ -610,7 +610,7 @@ static int32_t createFillLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect SFillNode* pFillNode = (SFillNode*)(((SIntervalWindowNode*)pSelect->pWindow)->pFill); - SFillLogicNode* pFill = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_FILL); + SFillLogicNode* pFill = (SFillLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_FILL); if (NULL == pFill) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -628,7 +628,7 @@ static int32_t createFillLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pFill; } else { - nodesDestroyNode(pFill); + nodesDestroyNode((SNode*)pFill); } return code; @@ -639,7 +639,7 @@ static int32_t createSortLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect return TSDB_CODE_SUCCESS; } - SSortLogicNode* pSort = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SORT); + SSortLogicNode* pSort = (SSortLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SORT); if (NULL == pSort) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -656,7 +656,7 @@ static int32_t createSortLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pSort; } else { - nodesDestroyNode(pSort); + nodesDestroyNode((SNode*)pSort); } return code; @@ -671,7 +671,7 @@ static int32_t createColumnByProjections(SLogicPlanContext* pCxt, const char* pS SNode* pNode; FOREACH(pNode, pExprs) { - if (TSDB_CODE_SUCCESS != nodesListAppend(pList, createColumnByExpr(pStmtName, (SExprNode*)pNode))) { + if (TSDB_CODE_SUCCESS != nodesListAppend(pList, (SNode*)createColumnByExpr(pStmtName, (SExprNode*)pNode))) { nodesDestroyList(pList); return TSDB_CODE_OUT_OF_MEMORY; } @@ -718,7 +718,7 @@ static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSel if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pProject; } else { - nodesDestroyNode(pProject); + nodesDestroyNode((SNode*)pProject); } return code; @@ -729,7 +729,7 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS return TSDB_CODE_SUCCESS; } - SPartitionLogicNode* pPartition = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_PARTITION); + SPartitionLogicNode* pPartition = (SPartitionLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_PARTITION); if (NULL == pPartition) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -747,7 +747,7 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pPartition; } else { - nodesDestroyNode(pPartition); + nodesDestroyNode((SNode*)pPartition); } return code; @@ -783,7 +783,7 @@ static int32_t createDistinctLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSe if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pAgg; } else { - nodesDestroyNode(pAgg); + nodesDestroyNode((SNode*)pAgg); } return code; @@ -820,7 +820,7 @@ static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele if (TSDB_CODE_SUCCESS == code) { *pLogicNode = pRoot; } else { - nodesDestroyNode(pRoot); + nodesDestroyNode((SNode*)pRoot); } return code; @@ -836,7 +836,7 @@ static int32_t createSetOpSortLogicNode(SLogicPlanContext* pCxt, SSetOperator* p return TSDB_CODE_SUCCESS; } - SSortLogicNode* pSort = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SORT); + SSortLogicNode* pSort = (SSortLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SORT); if (NULL == pSort) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -858,7 +858,7 @@ static int32_t createSetOpSortLogicNode(SLogicPlanContext* pCxt, SSetOperator* p if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pSort; } else { - nodesDestroyNode(pSort); + nodesDestroyNode((SNode*)pSort); } return code; @@ -894,7 +894,7 @@ static int32_t createSetOpProjectLogicNode(SLogicPlanContext* pCxt, SSetOperator if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pProject; } else { - nodesDestroyNode(pProject); + nodesDestroyNode((SNode*)pProject); } return code; @@ -925,7 +925,7 @@ static int32_t createSetOpAggLogicNode(SLogicPlanContext* pCxt, SSetOperator* pS if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pAgg; } else { - nodesDestroyNode(pAgg); + nodesDestroyNode((SNode*)pAgg); } return code; @@ -964,7 +964,7 @@ static int32_t createSetOpLogicNode(SLogicPlanContext* pCxt, SSetOperator* pSetO if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pSetOp; } else { - nodesDestroyNode(pSetOp); + nodesDestroyNode((SNode*)pSetOp); } return code; @@ -981,7 +981,7 @@ static int32_t createSetOperatorLogicNode(SLogicPlanContext* pCxt, SSetOperator* if (TSDB_CODE_SUCCESS == code) { *pLogicNode = pRoot; } else { - nodesDestroyNode(pRoot); + nodesDestroyNode((SNode*)pRoot); } return code; @@ -1003,7 +1003,7 @@ static int32_t getMsgType(ENodeType sqlType) { } static int32_t createVnodeModifLogicNode(SLogicPlanContext* pCxt, SVnodeModifOpStmt* pStmt, SLogicNode** pLogicNode) { - SVnodeModifyLogicNode* pModif = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY); + SVnodeModifyLogicNode* pModif = (SVnodeModifyLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY); if (NULL == pModif) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -1047,7 +1047,7 @@ static int32_t createDeleteScanLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* p if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pScan; } else { - nodesDestroyNode(pScan); + nodesDestroyNode((SNode*)pScan); } return code; @@ -1071,7 +1071,7 @@ static int32_t createDeleteAggLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pD if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pAgg; } else { - nodesDestroyNode(pAgg); + nodesDestroyNode((SNode*)pAgg); } return code; @@ -1094,7 +1094,7 @@ static int32_t createVnodeModifLogicNodeByDelete(SLogicPlanContext* pCxt, SDelet pModify->deleteTimeRange = pDelete->timeRange; pModify->pAffectedRows = nodesCloneNode(pDelete->pCountFunc); if (NULL == pModify->pAffectedRows) { - nodesDestroyNode(pModify); + nodesDestroyNode((SNode*)pModify); return TSDB_CODE_OUT_OF_MEMORY; } @@ -1115,7 +1115,7 @@ static int32_t createDeleteLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pDele if (TSDB_CODE_SUCCESS == code) { *pLogicNode = pRoot; } else { - nodesDestroyNode(pRoot); + nodesDestroyNode((SNode*)pRoot); } return code; @@ -1171,7 +1171,7 @@ int32_t createLogicPlan(SPlanContext* pCxt, SLogicSubplan** pLogicSubplan) { if (TSDB_CODE_SUCCESS == code) { *pLogicSubplan = pSubplan; } else { - nodesDestroyNode(pSubplan); + nodesDestroyNode((SNode*)pSubplan); } return code; diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index ae689c53d6..65d73b4cdb 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -247,7 +247,7 @@ static int32_t osdOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) } static int32_t cpdMergeCond(SNode** pDst, SNode** pSrc) { - SLogicConditionNode* pLogicCond = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); + SLogicConditionNode* pLogicCond = (SLogicConditionNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); if (NULL == pLogicCond) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -262,7 +262,7 @@ static int32_t cpdMergeCond(SNode** pDst, SNode** pSrc) { if (TSDB_CODE_SUCCESS == code) { *pDst = (SNode*)pLogicCond; } else { - nodesDestroyNode(pLogicCond); + nodesDestroyNode((SNode*)pLogicCond); } return code; } @@ -662,13 +662,13 @@ static int32_t opkGetScanNodesImpl(SLogicNode* pNode, bool* pNotOptimize, SNodeL switch (nodeType(pNode)) { case QUERY_NODE_LOGIC_PLAN_SCAN: if (TSDB_SUPER_TABLE != ((SScanLogicNode*)pNode)->tableType) { - return nodesListMakeAppend(pScanNodes, pNode); + return nodesListMakeAppend(pScanNodes, (SNode*)pNode); } break; case QUERY_NODE_LOGIC_PLAN_JOIN: - code = opkGetScanNodesImpl(nodesListGetNode(pNode->pChildren, 0), pNotOptimize, pScanNodes); + code = opkGetScanNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 0), pNotOptimize, pScanNodes); if (TSDB_CODE_SUCCESS == code) { - code = opkGetScanNodesImpl(nodesListGetNode(pNode->pChildren, 1), pNotOptimize, pScanNodes); + code = opkGetScanNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 1), pNotOptimize, pScanNodes); } return code; case QUERY_NODE_LOGIC_PLAN_AGG: @@ -683,7 +683,7 @@ static int32_t opkGetScanNodesImpl(SLogicNode* pNode, bool* pNotOptimize, SNodeL return TSDB_CODE_SUCCESS; } - return opkGetScanNodesImpl(nodesListGetNode(pNode->pChildren, 0), pNotOptimize, pScanNodes); + return opkGetScanNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 0), pNotOptimize, pScanNodes); } static int32_t opkGetScanNodes(SLogicNode* pNode, SNodeList** pScanNodes) { @@ -721,12 +721,12 @@ static int32_t opkDoOptimized(SOptimizeContext* pCxt, SSortLogicNode* pSort, SNo SNode* pDownNode = opkRewriteDownNode(pSort); SNode* pNode; FOREACH(pNode, pSort->node.pParent->pChildren) { - if (nodesEqualNode(pNode, pSort)) { + if (nodesEqualNode(pNode, (SNode*)pSort)) { REPLACE_NODE(pDownNode); break; } } - nodesDestroyNode(pSort); + nodesDestroyNode((SNode*)pSort); return TSDB_CODE_SUCCESS; } @@ -736,7 +736,7 @@ static int32_t opkOptimizeImpl(SOptimizeContext* pCxt, SSortLogicNode* pSort) { return TSDB_CODE_SUCCESS; } SNodeList* pScanNodes = NULL; - int32_t code = opkGetScanNodes(nodesListGetNode(pSort->node.pChildren, 0), &pScanNodes); + int32_t code = opkGetScanNodes((SLogicNode*)nodesListGetNode(pSort->node.pChildren, 0), &pScanNodes); if (TSDB_CODE_SUCCESS == code && NULL != pScanNodes) { code = opkDoOptimized(pCxt, pSort, pScanNodes); } @@ -768,7 +768,7 @@ static bool smaOptMayBeOptimized(SLogicNode* pNode) { } static int32_t smaOptCreateMerge(SLogicNode* pChild, SNodeList* pMergeKeys, SNodeList* pTargets, SLogicNode** pOutput) { - SMergeLogicNode* pMerge = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_MERGE); + SMergeLogicNode* pMerge = (SMergeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_MERGE); if (NULL == pMerge) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -778,7 +778,7 @@ static int32_t smaOptCreateMerge(SLogicNode* pChild, SNodeList* pMergeKeys, SNod pMerge->node.pTargets = pTargets; pMerge->pInputs = nodesCloneList(pChild->pTargets); if (NULL == pMerge->pInputs) { - nodesDestroyNode(pMerge); + nodesDestroyNode((SNode*)pMerge); return TSDB_CODE_OUT_OF_MEMORY; } @@ -788,9 +788,9 @@ static int32_t smaOptCreateMerge(SLogicNode* pChild, SNodeList* pMergeKeys, SNod static int32_t smaOptRecombinationNode(SLogicSubplan* pLogicSubplan, SLogicNode* pInterval, SLogicNode* pMerge, SLogicNode* pSmaScan) { - int32_t code = nodesListMakeAppend(&pMerge->pChildren, pInterval); + int32_t code = nodesListMakeAppend(&pMerge->pChildren, (SNode*)pInterval); if (TSDB_CODE_SUCCESS == code) { - code = nodesListMakeAppend(&pMerge->pChildren, pSmaScan); + code = nodesListMakeAppend(&pMerge->pChildren, (SNode*)pSmaScan); } if (TSDB_CODE_SUCCESS == code) { code = replaceLogicNode(pLogicSubplan, pInterval, pMerge); @@ -802,7 +802,7 @@ static int32_t smaOptRecombinationNode(SLogicSubplan* pLogicSubplan, SLogicNode* static int32_t smaOptCreateSmaScan(SScanLogicNode* pScan, STableIndexInfo* pIndex, SNodeList* pCols, SLogicNode** pOutput) { - SScanLogicNode* pSmaScan = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SCAN); + SScanLogicNode* pSmaScan = (SScanLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SCAN); if (NULL == pSmaScan) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -819,7 +819,7 @@ static int32_t smaOptCreateSmaScan(SScanLogicNode* pScan, STableIndexInfo* pInde pSmaScan->pVgroupList = taosMemoryCalloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo)); pSmaScan->node.pTargets = nodesCloneList(pCols); if (NULL == pSmaScan->pVgroupList || NULL == pSmaScan->node.pTargets) { - nodesDestroyNode(pSmaScan); + nodesDestroyNode((SNode*)pSmaScan); return TSDB_CODE_OUT_OF_MEMORY; } pSmaScan->pVgroupList->numOfVgroups = 1; @@ -851,7 +851,7 @@ static bool smaOptEqualInterval(SScanLogicNode* pScan, SWindowLogicNode* pWindow } static SNode* smaOptCreateSmaCol(SNode* pFunc, uint64_t tableId, int32_t colId) { - SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN); + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { return NULL; } @@ -926,32 +926,32 @@ static int32_t smaOptCouldApplyIndex(SScanLogicNode* pScan, STableIndexInfo* pIn } static SNode* smaOptCreateWStartTs() { - SFunctionNode* pWStart = nodesMakeNode(QUERY_NODE_FUNCTION); + SFunctionNode* pWStart = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); if (NULL == pWStart) { return NULL; } strcpy(pWStart->functionName, "_wstartts"); snprintf(pWStart->node.aliasName, sizeof(pWStart->node.aliasName), "%s.%p", pWStart->functionName, pWStart); if (TSDB_CODE_SUCCESS != fmGetFuncInfo(pWStart, NULL, 0)) { - nodesDestroyNode(pWStart); + nodesDestroyNode((SNode*)pWStart); return NULL; } return (SNode*)pWStart; } static int32_t smaOptCreateMergeKey(SNode* pCol, SNodeList** pMergeKeys) { - SOrderByExprNode* pMergeKey = nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR); + SOrderByExprNode* pMergeKey = (SOrderByExprNode*)nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR); if (NULL == pMergeKey) { return TSDB_CODE_OUT_OF_MEMORY; } pMergeKey->pExpr = nodesCloneNode(pCol); if (NULL == pMergeKey->pExpr) { - nodesDestroyNode(pMergeKey); + nodesDestroyNode((SNode*)pMergeKey); return TSDB_CODE_OUT_OF_MEMORY; } pMergeKey->order = ORDER_ASC; pMergeKey->nullOrder = NULL_ORDER_FIRST; - return nodesListMakeStrictAppend(pMergeKeys, pMergeKey); + return nodesListMakeStrictAppend(pMergeKeys, (SNode*)pMergeKey); } static int32_t smaOptRewriteInterval(SWindowLogicNode* pInterval, int32_t wstrartIndex, SNodeList** pMergeKeys) { diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 6391772abe..8502ffc04a 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -56,14 +56,14 @@ static int32_t getSlotKey(SNode* pNode, const char* pStmtName, char* pKey) { return sprintf(pKey, "%s", ((SExprNode*)pNode)->aliasName); } -static SNode* createSlotDesc(SPhysiPlanContext* pCxt, const SNode* pNode, int16_t slotId, bool output) { +static SNode* createSlotDesc(SPhysiPlanContext* pCxt, const SNode* pNode, int16_t slotId, bool output, bool reserve) { SSlotDescNode* pSlot = (SSlotDescNode*)nodesMakeNode(QUERY_NODE_SLOT_DESC); if (NULL == pSlot) { return NULL; } pSlot->slotId = slotId; pSlot->dataType = ((SExprNode*)pNode)->resType; - pSlot->reserve = false; + pSlot->reserve = reserve; pSlot->output = output; return (SNode*)pSlot; } @@ -131,7 +131,7 @@ static int32_t buildDataBlockSlots(SPhysiPlanContext* pCxt, SNodeList* pList, SD int16_t slotId = 0; SNode* pNode = NULL; FOREACH(pNode, pList) { - code = nodesListStrictAppend(pDataBlockDesc->pSlots, createSlotDesc(pCxt, pNode, slotId, true)); + code = nodesListStrictAppend(pDataBlockDesc->pSlots, createSlotDesc(pCxt, pNode, slotId, true, false)); if (TSDB_CODE_SUCCESS == code) { code = putSlotToHash(pDataBlockDesc->dataBlockId, slotId, pNode, pHash); } @@ -147,7 +147,7 @@ static int32_t buildDataBlockSlots(SPhysiPlanContext* pCxt, SNodeList* pList, SD } static int32_t createDataBlockDesc(SPhysiPlanContext* pCxt, SNodeList* pList, SDataBlockDescNode** pDataBlockDesc) { - SDataBlockDescNode* pDesc = nodesMakeNode(QUERY_NODE_DATABLOCK_DESC); + SDataBlockDescNode* pDesc = (SDataBlockDescNode*)nodesMakeNode(QUERY_NODE_DATABLOCK_DESC); if (NULL == pDesc) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -162,7 +162,7 @@ static int32_t createDataBlockDesc(SPhysiPlanContext* pCxt, SNodeList* pList, SD if (TSDB_CODE_SUCCESS == code) { *pDataBlockDesc = pDesc; } else { - nodesDestroyNode(pDesc); + nodesDestroyNode((SNode*)pDesc); } return code; @@ -181,7 +181,7 @@ static int16_t getUnsetSlotId(const SArray* pSlotIdsInfo) { } static int32_t addDataBlockSlotsImpl(SPhysiPlanContext* pCxt, SNodeList* pList, SDataBlockDescNode* pDataBlockDesc, - const char* pStmtName, bool output) { + const char* pStmtName, bool output, bool reserve) { if (NULL == pList) { return TSDB_CODE_SUCCESS; } @@ -196,7 +196,7 @@ static int32_t addDataBlockSlotsImpl(SPhysiPlanContext* pCxt, SNodeList* pList, int32_t len = getSlotKey(pExpr, pStmtName, name); SSlotIndex* pIndex = taosHashGet(pHash, name, len); if (NULL == pIndex) { - code = nodesListStrictAppend(pDataBlockDesc->pSlots, createSlotDesc(pCxt, pExpr, nextSlotId, output)); + code = nodesListStrictAppend(pDataBlockDesc->pSlots, createSlotDesc(pCxt, pExpr, nextSlotId, output, reserve)); if (TSDB_CODE_SUCCESS == code) { code = putSlotToHashImpl(pDataBlockDesc->dataBlockId, nextSlotId, name, len, pHash); } @@ -226,7 +226,7 @@ static int32_t addDataBlockSlotsImpl(SPhysiPlanContext* pCxt, SNodeList* pList, } static int32_t addDataBlockSlots(SPhysiPlanContext* pCxt, SNodeList* pList, SDataBlockDescNode* pDataBlockDesc) { - return addDataBlockSlotsImpl(pCxt, pList, pDataBlockDesc, NULL, false); + return addDataBlockSlotsImpl(pCxt, pList, pDataBlockDesc, NULL, false, false); } static int32_t addDataBlockSlot(SPhysiPlanContext* pCxt, SNode** pNode, SDataBlockDescNode* pDataBlockDesc) { @@ -248,11 +248,11 @@ static int32_t addDataBlockSlot(SPhysiPlanContext* pCxt, SNode** pNode, SDataBlo static int32_t addDataBlockSlotsForProject(SPhysiPlanContext* pCxt, const char* pStmtName, SNodeList* pList, SDataBlockDescNode* pDataBlockDesc) { - return addDataBlockSlotsImpl(pCxt, pList, pDataBlockDesc, pStmtName, true); + return addDataBlockSlotsImpl(pCxt, pList, pDataBlockDesc, pStmtName, true, false); } static int32_t pushdownDataBlockSlots(SPhysiPlanContext* pCxt, SNodeList* pList, SDataBlockDescNode* pDataBlockDesc) { - return addDataBlockSlotsImpl(pCxt, pList, pDataBlockDesc, NULL, true); + return addDataBlockSlotsImpl(pCxt, pList, pDataBlockDesc, NULL, true, true); } typedef struct SSetSlotIdCxt { @@ -350,7 +350,7 @@ static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode int32_t code = createDataBlockDesc(pCxt, pLogicNode->pTargets, &pPhysiNode->pOutputDataBlockDesc); if (TSDB_CODE_SUCCESS != code) { - nodesDestroyNode(pPhysiNode); + nodesDestroyNode((SNode*)pPhysiNode); return NULL; } pPhysiNode->pOutputDataBlockDesc->precision = pLogicNode->precision; @@ -439,7 +439,7 @@ static int32_t createScanPhysiNodeFinalize(SPhysiPlanContext* pCxt, SSubplan* pS if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pScanPhysiNode; } else { - nodesDestroyNode(pScanPhysiNode); + nodesDestroyNode((SNode*)pScanPhysiNode); } return code; @@ -486,7 +486,7 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp pTableScan->dataRequired = pScanLogicNode->dataRequired; pTableScan->pDynamicScanFuncs = nodesCloneList(pScanLogicNode->pDynamicScanFuncs); if (NULL != pScanLogicNode->pDynamicScanFuncs && NULL == pTableScan->pDynamicScanFuncs) { - nodesDestroyNode(pTableScan); + nodesDestroyNode((SNode*)pTableScan); return TSDB_CODE_OUT_OF_MEMORY; } pTableScan->interval = pScanLogicNode->interval; @@ -584,7 +584,7 @@ static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pJoin; } else { - nodesDestroyNode(pJoin); + nodesDestroyNode((SNode*)pJoin); } return code; @@ -635,7 +635,7 @@ static int32_t rewriteValueToOperator(SRewritePrecalcExprsCxt* pCxt, SNode** pNo } pOper->pLeft = nodesMakeNode(QUERY_NODE_LEFT_VALUE); if (NULL == pOper->pLeft) { - nodesDestroyNode(pOper); + nodesDestroyNode((SNode*)pOper); return TSDB_CODE_OUT_OF_MEMORY; } SValueNode* pVal = (SValueNode*)*pNode; @@ -782,7 +782,7 @@ static int32_t createAggPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pAgg; } else { - nodesDestroyNode(pAgg); + nodesDestroyNode((SNode*)pAgg); } nodesDestroyList(pPrecalcExprs); @@ -823,7 +823,7 @@ static int32_t createIndefRowsFuncPhysiNode(SPhysiPlanContext* pCxt, SNodeList* if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pIdfRowsFunc; } else { - nodesDestroyNode(pIdfRowsFunc); + nodesDestroyNode((SNode*)pIdfRowsFunc); } return code; @@ -855,7 +855,7 @@ static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChild if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pProject; } else { - nodesDestroyNode(pProject); + nodesDestroyNode((SNode*)pProject); } return code; @@ -904,7 +904,7 @@ static int32_t createStreamScanPhysiNodeByExchange(SPhysiPlanContext* pCxt, SExc if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pScan; } else { - nodesDestroyNode(pScan); + nodesDestroyNode((SNode*)pScan); } return code; @@ -952,7 +952,7 @@ static int32_t createWindowPhysiNodeFinalize(SPhysiPlanContext* pCxt, SNodeList* if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pWindow; } else { - nodesDestroyNode(pWindow); + nodesDestroyNode((SNode*)pWindow); } return code; @@ -1037,7 +1037,7 @@ static int32_t createStateWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pC } if (TSDB_CODE_SUCCESS != code) { - nodesDestroyNode(pState); + nodesDestroyNode((SNode*)pState); return code; } @@ -1094,7 +1094,7 @@ static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pSort; } else { - nodesDestroyNode(pSort); + nodesDestroyNode((SNode*)pSort); } return code; @@ -1117,7 +1117,7 @@ static int32_t createPartitionPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChi if (TSDB_CODE_SUCCESS == code && NULL != pPrecalcExprs) { code = setListSlotId(pCxt, pChildTupe->dataBlockId, -1, pPrecalcExprs, &pPart->pExprs); if (TSDB_CODE_SUCCESS == code) { - code = addDataBlockSlots(pCxt, pPart->pExprs, pChildTupe); + code = pushdownDataBlockSlots(pCxt, pPart->pExprs, pChildTupe); } } @@ -1135,7 +1135,7 @@ static int32_t createPartitionPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChi if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pPart; } else { - nodesDestroyNode(pPart); + nodesDestroyNode((SNode*)pPart); } return code; @@ -1174,28 +1174,28 @@ static int32_t createFillPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pFill; } else { - nodesDestroyNode(pFill); + nodesDestroyNode((SNode*)pFill); } return code; } static int32_t createExchangePhysiNodeByMerge(SMergePhysiNode* pMerge) { - SExchangePhysiNode* pExchange = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_EXCHANGE); + SExchangePhysiNode* pExchange = (SExchangePhysiNode*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_EXCHANGE); if (NULL == pExchange) { return TSDB_CODE_OUT_OF_MEMORY; } pExchange->srcGroupId = pMerge->srcGroupId; pExchange->singleChannel = true; pExchange->node.pParent = (SPhysiNode*)pMerge; - pExchange->node.pOutputDataBlockDesc = nodesCloneNode(pMerge->node.pOutputDataBlockDesc); + pExchange->node.pOutputDataBlockDesc = (SDataBlockDescNode*)nodesCloneNode((SNode*)pMerge->node.pOutputDataBlockDesc); if (NULL == pExchange->node.pOutputDataBlockDesc) { - nodesDestroyNode(pExchange); + nodesDestroyNode((SNode*)pExchange); return TSDB_CODE_OUT_OF_MEMORY; } SNode* pSlot = NULL; FOREACH(pSlot, pExchange->node.pOutputDataBlockDesc->pSlots) { ((SSlotDescNode*)pSlot)->output = true; } - return nodesListMakeStrictAppend(&pMerge->node.pChildren, pExchange); + return nodesListMakeStrictAppend(&pMerge->node.pChildren, (SNode*)pExchange); } static int32_t createMergePhysiNode(SPhysiPlanContext* pCxt, SMergeLogicNode* pMergeLogicNode, SPhysiNode** pPhyNode) { @@ -1235,7 +1235,7 @@ static int32_t createMergePhysiNode(SPhysiPlanContext* pCxt, SMergeLogicNode* pM if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pMerge; } else { - nodesDestroyNode(pMerge); + nodesDestroyNode((SNode*)pMerge); } return code; @@ -1287,7 +1287,7 @@ static int32_t createPhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode, SPhysiNode* pChild = NULL; code = createPhysiNode(pCxt, (SLogicNode*)pLogicChild, pSubplan, &pChild); if (TSDB_CODE_SUCCESS == code) { - code = nodesListStrictAppend(pChildren, pChild); + code = nodesListStrictAppend(pChildren, (SNode*)pChild); } } @@ -1311,7 +1311,7 @@ static int32_t createPhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode, } static int32_t createDataInserter(SPhysiPlanContext* pCxt, SVgDataBlocks* pBlocks, SDataSinkNode** pSink) { - SDataInserterNode* pInserter = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_INSERT); + SDataInserterNode* pInserter = (SDataInserterNode*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_INSERT); if (NULL == pInserter) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -1325,14 +1325,14 @@ static int32_t createDataInserter(SPhysiPlanContext* pCxt, SVgDataBlocks* pBlock } static int32_t createDataDispatcher(SPhysiPlanContext* pCxt, const SPhysiNode* pRoot, SDataSinkNode** pSink) { - SDataDispatcherNode* pDispatcher = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_DISPATCH); + SDataDispatcherNode* pDispatcher = (SDataDispatcherNode*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_DISPATCH); if (NULL == pDispatcher) { return TSDB_CODE_OUT_OF_MEMORY; } - pDispatcher->sink.pInputDataBlockDesc = nodesCloneNode(pRoot->pOutputDataBlockDesc); + pDispatcher->sink.pInputDataBlockDesc = (SDataBlockDescNode*)nodesCloneNode((SNode*)pRoot->pOutputDataBlockDesc); if (NULL == pDispatcher->sink.pInputDataBlockDesc) { - nodesDestroyNode(pDispatcher); + nodesDestroyNode((SNode*)pDispatcher); return TSDB_CODE_OUT_OF_MEMORY; } @@ -1341,7 +1341,7 @@ static int32_t createDataDispatcher(SPhysiPlanContext* pCxt, const SPhysiNode* p } static SSubplan* makeSubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubplan) { - SSubplan* pSubplan = nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN); + SSubplan* pSubplan = (SSubplan*)nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN); if (NULL == pSubplan) { return NULL; } @@ -1361,7 +1361,7 @@ static int32_t buildInsertSubplan(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode static int32_t createDataDeleter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode* pModify, const SPhysiNode* pRoot, SDataSinkNode** pSink) { - SDataDeleterNode* pDeleter = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_DELETE); + SDataDeleterNode* pDeleter = (SDataDeleterNode*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_DELETE); if (NULL == pDeleter) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -1374,7 +1374,7 @@ static int32_t createDataDeleter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode* int32_t code = setNodeSlotId(pCxt, pRoot->pOutputDataBlockDesc->dataBlockId, -1, pModify->pAffectedRows, &pDeleter->pAffectedRows); if (TSDB_CODE_SUCCESS == code) { - pDeleter->sink.pInputDataBlockDesc = nodesCloneNode(pRoot->pOutputDataBlockDesc); + pDeleter->sink.pInputDataBlockDesc = (SDataBlockDescNode*)nodesCloneNode((SNode*)pRoot->pOutputDataBlockDesc); if (NULL == pDeleter->sink.pInputDataBlockDesc) { code = TSDB_CODE_OUT_OF_MEMORY; } @@ -1383,7 +1383,7 @@ static int32_t createDataDeleter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode* if (TSDB_CODE_SUCCESS == code) { *pSink = (SDataSinkNode*)pDeleter; } else { - nodesDestroyNode(pDeleter); + nodesDestroyNode((SNode*)pDeleter); } return TSDB_CODE_SUCCESS; @@ -1437,38 +1437,38 @@ static int32_t createPhysiSubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogic if (TSDB_CODE_SUCCESS == code) { *pPhysiSubplan = pSubplan; } else { - nodesDestroyNode(pSubplan); + nodesDestroyNode((SNode*)pSubplan); } return code; } static SQueryPlan* makeQueryPhysiPlan(SPhysiPlanContext* pCxt) { - SQueryPlan* pPlan = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN); + SQueryPlan* pPlan = (SQueryPlan*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN); if (NULL == pPlan) { return NULL; } pPlan->pSubplans = nodesMakeList(); if (NULL == pPlan->pSubplans) { - nodesDestroyNode(pPlan); + nodesDestroyNode((SNode*)pPlan); return NULL; } pPlan->queryId = pCxt->pPlanCxt->queryId; return pPlan; } -static int32_t pushSubplan(SPhysiPlanContext* pCxt, SNodeptr pSubplan, int32_t level, SNodeList* pSubplans) { - SNodeListNode* pGroup; +static int32_t pushSubplan(SPhysiPlanContext* pCxt, SNode* pSubplan, int32_t level, SNodeList* pSubplans) { + SNodeListNode* pGroup = NULL; if (level >= LIST_LENGTH(pSubplans)) { - pGroup = nodesMakeNode(QUERY_NODE_NODE_LIST); + pGroup = (SNodeListNode*)nodesMakeNode(QUERY_NODE_NODE_LIST); if (NULL == pGroup) { return TSDB_CODE_OUT_OF_MEMORY; } - if (TSDB_CODE_SUCCESS != nodesListStrictAppend(pSubplans, pGroup)) { + if (TSDB_CODE_SUCCESS != nodesListStrictAppend(pSubplans, (SNode*)pGroup)) { return TSDB_CODE_OUT_OF_MEMORY; } } else { - pGroup = nodesListGetNode(pSubplans, level); + pGroup = (SNodeListNode*)nodesListGetNode(pSubplans, level); } if (NULL == pGroup->pNodeList) { pGroup->pNodeList = nodesMakeList(); @@ -1476,7 +1476,7 @@ static int32_t pushSubplan(SPhysiPlanContext* pCxt, SNodeptr pSubplan, int32_t l return TSDB_CODE_OUT_OF_MEMORY; } } - return nodesListStrictAppend(pGroup->pNodeList, pSubplan); + return nodesListStrictAppend(pGroup->pNodeList, (SNode*)pSubplan); } static int32_t buildPhysiPlan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubplan, SSubplan* pParent, @@ -1485,19 +1485,19 @@ static int32_t buildPhysiPlan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubp int32_t code = createPhysiSubplan(pCxt, pLogicSubplan, &pSubplan); if (TSDB_CODE_SUCCESS == code) { - code = pushSubplan(pCxt, pSubplan, pLogicSubplan->level, pQueryPlan->pSubplans); + code = pushSubplan(pCxt, (SNode*)pSubplan, pLogicSubplan->level, pQueryPlan->pSubplans); ++(pQueryPlan->numOfSubplans); } if (TSDB_CODE_SUCCESS != code) { - nodesDestroyNode(pSubplan); + nodesDestroyNode((SNode*)pSubplan); return code; } if (TSDB_CODE_SUCCESS == code && NULL != pParent) { - code = nodesListMakeAppend(&pParent->pChildren, pSubplan); + code = nodesListMakeAppend(&pParent->pChildren, (SNode*)pSubplan); if (TSDB_CODE_SUCCESS == code) { - code = nodesListMakeAppend(&pSubplan->pParents, pParent); + code = nodesListMakeAppend(&pSubplan->pParents, (SNode*)pParent); } } @@ -1515,7 +1515,7 @@ static int32_t buildPhysiPlan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubp } static int32_t doCreatePhysiPlan(SPhysiPlanContext* pCxt, SQueryLogicPlan* pLogicPlan, SQueryPlan** pPhysiPlan) { - SQueryPlan* pPlan = makeQueryPhysiPlan(pCxt); + SQueryPlan* pPlan = (SQueryPlan*)makeQueryPhysiPlan(pCxt); if (NULL == pPlan) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -1533,7 +1533,7 @@ static int32_t doCreatePhysiPlan(SPhysiPlanContext* pCxt, SQueryLogicPlan* pLogi if (TSDB_CODE_SUCCESS == code) { *pPhysiPlan = pPlan; } else { - nodesDestroyNode(pPlan); + nodesDestroyNode((SNode*)pPlan); } return code; diff --git a/source/libs/planner/src/planScaleOut.c b/source/libs/planner/src/planScaleOut.c index 5dd016afb8..9707b36f4a 100644 --- a/source/libs/planner/src/planScaleOut.c +++ b/source/libs/planner/src/planScaleOut.c @@ -21,13 +21,13 @@ typedef struct SScaleOutContext { } SScaleOutContext; static SLogicSubplan* singleCloneSubLogicPlan(SScaleOutContext* pCxt, SLogicSubplan* pSrc, int32_t level) { - SLogicSubplan* pDst = nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN); + SLogicSubplan* pDst = (SLogicSubplan*)nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN); if (NULL == pDst) { return NULL; } - pDst->pNode = nodesCloneNode(pSrc->pNode); + pDst->pNode = (SLogicNode*)nodesCloneNode((SNode*)pSrc->pNode); if (NULL == pDst->pNode) { - nodesDestroyNode(pDst); + nodesDestroyNode((SNode*)pDst); return NULL; } pDst->subplanType = pSrc->subplanType; @@ -73,7 +73,7 @@ static int32_t scaleOutByVgroups(SScaleOutContext* pCxt, SLogicSubplan* pSubplan } code = setScanVgroup(pNewSubplan->pNode, pSubplan->pVgroupList->vgroups + i); if (TSDB_CODE_SUCCESS == code) { - code = nodesListStrictAppend(pGroup, pNewSubplan); + code = nodesListStrictAppend(pGroup, (SNode*)pNewSubplan); } if (TSDB_CODE_SUCCESS != code) { break; @@ -95,7 +95,7 @@ static int32_t scaleOutForModify(SScaleOutContext* pCxt, SLogicSubplan* pSubplan } ((SVnodeModifyLogicNode*)pNewSubplan->pNode)->pVgDataBlocks = (SVgDataBlocks*)taosArrayGetP(pNode->pDataBlocks, i); - if (TSDB_CODE_SUCCESS != nodesListStrictAppend(pGroup, pNewSubplan)) { + if (TSDB_CODE_SUCCESS != nodesListStrictAppend(pGroup, (SNode*)pNewSubplan)) { return TSDB_CODE_OUT_OF_MEMORY; } } @@ -104,7 +104,7 @@ static int32_t scaleOutForModify(SScaleOutContext* pCxt, SLogicSubplan* pSubplan } static int32_t scaleOutForMerge(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32_t level, SNodeList* pGroup) { - return nodesListStrictAppend(pGroup, singleCloneSubLogicPlan(pCxt, pSubplan, level)); + return nodesListStrictAppend(pGroup, (SNode*)singleCloneSubLogicPlan(pCxt, pSubplan, level)); } static int32_t scaleOutForScan(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32_t level, SNodeList* pGroup) { @@ -189,7 +189,7 @@ static SQueryLogicPlan* makeQueryLogicPlan() { } pLogicPlan->pTopSubplans = nodesMakeList(); if (NULL == pLogicPlan->pTopSubplans) { - nodesDestroyNode(pLogicPlan); + nodesDestroyNode((SNode*)pLogicPlan); return NULL; } return pLogicPlan; @@ -206,7 +206,7 @@ int32_t scaleOutLogicPlan(SPlanContext* pCxt, SLogicSubplan* pLogicSubplan, SQue if (TSDB_CODE_SUCCESS == code) { *pLogicPlan = pPlan; } else { - nodesDestroyNode(pPlan); + nodesDestroyNode((SNode*)pPlan); } return code; diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index f33856c4ce..4b372bb7d4 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -15,6 +15,7 @@ #include "functionMgt.h" #include "planInt.h" +#include "tglobal.h" #define SPLIT_FLAG_MASK(n) (1 << n) @@ -37,7 +38,8 @@ typedef struct SSplitRule { FSplit splitFunc; } SSplitRule; -typedef bool (*FSplFindSplitNode)(SSplitContext* pCxt, SLogicSubplan* pSubplan, void* pInfo); +// typedef bool (*FSplFindSplitNode)(SSplitContext* pCxt, SLogicSubplan* pSubplan, void* pInfo); +typedef bool (*FSplFindSplitNode)(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode, void* pInfo); static void splSetSubplanVgroups(SLogicSubplan* pSubplan, SLogicNode* pNode) { if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode)) { @@ -50,7 +52,7 @@ static void splSetSubplanVgroups(SLogicSubplan* pSubplan, SLogicNode* pNode) { } static SLogicSubplan* splCreateScanSubplan(SSplitContext* pCxt, SLogicNode* pNode, int32_t flag) { - SLogicSubplan* pSubplan = nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN); + SLogicSubplan* pSubplan = (SLogicSubplan*)nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN); if (NULL == pSubplan) { return NULL; } @@ -65,7 +67,7 @@ static SLogicSubplan* splCreateScanSubplan(SSplitContext* pCxt, SLogicNode* pNod } static int32_t splCreateExchangeNode(SSplitContext* pCxt, SLogicNode* pChild, SExchangeLogicNode** pOutput) { - SExchangeLogicNode* pExchange = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE); + SExchangeLogicNode* pExchange = (SExchangeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE); if (NULL == pExchange) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -90,14 +92,28 @@ static int32_t splCreateExchangeNodeForSubplan(SSplitContext* pCxt, SLogicSubpla if (TSDB_CODE_SUCCESS == code) { pSubplan->subplanType = subplanType; } else { - nodesDestroyNode(pExchange); + nodesDestroyNode((SNode*)pExchange); } return code; } +static bool splMatchByNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode, FSplFindSplitNode func, + void* pInfo) { + if (func(pCxt, pSubplan, pNode, pInfo)) { + return true; + } + SNode* pChild; + FOREACH(pChild, pNode->pChildren) { + if (splMatchByNode(pCxt, pSubplan, (SLogicNode*)pChild, func, pInfo)) { + return true; + } + } + return NULL; +} + static bool splMatch(SSplitContext* pCxt, SLogicSubplan* pSubplan, int32_t flag, FSplFindSplitNode func, void* pInfo) { if (!SPLIT_FLAG_TEST_MASK(pSubplan->splitFlag, flag)) { - if (func(pCxt, pSubplan, pInfo)) { + if (splMatchByNode(pCxt, pSubplan, pSubplan->pNode, func, pInfo)) { return true; } } @@ -110,6 +126,11 @@ static bool splMatch(SSplitContext* pCxt, SLogicSubplan* pSubplan, int32_t flag, return false; } +static void splSetParent(SLogicNode* pNode) { + SNode* pChild = NULL; + FOREACH(pChild, pNode->pChildren) { ((SLogicNode*)pChild)->pParent = pNode; } +} + typedef struct SStableSplitInfo { SLogicNode* pSplitNode; SLogicSubplan* pSubplan; @@ -136,11 +157,21 @@ static bool stbSplHasMultiTbScan(bool streamQuery, SLogicNode* pNode) { return false; } SNode* pChild = nodesListGetNode(pNode->pChildren, 0); + if (QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pChild)) { + if (1 != LIST_LENGTH(((SLogicNode*)pChild)->pChildren)) { + return false; + } + pChild = nodesListGetNode(((SLogicNode*)pChild)->pChildren, 0); + } return (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pChild) && stbSplIsMultiTbScan(streamQuery, (SScanLogicNode*)pChild)); } static bool stbSplNeedSplit(bool streamQuery, SLogicNode* pNode) { switch (nodeType(pNode)) { + case QUERY_NODE_LOGIC_PLAN_SCAN: + return stbSplIsMultiTbScan(streamQuery, (SScanLogicNode*)pNode); + // case QUERY_NODE_LOGIC_PLAN_JOIN: + // return !(((SJoinLogicNode*)pNode)->isSingleTableJoin); case QUERY_NODE_LOGIC_PLAN_AGG: return !stbSplHasGatherExecFunc(((SAggLogicNode*)pNode)->pAggFuncs) && stbSplHasMultiTbScan(streamQuery, pNode); case QUERY_NODE_LOGIC_PLAN_WINDOW: { @@ -152,35 +183,20 @@ static bool stbSplNeedSplit(bool streamQuery, SLogicNode* pNode) { } case QUERY_NODE_LOGIC_PLAN_SORT: return stbSplHasMultiTbScan(streamQuery, pNode); - case QUERY_NODE_LOGIC_PLAN_SCAN: - return stbSplIsMultiTbScan(streamQuery, (SScanLogicNode*)pNode); default: break; } return false; } -static SLogicNode* stbSplMatchByNode(bool streamQuery, SLogicNode* pNode) { - if (stbSplNeedSplit(streamQuery, pNode)) { - return pNode; - } - SNode* pChild; - FOREACH(pChild, pNode->pChildren) { - SLogicNode* pSplitNode = stbSplMatchByNode(streamQuery, (SLogicNode*)pChild); - if (NULL != pSplitNode) { - return pSplitNode; - } - } - return NULL; -} - -static bool stbSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SStableSplitInfo* pInfo) { - SLogicNode* pSplitNode = stbSplMatchByNode(pCxt->pPlanCxt->streamQuery, pSubplan->pNode); - if (NULL != pSplitNode) { - pInfo->pSplitNode = pSplitNode; +static bool stbSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode, + SStableSplitInfo* pInfo) { + if (stbSplNeedSplit(pCxt->pPlanCxt->streamQuery, pNode)) { + pInfo->pSplitNode = pNode; pInfo->pSubplan = pSubplan; + return true; } - return NULL != pSplitNode; + return false; } static int32_t stbSplRewriteFuns(const SNodeList* pFuncs, SNodeList** pPartialFuncs, SNodeList** pMergeFuncs) { @@ -191,21 +207,21 @@ static int32_t stbSplRewriteFuns(const SNodeList* pFuncs, SNodeList** pPartialFu SFunctionNode* pMergeFunc = NULL; int32_t code = TSDB_CODE_SUCCESS; if (fmIsWindowPseudoColumnFunc(pFunc->funcId)) { - pPartFunc = nodesCloneNode(pFunc); - pMergeFunc = nodesCloneNode(pFunc); + pPartFunc = (SFunctionNode*)nodesCloneNode(pNode); + pMergeFunc = (SFunctionNode*)nodesCloneNode(pNode); if (NULL == pPartFunc || NULL == pMergeFunc) { - nodesDestroyNode(pPartFunc); - nodesDestroyNode(pMergeFunc); + nodesDestroyNode((SNode*)pPartFunc); + nodesDestroyNode((SNode*)pMergeFunc); code = TSDB_CODE_OUT_OF_MEMORY; } } else { code = fmGetDistMethod(pFunc, &pPartFunc, &pMergeFunc); } if (TSDB_CODE_SUCCESS == code) { - code = nodesListMakeStrictAppend(pPartialFuncs, pPartFunc); + code = nodesListMakeStrictAppend(pPartialFuncs, (SNode*)pPartFunc); } if (TSDB_CODE_SUCCESS == code) { - code = nodesListMakeStrictAppend(pMergeFuncs, pMergeFunc); + code = nodesListMakeStrictAppend(pMergeFuncs, (SNode*)pMergeFunc); } if (TSDB_CODE_SUCCESS != code) { nodesDestroyList(*pPartialFuncs); @@ -227,7 +243,7 @@ static int32_t stbSplAppendWStart(SNodeList* pFuncs, int32_t* pIndex) { ++index; } - SFunctionNode* pWStart = nodesMakeNode(QUERY_NODE_FUNCTION); + SFunctionNode* pWStart = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); if (NULL == pWStart) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -235,7 +251,7 @@ static int32_t stbSplAppendWStart(SNodeList* pFuncs, int32_t* pIndex) { snprintf(pWStart->node.aliasName, sizeof(pWStart->node.aliasName), "%s.%p", pWStart->functionName, pWStart); int32_t code = fmGetFuncInfo(pWStart, NULL, 0); if (TSDB_CODE_SUCCESS == code) { - code = nodesListStrictAppend(pFuncs, pWStart); + code = nodesListStrictAppend(pFuncs, (SNode*)pWStart); } *pIndex = index; return code; @@ -250,7 +266,7 @@ static int32_t stbSplCreatePartWindowNode(SWindowLogicNode* pMergeWindow, SLogic pMergeWindow->node.pChildren = NULL; int32_t code = TSDB_CODE_SUCCESS; - SWindowLogicNode* pPartWin = nodesCloneNode(pMergeWindow); + SWindowLogicNode* pPartWin = (SWindowLogicNode*)nodesCloneNode((SNode*)pMergeWindow); if (NULL == pPartWin) { code = TSDB_CODE_OUT_OF_MEMORY; } @@ -258,6 +274,7 @@ static int32_t stbSplCreatePartWindowNode(SWindowLogicNode* pMergeWindow, SLogic if (TSDB_CODE_SUCCESS == code) { pMergeWindow->node.pTargets = pTargets; pPartWin->node.pChildren = pChildren; + splSetParent((SLogicNode*)pPartWin); code = stbSplRewriteFuns(pFunc, &pPartWin->pFuncs, &pMergeWindow->pFuncs); } int32_t index = 0; @@ -279,19 +296,30 @@ static int32_t stbSplCreatePartWindowNode(SWindowLogicNode* pMergeWindow, SLogic if (TSDB_CODE_SUCCESS == code) { *pPartWindow = (SLogicNode*)pPartWin; } else { - nodesDestroyNode(pPartWin); + nodesDestroyNode((SNode*)pPartWin); } return code; } +static int32_t stbSplGetNumOfVgroups(SLogicNode* pNode) { + if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode)) { + return ((SScanLogicNode*)pNode)->pVgroupList->numOfVgroups; + } else { + if (1 == LIST_LENGTH(pNode->pChildren)) { + return stbSplGetNumOfVgroups((SLogicNode*)nodesListGetNode(pNode->pChildren, 0)); + } + } + return 0; +} + static int32_t stbSplCreateMergeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pSplitNode, SNodeList* pMergeKeys, SLogicNode* pPartChild) { - SMergeLogicNode* pMerge = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_MERGE); + SMergeLogicNode* pMerge = (SMergeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_MERGE); if (NULL == pMerge) { return TSDB_CODE_OUT_OF_MEMORY; } - pMerge->numOfChannels = ((SScanLogicNode*)nodesListGetNode(pPartChild->pChildren, 0))->pVgroupList->numOfVgroups; + pMerge->numOfChannels = stbSplGetNumOfVgroups(pPartChild); pMerge->srcGroupId = pCxt->groupId; pMerge->node.precision = pPartChild->precision; pMerge->pMergeKeys = pMergeKeys; @@ -309,13 +337,13 @@ static int32_t stbSplCreateMergeNode(SSplitContext* pCxt, SLogicSubplan* pSubpla } if (TSDB_CODE_SUCCESS == code) { if (NULL == pSubplan) { - code = nodesListMakeAppend(&pSplitNode->pChildren, pMerge); + code = nodesListMakeAppend(&pSplitNode->pChildren, (SNode*)pMerge); } else { code = replaceLogicNode(pSubplan, pSplitNode, (SLogicNode*)pMerge); } } if (TSDB_CODE_SUCCESS != code) { - nodesDestroyNode(pMerge); + nodesDestroyNode((SNode*)pMerge); } return code; } @@ -324,24 +352,24 @@ static int32_t stbSplCreateExchangeNode(SSplitContext* pCxt, SLogicNode* pParent SExchangeLogicNode* pExchange = NULL; int32_t code = splCreateExchangeNode(pCxt, pPartChild, &pExchange); if (TSDB_CODE_SUCCESS == code) { - code = nodesListMakeAppend(&pParent->pChildren, pExchange); + code = nodesListMakeAppend(&pParent->pChildren, (SNode*)pExchange); } return code; } -static int32_t stbSplCreateMergeKeysForInterval(SNode* pWStartTs, SNodeList** pMergeKeys) { - SOrderByExprNode* pMergeKey = nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR); +static int32_t stbSplCreateMergeKeysByPrimaryKey(SNode* pPrimaryKey, SNodeList** pMergeKeys) { + SOrderByExprNode* pMergeKey = (SOrderByExprNode*)nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR); if (NULL == pMergeKey) { return TSDB_CODE_OUT_OF_MEMORY; } - pMergeKey->pExpr = nodesCloneNode(pWStartTs); + pMergeKey->pExpr = nodesCloneNode(pPrimaryKey); if (NULL == pMergeKey->pExpr) { - nodesDestroyNode(pMergeKey); + nodesDestroyNode((SNode*)pMergeKey); return TSDB_CODE_OUT_OF_MEMORY; } pMergeKey->order = ORDER_ASC; pMergeKey->nullOrder = NULL_ORDER_FIRST; - return nodesListMakeStrictAppend(pMergeKeys, pMergeKey); + return nodesListMakeStrictAppend(pMergeKeys, (SNode*)pMergeKey); } static int32_t stbSplSplitIntervalForBatch(SSplitContext* pCxt, SStableSplitInfo* pInfo) { @@ -351,7 +379,7 @@ static int32_t stbSplSplitIntervalForBatch(SSplitContext* pCxt, SStableSplitInfo ((SWindowLogicNode*)pPartWindow)->intervalAlgo = INTERVAL_ALGO_HASH; ((SWindowLogicNode*)pInfo->pSplitNode)->intervalAlgo = INTERVAL_ALGO_MERGE; SNodeList* pMergeKeys = NULL; - code = stbSplCreateMergeKeysForInterval(((SWindowLogicNode*)pInfo->pSplitNode)->pTspk, &pMergeKeys); + code = stbSplCreateMergeKeysByPrimaryKey(((SWindowLogicNode*)pInfo->pSplitNode)->pTspk, &pMergeKeys); if (TSDB_CODE_SUCCESS == code) { code = stbSplCreateMergeNode(pCxt, NULL, pInfo->pSplitNode, pMergeKeys, pPartWindow); } @@ -361,7 +389,7 @@ static int32_t stbSplSplitIntervalForBatch(SSplitContext* pCxt, SStableSplitInfo } if (TSDB_CODE_SUCCESS == code) { code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, - splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT)); + (SNode*)splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT)); } pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE; return code; @@ -377,7 +405,7 @@ static int32_t stbSplSplitIntervalForStream(SSplitContext* pCxt, SStableSplitInf } if (TSDB_CODE_SUCCESS == code) { code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, - splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT)); + (SNode*)splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT)); } pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE; return code; @@ -416,9 +444,11 @@ static int32_t stbSplCreatePartAggNode(SAggLogicNode* pMergeAgg, SLogicNode** pO pMergeAgg->node.pTargets = NULL; SNodeList* pChildren = pMergeAgg->node.pChildren; pMergeAgg->node.pChildren = NULL; + SNode* pConditions = pMergeAgg->node.pConditions; + pMergeAgg->node.pConditions = NULL; int32_t code = TSDB_CODE_SUCCESS; - SAggLogicNode* pPartAgg = nodesCloneNode(pMergeAgg); + SAggLogicNode* pPartAgg = (SAggLogicNode*)nodesCloneNode((SNode*)pMergeAgg); if (NULL == pPartAgg) { code = TSDB_CODE_OUT_OF_MEMORY; } @@ -434,8 +464,10 @@ static int32_t stbSplCreatePartAggNode(SAggLogicNode* pMergeAgg, SLogicNode** pO } } if (TSDB_CODE_SUCCESS == code) { + pMergeAgg->node.pConditions = pConditions; pMergeAgg->node.pTargets = pTargets; pPartAgg->node.pChildren = pChildren; + splSetParent((SLogicNode*)pPartAgg); code = stbSplRewriteFuns(pFunc, &pPartAgg->pAggFuncs, &pMergeAgg->pAggFuncs); } @@ -447,7 +479,7 @@ static int32_t stbSplCreatePartAggNode(SAggLogicNode* pMergeAgg, SLogicNode** pO if (TSDB_CODE_SUCCESS == code) { *pOutput = (SLogicNode*)pPartAgg; } else { - nodesDestroyNode(pPartAgg); + nodesDestroyNode((SNode*)pPartAgg); } return code; @@ -461,14 +493,14 @@ static int32_t stbSplSplitAggNode(SSplitContext* pCxt, SStableSplitInfo* pInfo) } if (TSDB_CODE_SUCCESS == code) { code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, - splCreateScanSubplan(pCxt, pPartAgg, SPLIT_FLAG_STABLE_SPLIT)); + (SNode*)splCreateScanSubplan(pCxt, pPartAgg, SPLIT_FLAG_STABLE_SPLIT)); } pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE; return code; } static SNode* stbSplCreateColumnNode(SExprNode* pExpr) { - SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN); + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { return NULL; } @@ -482,13 +514,13 @@ static SNode* stbSplCreateColumnNode(SExprNode* pExpr) { } static SNode* stbSplCreateOrderByExpr(SOrderByExprNode* pSortKey, SNode* pCol) { - SOrderByExprNode* pOutput = nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR); + SOrderByExprNode* pOutput = (SOrderByExprNode*)nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR); if (NULL == pOutput) { return NULL; } pOutput->pExpr = nodesCloneNode(pCol); if (NULL == pOutput->pExpr) { - nodesDestroyNode(pOutput); + nodesDestroyNode((SNode*)pOutput); return NULL; } pOutput->order = pSortKey->order; @@ -542,7 +574,7 @@ static int32_t stbSplCreatePartSortNode(SSortLogicNode* pSort, SLogicNode** pOut pSort->node.pChildren = NULL; int32_t code = TSDB_CODE_SUCCESS; - SSortLogicNode* pPartSort = nodesCloneNode(pSort); + SSortLogicNode* pPartSort = (SSortLogicNode*)nodesCloneNode((SNode*)pSort); if (NULL == pPartSort) { code = TSDB_CODE_OUT_OF_MEMORY; } @@ -550,6 +582,7 @@ static int32_t stbSplCreatePartSortNode(SSortLogicNode* pSort, SLogicNode** pOut SNodeList* pMergeKeys = NULL; if (TSDB_CODE_SUCCESS == code) { pPartSort->node.pChildren = pChildren; + splSetParent((SLogicNode*)pPartSort); pPartSort->pSortKeys = pSortKeys; code = stbSplCreateMergeKeys(pPartSort->pSortKeys, pPartSort->node.pTargets, &pMergeKeys); } @@ -558,7 +591,7 @@ static int32_t stbSplCreatePartSortNode(SSortLogicNode* pSort, SLogicNode** pOut *pOutputPartSort = (SLogicNode*)pPartSort; *pOutputMergeKeys = pMergeKeys; } else { - nodesDestroyNode(pPartSort); + nodesDestroyNode((SNode*)pPartSort); nodesDestroyList(pMergeKeys); } @@ -574,7 +607,7 @@ static int32_t stbSplSplitSortNode(SSplitContext* pCxt, SStableSplitInfo* pInfo) } if (TSDB_CODE_SUCCESS == code) { code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, - splCreateScanSubplan(pCxt, pPartSort, SPLIT_FLAG_STABLE_SPLIT)); + (SNode*)splCreateScanSubplan(pCxt, pPartSort, SPLIT_FLAG_STABLE_SPLIT)); } pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE; return code; @@ -584,7 +617,57 @@ static int32_t stbSplSplitScanNode(SSplitContext* pCxt, SStableSplitInfo* pInfo) int32_t code = splCreateExchangeNodeForSubplan(pCxt, pInfo->pSubplan, pInfo->pSplitNode, SUBPLAN_TYPE_MERGE); if (TSDB_CODE_SUCCESS == code) { code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, - splCreateScanSubplan(pCxt, pInfo->pSplitNode, SPLIT_FLAG_STABLE_SPLIT)); + (SNode*)splCreateScanSubplan(pCxt, pInfo->pSplitNode, SPLIT_FLAG_STABLE_SPLIT)); + } + return code; +} + +static SNode* stbSplFindPrimaryKeyFromScan(SScanLogicNode* pScan) { + SNode* pCol = NULL; + FOREACH(pCol, pScan->pScanCols) { + if (PRIMARYKEY_TIMESTAMP_COL_ID == ((SColumnNode*)pCol)->colId) { + return pCol; + } + } + return NULL; +} + +static int32_t stbSplSplitScanNodeForJoin(SSplitContext* pCxt, SLogicSubplan* pSubplan, SScanLogicNode* pScan) { + SNodeList* pMergeKeys = NULL; + int32_t code = stbSplCreateMergeKeysByPrimaryKey(stbSplFindPrimaryKeyFromScan(pScan), &pMergeKeys); + if (TSDB_CODE_SUCCESS == code) { + code = stbSplCreateMergeNode(pCxt, pSubplan, (SLogicNode*)pScan, pMergeKeys, (SLogicNode*)pScan); + } + if (TSDB_CODE_SUCCESS == code) { + code = nodesListMakeStrictAppend(&pSubplan->pChildren, + (SNode*)splCreateScanSubplan(pCxt, (SLogicNode*)pScan, SPLIT_FLAG_STABLE_SPLIT)); + } + return code; +} + +static int32_t stbSplSplitJoinNodeImpl(SSplitContext* pCxt, SLogicSubplan* pSubplan, SJoinLogicNode* pJoin) { + int32_t code = TSDB_CODE_SUCCESS; + SNode* pChild = NULL; + FOREACH(pChild, pJoin->node.pChildren) { + if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pChild)) { + code = stbSplSplitScanNodeForJoin(pCxt, pSubplan, (SScanLogicNode*)pChild); + } else if (QUERY_NODE_LOGIC_PLAN_JOIN == nodeType(pChild)) { + code = stbSplSplitJoinNodeImpl(pCxt, pSubplan, (SJoinLogicNode*)pChild); + } else { + code = TSDB_CODE_PLAN_INTERNAL_ERROR; + } + if (TSDB_CODE_SUCCESS != code) { + break; + } + } + return code; +} + +static int32_t stbSplSplitJoinNode(SSplitContext* pCxt, SStableSplitInfo* pInfo) { + int32_t code = stbSplSplitJoinNodeImpl(pCxt, pInfo->pSubplan, (SJoinLogicNode*)pInfo->pSplitNode); + if (TSDB_CODE_SUCCESS == code) { + pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE; + SPLIT_FLAG_SET_MASK(pInfo->pSubplan->splitFlag, SPLIT_FLAG_STABLE_SPLIT); } return code; } @@ -601,6 +684,12 @@ static int32_t stableSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(info.pSplitNode)) { + case QUERY_NODE_LOGIC_PLAN_SCAN: + code = stbSplSplitScanNode(pCxt, &info); + break; + case QUERY_NODE_LOGIC_PLAN_JOIN: + code = stbSplSplitJoinNode(pCxt, &info); + break; case QUERY_NODE_LOGIC_PLAN_AGG: code = stbSplSplitAggNode(pCxt, &info); break; @@ -610,9 +699,6 @@ static int32_t stableSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) { case QUERY_NODE_LOGIC_PLAN_SORT: code = stbSplSplitSortNode(pCxt, &info); break; - case QUERY_NODE_LOGIC_PLAN_SCAN: - code = stbSplSplitScanNode(pCxt, &info); - break; default: break; } @@ -628,7 +714,12 @@ typedef struct SSigTbJoinSplitInfo { SLogicSubplan* pSubplan; } SSigTbJoinSplitInfo; -static bool sigTbJoinSplNeedSplit(SJoinLogicNode* pJoin) { +static bool sigTbJoinSplNeedSplit(SLogicNode* pNode) { + if (QUERY_NODE_LOGIC_PLAN_JOIN != nodeType(pNode)) { + return false; + } + + SJoinLogicNode* pJoin = (SJoinLogicNode*)pNode; if (!pJoin->isSingleTableJoin) { return false; } @@ -636,28 +727,15 @@ static bool sigTbJoinSplNeedSplit(SJoinLogicNode* pJoin) { QUERY_NODE_LOGIC_PLAN_EXCHANGE != nodeType(nodesListGetNode(pJoin->node.pChildren, 1)); } -static SJoinLogicNode* sigTbJoinSplMatchByNode(SLogicNode* pNode) { - if (QUERY_NODE_LOGIC_PLAN_JOIN == nodeType(pNode) && sigTbJoinSplNeedSplit((SJoinLogicNode*)pNode)) { - return (SJoinLogicNode*)pNode; - } - SNode* pChild; - FOREACH(pChild, pNode->pChildren) { - SJoinLogicNode* pSplitNode = sigTbJoinSplMatchByNode((SLogicNode*)pChild); - if (NULL != pSplitNode) { - return pSplitNode; - } - } - return NULL; -} - -static bool sigTbJoinSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SSigTbJoinSplitInfo* pInfo) { - SJoinLogicNode* pJoin = sigTbJoinSplMatchByNode(pSubplan->pNode); - if (NULL != pJoin) { - pInfo->pJoin = pJoin; - pInfo->pSplitNode = nodesListGetNode(pJoin->node.pChildren, 1); +static bool sigTbJoinSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode, + SSigTbJoinSplitInfo* pInfo) { + if (sigTbJoinSplNeedSplit(pNode)) { + pInfo->pJoin = (SJoinLogicNode*)pNode; + pInfo->pSplitNode = (SLogicNode*)nodesListGetNode(pNode->pChildren, 1); pInfo->pSubplan = pSubplan; + return true; } - return NULL != pJoin; + return false; } static int32_t singleTableJoinSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) { @@ -667,7 +745,7 @@ static int32_t singleTableJoinSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan } int32_t code = splCreateExchangeNodeForSubplan(pCxt, info.pSubplan, info.pSplitNode, info.pSubplan->subplanType); if (TSDB_CODE_SUCCESS == code) { - code = nodesListMakeStrictAppend(&info.pSubplan->pChildren, splCreateScanSubplan(pCxt, info.pSplitNode, 0)); + code = nodesListMakeStrictAppend(&info.pSubplan->pChildren, (SNode*)splCreateScanSubplan(pCxt, info.pSplitNode, 0)); } ++(pCxt->groupId); pCxt->split = true; @@ -708,7 +786,7 @@ static int32_t unionMountSubplan(SLogicSubplan* pParent, SNodeList* pChildren) { } static SLogicSubplan* unionCreateSubplan(SSplitContext* pCxt, SLogicNode* pNode) { - SLogicSubplan* pSubplan = nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN); + SLogicSubplan* pSubplan = (SLogicSubplan*)nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN); if (NULL == pSubplan) { return NULL; } @@ -729,7 +807,7 @@ static int32_t unionSplitSubplan(SSplitContext* pCxt, SLogicSubplan* pUnionSubpl SNode* pChild = NULL; FOREACH(pChild, pSplitNode->pChildren) { SLogicSubplan* pNewSubplan = unionCreateSubplan(pCxt, (SLogicNode*)pChild); - code = nodesListMakeStrictAppend(&pUnionSubplan->pChildren, pNewSubplan); + code = nodesListMakeStrictAppend(&pUnionSubplan->pChildren, (SNode*)pNewSubplan); if (TSDB_CODE_SUCCESS == code) { REPLACE_NODE(NULL); code = unionMountSubplan(pNewSubplan, pSubplanChildren); @@ -750,31 +828,18 @@ typedef struct SUnionAllSplitInfo { SLogicSubplan* pSubplan; } SUnionAllSplitInfo; -static SLogicNode* unAllSplMatchByNode(SLogicNode* pNode) { +static bool unAllSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode, + SUnionAllSplitInfo* pInfo) { if (QUERY_NODE_LOGIC_PLAN_PROJECT == nodeType(pNode) && LIST_LENGTH(pNode->pChildren) > 1) { - return pNode; - } - SNode* pChild; - FOREACH(pChild, pNode->pChildren) { - SLogicNode* pSplitNode = unAllSplMatchByNode((SLogicNode*)pChild); - if (NULL != pSplitNode) { - return pSplitNode; - } - } - return NULL; -} - -static bool unAllSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SUnionAllSplitInfo* pInfo) { - SLogicNode* pSplitNode = unAllSplMatchByNode(pSubplan->pNode); - if (NULL != pSplitNode) { - pInfo->pProject = (SProjectLogicNode*)pSplitNode; + pInfo->pProject = (SProjectLogicNode*)pNode; pInfo->pSubplan = pSubplan; + return true; } - return NULL != pSplitNode; + return false; } static int32_t unAllSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SProjectLogicNode* pProject) { - SExchangeLogicNode* pExchange = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE); + SExchangeLogicNode* pExchange = (SExchangeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE); if (NULL == pExchange) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -789,20 +854,20 @@ static int32_t unAllSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pS if (NULL == pProject->node.pParent) { pSubplan->pNode = (SLogicNode*)pExchange; - nodesDestroyNode(pProject); + nodesDestroyNode((SNode*)pProject); return TSDB_CODE_SUCCESS; } SNode* pNode; FOREACH(pNode, pProject->node.pParent->pChildren) { - if (nodesEqualNode(pNode, pProject)) { + if (nodesEqualNode(pNode, (SNode*)pProject)) { REPLACE_NODE(pExchange); nodesDestroyNode(pNode); return TSDB_CODE_SUCCESS; } } - nodesDestroyNode(pExchange); - return TSDB_CODE_FAILED; + nodesDestroyNode((SNode*)pExchange); + return TSDB_CODE_PLAN_INTERNAL_ERROR; } static int32_t unionAllSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) { @@ -825,22 +890,8 @@ typedef struct SUnionDistinctSplitInfo { SLogicSubplan* pSubplan; } SUnionDistinctSplitInfo; -static SLogicNode* unDistSplMatchByNode(SLogicNode* pNode) { - if (QUERY_NODE_LOGIC_PLAN_AGG == nodeType(pNode) && LIST_LENGTH(pNode->pChildren) > 1) { - return pNode; - } - SNode* pChild; - FOREACH(pChild, pNode->pChildren) { - SLogicNode* pSplitNode = unDistSplMatchByNode((SLogicNode*)pChild); - if (NULL != pSplitNode) { - return pSplitNode; - } - } - return NULL; -} - static int32_t unDistSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SAggLogicNode* pAgg) { - SExchangeLogicNode* pExchange = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE); + SExchangeLogicNode* pExchange = (SExchangeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE); if (NULL == pExchange) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -853,16 +904,17 @@ static int32_t unDistSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* p pSubplan->subplanType = SUBPLAN_TYPE_MERGE; - return nodesListMakeAppend(&pAgg->node.pChildren, pExchange); + return nodesListMakeAppend(&pAgg->node.pChildren, (SNode*)pExchange); } -static bool unDistSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SUnionDistinctSplitInfo* pInfo) { - SLogicNode* pSplitNode = unDistSplMatchByNode(pSubplan->pNode); - if (NULL != pSplitNode) { - pInfo->pAgg = (SAggLogicNode*)pSplitNode; +static bool unDistSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode, + SUnionDistinctSplitInfo* pInfo) { + if (QUERY_NODE_LOGIC_PLAN_AGG == nodeType(pNode) && LIST_LENGTH(pNode->pChildren) > 1) { + pInfo->pAgg = (SAggLogicNode*)pNode; pInfo->pSubplan = pSubplan; + return true; } - return NULL != pSplitNode; + return false; } static int32_t unionDistinctSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) { @@ -885,27 +937,14 @@ typedef struct SSmaIndexSplitInfo { SLogicSubplan* pSubplan; } SSmaIndexSplitInfo; -static SLogicNode* smaIdxSplMatchByNode(SLogicNode* pNode) { +static bool smaIdxSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode, + SSmaIndexSplitInfo* pInfo) { if (QUERY_NODE_LOGIC_PLAN_MERGE == nodeType(pNode) && LIST_LENGTH(pNode->pChildren) > 1) { - return pNode; - } - SNode* pChild; - FOREACH(pChild, pNode->pChildren) { - SLogicNode* pSplitNode = smaIdxSplMatchByNode((SLogicNode*)pChild); - if (NULL != pSplitNode) { - return pSplitNode; - } - } - return NULL; -} - -static bool smaIdxSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SSmaIndexSplitInfo* pInfo) { - SLogicNode* pSplitNode = smaIdxSplMatchByNode(pSubplan->pNode); - if (NULL != pSplitNode) { - pInfo->pMerge = (SMergeLogicNode*)pSplitNode; + pInfo->pMerge = (SMergeLogicNode*)pNode; pInfo->pSubplan = pSubplan; + return true; } - return NULL != pSplitNode; + return false; } static int32_t smaIndexSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) { @@ -923,13 +962,47 @@ static int32_t smaIndexSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) { return code; } +typedef struct SQnodeSplitInfo { + SLogicNode* pSplitNode; + SLogicSubplan* pSubplan; +} SQnodeSplitInfo; + +static bool qndSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode, + SQnodeSplitInfo* pInfo) { + if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode) && NULL != pNode->pParent) { + pInfo->pSplitNode = pNode; + pInfo->pSubplan = pSubplan; + return true; + } + return false; +} + +static int32_t qnodeSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) { + if (QUERY_POLICY_QNODE != tsQueryPolicy) { + return TSDB_CODE_SUCCESS; + } + + SQnodeSplitInfo info = {0}; + if (!splMatch(pCxt, pSubplan, 0, (FSplFindSplitNode)qndSplFindSplitNode, &info)) { + return TSDB_CODE_SUCCESS; + } + int32_t code = splCreateExchangeNodeForSubplan(pCxt, info.pSubplan, info.pSplitNode, info.pSubplan->subplanType); + if (TSDB_CODE_SUCCESS == code) { + code = nodesListMakeStrictAppend(&info.pSubplan->pChildren, (SNode*)splCreateScanSubplan(pCxt, info.pSplitNode, 0)); + } + ++(pCxt->groupId); + pCxt->split = true; + return code; +} + // clang-format off static const SSplitRule splitRuleSet[] = { {.pName = "SuperTableSplit", .splitFunc = stableSplit}, {.pName = "SingleTableJoinSplit", .splitFunc = singleTableJoinSplit}, {.pName = "UnionAllSplit", .splitFunc = unionAllSplit}, {.pName = "UnionDistinctSplit", .splitFunc = unionDistinctSplit}, - {.pName = "SmaIndexSplit", .splitFunc = smaIndexSplit} + {.pName = "SmaIndexSplit", .splitFunc = smaIndexSplit}, + {.pName = "QnodeSplit", .splitFunc = qnodeSplit} }; // clang-format on @@ -937,7 +1010,7 @@ static const int32_t splitRuleNum = (sizeof(splitRuleSet) / sizeof(SSplitRule)); static void dumpLogicSubplan(const char* pRuleName, SLogicSubplan* pSubplan) { char* pStr = NULL; - nodesNodeToString(pSubplan, false, &pStr, NULL); + nodesNodeToString((SNode*)pSubplan, false, &pStr, NULL); qDebugL("apply %s rule: %s", pRuleName, pStr); taosMemoryFree(pStr); } diff --git a/source/libs/planner/src/planUtil.c b/source/libs/planner/src/planUtil.c index 232a49ee3a..7f650c7c9a 100644 --- a/source/libs/planner/src/planUtil.c +++ b/source/libs/planner/src/planUtil.c @@ -60,7 +60,8 @@ static EDealRes doCreateColumn(SNode* pNode, void* pContext) { } pCol->node.resType = pExpr->resType; strcpy(pCol->colName, pExpr->aliasName); - return (TSDB_CODE_SUCCESS == nodesListAppend(pCxt->pList, pCol) ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR); + return (TSDB_CODE_SUCCESS == nodesListStrictAppend(pCxt->pList, (SNode*)pCol) ? DEAL_RES_IGNORE_CHILD + : DEAL_RES_ERROR); } default: break; @@ -111,7 +112,7 @@ int32_t replaceLogicNode(SLogicSubplan* pSubplan, SLogicNode* pOld, SLogicNode* SNode* pNode; FOREACH(pNode, pOld->pParent->pChildren) { - if (nodesEqualNode(pNode, pOld)) { + if (nodesEqualNode(pNode, (SNode*)pOld)) { REPLACE_NODE(pNew); pNew->pParent = pOld->pParent; return TSDB_CODE_SUCCESS; diff --git a/source/libs/planner/src/planner.c b/source/libs/planner/src/planner.c index 83657d27d0..c4385d576e 100644 --- a/source/libs/planner/src/planner.c +++ b/source/libs/planner/src/planner.c @@ -20,7 +20,7 @@ static void dumpQueryPlan(SQueryPlan* pPlan) { char* pStr = NULL; - nodesNodeToString(pPlan, false, &pStr, NULL); + nodesNodeToString((SNode*)pPlan, false, &pStr, NULL); planDebugL("Query Plan: %s", pStr); taosMemoryFree(pStr); } @@ -46,8 +46,8 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo dumpQueryPlan(*pPlan); } - nodesDestroyNode(pLogicSubplan); - nodesDestroyNode(pLogicPlan); + nodesDestroyNode((SNode*)pLogicSubplan); + nodesDestroyNode((SNode*)pLogicPlan); terrno = code; return code; } @@ -56,7 +56,7 @@ static int32_t setSubplanExecutionNode(SPhysiNode* pNode, int32_t groupId, SDown if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == nodeType(pNode)) { SExchangePhysiNode* pExchange = (SExchangePhysiNode*)pNode; if (pExchange->srcGroupId == groupId) { - return nodesListMakeStrictAppend(&pExchange->pSrcEndPoints, nodesCloneNode(pSource)); + return nodesListMakeStrictAppend(&pExchange->pSrcEndPoints, nodesCloneNode((SNode*)pSource)); } } else if (QUERY_NODE_PHYSICAL_PLAN_MERGE == nodeType(pNode)) { SMergePhysiNode* pMerge = (SMergePhysiNode*)pNode; @@ -68,7 +68,7 @@ static int32_t setSubplanExecutionNode(SPhysiNode* pNode, int32_t groupId, SDown } else { --(pMerge->numOfChannels); } - return nodesListMakeStrictAppend(&pExchange->pSrcEndPoints, nodesCloneNode(pSource)); + return nodesListMakeStrictAppend(&pExchange->pSrcEndPoints, nodesCloneNode((SNode*)pSource)); } } @@ -101,7 +101,7 @@ int32_t qStringToSubplan(const char* pStr, SSubplan** pSubplan) { return nodesSt char* qQueryPlanToString(const SQueryPlan* pPlan) { char* pStr = NULL; int32_t len = 0; - if (TSDB_CODE_SUCCESS != nodesNodeToString(pPlan, false, &pStr, &len)) { + if (TSDB_CODE_SUCCESS != nodesNodeToString((SNode*)pPlan, false, &pStr, &len)) { return NULL; } return pStr; @@ -115,4 +115,4 @@ SQueryPlan* qStringToQueryPlan(const char* pStr) { return pPlan; } -void qDestroyQueryPlan(SQueryPlan* pPlan) { nodesDestroyNode(pPlan); } +void qDestroyQueryPlan(SQueryPlan* pPlan) { nodesDestroyNode((SNode*)pPlan); } diff --git a/source/libs/planner/test/planGroupByTest.cpp b/source/libs/planner/test/planGroupByTest.cpp index 201df2efde..a73c99bf68 100644 --- a/source/libs/planner/test/planGroupByTest.cpp +++ b/source/libs/planner/test/planGroupByTest.cpp @@ -53,6 +53,14 @@ TEST_F(PlanGroupByTest, aggFunc) { run("SELECT SUM(10), COUNT(c1) FROM t1 GROUP BY c2"); } +TEST_F(PlanGroupByTest, rewriteFunc) { + useDb("root", "test"); + + run("SELECT AVG(c1) FROM t1"); + + run("SELECT AVG(c1) FROM t1 GROUP BY c2"); +} + TEST_F(PlanGroupByTest, selectFunc) { useDb("root", "test"); @@ -74,4 +82,8 @@ TEST_F(PlanGroupByTest, stable) { run("SELECT COUNT(*) FROM st1"); run("SELECT COUNT(*) FROM st1 GROUP BY c1"); + + run("SELECT COUNT(*) FROM st1 PARTITION BY c2 GROUP BY c1"); + + run("SELECT SUM(c1) FROM st1 GROUP BY c2 HAVING SUM(c1) IS NOT NULL"); } diff --git a/source/libs/planner/test/planIntervalTest.cpp b/source/libs/planner/test/planIntervalTest.cpp index 672bbaddf7..10ef09adb9 100644 --- a/source/libs/planner/test/planIntervalTest.cpp +++ b/source/libs/planner/test/planIntervalTest.cpp @@ -60,4 +60,6 @@ TEST_F(PlanIntervalTest, stable) { run("SELECT COUNT(*) FROM st1 INTERVAL(10s)"); run("SELECT _WSTARTTS, COUNT(*) FROM st1 INTERVAL(10s)"); + + run("SELECT _WSTARTTS, COUNT(*) FROM st1 PARTITION BY TBNAME INTERVAL(10s)"); } diff --git a/source/libs/planner/test/planJoinTest.cpp b/source/libs/planner/test/planJoinTest.cpp index a3c5258e33..8c321e75be 100644 --- a/source/libs/planner/test/planJoinTest.cpp +++ b/source/libs/planner/test/planJoinTest.cpp @@ -50,3 +50,9 @@ TEST_F(PlanJoinTest, multiJoin) { run("SELECT t1.c1, t2.c1 FROM st1s1 t1 JOIN st1s2 t2 ON t1.ts = t2.ts JOIN st1s3 t3 ON t1.ts = t3.ts"); } + +TEST_F(PlanJoinTest, stable) { + useDb("root", "test"); + + run("SELECT t1.c1, t2.c1 FROM st1 t1 JOIN st2 t2 ON t1.ts = t2.ts "); +} diff --git a/source/libs/planner/test/planOrderByTest.cpp b/source/libs/planner/test/planOrderByTest.cpp index 851eda81b5..39e93fcff9 100644 --- a/source/libs/planner/test/planOrderByTest.cpp +++ b/source/libs/planner/test/planOrderByTest.cpp @@ -49,4 +49,6 @@ TEST_F(PlanOrderByTest, stable) { // ORDER BY key is not in the projection list run("SELECT c2 FROM st1 ORDER BY c1"); + + run("SELECT c2 FROM st1 PARTITION BY c2 ORDER BY c1"); } diff --git a/source/libs/planner/test/planOtherTest.cpp b/source/libs/planner/test/planOtherTest.cpp index 4bfb9a6fda..f9feb8d1fe 100644 --- a/source/libs/planner/test/planOtherTest.cpp +++ b/source/libs/planner/test/planOtherTest.cpp @@ -83,3 +83,10 @@ TEST_F(PlanOtherTest, delete) { run("DELETE FROM st1 WHERE ts > now - 2d and ts < now - 1d AND tag1 = 10"); } + +TEST_F(PlanOtherTest, queryPolicy) { + useDb("root", "test"); + + tsQueryPolicy = QUERY_POLICY_QNODE; + run("SELECT COUNT(*) FROM st1"); +} diff --git a/source/libs/planner/test/planPartByTest.cpp b/source/libs/planner/test/planPartByTest.cpp index 230500e702..9437f6ad3f 100644 --- a/source/libs/planner/test/planPartByTest.cpp +++ b/source/libs/planner/test/planPartByTest.cpp @@ -24,6 +24,10 @@ TEST_F(PlanPartitionByTest, basic) { useDb("root", "test"); run("select * from t1 partition by c1"); + + run("select ts, c1 + 1 from st1 partition by c1 + 1"); + + run("select ts, jtag->'tag1' from st2 partition by jtag->'tag1'"); } TEST_F(PlanPartitionByTest, withAggFunc) { diff --git a/source/libs/planner/test/planTestUtil.h b/source/libs/planner/test/planTestUtil.h index 6b75573fb3..b188a7a054 100644 --- a/source/libs/planner/test/planTestUtil.h +++ b/source/libs/planner/test/planTestUtil.h @@ -18,6 +18,10 @@ #include +#define ALLOW_FORBID_FUNC + +#include "planInt.h" + class PlannerTestBaseImpl; struct TAOS_MULTI_BIND; diff --git a/source/libs/qworker/src/qwUtil.c b/source/libs/qworker/src/qwUtil.c index b9f394e186..0759cf360a 100644 --- a/source/libs/qworker/src/qwUtil.c +++ b/source/libs/qworker/src/qwUtil.c @@ -308,7 +308,7 @@ void qwFreeTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx *ctx) { } if (ctx->plan) { - nodesDestroyNode(ctx->plan); + nodesDestroyNode((SNode*)ctx->plan); ctx->plan = NULL; } } diff --git a/source/libs/sync/inc/syncInt.h b/source/libs/sync/inc/syncInt.h index e7777af749..8a44dcd9bc 100644 --- a/source/libs/sync/inc/syncInt.h +++ b/source/libs/sync/inc/syncInt.h @@ -168,6 +168,7 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pSyncInfo); void syncNodeStart(SSyncNode* pSyncNode); void syncNodeStartStandBy(SSyncNode* pSyncNode); void syncNodeClose(SSyncNode* pSyncNode); +int32_t syncNodePropose(SSyncNode* pSyncNode, const SRpcMsg* pMsg, bool isWeak); // option bool syncNodeSnapshotEnable(SSyncNode* pSyncNode); @@ -232,6 +233,9 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, bool syncNodeInRaftGroup(SSyncNode* ths, SRaftId* pRaftId); SSyncSnapshotSender* syncNodeGetSnapshotSender(SSyncNode* ths, SRaftId* pDestId); +void syncStartNormal(int64_t rid); +void syncStartStandBy(int64_t rid); + // for debug -------------- void syncNodePrint(SSyncNode* pObj); void syncNodePrint2(char* s, SSyncNode* pObj); diff --git a/source/libs/sync/src/syncAppendEntries.c b/source/libs/sync/src/syncAppendEntries.c index 29ee263756..08a4081ad3 100644 --- a/source/libs/sync/src/syncAppendEntries.c +++ b/source/libs/sync/src/syncAppendEntries.c @@ -995,7 +995,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs ths->commitIndex = snapshot.lastApplyIndex; sDebug("vgId:%d sync event commit by snapshot from index:%ld to index:%ld, %s", ths->vgId, commitBegin, - commitEnd, syncUtilState2String(ths->state)); + commitEnd, syncUtilState2String(ths->state)); } SyncIndex beginIndex = ths->commitIndex + 1; diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index eac9c1fbd8..3424fac5e7 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -57,7 +57,7 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { pSyncNode->commitIndex = snapshot.lastApplyIndex; sDebug("vgId:%d sync event commit by snapshot from index:%ld to index:%ld, %s", pSyncNode->vgId, - pSyncNode->commitIndex, snapshot.lastApplyIndex, syncUtilState2String(pSyncNode->state)); + pSyncNode->commitIndex, snapshot.lastApplyIndex, syncUtilState2String(pSyncNode->state)); } // update commit index diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index bd4d865ed2..9db9550681 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -149,12 +149,12 @@ void syncStop(int64_t rid) { int32_t syncSetStandby(int64_t rid) { SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid); if (pSyncNode == NULL) { - return -1; + return TAOS_SYNC_OTHER_ERROR; } - if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) { + if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) { taosReleaseRef(tsNodeRefId, pSyncNode->rid); - return -1; + return TAOS_SYNC_OTHER_ERROR; } // state change @@ -170,17 +170,92 @@ int32_t syncSetStandby(int64_t rid) { raftCfgPersist(pSyncNode->pRaftCfg); taosReleaseRef(tsNodeRefId, pSyncNode->rid); + sInfo("vgId:%d, set to standby", pSyncNode->vgId); return 0; } -int32_t syncReconfig(int64_t rid, const SSyncCfg* pSyncCfg) { - int32_t ret = 0; - char* newconfig = syncCfg2Str((SSyncCfg*)pSyncCfg); +int32_t syncReconfigBuild(int64_t rid, const SSyncCfg* pNewCfg, SRpcMsg* pRpcMsg) { + SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid); + if (pSyncNode == NULL) { + return TAOS_SYNC_OTHER_ERROR; + } + ASSERT(rid == pSyncNode->rid); + int32_t ret = 0; + bool IamInNew = false; + for (int i = 0; i < pNewCfg->replicaNum; ++i) { + if (strcmp((pNewCfg->nodeInfo)[i].nodeFqdn, pSyncNode->myNodeInfo.nodeFqdn) == 0 && + (pNewCfg->nodeInfo)[i].nodePort == pSyncNode->myNodeInfo.nodePort) { + IamInNew = true; + } + + /* + SRaftId newId; + newId.addr = syncUtilAddr2U64((pNewCfg->nodeInfo)[i].nodeFqdn, (pNewCfg->nodeInfo)[i].nodePort); + newId.vgId = pSyncNode->vgId; + if (syncUtilSameId(&(pSyncNode->myRaftId), &newId)) { + IamInNew = true; + } + */ + } + + if (!IamInNew) { + taosReleaseRef(tsNodeRefId, pSyncNode->rid); + return TAOS_SYNC_NOT_IN_NEW_CONFIG; + } + + char* newconfig = syncCfg2Str((SSyncCfg*)pNewCfg); + pRpcMsg->msgType = TDMT_SYNC_CONFIG_CHANGE; + pRpcMsg->info.noResp = 1; + pRpcMsg->contLen = strlen(newconfig) + 1; + pRpcMsg->pCont = rpcMallocCont(pRpcMsg->contLen); + snprintf(pRpcMsg->pCont, pRpcMsg->contLen, "%s", newconfig); + taosMemoryFree(newconfig); + + taosReleaseRef(tsNodeRefId, pSyncNode->rid); + return ret; +} + +int32_t syncReconfig(int64_t rid, const SSyncCfg* pNewCfg) { + SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid); + if (pSyncNode == NULL) { + return TAOS_SYNC_OTHER_ERROR; + } + ASSERT(rid == pSyncNode->rid); + + bool IamInNew = false; + for (int i = 0; i < pNewCfg->replicaNum; ++i) { + if (strcmp((pNewCfg->nodeInfo)[i].nodeFqdn, pSyncNode->myNodeInfo.nodeFqdn) == 0 && + (pNewCfg->nodeInfo)[i].nodePort == pSyncNode->myNodeInfo.nodePort) { + IamInNew = true; + } + + /* + // some problem in inet_addr + + SRaftId newId = EMPTY_RAFT_ID; + newId.addr = syncUtilAddr2U64((pNewCfg->nodeInfo)[i].nodeFqdn, (pNewCfg->nodeInfo)[i].nodePort); + newId.vgId = pSyncNode->vgId; + + if (syncUtilSameId(&(pSyncNode->myRaftId), &newId)) { + IamInNew = true; + } + */ + } + + if (!IamInNew) { + sError("sync reconfig error, not in new config"); + taosReleaseRef(tsNodeRefId, pSyncNode->rid); + return TAOS_SYNC_NOT_IN_NEW_CONFIG; + } + + char* newconfig = syncCfg2Str((SSyncCfg*)pNewCfg); if (gRaftDetailLog) { sInfo("==syncReconfig== newconfig:%s", newconfig); } + int32_t ret = 0; + SRpcMsg rpcMsg = {0}; rpcMsg.msgType = TDMT_SYNC_CONFIG_CHANGE; rpcMsg.info.noResp = 1; @@ -188,58 +263,59 @@ int32_t syncReconfig(int64_t rid, const SSyncCfg* pSyncCfg) { rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen); snprintf(rpcMsg.pCont, rpcMsg.contLen, "%s", newconfig); taosMemoryFree(newconfig); - ret = syncPropose(rid, &rpcMsg, false); + ret = syncNodePropose(pSyncNode, &rpcMsg, false); + + taosReleaseRef(tsNodeRefId, pSyncNode->rid); return ret; } int32_t syncLeaderTransfer(int64_t rid) { - int32_t ret = 0; + SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid); + if (pSyncNode == NULL) { + return TAOS_SYNC_OTHER_ERROR; + } + ASSERT(rid == pSyncNode->rid); + if (pSyncNode->peersNum == 0) { + taosReleaseRef(tsNodeRefId, pSyncNode->rid); + return TAOS_SYNC_OTHER_ERROR; + } + + SNodeInfo newLeader = (pSyncNode->peersNodeInfo)[0]; + taosReleaseRef(tsNodeRefId, pSyncNode->rid); + + int32_t ret = syncLeaderTransferTo(rid, newLeader); return ret; } int32_t syncLeaderTransferTo(int64_t rid, SNodeInfo newLeader) { SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid); if (pSyncNode == NULL) { - return false; + return TAOS_SYNC_OTHER_ERROR; } - assert(rid == pSyncNode->rid); + ASSERT(rid == pSyncNode->rid); int32_t ret = 0; if (pSyncNode->replicaNum == 1) { - taosReleaseRef(tsNodeRefId, pSyncNode->rid); sError("only one replica, cannot drop leader"); + taosReleaseRef(tsNodeRefId, pSyncNode->rid); return TAOS_SYNC_ONLY_ONE_REPLICA; } SyncLeaderTransfer* pMsg = syncLeaderTransferBuild(pSyncNode->vgId); pMsg->newLeaderId.addr = syncUtilAddr2U64(newLeader.nodeFqdn, newLeader.nodePort); pMsg->newLeaderId.vgId = pSyncNode->vgId; + pMsg->newNodeInfo = newLeader; ASSERT(pMsg != NULL); SRpcMsg rpcMsg = {0}; syncLeaderTransfer2RpcMsg(pMsg, &rpcMsg); syncLeaderTransferDestroy(pMsg); - ret = syncPropose(rid, &rpcMsg, false); - + ret = syncNodePropose(pSyncNode, &rpcMsg, false); taosReleaseRef(tsNodeRefId, pSyncNode->rid); return ret; } -int32_t syncReconfigRaw(int64_t rid, const SSyncCfg* pNewCfg, SRpcMsg* pRpcMsg) { - int32_t ret = 0; - char* newconfig = syncCfg2Str((SSyncCfg*)pNewCfg); - - pRpcMsg->msgType = TDMT_SYNC_CONFIG_CHANGE; - pRpcMsg->info.noResp = 1; - pRpcMsg->contLen = strlen(newconfig) + 1; - pRpcMsg->pCont = rpcMallocCont(pRpcMsg->contLen); - snprintf(pRpcMsg->pCont, pRpcMsg->contLen, "%s", newconfig); - taosMemoryFree(newconfig); - - return ret; -} - bool syncCanLeaderTransfer(int64_t rid) { SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid); if (pSyncNode == NULL) { @@ -272,8 +348,6 @@ bool syncCanLeaderTransfer(int64_t rid) { return matchOK; } -int32_t syncGiveUpLeader(int64_t rid) { return 0; } - int32_t syncForwardToPeer(int64_t rid, const SRpcMsg* pMsg, bool isWeak) { int32_t ret = syncPropose(rid, pMsg, isWeak); return ret; @@ -468,17 +542,25 @@ int32_t syncPropose(int64_t rid, const SRpcMsg* pMsg, bool isWeak) { SSyncNode* pSyncNode = taosAcquireRef(tsNodeRefId, rid); if (pSyncNode == NULL) { - return TAOS_SYNC_PROPOSE_OTHER_ERROR; + return TAOS_SYNC_OTHER_ERROR; } assert(rid == pSyncNode->rid); + sDebug("vgId:%d sync event propose msgType:%s", pSyncNode->vgId, TMSG_INFO(pMsg->msgType)); + ret = syncNodePropose(pSyncNode, pMsg, isWeak); + + taosReleaseRef(tsNodeRefId, pSyncNode->rid); + return ret; +} + +int32_t syncNodePropose(SSyncNode* pSyncNode, const SRpcMsg* pMsg, bool isWeak) { + int32_t ret = TAOS_SYNC_PROPOSE_SUCCESS; + sDebug("vgId:%d sync event propose msgType:%s", pSyncNode->vgId, TMSG_INFO(pMsg->msgType)); if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) { SRespStub stub; stub.createTime = taosGetTimestampMs(); stub.rpcMsg = *pMsg; uint64_t seqNum = syncRespMgrAdd(pSyncNode->pSyncRespMgr, &stub); - sDebug("vgId:%d, sync event propose, type:%s seq:%" PRIu64 " handle:%p", pSyncNode->vgId, TMSG_INFO(pMsg->msgType), - seqNum, pMsg->info.handle); SyncClientRequest* pSyncMsg = syncClientRequestBuild2(pMsg, seqNum, isWeak, pSyncNode->vgId); SRpcMsg rpcMsg; @@ -487,16 +569,14 @@ int32_t syncPropose(int64_t rid, const SRpcMsg* pMsg, bool isWeak) { if (pSyncNode->FpEqMsg != NULL && (*pSyncNode->FpEqMsg)(pSyncNode->msgcb, &rpcMsg) == 0) { ret = TAOS_SYNC_PROPOSE_SUCCESS; } else { - sTrace("syncPropose pSyncNode->FpEqMsg is NULL"); + sError("syncPropose pSyncNode->FpEqMsg is NULL"); } syncClientRequestDestroy(pSyncMsg); } else { - sDebug("vgId:%d, failed to propose since not leader, type:%s handle:%p %s", pSyncNode->vgId, - TMSG_INFO(pMsg->msgType), pMsg->info.handle, syncUtilState2String(pSyncNode->state)); + sError("syncPropose not leader, %s", syncUtilState2String(pSyncNode->state)); ret = TAOS_SYNC_PROPOSE_NOT_LEADER; } - taosReleaseRef(tsNodeRefId, pSyncNode->rid); return ret; } @@ -689,7 +769,7 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { } // tools - pSyncNode->pSyncRespMgr = syncRespMgrCreate(NULL, 0); + pSyncNode->pSyncRespMgr = syncRespMgrCreate(pSyncNode, 0); assert(pSyncNode->pSyncRespMgr != NULL); // restore state @@ -1157,6 +1237,19 @@ void syncNodeUpdateConfig(SSyncNode* pSyncNode, SSyncCfg* newConfig, SyncIndex l int32_t ret = 0; + // save snapshot senders + int32_t oldReplicaNum = pSyncNode->replicaNum; + SRaftId oldReplicasId[TSDB_MAX_REPLICA]; + memcpy(oldReplicasId, pSyncNode->replicasId, sizeof(oldReplicasId)); + SSyncSnapshotSender* oldSenders[TSDB_MAX_REPLICA]; + for (int i = 0; i < TSDB_MAX_REPLICA; ++i) { + oldSenders[i] = (pSyncNode->senders)[i]; + sDebug("vgId:%d sync event save senders %d, %p", pSyncNode->vgId, i, oldSenders[i]); + if (gRaftDetailLog) { + ; + } + } + // init internal pSyncNode->myNodeInfo = pSyncNode->pRaftCfg->cfg.nodeInfo[pSyncNode->pRaftCfg->cfg.myIndex]; syncUtilnodeInfo2raftId(&pSyncNode->myNodeInfo, pSyncNode->vgId, &pSyncNode->myRaftId); @@ -1187,6 +1280,54 @@ void syncNodeUpdateConfig(SSyncNode* pSyncNode, SSyncCfg* newConfig, SyncIndex l pSyncNode->quorum = syncUtilQuorum(pSyncNode->pRaftCfg->cfg.replicaNum); + // reset snapshot senders + + // clear new + for (int i = 0; i < TSDB_MAX_REPLICA; ++i) { + (pSyncNode->senders)[i] = NULL; + } + + // reset new + for (int i = 0; i < pSyncNode->replicaNum; ++i) { + // reset sender + bool reset = false; + for (int j = 0; j < TSDB_MAX_REPLICA; ++j) { + if (syncUtilSameId(&(pSyncNode->replicasId)[i], &oldReplicasId[j])) { + char host[128]; + uint16_t port; + syncUtilU642Addr((pSyncNode->replicasId)[i].addr, host, sizeof(host), &port); + sDebug("vgId:%d sync event reset sender for %lu, newIndex:%d, %s:%d, %p", pSyncNode->vgId, + (pSyncNode->replicasId)[i].addr, i, host, port, oldSenders[j]); + (pSyncNode->senders)[i] = oldSenders[j]; + oldSenders[j] = NULL; + reset = true; + + // reset replicaIndex + int32_t oldreplicaIndex = (pSyncNode->senders)[i]->replicaIndex; + (pSyncNode->senders)[i]->replicaIndex = i; + sDebug("vgId:%d sync event udpate replicaIndex from %d to %d, %s:%d, %p, reset:%d", pSyncNode->vgId, + oldreplicaIndex, i, host, port, (pSyncNode->senders)[i], reset); + } + } + } + + // create new + for (int i = 0; i < TSDB_MAX_REPLICA; ++i) { + if ((pSyncNode->senders)[i] == NULL) { + (pSyncNode->senders)[i] = snapshotSenderCreate(pSyncNode, i); + sDebug("vgId:%d sync event create new sender %p replicaIndex:%d", pSyncNode->vgId, (pSyncNode->senders)[i], i); + } + } + + // free old + for (int i = 0; i < TSDB_MAX_REPLICA; ++i) { + if (oldSenders[i] != NULL) { + snapshotSenderDestroy(oldSenders[i]); + sDebug("vgId:%d sync event delete old sender %p replicaIndex:%d", pSyncNode->vgId, oldSenders[i], i); + oldSenders[i] = NULL; + } + } + bool IamInOld = false; bool IamInNew = false; for (int i = 0; i < oldConfig.replicaNum; ++i) { @@ -1243,8 +1384,8 @@ void syncNodeUpdateTerm(SSyncNode* pSyncNode, SyncTerm term) { } void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr) { - sDebug("vgId:%d sync event become follower, isStandBy:%d, %s", pSyncNode->vgId, pSyncNode->pRaftCfg->isStandBy, - debugStr); + sDebug("vgId:%d sync event become follower, isStandBy:%d, replicaNum:%d, %s", pSyncNode->vgId, + pSyncNode->pRaftCfg->isStandBy, pSyncNode->replicaNum, debugStr); // maybe clear leader cache if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) { @@ -1278,8 +1419,8 @@ void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr) { // /\ UNCHANGED <> // void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) { - sDebug("vgId:%d sync event become leader, isStandBy:%d, %s", pSyncNode->vgId, pSyncNode->pRaftCfg->isStandBy, - debugStr); + sDebug("vgId:%d sync event become leader, isStandBy:%d, replicaNum:%d %s", pSyncNode->vgId, + pSyncNode->pRaftCfg->isStandBy, pSyncNode->replicaNum, debugStr); // state change pSyncNode->state = TAOS_SYNC_STATE_LEADER; @@ -1629,14 +1770,24 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) { syncTimeout2RpcMsg(pSyncMsg, &rpcMsg); syncRpcMsgLog2((char*)"==syncNodeEqHeartbeatTimer==", &rpcMsg); if (pSyncNode->FpEqMsg != NULL) { - pSyncNode->FpEqMsg(pSyncNode->msgcb, &rpcMsg); + int32_t code = pSyncNode->FpEqMsg(pSyncNode->msgcb, &rpcMsg); + if (code != 0) { + sError("vgId:%d sync enqueue timer msg error, code:%d", pSyncNode->vgId, code); + rpcFreeCont(rpcMsg.pCont); + return; + } + } else { sTrace("syncNodeEqHeartbeatTimer pSyncNode->FpEqMsg is NULL"); } syncTimeoutDestroy(pSyncMsg); + if (gSyncEnv != NULL) { taosTmrReset(syncNodeEqHeartbeatTimer, pSyncNode->heartbeatTimerMS, pSyncNode, gSyncEnv->pTimerManager, &pSyncNode->pHeartbeatTimer); + } else { + sError("sync env is already stop"); + } } else { sTrace("==syncNodeEqHeartbeatTimer== heartbeatTimerLogicClock:%" PRIu64 ", heartbeatTimerLogicClockUser:%" PRIu64 "", @@ -1818,10 +1969,52 @@ const char* syncStr(ESyncState state) { } static int32_t syncDoLeaderTransfer(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftEntry* pEntry) { - SyncLeaderTransfer* pSyncLeaderTransfer; - if (syncUtilSameId(&(pSyncLeaderTransfer->newLeaderId), &(ths->myRaftId))) { + SyncLeaderTransfer* pSyncLeaderTransfer = syncLeaderTransferFromRpcMsg2(pRpcMsg); + + /* + char host[128]; + uint16_t port; + syncUtilU642Addr(pSyncLeaderTransfer->newLeaderId.addr, host, sizeof(host), &port); + sDebug("vgId:%d sync event, maybe leader transfer to %s:%d %lu", ths->vgId, host, port, + pSyncLeaderTransfer->newLeaderId.addr); + */ + + sDebug("vgId:%d sync event, begin leader transfer", ths->vgId); + + if (strcmp(pSyncLeaderTransfer->newNodeInfo.nodeFqdn, ths->myNodeInfo.nodeFqdn) == 0 && + pSyncLeaderTransfer->newNodeInfo.nodePort == ths->myNodeInfo.nodePort) { + sDebug("vgId:%d sync event, maybe leader transfer to %s:%d %lu", ths->vgId, + pSyncLeaderTransfer->newNodeInfo.nodeFqdn, pSyncLeaderTransfer->newNodeInfo.nodePort, + pSyncLeaderTransfer->newLeaderId.addr); + + // reset elect timer now! + int32_t electMS = 1; + int32_t ret = syncNodeRestartElectTimer(ths, electMS); + ASSERT(ret == 0); } + /* + if (syncUtilSameId(&(pSyncLeaderTransfer->newLeaderId), &(ths->myRaftId))) { + // reset elect timer now! + int32_t electMS = 1; + int32_t ret = syncNodeRestartElectTimer(ths, electMS); + ASSERT(ret == 0); + } + */ + if (ths->pFsm->FpLeaderTransferCb != NULL) { + SFsmCbMeta cbMeta; + cbMeta.code = 0; + cbMeta.currentTerm = ths->pRaftStore->currentTerm; + cbMeta.flag = 0; + cbMeta.index = pEntry->index; + cbMeta.isWeak = pEntry->isWeak; + cbMeta.seqNum = pEntry->seqNum; + cbMeta.state = ths->state; + cbMeta.term = pEntry->term; + ths->pFsm->FpLeaderTransferCb(ths->pFsm, pRpcMsg, cbMeta); + } + + syncLeaderTransferDestroy(pSyncLeaderTransfer); return 0; } @@ -1845,25 +2038,33 @@ static int32_t syncNodeConfigChange(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftE bool isDrop; - if (IamInNew || (!IamInNew && ths->state != TAOS_SYNC_STATE_LEADER)) { + // if (IamInNew || (!IamInNew && ths->state != TAOS_SYNC_STATE_LEADER)) { + if (IamInNew) { syncNodeUpdateConfig(ths, &newSyncCfg, pEntry->index, &isDrop); // change isStandBy to normal if (!isDrop) { + char tmpbuf[128]; + snprintf(tmpbuf, sizeof(tmpbuf), "config change from %d to %d", oldSyncCfg.replicaNum, newSyncCfg.replicaNum); if (ths->state == TAOS_SYNC_STATE_LEADER) { - syncNodeBecomeLeader(ths, "config change"); + syncNodeBecomeLeader(ths, tmpbuf); } else { - syncNodeBecomeFollower(ths, "config change"); + syncNodeBecomeFollower(ths, tmpbuf); } } + } else { + char tmpbuf[128]; + snprintf(tmpbuf, sizeof(tmpbuf), "config change2 from %d to %d", oldSyncCfg.replicaNum, newSyncCfg.replicaNum); + syncNodeBecomeFollower(ths, tmpbuf); + } - if (gRaftDetailLog) { - char* sOld = syncCfg2Str(&oldSyncCfg); - char* sNew = syncCfg2Str(&newSyncCfg); - sInfo("==config change== 0x11 old:%s new:%s isDrop:%d \n", sOld, sNew, isDrop); - taosMemoryFree(sOld); - taosMemoryFree(sNew); - } + if (gRaftDetailLog) { + char* sOld = syncCfg2Str(&oldSyncCfg); + char* sNew = syncCfg2Str(&newSyncCfg); + sInfo("==config change== 0x11 old:%s new:%s isDrop:%d index:%ld IamInNew:%d \n", sOld, sNew, isDrop, pEntry->index, + IamInNew); + taosMemoryFree(sOld); + taosMemoryFree(sNew); } // always call FpReConfigCb @@ -1888,7 +2089,7 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, int32_t code = 0; ESyncState state = flag; sDebug("vgId:%d sync event commit by wal from index:%" PRId64 " to index:%" PRId64 ", %s", ths->vgId, beginIndex, - endIndex, syncUtilState2String(state)); + endIndex, syncUtilState2String(state)); // execute fsm if (ths->pFsm != NULL) { @@ -1923,7 +2124,7 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, ASSERT(code == 0); } - // config change + // leader transfer if (pEntry->originalRpcType == TDMT_SYNC_LEADER_TRANSFER) { code = syncDoLeaderTransfer(ths, &rpcMsg, pEntry); ASSERT(code == 0); diff --git a/source/libs/sync/src/syncRespMgr.c b/source/libs/sync/src/syncRespMgr.c index 642e572434..5087cacd02 100644 --- a/source/libs/sync/src/syncRespMgr.c +++ b/source/libs/sync/src/syncRespMgr.c @@ -44,6 +44,10 @@ int64_t syncRespMgrAdd(SSyncRespMgr *pObj, SRespStub *pStub) { uint64_t keyCode = ++(pObj->seqNum); taosHashPut(pObj->pRespHash, &keyCode, sizeof(keyCode), pStub, sizeof(SRespStub)); + SSyncNode *pSyncNode = pObj->data; + sDebug("vgId:%d sync event resp mgr add, type:%s seq:%lu handle:%p", pSyncNode->vgId, + TMSG_INFO(pStub->rpcMsg.msgType), keyCode, pStub->rpcMsg.info.handle); + taosThreadMutexUnlock(&(pObj->mutex)); return keyCode; } @@ -63,6 +67,11 @@ int32_t syncRespMgrGet(SSyncRespMgr *pObj, uint64_t index, SRespStub *pStub) { void *pTmp = taosHashGet(pObj->pRespHash, &index, sizeof(index)); if (pTmp != NULL) { memcpy(pStub, pTmp, sizeof(SRespStub)); + + SSyncNode *pSyncNode = pObj->data; + sDebug("vgId:%d sync event resp mgr get, type:%s seq:%lu handle:%p", pSyncNode->vgId, + TMSG_INFO(pStub->rpcMsg.msgType), index, pStub->rpcMsg.info.handle); + taosThreadMutexUnlock(&(pObj->mutex)); return 1; // get one object } @@ -76,6 +85,11 @@ int32_t syncRespMgrGetAndDel(SSyncRespMgr *pObj, uint64_t index, SRespStub *pStu void *pTmp = taosHashGet(pObj->pRespHash, &index, sizeof(index)); if (pTmp != NULL) { memcpy(pStub, pTmp, sizeof(SRespStub)); + + SSyncNode *pSyncNode = pObj->data; + sDebug("vgId:%d sync event resp mgr get and del, type:%s seq:%lu handle:%p", pSyncNode->vgId, + TMSG_INFO(pStub->rpcMsg.msgType), index, pStub->rpcMsg.info.handle); + taosHashRemove(pObj->pRespHash, &index, sizeof(index)); taosThreadMutexUnlock(&(pObj->mutex)); return 1; // get one object diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 38742220fe..afebfa798e 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -393,7 +393,7 @@ cJSON *snapshotSender2Json(SSyncSnapshotSender *pSender) { char *snapshotSender2Str(SSyncSnapshotSender *pSender) { cJSON *pJson = snapshotSender2Json(pSender); - char * serialized = cJSON_Print(pJson); + char *serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } @@ -514,7 +514,7 @@ cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver) { cJSON_AddStringToObject(pFromId, "addr", u64buf); { uint64_t u64 = pReceiver->fromId.addr; - cJSON * pTmp = pFromId; + cJSON *pTmp = pFromId; char host[128] = {0}; uint16_t port; syncUtilU642Addr(u64, host, sizeof(host), &port); @@ -538,7 +538,7 @@ cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver) { char *snapshotReceiver2Str(SSyncSnapshotReceiver *pReceiver) { cJSON *pJson = snapshotReceiver2Json(pReceiver); - char * serialized = cJSON_Print(pJson); + char *serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } @@ -588,6 +588,8 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { // maybe update lastconfig if (pMsg->lastConfigIndex >= SYNC_INDEX_BEGIN) { + int32_t oldReplicaNum = pSyncNode->replicaNum; + // update new config myIndex bool IamInNew = false; SSyncCfg newSyncCfg = pMsg->lastConfig; @@ -614,10 +616,12 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { // change isStandBy to normal if (!isDrop) { + char tmpbuf[128]; + snprintf(tmpbuf, sizeof(tmpbuf), "config change3 from %d to %d", oldReplicaNum, newSyncCfg.replicaNum); if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) { - syncNodeBecomeLeader(pSyncNode, "config change"); + syncNodeBecomeLeader(pSyncNode, tmpbuf); } else { - syncNodeBecomeFollower(pSyncNode, "config change"); + syncNodeBecomeFollower(pSyncNode, tmpbuf); } } } @@ -755,6 +759,12 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { // sender receives ack, set seq = ack + 1, send msg from seq // if ack == SYNC_SNAPSHOT_SEQ_END, stop sender int32_t syncNodeOnSnapshotRspCb(SSyncNode *pSyncNode, SyncSnapshotRsp *pMsg) { + // if already drop replica, do not process + if (!syncNodeInRaftGroup(pSyncNode, &(pMsg->srcId)) && pSyncNode->state == TAOS_SYNC_STATE_LEADER) { + sInfo("recv SyncSnapshotRsp maybe replica already dropped"); + return 0; + } + // get sender SSyncSnapshotSender *pSender = syncNodeGetSnapshotSender(pSyncNode, &(pMsg->srcId)); ASSERT(pSender != NULL); @@ -788,4 +798,4 @@ int32_t syncNodeOnSnapshotRspCb(SSyncNode *pSyncNode, SyncSnapshotRsp *pMsg) { } return 0; -} \ No newline at end of file +} diff --git a/source/libs/sync/src/syncUtil.c b/source/libs/sync/src/syncUtil.c index d12c5058cc..4026596548 100644 --- a/source/libs/sync/src/syncUtil.c +++ b/source/libs/sync/src/syncUtil.c @@ -14,6 +14,8 @@ */ #include "syncUtil.h" +#include + #include "syncEnv.h" void addEpIntoEpSet(SEpSet* pEpSet, const char* fqdn, uint16_t port); @@ -21,8 +23,31 @@ void addEpIntoEpSet(SEpSet* pEpSet, const char* fqdn, uint16_t port); // ---- encode / decode uint64_t syncUtilAddr2U64(const char* host, uint16_t port) { uint64_t u64; + + uint32_t hostU32 = taosGetIpv4FromFqdn(host); + if (hostU32 == (uint32_t)-1) { + sError("Get IP address error"); + return -1; + } + + /* uint32_t hostU32 = (uint32_t)taosInetAddr(host); - // assert(hostU32 != (uint32_t)-1); + if (hostU32 == (uint32_t)-1) { + struct hostent* hostEnt = gethostbyname(host); + if (hostEnt == NULL) { + sError("Get IP address error"); + return -1; + } + + const char* newHost = taosInetNtoa(*(struct in_addr*)(hostEnt->h_addr_list[0])); + hostU32 = (uint32_t)taosInetAddr(newHost); + if (hostU32 == (uint32_t)-1) { + sError("change %s to id, error", newHost); + } + // ASSERT(hostU32 != (uint32_t)-1); + } + */ + u64 = (((uint64_t)hostU32) << 32) | (((uint32_t)port) << 16); return u64; } diff --git a/source/libs/sync/test/CMakeLists.txt b/source/libs/sync/test/CMakeLists.txt index d39035ba53..725343e373 100644 --- a/source/libs/sync/test/CMakeLists.txt +++ b/source/libs/sync/test/CMakeLists.txt @@ -1,4 +1,5 @@ add_executable(syncTest "") +add_executable(syncRaftIdCheck "") add_executable(syncEnvTest "") add_executable(syncPingTimerTest "") add_executable(syncIOTickQTest "") @@ -54,6 +55,10 @@ target_sources(syncTest PRIVATE "syncTest.cpp" ) +target_sources(syncRaftIdCheck + PRIVATE + "syncRaftIdCheck.cpp" +) target_sources(syncEnvTest PRIVATE "syncEnvTest.cpp" @@ -257,6 +262,11 @@ target_include_directories(syncTest "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) +target_include_directories(syncRaftIdCheck + PUBLIC + "${TD_SOURCE_DIR}/include/libs/sync" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) target_include_directories(syncEnvTest PUBLIC "${TD_SOURCE_DIR}/include/libs/sync" @@ -508,6 +518,10 @@ target_link_libraries(syncTest sync gtest_main ) +target_link_libraries(syncRaftIdCheck + sync + gtest_main +) target_link_libraries(syncEnvTest sync gtest_main diff --git a/source/libs/sync/test/syncRaftIdCheck.cpp b/source/libs/sync/test/syncRaftIdCheck.cpp new file mode 100644 index 0000000000..90560e91e7 --- /dev/null +++ b/source/libs/sync/test/syncRaftIdCheck.cpp @@ -0,0 +1,32 @@ +#include +#include +#include "syncIO.h" +#include "syncInt.h" +#include "syncUtil.h" + +void usage(char* exe) { + printf("Usage: %s host port \n", exe); + printf("Usage: %s u64 \n", exe); +} + +int main(int argc, char** argv) { + if (argc == 2) { + uint64_t u64 = atoll(argv[1]); + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + printf("%lu -> %s:%d \n", u64, host, port); + + } else if (argc == 3) { + uint64_t u64; + char* host = argv[1]; + uint16_t port = atoi(argv[2]); + u64 = syncUtilAddr2U64(host, port); + printf("%s:%d -> %lu \n", host, port, u64); + } else { + usage(argv[0]); + exit(-1); + } + + return 0; +} diff --git a/source/libs/sync/test/syncTestTool.cpp b/source/libs/sync/test/syncTestTool.cpp index 0c8b26e9d9..ebcd7368cc 100644 --- a/source/libs/sync/test/syncTestTool.cpp +++ b/source/libs/sync/test/syncTestTool.cpp @@ -153,6 +153,16 @@ void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta cbMe taosMemoryFree(s); } +void LeaderTransferCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) { + char logBuf[256] = {0}; + snprintf(logBuf, sizeof(logBuf), + "==callback== ==LeaderTransferCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s, flag:%lu, term:%lu " + "currentTerm:%lu \n", + pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), + cbMeta.flag, cbMeta.term, cbMeta.currentTerm); + syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg); +} + SSyncFSM* createFsm() { SSyncFSM* pFsm = (SSyncFSM*)taosMemoryMalloc(sizeof(SSyncFSM)); memset(pFsm, 0, sizeof(*pFsm)); @@ -172,6 +182,8 @@ SSyncFSM* createFsm() { pFsm->FpSnapshotStopWrite = SnapshotStopWrite; pFsm->FpSnapshotDoWrite = SnapshotDoWrite; + pFsm->FpLeaderTransferCb = LeaderTransferCb; + return pFsm; } @@ -277,7 +289,8 @@ void usage(char* exe) { printf( "usage: %s replicaNum(1-5) myIndex(0-..) enableSnapshot(0/1) lastApplyIndex(>=-1) lastApplyTerm(>=0) " "writeRecordNum(>=0) " - "isStandBy(0/1) isConfigChange(0-5) iterTimes(>=0) finishLastApplyIndex(>=-1) finishLastApplyTerm(>=0) \n", + "isStandBy(0/1) isConfigChange(0-5) iterTimes(>=0) finishLastApplyIndex(>=-1) finishLastApplyTerm(>=0) " + "leaderTransfer(0/1) \n", exe); } @@ -294,9 +307,9 @@ SRpcMsg* createRpcMsg(int i, int count, int myIndex) { int main(int argc, char** argv) { sprintf(tsTempDir, "%s", "."); tsAsyncLog = 0; - sDebugFlag = DEBUG_SCREEN + DEBUG_FILE + DEBUG_TRACE + DEBUG_INFO + DEBUG_ERROR; + sDebugFlag = DEBUG_SCREEN + DEBUG_FILE + DEBUG_TRACE + DEBUG_INFO + DEBUG_ERROR + DEBUG_DEBUG; - if (argc != 12) { + if (argc != 13) { usage(argv[0]); exit(-1); } @@ -312,12 +325,14 @@ int main(int argc, char** argv) { int32_t iterTimes = atoi(argv[9]); int32_t finishLastApplyIndex = atoi(argv[10]); int32_t finishLastApplyTerm = atoi(argv[11]); + int32_t leaderTransfer = atoi(argv[12]); - sTrace( + sInfo( "args: replicaNum:%d, myIndex:%d, enableSnapshot:%d, lastApplyIndex:%d, lastApplyTerm:%d, writeRecordNum:%d, " - "isStandBy:%d, isConfigChange:%d, iterTimes:%d, finishLastApplyIndex:%d, finishLastApplyTerm:%d", + "isStandBy:%d, isConfigChange:%d, iterTimes:%d, finishLastApplyIndex:%d, finishLastApplyTerm:%d, " + "leaderTransfer:%d", replicaNum, myIndex, enableSnapshot, lastApplyIndex, lastApplyTerm, writeRecordNum, isStandBy, isConfigChange, - iterTimes, finishLastApplyIndex, finishLastApplyTerm); + iterTimes, finishLastApplyIndex, finishLastApplyTerm, leaderTransfer); // check parameter assert(replicaNum >= 1 && replicaNum <= 5); @@ -363,24 +378,31 @@ int main(int argc, char** argv) { //--------------------------- int32_t alreadySend = 0; + int32_t leaderTransferWait = 0; while (1) { char* simpleStr = syncNode2SimpleStr(pSyncNode); + leaderTransferWait++; + if (leaderTransferWait == 7) { + sTrace("begin leader transfer ..."); + int32_t ret = syncLeaderTransfer(rid); + } + if (alreadySend < writeRecordNum) { SRpcMsg* pRpcMsg = createRpcMsg(alreadySend, writeRecordNum, myIndex); int32_t ret = syncPropose(rid, pRpcMsg, false); if (ret == TAOS_SYNC_PROPOSE_NOT_LEADER) { - sTrace("%s value%d write not leader", simpleStr, alreadySend); + sTrace("%s value%d write not leader, leaderTransferWait:%d", simpleStr, alreadySend, leaderTransferWait); } else { assert(ret == 0); - sTrace("%s value%d write ok", simpleStr, alreadySend); + sTrace("%s value%d write ok, leaderTransferWait:%d", simpleStr, alreadySend, leaderTransferWait); } alreadySend++; rpcFreeCont(pRpcMsg->pCont); taosMemoryFree(pRpcMsg); } else { - sTrace("%s", simpleStr); + sTrace("%s, leaderTransferWait:%d", simpleStr, leaderTransferWait); } taosMsleep(1000); diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index d1debc6af6..fbf4d6aa9f 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -41,7 +41,7 @@ typedef struct SCliConn { // debug and log info struct sockaddr_in addr; - struct sockaddr_in locaddr; + struct sockaddr_in localAddr; } SCliConn; typedef struct SCliMsg { @@ -54,7 +54,8 @@ typedef struct SCliMsg { } SCliMsg; typedef struct SCliThrdObj { - TdThread thread; + TdThread thread; // tid + int64_t pid; // pid uv_loop_t* loop; SAsyncPool* asyncPool; uv_timer_t timer; @@ -325,7 +326,7 @@ void cliHandleResp(SCliConn* conn) { tDebug("%s cli conn %p %s received from %s:%d, local info: %s:%d, msg size: %d", pTransInst->label, conn, TMSG_INFO(pHead->msgType), taosInetNtoa(conn->addr.sin_addr), ntohs(conn->addr.sin_port), - taosInetNtoa(conn->locaddr.sin_addr), ntohs(conn->locaddr.sin_port), transMsg.contLen); + taosInetNtoa(conn->localAddr.sin_addr), ntohs(conn->localAddr.sin_port), transMsg.contLen); if (pCtx == NULL && CONN_NO_PERSIST_BY_APP(conn)) { tTrace("except, server continue send while cli ignore it"); @@ -643,7 +644,7 @@ void cliSend(SCliConn* pConn) { uv_buf_t wb = uv_buf_init((char*)pHead, msgLen); tDebug("%s cli conn %p %s is send to %s:%d, local info %s:%d", CONN_GET_INST_LABEL(pConn), pConn, TMSG_INFO(pHead->msgType), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), - taosInetNtoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port)); + taosInetNtoa(pConn->localAddr.sin_addr), ntohs(pConn->localAddr.sin_port)); if (pHead->persist == 1) { CONN_SET_PERSIST_BY_APP(pConn); @@ -668,8 +669,8 @@ void cliConnCb(uv_connect_t* req, int status) { int addrlen = sizeof(pConn->addr); uv_tcp_getpeername((uv_tcp_t*)pConn->stream, (struct sockaddr*)&pConn->addr, &addrlen); - addrlen = sizeof(pConn->locaddr); - uv_tcp_getsockname((uv_tcp_t*)pConn->stream, (struct sockaddr*)&pConn->locaddr, &addrlen); + addrlen = sizeof(pConn->localAddr); + uv_tcp_getsockname((uv_tcp_t*)pConn->stream, (struct sockaddr*)&pConn->localAddr, &addrlen); tTrace("%s cli conn %p connect to server successfully", CONN_GET_INST_LABEL(pConn), pConn); assert(pConn->stream == req->handle); @@ -742,8 +743,7 @@ void cliMayCvtFqdnToIp(SEpSet* pEpSet, SCvtAddr* pCvtAddr) { void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) { uint64_t et = taosGetTimestampUs(); uint64_t el = et - pMsg->st; - tTrace("%s cli msg tran time cost: %" PRIu64 "us, threadID: %" PRId64 "", ((STrans*)pThrd->pTransInst)->label, el, - pThrd->thread); + // tTrace("%s cli msg tran time cost: %" PRIu64 "us", ((STrans*)pThrd->pTransInst)->label, el); STransConnCtx* pCtx = pMsg->ctx; STrans* pTransInst = pThrd->pTransInst; @@ -822,6 +822,7 @@ static void cliAsyncCb(uv_async_t* handle) { static void* cliWorkThread(void* arg) { SCliThrdObj* pThrd = (SCliThrdObj*)arg; + pThrd->pid = taosGetSelfPthreadId(); setThreadName("trans-cli-work"); uv_run(pThrd->loop, UV_RUN_DEFAULT); return NULL; @@ -966,27 +967,31 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { pMsg->st = taosGetTimestampUs(); pCtx->retryCount += 1; if (pResp->code == TSDB_CODE_RPC_NETWORK_UNAVAIL) { - if (pCtx->retryCount < pEpSet->numOfEps) { + if (pCtx->retryCount < pEpSet->numOfEps * 3) { pEpSet->inUse = (++pEpSet->inUse) % pEpSet->numOfEps; STaskArg* arg = taosMemoryMalloc(sizeof(STaskArg)); arg->param1 = pMsg; arg->param2 = pThrd; transDQSched(pThrd->delayQueue, doDelayTask, arg, TRANS_RETRY_INTERVAL); + tTrace("use local epset, current in use: %d, retry count:%d, limit: %d", pEpSet->inUse, pCtx->retryCount + 1, + pEpSet->numOfEps * 3); transUnrefCliHandle(pConn); return -1; } } else if (pCtx->retryCount < TRANS_RETRY_COUNT_LIMIT) { if (pResp->contLen == 0) { pEpSet->inUse = (++pEpSet->inUse) % pEpSet->numOfEps; + tTrace("use local epset, current in use: %d, retry count:%d, limit: %d", pEpSet->inUse, pCtx->retryCount + 1, + TRANS_RETRY_COUNT_LIMIT); } else { SEpSet epSet = {0}; tDeserializeSEpSet(pResp->pCont, pResp->contLen, &epSet); pCtx->epSet = epSet; + tTrace("use remote epset, current in use: %d, retry count:%d, limit: %d", pEpSet->inUse, pCtx->retryCount + 1, + TRANS_RETRY_COUNT_LIMIT); } addConnToPool(pThrd->pool, pConn); - tTrace("use remote epset, current in use: %d, retry count:%d, try limit: %d", pEpSet->inUse, pCtx->retryCount + 1, - TRANS_RETRY_COUNT_LIMIT); STaskArg* arg = taosMemoryMalloc(sizeof(STaskArg)); arg->param1 = pMsg; @@ -1086,7 +1091,7 @@ void transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STra SCliThrdObj* thrd = ((SCliObj*)pTransInst->tcphandle)->pThreadObj[index]; - tDebug("send request at thread:%d, threadID: %" PRId64 ", msg: %p, dst: %s:%d, app:%p", index, thrd->thread, pReq, + tDebug("send request at thread:%d, threadID: %08" PRId64 ", msg: %p, dst: %s:%d, app:%p", index, thrd->pid, pReq, EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle); ASSERT(transSendAsync(thrd->asyncPool, &(cliMsg->q)) == 0); } @@ -1115,7 +1120,7 @@ void transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransM cliMsg->type = Normal; SCliThrdObj* thrd = ((SCliObj*)pTransInst->tcphandle)->pThreadObj[index]; - tDebug("send request at thread:%d, threadID:%" PRId64 ", msg: %p, dst: %s:%d, app:%p", index, thrd->thread, pReq, + tDebug("send request at thread:%d, threadID:%08" PRId64 ", msg: %p, dst: %s:%d, app:%p", index, thrd->pid, pReq, EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle); transSendAsync(thrd->asyncPool, &(cliMsg->q)); @@ -1146,7 +1151,7 @@ void transSetDefaultAddr(void* ahandle, const char* ip, const char* fqdn) { cliMsg->type = Update; SCliThrdObj* thrd = ((SCliObj*)pTransInst->tcphandle)->pThreadObj[i]; - tDebug("update epset at thread:%d, threadID:%" PRId64 "", i, thrd->thread); + tDebug("update epset at thread:%d, threadID:%08" PRId64 "", i, thrd->pid); transSendAsync(thrd->asyncPool, &(cliMsg->q)); } diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index 4c4714e248..020435d076 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -48,7 +48,7 @@ typedef struct SSvrConn { ConnStatus status; struct sockaddr_in addr; - struct sockaddr_in locaddr; + struct sockaddr_in localAddr; int64_t refId; int spi; @@ -286,12 +286,12 @@ static void uvHandleReq(SSvrConn* pConn) { if (pConn->status == ConnNormal && pHead->noResp == 0) { transRefSrvHandle(pConn); tDebug("server conn %p %s received from %s:%d, local info: %s:%d, msg size: %d", pConn, TMSG_INFO(transMsg.msgType), - taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), taosInetNtoa(pConn->locaddr.sin_addr), - ntohs(pConn->locaddr.sin_port), transMsg.contLen); + taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), taosInetNtoa(pConn->localAddr.sin_addr), + ntohs(pConn->localAddr.sin_port), transMsg.contLen); } else { tDebug("server conn %p %s received from %s:%d, local info: %s:%d, msg size: %d, resp:%d ", pConn, TMSG_INFO(transMsg.msgType), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), - taosInetNtoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port), transMsg.contLen, pHead->noResp); + taosInetNtoa(pConn->localAddr.sin_addr), ntohs(pConn->localAddr.sin_port), transMsg.contLen, pHead->noResp); // no ref here } @@ -454,8 +454,8 @@ static void uvPrepareSendData(SSvrMsg* smsg, uv_buf_t* wb) { char* msg = (char*)pHead; int32_t len = transMsgLenFromCont(pMsg->contLen); tDebug("server conn %p %s is sent to %s:%d, local info: %s:%d, msglen:%d", pConn, TMSG_INFO(pHead->msgType), - taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), taosInetNtoa(pConn->locaddr.sin_addr), - ntohs(pConn->locaddr.sin_port), len); + taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), taosInetNtoa(pConn->localAddr.sin_addr), + ntohs(pConn->localAddr.sin_port), len); pHead->msgLen = htonl(len); wb->base = msg; @@ -686,8 +686,8 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) { return; } - addrlen = sizeof(pConn->locaddr); - if (0 != uv_tcp_getsockname(pConn->pTcp, (struct sockaddr*)&pConn->locaddr, &addrlen)) { + addrlen = sizeof(pConn->localAddr); + if (0 != uv_tcp_getsockname(pConn->pTcp, (struct sockaddr*)&pConn->localAddr, &addrlen)) { tError("server conn %p failed to get local info", pConn); transUnrefSrvHandle(pConn); return; diff --git a/source/libs/transport/test/transUT.cpp b/source/libs/transport/test/transUT.cpp index 25b04e769c..86c4830284 100644 --- a/source/libs/transport/test/transUT.cpp +++ b/source/libs/transport/test/transUT.cpp @@ -381,28 +381,29 @@ TEST_F(TransEnv, srvReleaseHandle) { } ////////////////// } -TEST_F(TransEnv, cliReleaseHandleExcept) { - SRpcMsg resp = {0}; - SRpcMsg req = {0}; - for (int i = 0; i < 3; i++) { - memset(&req, 0, sizeof(req)); - req.info = resp.info; - req.info.persistHandle = 1; - req.info.ahandle = (void *)1234; - req.msgType = 1; - req.pCont = rpcMallocCont(10); - req.contLen = 10; - tr->cliSendAndRecv(&req, &resp); - if (i == 1) { - std::cout << "stop server" << std::endl; - tr->StopSrv(); - } - if (i > 1) { - EXPECT_TRUE(resp.code != 0); - } - } - ////////////////// -} +// reopen later +// TEST_F(TransEnv, cliReleaseHandleExcept) { +// SRpcMsg resp = {0}; +// SRpcMsg req = {0}; +// for (int i = 0; i < 3; i++) { +// memset(&req, 0, sizeof(req)); +// req.info = resp.info; +// req.info.persistHandle = 1; +// req.info.ahandle = (void *)1234; +// req.msgType = 1; +// req.pCont = rpcMallocCont(10); +// req.contLen = 10; +// tr->cliSendAndRecv(&req, &resp); +// if (i == 1) { +// std::cout << "stop server" << std::endl; +// tr->StopSrv(); +// } +// if (i > 1) { +// EXPECT_TRUE(resp.code != 0); +// } +// } +// ////////////////// +//} TEST_F(TransEnv, srvContinueSend) { tr->SetSrvContinueSend(processContinueSend); SRpcMsg req = {0}, resp = {0}; diff --git a/source/os/src/osLz4.c b/source/os/src/osLz4.c index f4e4951857..7f3c42fb6c 100644 --- a/source/os/src/osLz4.c +++ b/source/os/src/osLz4.c @@ -45,13 +45,13 @@ int32_t BUILDIN_CLZL(uint64_t val) { #else _MyBitScanReverse64(&r, val); #endif - return (int)(r >> 3); + return (int)(63 - r); } int32_t BUILDIN_CLZ(uint32_t val) { unsigned long r = 0; _BitScanReverse(&r, val); - return (int)(r >> 3); + return (int)(31 - r); } int32_t BUILDIN_CTZL(uint64_t val) { @@ -61,13 +61,13 @@ int32_t BUILDIN_CTZL(uint64_t val) { #else _MyBitScanForward64(&r, val); #endif - return (int)(r >> 3); + return (int)(r); } int32_t BUILDIN_CTZ(uint32_t val) { unsigned long r = 0; _BitScanForward(&r, val); - return (int)(r >> 3); + return (int)(r); } #endif diff --git a/source/util/src/talgo.c b/source/util/src/talgo.c index 866ac5757b..5353cd9bfe 100644 --- a/source/util/src/talgo.c +++ b/source/util/src/talgo.c @@ -175,7 +175,13 @@ void *taosbsearch(const void *key, const void *base, int32_t nmemb, int32_t size c = compar(key, p); if (c == 0) { - break; + if (flags == TD_GT){ + lidx = midx + 1; + } else if(flags == TD_LT){ + ridx = midx - 1; + }else{ + break; + } } else if (c < 0) { ridx = midx - 1; } else { @@ -189,6 +195,10 @@ void *taosbsearch(const void *key, const void *base, int32_t nmemb, int32_t size return (c <= 0) ? p : (midx + 1 < nmemb ? p + size : NULL); } else if (flags == TD_LE) { return (c >= 0) ? p : (midx > 0 ? p - size : NULL); + } else if (flags == TD_GT) { + return (c < 0) ? p : (midx + 1 < nmemb ? p + size : NULL); + } else if (flags == TD_LT) { + return (c > 0) ? p : (midx > 0 ? p - size : NULL); } else { ASSERT(0); } diff --git a/source/util/src/terror.c b/source/util/src/terror.c index e122ad0ab6..8e6284d2cb 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -559,14 +559,18 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_ALREADY_EXIST, "Tsma already exists TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_NO_INDEX_IN_META, "No tsma index in meta") TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_ENV, "Invalid tsma env") TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_STAT, "Invalid tsma state") +TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_PTR, "Invalid tsma pointer") +TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_PARA, "Invalid tsma parameters") TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_NO_INDEX_IN_CACHE, "No tsma index in cache") -TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_RM_SKEY_IN_HASH, "Rm tsma skey in cache") + //rsma TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_INVALID_ENV, "Invalid rsma env") TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_INVALID_STAT, "Invalid rsma state") +TAOS_DEFINE_ERROR(TSDB_CODE_INDEX_REBUILDING, "Index is rebuilding") + #ifdef TAOS_ERROR_C }; #endif diff --git a/source/util/src/thash.c b/source/util/src/thash.c index f564ae45b6..8bda59bba7 100644 --- a/source/util/src/thash.c +++ b/source/util/src/thash.c @@ -33,9 +33,9 @@ #define FREE_HASH_NODE(_fp, _n) \ do { \ - /* if (_fp != NULL) { \ - (_fp)(_n); \ - }*/ \ + if (_fp != NULL) { \ + (_fp)(_n); \ + } \ taosMemoryFreeClear(_n); \ } while (0); diff --git a/source/util/test/taosbsearchTest.cpp b/source/util/test/taosbsearchTest.cpp index 0b250c9ecc..b8fa3a4476 100644 --- a/source/util/test/taosbsearchTest.cpp +++ b/source/util/test/taosbsearchTest.cpp @@ -248,6 +248,170 @@ TEST(testCase, taosbsearch_greater_or_equal) { ASSERT_EQ(pRet, nullptr); } +TEST(testCase, taosbsearch_greater) { + // For equal test + int key = 3; + void *pRet = NULL; + + pRet = taosbsearch((void *)&key, NULL, 0, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(pRet, nullptr); + + // 1 element + int array1[1] = {5}; + + key = 1; + pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 5); + + key = 6; + pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(pRet, nullptr); + + key = 5; + pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(pRet, nullptr); + + // 2 element + int array2[2] = {3, 6}; + + key = 1; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 3); + + key = 3; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 6); + + key = 4; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 6); + + key = 6; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(pRet, nullptr); + + key = 7; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(pRet, nullptr); + + // 3 element + int array3[3] = {3, 6, 8}; + + key = 1; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 3); + + key = 3; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 6); + + key = 4; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 6); + + key = 6; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 8); + + key = 7; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 8); + + key = 8; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(pRet, nullptr); + + key = 9; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(pRet, nullptr); + + // 4 element + int array4[4] = {3, 6, 8, 11}; + + key = 1; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 3); + + key = 3; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 6); + + key = 4; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 6); + + key = 6; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 8); + + key = 7; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 8); + + key = 8; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 11); + + key = 9; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 11); + + key = 11; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(pRet, nullptr); + + key = 13; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(pRet, nullptr); + + // 5 element + int array5[5] = {3, 6, 8, 11, 15}; + + key = 1; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 3); + + key = 3; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 6); + + key = 4; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 6); + + key = 6; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 8); + + key = 7; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 8); + + key = 8; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 11); + + key = 9; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 11); + + key = 11; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 15); + + key = 13; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(*(int *)pRet, 15); + + key = 15; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(pRet, nullptr); + + key = 17; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GT); + ASSERT_EQ(pRet, nullptr); +} + TEST(testCase, taosbsearch_less_or_equal) { // For equal test int key = 3; @@ -411,4 +575,168 @@ TEST(testCase, taosbsearch_less_or_equal) { key = 17; pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LE); ASSERT_EQ(*(int *)pRet, 15); +} + +TEST(testCase, taosbsearch_less) { + // For equal test + int key = 3; + void *pRet = NULL; + + pRet = taosbsearch((void *)&key, NULL, 0, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(pRet, nullptr); + + // 1 element + int array1[1] = {5}; + + key = 1; + pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(pRet, nullptr); + + key = 6; + pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 5); + + key = 5; + pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(pRet, nullptr); + + // 2 element + int array2[2] = {3, 6}; + + key = 1; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(pRet, nullptr); + + key = 3; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(pRet, nullptr); + + key = 4; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 3); + + key = 6; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 3); + + key = 7; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 6); + + // 3 element + int array3[3] = {3, 6, 8}; + + key = 1; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(pRet, nullptr); + + key = 3; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(pRet, nullptr); + + key = 4; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 3); + + key = 6; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 3); + + key = 7; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 6); + + key = 8; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 6); + + key = 9; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 8); + + // 4 element + int array4[4] = {3, 6, 8, 11}; + + key = 1; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(pRet, nullptr); + + key = 3; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(pRet, nullptr); + + key = 4; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 3); + + key = 6; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 3); + + key = 7; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 6); + + key = 8; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 6); + + key = 9; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 8); + + key = 11; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 8); + + key = 13; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 11); + + // 5 element + int array5[5] = {3, 6, 8, 11, 15}; + + key = 1; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(pRet, nullptr); + + key = 3; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(pRet, nullptr); + + key = 4; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 3); + + key = 6; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 3); + + key = 7; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 6); + + key = 8; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 6); + + key = 9; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 8); + + key = 11; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 8); + + key = 13; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 11); + + key = 15; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 11); + + key = 17; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LT); + ASSERT_EQ(*(int *)pRet, 15); } \ No newline at end of file diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index db8a055362..6fe1251ed7 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -2,20 +2,20 @@ #======================b1-start=============== # ---- user -#./test.sh -f tsim/user/basic1.sim -#./test.sh -f tsim/user/pass_alter.sim -#./test.sh -f tsim/user/pass_len.sim -#./test.sh -f tsim/user/user_len.sim -#./test.sh -f tsim/user/privilege1.sim -#./test.sh -f tsim/user/privilege2.sim# +./test.sh -f tsim/user/basic1.sim +./test.sh -f tsim/user/pass_alter.sim +./test.sh -f tsim/user/pass_len.sim +./test.sh -f tsim/user/user_len.sim +./test.sh -f tsim/user/privilege1.sim +./test.sh -f tsim/user/privilege2.sim ## ---- db -#./test.sh -f tsim/db/create_all_options.sim -#./test.sh -f tsim/db/alter_option.sim -#./test.sh -f tsim/db/basic1.sim -#./test.sh -f tsim/db/basic2.sim -#./test.sh -f tsim/db/basic3.sim -#./test.sh -f tsim/db/basic6.sim +./test.sh -f tsim/db/create_all_options.sim +./test.sh -f tsim/db/alter_option.sim +./test.sh -f tsim/db/basic1.sim +./test.sh -f tsim/db/basic2.sim +./test.sh -f tsim/db/basic3.sim +./test.sh -f tsim/db/basic6.sim ./test.sh -f tsim/db/basic7.sim ./test.sh -f tsim/db/error1.sim ./test.sh -f tsim/db/taosdlog.sim @@ -78,6 +78,7 @@ # ./test.sh -f tsim/stream/state0.sim # ./test.sh -f tsim/stream/triggerInterval0.sim # ./test.sh -f tsim/stream/triggerSession0.sim +# ./test.sh -f tsim/stream/partitionby.sim # ---- transaction @@ -131,7 +132,7 @@ #./test.sh -f tsim/mnode/basic1.sim -m # --- sma -#./test.sh -f tsim/sma/tsmaCreateInsertData.sim +./test.sh -f tsim/sma/tsmaCreateInsertData.sim ./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim # --- valgrind diff --git a/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim index a73c140a0c..73be4a35bf 100644 --- a/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim +++ b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim @@ -171,6 +171,8 @@ if $rows != 1 then return -1 endi +return + print =============== step33: move follower1 print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5 sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5 diff --git a/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim index 6ce6fb4187..90f7b1ad1f 100644 --- a/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim +++ b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim @@ -160,53 +160,110 @@ if $rows != 1 then return -1 endi +<<<<<<< HEAD +print =============== step32: move follower2 +print redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5 +sql redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5 +<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim +======= +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim +======= print =============== step32: move leader print redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5 sql redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5 sql show d1.vgroups print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +>>>>>>> origin/3.0 sql show d1.tables if $rows != 1 then return -1 endi +<<<<<<< HEAD +print =============== step33: move follower1 +print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5 +sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5 +<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim +======= +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim +======= print =============== step33: move follower2 print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5 sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5 sql show d1.vgroups print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +>>>>>>> origin/3.0 sql show d1.tables if $rows != 1 then return -1 endi +<<<<<<< HEAD +print =============== step34: move follower2 +print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2 +sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2 +<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim +======= +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim +======= print =============== step34: move follower1 print redistribute vgroup 2 dnode $follower2 dnode 5 dnode $leaderVnode sql redistribute vgroup 2 dnode $follower2 dnode 5 dnode $leaderVnode sql show d1.vgroups print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +>>>>>>> origin/3.0 sql show d1.tables if $rows != 1 then return -1 endi +<<<<<<< HEAD +print =============== step35: move follower1 +print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1 +sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1 +<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim +sql show d1.tables +if $rows != 1 then + return -1 +endi +======= +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim +======= print =============== step35: move 5 print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode $follower2 sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode $follower2 sql show d1.vgroups print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +>>>>>>> origin/3.0 sql show d1.tables if $rows != 1 then return -1 endi +<<<<<<< HEAD +print =============== step36: move follower2 +print redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5 +sql redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5 +======= print =============== step36: move follower1 print redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5 sql redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5 +>>>>>>> origin/3.0 sql show d1.vgroups print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 @@ -215,7 +272,11 @@ if $rows != 1 then return -1 endi +<<<<<<< HEAD +print =============== step37: move follower1 +======= print =============== step37: move follower2 +>>>>>>> origin/3.0 print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5 sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5 sql show d1.vgroups @@ -226,9 +287,17 @@ if $rows != 1 then return -1 endi +<<<<<<< HEAD +<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim +======= +print =============== step38: move follower2 +print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2 +sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2 +======= print =============== step38: move leader print redistribute vgroup 2 dnode $follower1 dnode 5 dnode $follower2 sql redistribute vgroup 2 dnode $follower1 dnode 5 dnode $follower2 +>>>>>>> origin/3.0 sql show d1.vgroups print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 @@ -236,10 +305,18 @@ sql show d1.tables if $rows != 1 then return -1 endi +<<<<<<< HEAD +>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim + +print =============== step39: move follower1 +print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1 +sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1 +======= print =============== step39: move 5 print redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode $follower1 sql redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode $follower1 +>>>>>>> origin/3.0 sql show d1.vgroups print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 diff --git a/tests/script/tsim/sma/tsmaCreateInsertData.sim b/tests/script/tsim/sma/tsmaCreateInsertData.sim index 0202c53800..7a8cc2a555 100644 --- a/tests/script/tsim/sma/tsmaCreateInsertData.sim +++ b/tests/script/tsim/sma/tsmaCreateInsertData.sim @@ -37,6 +37,14 @@ print =============== trigger stream to execute sma aggr task and insert sma dat sql insert into ct1 values(now+5s, 20, 20.0, 30.0) #=================================================================== +print =============== show streams ================================ +sql show streams; +print $data00 $data01 $data02 + +if $data00 != d1 then + return -1 +endi + print =============== select * from ct1 from memory sql select * from ct1; print $data00 $data01 diff --git a/tests/script/tsim/stable/tag_filter.sim b/tests/script/tsim/stable/tag_filter.sim index 04b8f21de9..1f400eb803 100644 --- a/tests/script/tsim/stable/tag_filter.sim +++ b/tests/script/tsim/stable/tag_filter.sim @@ -73,5 +73,80 @@ if $rows != 6 then endi +print ========== prepare stbBin and ctbBin +sql create table db.stbBin (ts timestamp, c1 int, c2 binary(4)) tags(t1 binary(16)) + +sql create table db.ctbBin using db.stbBin tags("a") +sql insert into db.ctbBin values(now, 1, "2") + +sql create table db.ctbBin1 using db.stbBin tags("b") +sql insert into db.ctbBin1 values(now, 2, "2") + +sql create table db.ctbBin2 using db.stbBin tags("c") +sql insert into db.ctbBin2 values(now, 3, "2") + +sql create table db.ctbBin3 using db.stbBin tags("d") +sql insert into db.ctbBin3 values(now, 4, "2") + +sql select * from db.stbBin where t1 = "a" +if $rows != 1 then + return -1 +endi + + +sql select * from db.stbBin where t1 < "a" +if $rows != 0 then + return -=1 +endi + +sql select * from db.stbBin where t1 < "b" +if $rows != 1 then + return -1 +endi + + +sql select * from db.stbBin where t1 between "a" and "e" +if $rows != 4 then + return -1 +endi + + +print ========== prepare stbNc and ctbNc +sql create table db.stbNc (ts timestamp, c1 int, c2 binary(4)) tags(t1 nchar(16)) + + +sql create table db.ctbNc using db.stbNc tags("a") +sql insert into db.ctbNc values(now, 1, "2") + +sql create table db.ctbNc1 using db.stbNc tags("b") +sql insert into db.ctbNc1 values(now, 2, "2") + +sql create table db.ctbNc2 using db.stbNc tags("c") +sql insert into db.ctbNc2 values(now, 3, "2") + +sql create table db.ctbNc3 using db.stbNc tags("d") +sql insert into db.ctbNc3 values(now, 4, "2") + +sql select * from db.stbNc where t1 = "a" +if $rows != 1 then + return -1 +endi + + +sql select * from db.stbNc where t1 < "a" +if $rows != 0 then + return -=1 +endi + +sql select * from db.stbNc where t1 < "b" +if $rows != 1 then + return -1 +endi + + +sql select * from db.stbNc where t1 between "a" and "e" +if $rows != 4 then + return -1 +endi system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stream/partitionby.sim b/tests/script/tsim/stream/partitionby.sim new file mode 100644 index 0000000000..df1e096551 --- /dev/null +++ b/tests/script/tsim/stream/partitionby.sim @@ -0,0 +1,68 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 50 +sql connect + +sql create database test vgroups 4; +sql use test; +sql create stable st(ts timestamp, a int, b int , c int, d double) tags(ta int,tb int,tc int); +sql create table ts1 using st tags(1,1,1); +sql create table ts2 using st tags(2,2,2); +sql create table ts3 using st tags(3,2,2); +sql create table ts4 using st tags(4,2,2); +sql create stream stream_t1 trigger at_once into streamtST1 as select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from st partition by ta,tb,tc interval(10s); + +sql insert into ts1 values(1648791213001,1,12,3,1.0); +sql insert into ts2 values(1648791213001,1,12,3,1.0); + +sql insert into ts3 values(1648791213001,1,12,3,1.0); +sql insert into ts4 values(1648791213001,1,12,3,1.0); +$loop_count = 0 + +loop0: +sleep 300 +sql select * from streamtST1; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 4 then +print =====rows=$rows +goto loop0 +endi + + +sql create database test1 vgroups 1; +sql use test1; +sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int); +sql create table ts1 using st tags(1,2,3); +sql create table ts2 using st tags(1,3,4); +sql create table ts3 using st tags(1,4,5); + +sql create stream streams1 trigger at_once into streamt as select _wstartts, count(*) c1, count(a) c2 from st partition by ta,tb,tc interval(10s); + + +sql insert into ts1 values(1648791211000,1,2,3); + +sql insert into ts2 values(1648791211000,1,2,3); + +$loop_count = 0 + +loop0: +sleep 300 +sql select * from streamt; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 2 then +print =====rows=$rows +goto loop0 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/testsuit.sim b/tests/script/tsim/testsuit.sim index 1f258028cc..90210fd436 100644 --- a/tests/script/tsim/testsuit.sim +++ b/tests/script/tsim/testsuit.sim @@ -37,7 +37,7 @@ run tsim/db/error1.sim run tsim/db/taosdlog.sim run tsim/db/alter_option.sim run tsim/mnode/basic1.sim -run tsim/mnode/basic3.sim +#run tsim/mnode/basic3.sim run tsim/mnode/basic2.sim run tsim/parser/fourArithmetic-basic.sim run tsim/parser/groupby-basic.sim diff --git a/tests/script/tsim/trans/create_db.sim b/tests/script/tsim/trans/create_db.sim index e13014f9c0..f730f2fb67 100644 --- a/tests/script/tsim/trans/create_db.sim +++ b/tests/script/tsim/trans/create_db.sim @@ -7,44 +7,28 @@ system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode2 -s start sql connect -print =============== show dnodes -sql show dnodes; -if $rows != 1 then - return -1 -endi - -if $data00 != 1 then - return -1 -endi - -sql show mnodes; -if $rows != 1 then - return -1 -endi - -if $data00 != 1 then - return -1 -endi - -if $data02 != leader then - return -1 -endi - print =============== create dnodes sql create dnode $hostname port 7200 -sleep 2000 -sql show dnodes; -if $rows != 2 then - return -1 -endi - -if $data00 != 1 then +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 2 then return -1 endi - -if $data10 != 2 then - return -1 +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 endi print =============== kill dnode2 @@ -68,7 +52,7 @@ if $data[0][0] != 7 then return -1 endi -if $data[0][2] != undoAction then +if $data[0][2] != redoAction then return -1 endi @@ -80,14 +64,34 @@ sql_error create database d1 vgroups 2; print =============== start dnode2 system sh/exec.sh -n dnode2 -s start -sleep 3000 + +$x = 0 +step2: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 2 then + return -1 +endi +if $data(1)[4] != ready then + goto step2 +endi +if $data(2)[4] != ready then + goto step2 +endi sql show transactions if $rows != 0 then return -1 endi -sql create database d1 vgroups 2; +sql_error create database d1 vgroups 2; print =============== kill dnode2 system sh/exec.sh -n dnode2 -s stop -x SIGINT @@ -106,22 +110,31 @@ if $rows != 1 then return -1 endi -if $data[0][0] != 9 then +if $data[0][0] != 8 then return -1 endi -if $data[0][2] != undoAction then +if $data[0][2] != redoAction then return -1 endi if $data[0][3] != d2 then return -1 endi -return + +sql show databases ; +if $rows != 4 then + return -1 +endi +print d2 ==> $data(d2)[19] +if $data(d2)[19] != creating then + return -1 +endi + sql_error create database d2 vgroups 2; print =============== kill transaction -sql kill transaction 9; +sql kill transaction 8; sleep 2000 sql show transactions @@ -131,7 +144,34 @@ endi print =============== start dnode2 system sh/exec.sh -n dnode2 -s start -sleep 3000 + +$x = 0 +step3: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 2 then + return -1 +endi +if $data(1)[4] != ready then + goto step3 +endi +if $data(2)[4] != ready then + goto step3 +endi + +sql show transactions +if $rows != 0 then + return -1 +endi + +sql drop database d2; sql show transactions if $rows != 0 then @@ -145,6 +185,5 @@ sql_error kill transaction 3; sql_error kill transaction 4; sql_error kill transaction 5; -return system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/system-test/1-insert/create_retentions.py b/tests/system-test/1-insert/create_retentions.py new file mode 100644 index 0000000000..313c643822 --- /dev/null +++ b/tests/system-test/1-insert/create_retentions.py @@ -0,0 +1,254 @@ +import datetime + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * + +PRIMARY_COL = "ts" + +INT_COL = "c_int" +BINT_COL = "c_bint" +SINT_COL = "c_sint" +TINT_COL = "c_tint" +FLOAT_COL = "c_float" +DOUBLE_COL = "c_double" +BOOL_COL = "c_bool" +TINT_UN_COL = "c_tint_un" +SINT_UN_COL = "c_sint_un" +BINT_UN_COL = "c_bint_un" +INT_UN_COL = "c_int_un" + +BINARY_COL = "c8" +NCHAR_COL = "c9" +TS_COL = "c10" + +NUM_COL = [ INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, ] +CHAR_COL = [ BINARY_COL, NCHAR_COL, ] +BOOLEAN_COL = [ BOOL_COL, ] +TS_TYPE_COL = [ TS_COL, ] + +class TDTestCase: + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor(), True) + + @property + def create_databases_sql_err(self): + return [ + "create database if not exists db1 retentions 0s:1d", + "create database if not exists db1 retentions 1s:1y", + "create database if not exists db1 retentions 1s:1n", + "create database if not exists db1 retentions 1s:1n,2s:2d,3s:3d,4s:4d", + ] + + @property + def create_databases_sql_current(self): + return [ + "create database db1 retentions 1s:1d", + "create database db2 retentions 1s:1d,2m:2d,3h:3d", + ] + + @property + def alter_database_sql(self): + return [ + "alter database db1 retentions 99h:99d", + "alter database db2 retentions 97h:97d,98h:98d,99h:99d,", + ] + + @property + def create_stable_sql_err(self): + return [ + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(ceil) delay 1", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(count) delay 1", + f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} binary(16)) tags (tag1 int) rollup(avg) delay 1", + f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) tags (tag1 int) rollup(avg) delay 1", + ] + + @property + def create_stable_sql_current(self): + return [ + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(avg) delay 5", + ] + + def test_create_stb(self): + tdSql.execute("use db2") + for err_sql in self.create_stable_sql_err: + tdSql.error(err_sql) + for cur_sql in self.create_stable_sql_current: + tdSql.execute(cur_sql) + tdSql.query("show stables") + tdSql.checkRows(len(self.create_stable_sql_current)) + + def test_create_databases(self): + for err_sql in self.create_databases_sql_err: + tdSql.error(err_sql) + for cur_sql in self.create_databases_sql_current: + tdSql.execute(cur_sql) + tdSql.query("show databases") + for alter_sql in self.alter_database_sql: + tdSql.error(alter_sql) + + def all_test(self): + self.test_create_databases() + self.test_create_stb() + + def __create_tb(self): + tdSql.prepare() + + tdLog.printNoPrefix("==========step1:create table") + create_stb_sql = f'''create table stb1( + ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, + {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, + {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp, + {TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned, + {INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned + ) tags (t1 int) + ''' + create_ntb_sql = f'''create table t1( + ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, + {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, + {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp, + {TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned, + {INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned + ) + ''' + tdSql.execute(create_stb_sql) + tdSql.execute(create_ntb_sql) + + for i in range(4): + tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + + def __create_data_set(self, rows): + now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) + pos_data = [] + neg_data = [] + spec_data = [] + for i in range(rows): + pos_data.append( + ( + now_time - i * 1000, i, 11111 * i, 111 * i % 32767 , 11 * i % 127, 1.11 * i, 1100.0011 * i, + i % 2, f'binary{i}', f'nchar_测试_{i}', now_time + 1 * i, 11 * i % 127, 111 * i % 32767, i, 11111 * i + ) + ) + neg_data.append( + ( + now_time - i * 7776000000, -i, -11111 * i, -111 * i % 32767, -11 * i % 127, -1.11 * i, -1100.0011 * i, + i % 2, f'binary{i}', f'nchar_测试_{i}', now_time + 1 * i, 11 * i % 127, 111 * i % 32767, i, 11111 * i + ) + ) + + def __insert_data(self, rows): + now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) + for i in range(rows): + tdSql.execute( + f'''insert into ct1 values ( + { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, + {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i }, {11 * i % 127}, {111 * i % 32767}, {i}, {11111 * i} )''' + ) + tdSql.execute( + f'''insert into ct4 values ( + { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, + {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i }, {11 * i % 127}, {111 * i % 32767}, {i}, {11111 * i} )''' + ) + tdSql.execute( + f'''insert into ct2 values ( + { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, + {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i }, {11 * i % 127}, {111 * i % 32767}, {i}, {11111 * i} )''' + ) + tdSql.execute( + f'''insert into ct1 values + ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 }, 0, 0, 0, 0) + ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 }, 0, 0, 0, 0 ) + ''' + ) + + tdSql.execute( + f'''insert into ct4 values + ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( + { now_time + 5184000000}, {pow(2,31)-pow(2,15)}, {pow(2,63)-pow(2,30)}, 32767, 127, + { 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000}, + 254, 65534, {pow(2,32)-pow(2,16)}, {pow(2,64)-pow(2,31)} + ) + ( + { now_time + 2592000000 }, {pow(2,31)-pow(2,16)}, {pow(2,63)-pow(2,31)}, 32766, 126, + { 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000}, + 255, 65535, {pow(2,32)-pow(2,15)}, {pow(2,64)-pow(2,30)} + ) + ''' + ) + + tdSql.execute( + f'''insert into ct2 values + ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( + { now_time + 5184000000 }, { -1 * pow(2,31) + pow(2,15) }, { -1 * pow(2,63) + pow(2,30) }, -32766, -126, { -1 * 3.2 * pow(10,38) }, + { -1.2 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 }, 1, 1, 1, 1 + ) + ( + { now_time + 2592000000 }, { -1 * pow(2,31) + pow(2,16) }, { -1 * pow(2,63) + pow(2,31) }, -32767, -127, { - 3.3 * pow(10,38) }, + { -1.3 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 }, 1, 1, 1, 1 + ) + ''' + ) + + for i in range(rows): + insert_data = f'''insert into t1 values + ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, + "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i }, {i % 127}, {i % 32767}, {i}, {i * 11111}) + ''' + tdSql.execute(insert_data) + tdSql.execute( + f'''insert into t1 values + ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) + ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( + { now_time + 7200000 }, { pow(2,31) - pow(2,15) }, { pow(2,63) - pow(2,30) }, 32767, 127, { 3.3 * pow(10,38) }, + { 1.3 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 }, + 254, 65534, {pow(2,32)-pow(2,16)}, {pow(2,64)-pow(2,31)} + ) + ( + { now_time + 3600000 } , { pow(2,31) - pow(2,16) }, { pow(2,63) - pow(2,31) }, 32766, 126, { 3.2 * pow(10,38) }, + { 1.2 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 }, + 255, 65535, {pow(2,32)-pow(2,15)}, {pow(2,64)-pow(2,30)} + ) + ''' + ) + + + def run(self): + tdSql.prepare() + + tdLog.printNoPrefix("==========step1:create table") + self.__create_tb() + + tdLog.printNoPrefix("==========step2:insert data") + self.rows = 10 + self.__insert_data(self.rows) + + tdLog.printNoPrefix("==========step3:all check") + self.all_test() + tdSql.execute("drop database if exists db1 ") + tdSql.execute("drop database if exists db2 ") + + tdDnodes.stop(1) + tdDnodes.start(1) + + tdSql.execute("use db") + + tdLog.printNoPrefix("==========step4:after wal, all check again ") + self.all_test() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/2-query/explain.py b/tests/system-test/2-query/explain.py new file mode 100644 index 0000000000..d440144841 --- /dev/null +++ b/tests/system-test/2-query/explain.py @@ -0,0 +1,357 @@ +import datetime + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * + +PRIMARY_COL = "ts" + +INT_COL = "c1" +BINT_COL = "c2" +SINT_COL = "c3" +TINT_COL = "c4" +FLOAT_COL = "c5" +DOUBLE_COL = "c6" +BOOL_COL = "c7" + +BINARY_COL = "c8" +NCHAR_COL = "c9" +TS_COL = "c10" + +NUM_COL = [ INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, ] +CHAR_COL = [ BINARY_COL, NCHAR_COL, ] +BOOLEAN_COL = [ BOOL_COL, ] +TS_TYPE_COL = [ TS_COL, ] + +ALL_COL = [ INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, BOOL_COL, BINARY_COL, NCHAR_COL, TS_COL ] + +class TDTestCase: + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + + def __query_condition(self,tbname): + query_condition = [f"{tbname}.{col}" for col in ALL_COL] + for num_col in NUM_COL: + query_condition.extend( + ( + f"abs( {tbname}.{num_col} )", + f"acos( {tbname}.{num_col} )", + f"asin( {tbname}.{num_col} )", + f"atan( {tbname}.{num_col} )", + f"avg( {tbname}.{num_col} )", + f"ceil( {tbname}.{num_col} )", + f"cos( {tbname}.{num_col} )", + f"count( {tbname}.{num_col} )", + f"floor( {tbname}.{num_col} )", + f"log( {tbname}.{num_col}, {tbname}.{num_col})", + f"max( {tbname}.{num_col} )", + f"min( {tbname}.{num_col} )", + f"pow( {tbname}.{num_col}, 2)", + f"round( {tbname}.{num_col} )", + f"sum( {tbname}.{num_col} )", + f"sin( {tbname}.{num_col} )", + f"sqrt( {tbname}.{num_col} )", + f"tan( {tbname}.{num_col} )", + f"cast( {tbname}.{num_col} as timestamp)", + ) + ) + query_condition.extend((f"{num_col} + {any_col}" for any_col in ALL_COL)) + for char_col in CHAR_COL: + query_condition.extend( + ( + f"sum(cast({tbname}.{char_col} as bigint ))", + f"max(cast({tbname}.{char_col} as bigint ))", + f"min(cast({tbname}.{char_col} as bigint ))", + f"avg(cast({tbname}.{char_col} as bigint ))", + ) + ) + query_condition.extend( + ( + 1010, + ''' "test1234!@#$%^&*():'>= 0" + if col in CHAR_COL: + return f" where lower( {tbname}.{col} ) like 'bina%' or lower( {tbname}.{col} ) like '_cha%' " + if col in BOOLEAN_COL: + return f" where {tbname}.{col} in (false, true) " + if col in TS_TYPE_COL or col in PRIMARY_COL: + return f" where cast( {tbname}.{col} as binary(16) ) is not null " + + return "" + + def __group_condition(self, col, having = None): + if isinstance(col, str): + if col.startswith("count"): + col = col[6:-1] + elif col.startswith("max"): + col = col[4:-1] + elif col.startswith("sum"): + col = col[4:-1] + elif col.startswith("min"): + col = col[4:-1] + elif col.startswith("avg"): + col = col[4:-1] + return f" group by {col} having {having}" if having else f" group by {col} " + + def __single_sql(self, select_clause, from_clause, where_condition="", group_condition=""): + if isinstance(select_clause, str) and "on" not in from_clause and select_clause.split(".")[0].split("(")[-1] != from_clause.split(".")[0]: + return + return f"explain select {select_clause} from {from_clause} {where_condition} {group_condition}" + + @property + def __tb_list(self): + return [ + "ct1", + "ct4", + "t1", + "ct2", + "stb1", + ] + + def sql_list(self): + sqls = [] + __no_join_tblist = self.__tb_list + for tb in __no_join_tblist: + select_claus_list = self.__query_condition(tb) + for select_claus in select_claus_list: + group_claus = self.__group_condition(col=select_claus) + where_claus = self.__where_condition(query_conditon=select_claus) + having_claus = self.__group_condition(col=select_claus, having=f"{select_claus} is not null") + sqls.extend( + ( + self.__single_sql(select_claus, tb, where_claus, having_claus), + self.__single_sql(select_claus, tb,), + self.__single_sql(select_claus, tb, where_condition=where_claus), + self.__single_sql(select_claus, tb, group_condition=group_claus), + ) + ) + + # return filter(None, sqls) + return list(filter(None, sqls)) + + def __get_type(self, col): + if tdSql.cursor.istype(col, "BOOL"): + return "BOOL" + if tdSql.cursor.istype(col, "INT"): + return "INT" + if tdSql.cursor.istype(col, "BIGINT"): + return "BIGINT" + if tdSql.cursor.istype(col, "TINYINT"): + return "TINYINT" + if tdSql.cursor.istype(col, "SMALLINT"): + return "SMALLINT" + if tdSql.cursor.istype(col, "FLOAT"): + return "FLOAT" + if tdSql.cursor.istype(col, "DOUBLE"): + return "DOUBLE" + if tdSql.cursor.istype(col, "BINARY"): + return "BINARY" + if tdSql.cursor.istype(col, "NCHAR"): + return "NCHAR" + if tdSql.cursor.istype(col, "TIMESTAMP"): + return "TIMESTAMP" + if tdSql.cursor.istype(col, "JSON"): + return "JSON" + if tdSql.cursor.istype(col, "TINYINT UNSIGNED"): + return "TINYINT UNSIGNED" + if tdSql.cursor.istype(col, "SMALLINT UNSIGNED"): + return "SMALLINT UNSIGNED" + if tdSql.cursor.istype(col, "INT UNSIGNED"): + return "INT UNSIGNED" + if tdSql.cursor.istype(col, "BIGINT UNSIGNED"): + return "BIGINT UNSIGNED" + + def explain_check(self): + sqls = self.sql_list() + tdLog.printNoPrefix("===step 1: curent case, must return query OK") + for i in range(len(sqls)): + tdLog.info(f"sql: {sqls[i]}") + tdSql.query(sqls[i]) + + def __test_current(self): + tdSql.query("explain select c1 from ct1") + tdSql.query("explain select 1 from ct2") + tdSql.query("explain select cast(ceil(c6) as bigint) from ct4 group by c6") + tdSql.query("explain select count(c3) from ct4 group by c7 having count(c3) > 0") + tdSql.query("explain select ct2.c3 from ct4 join ct2 on ct4.ts=ct2.ts") + tdSql.query("explain select c1 from stb1 where c1 is not null and c1 in (0, 1, 2) or c1 between 2 and 100 ") + + self.explain_check() + + def __test_error(self): + + tdLog.printNoPrefix("===step 0: err case, must return err") + tdSql.error( "explain select hyperloglog(c1) from ct8" ) + tdSql.error( "explain show databases " ) + tdSql.error( "explain show stables " ) + tdSql.error( "explain show tables " ) + tdSql.error( "explain show vgroups " ) + tdSql.error( "explain show dnodes " ) + tdSql.error( '''explain select hyperloglog(['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10']) + from ct1 + where ['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'] is not null + group by ['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'] + having ['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'] is not null ''' ) + + def all_test(self): + self.__test_error() + self.__test_current() + + def __create_tb(self): + + tdLog.printNoPrefix("==========step1:create table") + create_stb_sql = f'''create table stb1( + ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, + {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, + {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp + ) tags (t1 int) + ''' + create_ntb_sql = f'''create table t1( + ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, + {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, + {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp + ) + ''' + tdSql.execute(create_stb_sql) + tdSql.execute(create_ntb_sql) + + for i in range(4): + tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2} + + def __insert_data(self, rows): + now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) + for i in range(rows): + tdSql.execute( + f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + ) + tdSql.execute( + f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + ) + tdSql.execute( + f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + ) + tdSql.execute( + f'''insert into ct1 values + ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } ) + ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } ) + ''' + ) + + tdSql.execute( + f'''insert into ct4 values + ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( + { now_time + 5184000000}, {pow(2,31)-pow(2,15)}, {pow(2,63)-pow(2,30)}, 32767, 127, + { 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000} + ) + ( + { now_time + 2592000000 }, {pow(2,31)-pow(2,16)}, {pow(2,63)-pow(2,31)}, 32766, 126, + { 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000} + ) + ''' + ) + + tdSql.execute( + f'''insert into ct2 values + ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( + { now_time + 5184000000 }, { -1 * pow(2,31) + pow(2,15) }, { -1 * pow(2,63) + pow(2,30) }, -32766, -126, + { -1 * 3.2 * pow(10,38) }, { -1.2 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 } + ) + ( + { now_time + 2592000000 }, { -1 * pow(2,31) + pow(2,16) }, { -1 * pow(2,63) + pow(2,31) }, -32767, -127, + { - 3.3 * pow(10,38) }, { -1.3 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 } + ) + ''' + ) + + for i in range(rows): + insert_data = f'''insert into t1 values + ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, + "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } ) + ''' + tdSql.execute(insert_data) + tdSql.execute( + f'''insert into t1 values + ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time + 7200000 }, { pow(2,31) - pow(2,15) }, { pow(2,63) - pow(2,30) }, 32767, 127, + { 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, + "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 } + ) + ( + { now_time + 3600000 } , { pow(2,31) - pow(2,16) }, { pow(2,63) - pow(2,31) }, 32766, 126, + { 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, + "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 } + ) + ''' + ) + + + def run(self): + tdSql.prepare() + + tdLog.printNoPrefix("==========step1:create table") + self.__create_tb() + + tdLog.printNoPrefix("==========step2:insert data") + self.rows = 10 + self.__insert_data(self.rows) + + tdLog.printNoPrefix("==========step3:all check") + self.all_test() + + tdDnodes.stop(1) + tdDnodes.start(1) + + tdSql.execute("use db") + + tdLog.printNoPrefix("==========step4:after wal, all check again ") + self.all_test() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/2-query/histogram.py b/tests/system-test/2-query/histogram.py index c8952c4af5..0448952be8 100644 --- a/tests/system-test/2-query/histogram.py +++ b/tests/system-test/2-query/histogram.py @@ -1,365 +1,3 @@ -import datetime - -from util.log import * -from util.sql import * -from util.cases import * -from util.dnodes import * - -PRIMARY_COL = "ts" - -INT_COL = "c1" -BINT_COL = "c2" -SINT_COL = "c3" -TINT_COL = "c4" -FLOAT_COL = "c5" -DOUBLE_COL = "c6" -BOOL_COL = "c7" - -BINARY_COL = "c8" -NCHAR_COL = "c9" -TS_COL = "c10" - -NUM_COL = [ INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, ] -CHAR_COL = [ BINARY_COL, NCHAR_COL, ] -BOOLEAN_COL = [ BOOL_COL, ] -TS_TYPE_COL = [ TS_COL, ] - -ALL_COL = [ INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, BOOL_COL, BINARY_COL, NCHAR_COL, TS_COL ] - -class TDTestCase: - - def init(self, conn, logSql): - tdLog.debug(f"start to excute {__file__}") - tdSql.init(conn.cursor()) - - def __query_condition(self,tbname): - query_condition = [f"cast({col} as bigint)" for col in ALL_COL] - for num_col in NUM_COL: - query_condition.extend( - ( - f"{tbname}.{num_col}", - f"abs( {tbname}.{num_col} )", - f"acos( {tbname}.{num_col} )", - f"asin( {tbname}.{num_col} )", - f"atan( {tbname}.{num_col} )", - f"avg( {tbname}.{num_col} )", - f"ceil( {tbname}.{num_col} )", - f"cos( {tbname}.{num_col} )", - f"count( {tbname}.{num_col} )", - f"floor( {tbname}.{num_col} )", - f"log( {tbname}.{num_col}, {tbname}.{num_col})", - f"max( {tbname}.{num_col} )", - f"min( {tbname}.{num_col} )", - f"pow( {tbname}.{num_col}, 2)", - f"round( {tbname}.{num_col} )", - f"sum( {tbname}.{num_col} )", - f"sin( {tbname}.{num_col} )", - f"sqrt( {tbname}.{num_col} )", - f"tan( {tbname}.{num_col} )", - f"cast( {tbname}.{num_col} as timestamp)", - ) - ) - [ query_condition.append(f"{num_col} + {any_col}") for any_col in ALL_COL ] - for char_col in CHAR_COL: - query_condition.extend( - ( - f"count({tbname}.{char_col})", - f"sum(cast({tbname}.{char_col}) as bigint)", - f"max(cast({tbname}.{char_col}) as bigint)", - f"min(cast({tbname}.{char_col}) as bigint)", - f"avg(cast({tbname}.{char_col}) as bigint)", - ) - ) - query_condition.extend( - ( - 1010, - ) - ) - - return query_condition - - def __join_condition(self, tb_list, filter=PRIMARY_COL, INNER=False): - table_reference = tb_list[0] - join_condition = table_reference - join = "inner join" if INNER else "join" - for i in range(len(tb_list[1:])): - join_condition += f" {join} {tb_list[i+1]} on {table_reference}.{filter}={tb_list[i+1]}.{filter}" - - return join_condition - - def __where_condition(self, col=None, tbname=None, query_conditon=None): - if query_conditon and isinstance(query_conditon, str): - if query_conditon.startswith("count"): - query_conditon = query_conditon[6:-1] - elif query_conditon.startswith("max"): - query_conditon = query_conditon[4:-1] - elif query_conditon.startswith("sum"): - query_conditon = query_conditon[4:-1] - elif query_conditon.startswith("min"): - query_conditon = query_conditon[4:-1] - - if query_conditon: - return f" where {query_conditon} is not null" - if col in NUM_COL: - return f" where abs( {tbname}.{col} ) >= 0" - if col in CHAR_COL: - return f" where lower( {tbname}.{col} ) like 'bina%' or lower( {tbname}.{col} ) like '_cha%' " - if col in BOOLEAN_COL: - return f" where {tbname}.{col} in (false, true) " - if col in TS_TYPE_COL or col in PRIMARY_COL: - return f" where cast( {tbname}.{col} as binary(16) ) is not null " - - return "" - - def __group_condition(self, col, having = None): - if isinstance(col, str): - if col.startswith("count"): - col = col[6:-1] - elif col.startswith("max"): - col = col[4:-1] - elif col.startswith("sum"): - col = col[4:-1] - elif col.startswith("min"): - col = col[4:-1] - return f" group by {col} having {having}" if having else f" group by {col} " - - def __single_sql(self, select_clause, from_clause, where_condition="", group_condition=""): - if isinstance(select_clause, str) and "on" not in from_clause and select_clause.split(".")[0] != from_clause.split(".")[0]: - return - return f"select spread({select_clause}) from {from_clause} {where_condition} {group_condition}" - - @property - def __tb_list(self): - return [ - "ct1", - "ct4", - "t1", - "ct2", - "stb1", - ] - - def sql_list(self): - sqls = [] - __no_join_tblist = self.__tb_list - for tb in __no_join_tblist: - select_claus_list = self.__query_condition(tb) - for select_claus in select_claus_list: - group_claus = self.__group_condition(col=select_claus) - where_claus = self.__where_condition(query_conditon=select_claus) - having_claus = self.__group_condition(col=select_claus, having=f"{select_claus} is not null") - sqls.extend( - ( - self.__single_sql(select_claus, tb, where_claus, having_claus), - self.__single_sql(select_claus, tb,), - self.__single_sql(select_claus, tb, where_condition=where_claus), - self.__single_sql(select_claus, tb, group_condition=group_claus), - ) - ) - - # return filter(None, sqls) - return list(filter(None, sqls)) - - def __get_type(self, col): - if tdSql.cursor.istype(col, "BOOL"): - return "BOOL" - if tdSql.cursor.istype(col, "INT"): - return "INT" - if tdSql.cursor.istype(col, "BIGINT"): - return "BIGINT" - if tdSql.cursor.istype(col, "TINYINT"): - return "TINYINT" - if tdSql.cursor.istype(col, "SMALLINT"): - return "SMALLINT" - if tdSql.cursor.istype(col, "FLOAT"): - return "FLOAT" - if tdSql.cursor.istype(col, "DOUBLE"): - return "DOUBLE" - if tdSql.cursor.istype(col, "BINARY"): - return "BINARY" - if tdSql.cursor.istype(col, "NCHAR"): - return "NCHAR" - if tdSql.cursor.istype(col, "TIMESTAMP"): - return "TIMESTAMP" - if tdSql.cursor.istype(col, "JSON"): - return "JSON" - if tdSql.cursor.istype(col, "TINYINT UNSIGNED"): - return "TINYINT UNSIGNED" - if tdSql.cursor.istype(col, "SMALLINT UNSIGNED"): - return "SMALLINT UNSIGNED" - if tdSql.cursor.istype(col, "INT UNSIGNED"): - return "INT UNSIGNED" - if tdSql.cursor.istype(col, "BIGINT UNSIGNED"): - return "BIGINT UNSIGNED" - - def spread_check(self): - sqls = self.sql_list() - tdLog.printNoPrefix("===step 1: curent case, must return query OK") - for i in range(len(sqls)): - tdLog.info(f"sql: {sqls[i]}") - tdSql.query(sqls[i]) - - def __test_current(self): - tdSql.query("select spread(ts) from ct1") - tdSql.checkRows(1) - tdSql.query("select spread(c1) from ct2") - tdSql.checkRows(1) - tdSql.query("select spread(c1) from ct4 group by c1") - tdSql.checkRows(self.rows + 3) - tdSql.query("select spread(c1) from ct4 group by c7") - tdSql.checkRows(3) - tdSql.query("select spread(ct2.c1) from ct4 join ct2 on ct4.ts=ct2.ts") - tdSql.checkRows(1) - - self.spread_check() - - def __test_error(self): - - tdLog.printNoPrefix("===step 0: err case, must return err") - tdSql.error( "select spread() from ct1" ) - tdSql.error( "select spread(1, 2) from ct2" ) - tdSql.error( f"select spread({NUM_COL[0]}, {NUM_COL[1]}) from ct4" ) - tdSql.error( f"select spread({BOOLEAN_COL[0]}) from t1" ) - tdSql.error( f"select spread({CHAR_COL[0]}) from stb1" ) - - # tdSql.error( ''' select spread(['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10']) - # from ct1 - # where ['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'] is not null - # group by ['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'] - # having ['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'] is not null ''' ) - # tdSql.error( "select c1 from ct1 union select c1 from ct2 union select c1 from ct4 ") - - def all_test(self): - self.__test_error() - self.__test_current() - - def __create_tb(self): - - tdLog.printNoPrefix("==========step1:create table") - create_stb_sql = f'''create table stb1( - ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, - {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, - {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp - ) tags (t1 int) - ''' - create_ntb_sql = f'''create table t1( - ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, - {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, - {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp - ) - ''' - tdSql.execute(create_stb_sql) - tdSql.execute(create_ntb_sql) - - for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') - { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2} - - def __insert_data(self, rows): - now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) - for i in range(rows): - tdSql.execute( - f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" - ) - tdSql.execute( - f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" - ) - tdSql.execute( - f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" - ) - tdSql.execute( - f'''insert into ct1 values - ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } ) - ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } ) - ''' - ) - - tdSql.execute( - f'''insert into ct4 values - ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( - { now_time + 5184000000}, {pow(2,31)-pow(2,15)}, {pow(2,63)-pow(2,30)}, 32767, 127, - { 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000} - ) - ( - { now_time + 2592000000 }, {pow(2,31)-pow(2,16)}, {pow(2,63)-pow(2,31)}, 32766, 126, - { 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000} - ) - ''' - ) - - tdSql.execute( - f'''insert into ct2 values - ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( - { now_time + 5184000000 }, { -1 * pow(2,31) + pow(2,15) }, { -1 * pow(2,63) + pow(2,30) }, -32766, -126, - { -1 * 3.2 * pow(10,38) }, { -1.2 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 } - ) - ( - { now_time + 2592000000 }, { -1 * pow(2,31) + pow(2,16) }, { -1 * pow(2,63) + pow(2,31) }, -32767, -127, - { - 3.3 * pow(10,38) }, { -1.3 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 } - ) - ''' - ) - - for i in range(rows): - insert_data = f'''insert into t1 values - ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, - "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } ) - ''' - tdSql.execute(insert_data) - tdSql.execute( - f'''insert into t1 values - ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( { now_time + 7200000 }, { pow(2,31) - pow(2,15) }, { pow(2,63) - pow(2,30) }, 32767, 127, - { 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, - "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 } - ) - ( - { now_time + 3600000 } , { pow(2,31) - pow(2,16) }, { pow(2,63) - pow(2,31) }, 32766, 126, - { 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, - "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 } - ) - ''' - ) - - - def run(self): - tdSql.prepare() - - tdLog.printNoPrefix("==========step1:create table") - self.__create_tb() - - tdLog.printNoPrefix("==========step2:insert data") - self.rows = 10 - self.__insert_data(self.rows) - - tdLog.printNoPrefix("==========step3:all check") - self.all_test() - - tdDnodes.stop(1) - tdDnodes.start(1) - - tdSql.execute("use db") - - tdLog.printNoPrefix("==========step4:after wal, all check again ") - self.all_test() - - def stop(self): - tdSql.close() - tdLog.success(f"{__file__} successfully executed") - -tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) - - - - ################################################################### # Copyright (c) 2021 by TAOS Technologies, Inc. @@ -532,21 +170,21 @@ class TDTestCase: tdSql.error('select histogram(tag_smallint, "user_input", "[1,3,5,7]", 0) from ctb;') tdSql.error('select histogram(tag_smallint, "user_input", "[1,3,5,7]", 0) from tb;') - tdSql.error('select histogram(tag_int, "user_input", "[1,3,5,7]", 0) from stb;') - tdSql.error('select histogram(tag_int, "user_input", "[1,3,5,7]", 0) from ctb;') - tdSql.error('select histogram(tag_int, "user_input", "[1,3,5,7]", 0) from tb;') + tdSql.query('select histogram(tag_int, "user_input", "[1,3,5,7]", 0) from stb;') + tdSql.query('select histogram(tag_int, "user_input", "[1,3,5,7]", 0) from ctb;') + tdSql.query('select histogram(tag_int, "user_input", "[1,3,5,7]", 0) from tb;') - tdSql.error('select histogram(tag_bigint, "user_input", "[1,3,5,7]", 0) from stb;') - tdSql.error('select histogram(tag_bigint, "user_input", "[1,3,5,7]", 0) from ctb;') - tdSql.error('select histogram(tag_bigint, "user_input", "[1,3,5,7]", 0) from tb;') + tdSql.query('select histogram(tag_bigint, "user_input", "[1,3,5,7]", 0) from stb;') + tdSql.query('select histogram(tag_bigint, "user_input", "[1,3,5,7]", 0) from ctb;') + tdSql.query('select histogram(tag_bigint, "user_input", "[1,3,5,7]", 0) from tb;') - tdSql.error('select histogram(tag_float, "user_input", "[1,3,5,7]", 0) from stb;') - tdSql.error('select histogram(tag_float, "user_input", "[1,3,5,7]", 0) from ctb;') - tdSql.error('select histogram(tag_float, "user_input", "[1,3,5,7]", 0) from tb;') + tdSql.query('select histogram(tag_float, "user_input", "[1,3,5,7]", 0) from stb;') + tdSql.query('select histogram(tag_float, "user_input", "[1,3,5,7]", 0) from ctb;') + tdSql.query('select histogram(tag_float, "user_input", "[1,3,5,7]", 0) from tb;') - tdSql.error('select histogram(tag_double, "user_input", "[1,3,5,7]", 0) from stb;') - tdSql.error('select histogram(tag_double, "user_input", "[1,3,5,7]", 0) from ctb;') - tdSql.error('select histogram(tag_double, "user_input", "[1,3,5,7]", 0) from tb;') + tdSql.query('select histogram(tag_double, "user_input", "[1,3,5,7]", 0) from stb;') + tdSql.query('select histogram(tag_double, "user_input", "[1,3,5,7]", 0) from ctb;') + tdSql.query('select histogram(tag_double, "user_input", "[1,3,5,7]", 0) from tb;') tdSql.error('select histogram(tag_bool, "user_input", "[1,3,5,7]", 0) from stb;') tdSql.error('select histogram(tag_bool, "user_input", "[1,3,5,7]", 0) from ctb;') diff --git a/tests/system-test/2-query/hyperloglog.py b/tests/system-test/2-query/hyperloglog.py index b20ec35f07..337db140a1 100644 --- a/tests/system-test/2-query/hyperloglog.py +++ b/tests/system-test/2-query/hyperloglog.py @@ -33,50 +33,7 @@ class TDTestCase: tdSql.init(conn.cursor()) def __query_condition(self,tbname): - query_condition = [f"cast({col} as bigint)" for col in ALL_COL] - for num_col in NUM_COL: - query_condition.extend( - ( - f"{tbname}.{num_col}", - f"abs( {tbname}.{num_col} )", - f"acos( {tbname}.{num_col} )", - f"asin( {tbname}.{num_col} )", - f"atan( {tbname}.{num_col} )", - f"avg( {tbname}.{num_col} )", - f"ceil( {tbname}.{num_col} )", - f"cos( {tbname}.{num_col} )", - f"count( {tbname}.{num_col} )", - f"floor( {tbname}.{num_col} )", - f"log( {tbname}.{num_col}, {tbname}.{num_col})", - f"max( {tbname}.{num_col} )", - f"min( {tbname}.{num_col} )", - f"pow( {tbname}.{num_col}, 2)", - f"round( {tbname}.{num_col} )", - f"sum( {tbname}.{num_col} )", - f"sin( {tbname}.{num_col} )", - f"sqrt( {tbname}.{num_col} )", - f"tan( {tbname}.{num_col} )", - f"cast( {tbname}.{num_col} as timestamp)", - ) - ) - query_condition.extend((f"{num_col} + {any_col}" for any_col in ALL_COL)) - for char_col in CHAR_COL: - query_condition.extend( - ( - f"count({tbname}.{char_col})", - f"sum(cast({tbname}.{char_col}) as bigint)", - f"max(cast({tbname}.{char_col}) as bigint)", - f"min(cast({tbname}.{char_col}) as bigint)", - f"avg(cast({tbname}.{char_col}) as bigint)", - ) - ) - # query_condition.extend( - # ( - # 1010, - # ) - # ) - - return query_condition + return [ f"{any_col}" for any_col in ALL_COL ] def __join_condition(self, tb_list, filter=PRIMARY_COL, INNER=False): table_reference = tb_list[0] @@ -124,7 +81,7 @@ class TDTestCase: return f" group by {col} having {having}" if having else f" group by {col} " def __single_sql(self, select_clause, from_clause, where_condition="", group_condition=""): - if isinstance(select_clause, str) and "on" not in from_clause and select_clause.split(".")[0] != from_clause.split(".")[0]: + if isinstance(select_clause, str) and "on" not in from_clause and select_clause.split(".")[0].split("(")[-1] != from_clause.split(".")[0]: return return f"select hyperloglog({select_clause}) from {from_clause} {where_condition} {group_condition}" @@ -191,7 +148,7 @@ class TDTestCase: if tdSql.cursor.istype(col, "BIGINT UNSIGNED"): return "BIGINT UNSIGNED" - def spread_check(self): + def hyperloglog_check(self): sqls = self.sql_list() tdLog.printNoPrefix("===step 1: curent case, must return query OK") for i in range(len(sqls)): @@ -214,15 +171,16 @@ class TDTestCase: for i in range(tdSql.queryRows): tdSql.checkData(i, 0, 1) if tdSql.queryResult[i][1] is not None else tdSql.checkData(i, 0, 0) - - - self.spread_check() + self.hyperloglog_check() def __test_error(self): tdLog.printNoPrefix("===step 0: err case, must return err") tdSql.error( "select hyperloglog() from ct1" ) tdSql.error( "select hyperloglog(c1, c2) from ct2" ) + # tdSql.error( "select hyperloglog(1) from stb1" ) + # tdSql.error( "select hyperloglog(abs(c1)) from ct4" ) + tdSql.error( "select hyperloglog(count(c1)) from t1" ) # tdSql.error( "select hyperloglog(1) from ct2" ) tdSql.error( f"select hyperloglog({NUM_COL[0]}, {NUM_COL[1]}) from ct4" ) tdSql.error( ''' select hyperloglog(['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10']) diff --git a/tests/system-test/2-query/leastsquares.py b/tests/system-test/2-query/leastsquares.py new file mode 100644 index 0000000000..e8fa32e8b3 --- /dev/null +++ b/tests/system-test/2-query/leastsquares.py @@ -0,0 +1,392 @@ +import datetime + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * + +PRIMARY_COL = "ts" + +INT_COL = "c1" +BINT_COL = "c2" +SINT_COL = "c3" +TINT_COL = "c4" +FLOAT_COL = "c5" +DOUBLE_COL = "c6" +BOOL_COL = "c7" + +BINARY_COL = "c8" +NCHAR_COL = "c9" +TS_COL = "c10" + +NUM_COL = [ INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, ] +CHAR_COL = [ BINARY_COL, NCHAR_COL, ] +BOOLEAN_COL = [ BOOL_COL, ] +TS_TYPE_COL = [ TS_COL, ] + +ALL_COL = [ INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, BOOL_COL, BINARY_COL, NCHAR_COL, TS_COL ] + +class TDTestCase: + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + + def __query_condition(self,tbname): + query_condition = [f"{tbname}.{col}" for col in ALL_COL] + for num_col in NUM_COL: + query_condition.extend( + ( + f"abs( {tbname}.{num_col} )", + f"acos( {tbname}.{num_col} )", + f"asin( {tbname}.{num_col} )", + f"atan( {tbname}.{num_col} )", + f"avg( {tbname}.{num_col} )", + f"ceil( {tbname}.{num_col} )", + f"cos( {tbname}.{num_col} )", + f"count( {tbname}.{num_col} )", + f"floor( {tbname}.{num_col} )", + f"log( {tbname}.{num_col}, {tbname}.{num_col})", + f"max( {tbname}.{num_col} )", + f"min( {tbname}.{num_col} )", + f"pow( {tbname}.{num_col}, 2)", + f"round( {tbname}.{num_col} )", + f"sum( {tbname}.{num_col} )", + f"sin( {tbname}.{num_col} )", + f"sqrt( {tbname}.{num_col} )", + f"tan( {tbname}.{num_col} )", + f"cast( {tbname}.{num_col} as timestamp)", + ) + ) + query_condition.extend((f"{num_col} + {any_col}" for any_col in ALL_COL)) + for char_col in CHAR_COL: + query_condition.extend( + ( + f"sum(cast({tbname}.{char_col} as bigint ))", + f"max(cast({tbname}.{char_col} as bigint ))", + f"min(cast({tbname}.{char_col} as bigint ))", + f"avg(cast({tbname}.{char_col} as bigint ))", + ) + ) + query_condition.extend( + ( + 1010, + ''' "test1234!@#$%^&*():'>= 0" + if col in CHAR_COL: + return f" where lower( {tbname}.{col} ) like 'bina%' or lower( {tbname}.{col} ) like '_cha%' " + if col in BOOLEAN_COL: + return f" where {tbname}.{col} in (false, true) " + if col in TS_TYPE_COL or col in PRIMARY_COL: + return f" where cast( {tbname}.{col} as binary(16) ) is not null " + + return "" + + def __group_condition(self, col, having = None): + if isinstance(col, str): + if col.startswith("count"): + col = col[6:-1] + elif col.startswith("max"): + col = col[4:-1] + elif col.startswith("sum"): + col = col[4:-1] + elif col.startswith("min"): + col = col[4:-1] + elif col.startswith("avg"): + col = col[4:-1] + return f" group by {col} having {having}" if having else f" group by {col} " + + def __single_sql(self, select_clause, from_clause, start_val=None, step_val=None, where_condition="", group_condition=""): + if isinstance(select_clause, str) and "on" not in from_clause and select_clause.split(".")[0].split("(")[-1] != from_clause.split(".")[0]: + return + return f"select leastsquares({select_clause}, {start_val}, {step_val}) from {from_clause} {where_condition} {group_condition}" + + @property + def __tb_list(self): + return [ + "ct1", + "ct4", + "t1", + "ct2", + "stb1", + ] + + @property + def start_step_val(self): + return [ + 1, + 0, + 1.25, + -2.5, + True, + False, + None, + "", + "str", + ] + + def sql_list(self): + current_sqls = [] + err_sqls = [] + __no_join_tblist = self.__tb_list + for tb in __no_join_tblist: + select_claus_list = self.__query_condition(tb) + for select_claus in select_claus_list: + group_claus = self.__group_condition(col=select_claus) + where_claus = self.__where_condition(query_conditon=select_claus) + having_claus = self.__group_condition(col=select_claus, having=f"{select_claus} is not null") + for arg in self.start_step_val: + if not isinstance(arg,int) or isinstance(arg, bool) : + err_sqls.extend( + ( + self.__single_sql(select_clause=select_claus, from_clause=tb, start_val=arg), + self.__single_sql(select_clause=select_claus, from_clause=tb, step_val=arg, group_condition=group_claus), + self.__single_sql(select_clause=select_claus, from_clause=tb, start_val=arg, where_condition=where_claus, group_condition=having_claus), + ) + ) + elif isinstance(select_claus, str) and any([BOOL_COL in select_claus, BINARY_COL in select_claus, NCHAR_COL in select_claus, TS_COL in select_claus]): + err_sqls.extend( + ( + self.__single_sql(select_clause=select_claus, from_clause=tb, start_val=arg), + self.__single_sql(select_clause=select_claus, from_clause=tb, step_val=arg, group_condition=group_claus), + self.__single_sql(select_clause=select_claus, from_clause=tb, start_val=arg, where_condition=where_claus, group_condition=having_claus), + ) + ) + else: + current_sqls.extend( + ( + self.__single_sql(select_clause=select_claus, from_clause=tb, start_val=arg, step_val=0), + self.__single_sql(select_clause=select_claus, from_clause=tb, start_val=0, step_val=arg, group_condition=group_claus), + self.__single_sql(select_clause=select_claus, from_clause=tb, start_val=arg, step_val=arg, where_condition=where_claus, group_condition=having_claus), + ) + ) + + # return filter(None, sqls) + return list(filter(None, current_sqls)), list(filter(None, err_sqls)) + + def __get_type(self, col): + if tdSql.cursor.istype(col, "BOOL"): + return "BOOL" + if tdSql.cursor.istype(col, "INT"): + return "INT" + if tdSql.cursor.istype(col, "BIGINT"): + return "BIGINT" + if tdSql.cursor.istype(col, "TINYINT"): + return "TINYINT" + if tdSql.cursor.istype(col, "SMALLINT"): + return "SMALLINT" + if tdSql.cursor.istype(col, "FLOAT"): + return "FLOAT" + if tdSql.cursor.istype(col, "DOUBLE"): + return "DOUBLE" + if tdSql.cursor.istype(col, "BINARY"): + return "BINARY" + if tdSql.cursor.istype(col, "NCHAR"): + return "NCHAR" + if tdSql.cursor.istype(col, "TIMESTAMP"): + return "TIMESTAMP" + if tdSql.cursor.istype(col, "JSON"): + return "JSON" + if tdSql.cursor.istype(col, "TINYINT UNSIGNED"): + return "TINYINT UNSIGNED" + if tdSql.cursor.istype(col, "SMALLINT UNSIGNED"): + return "SMALLINT UNSIGNED" + if tdSql.cursor.istype(col, "INT UNSIGNED"): + return "INT UNSIGNED" + if tdSql.cursor.istype(col, "BIGINT UNSIGNED"): + return "BIGINT UNSIGNED" + + def leastsquares_check(self): + current_sqls, err_sqls = self.sql_list() + for i in range(len(err_sqls)): + tdSql.error(err_sqls[i]) + + tdLog.printNoPrefix("===step 1: curent case, must return query OK") + for i in range(len(current_sqls)): + tdLog.info(f"sql: {current_sqls[i]}") + tdSql.query(current_sqls[i]) + + + def __test_current(self): + # tdSql.query("explain select c1 from ct1") + # tdSql.query("explain select 1 from ct2") + # tdSql.query("explain select cast(ceil(c6) as bigint) from ct4 group by c6") + # tdSql.query("explain select count(c3) from ct4 group by c7 having count(c3) > 0") + # tdSql.query("explain select ct2.c3 from ct4 join ct2 on ct4.ts=ct2.ts") + # tdSql.query("explain select c1 from stb1 where c1 is not null and c1 in (0, 1, 2) or c1 between 2 and 100 ") + + self.leastsquares_check() + + def __test_error(self): + + tdLog.printNoPrefix("===step 0: err case, must return err") + tdSql.error( "select leastsquares(c1) from ct8" ) + tdSql.error( "select leastsquares(c1, 1) from ct1 " ) + tdSql.error( "select leastsquares(c1, null, 1) from ct1 " ) + tdSql.error( "select leastsquares(c1, 1, null) from ct1 " ) + tdSql.error( "select leastsquares(null, 1, 1) from ct1 " ) + tdSql.error( '''select leastsquares(['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10']) + from ct1 + where ['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'] is not null + group by ['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'] + having ['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'] is not null ''' ) + + def all_test(self): + self.__test_error() + self.__test_current() + + def __create_tb(self): + + tdLog.printNoPrefix("==========step1:create table") + create_stb_sql = f'''create table stb1( + ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, + {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, + {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp + ) tags (t1 int) + ''' + create_ntb_sql = f'''create table t1( + ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, + {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, + {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp + ) + ''' + tdSql.execute(create_stb_sql) + tdSql.execute(create_ntb_sql) + + for i in range(4): + tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2} + + def __insert_data(self, rows): + now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) + for i in range(rows): + tdSql.execute( + f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + ) + tdSql.execute( + f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + ) + tdSql.execute( + f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + ) + tdSql.execute( + f'''insert into ct1 values + ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } ) + ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } ) + ''' + ) + + tdSql.execute( + f'''insert into ct4 values + ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( + { now_time + 5184000000}, {pow(2,31)-pow(2,15)}, {pow(2,63)-pow(2,30)}, 32767, 127, + { 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000} + ) + ( + { now_time + 2592000000 }, {pow(2,31)-pow(2,16)}, {pow(2,63)-pow(2,31)}, 32766, 126, + { 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000} + ) + ''' + ) + + tdSql.execute( + f'''insert into ct2 values + ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( + { now_time + 5184000000 }, { -1 * pow(2,31) + pow(2,15) }, { -1 * pow(2,63) + pow(2,30) }, -32766, -126, + { -1 * 3.2 * pow(10,38) }, { -1.2 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 } + ) + ( + { now_time + 2592000000 }, { -1 * pow(2,31) + pow(2,16) }, { -1 * pow(2,63) + pow(2,31) }, -32767, -127, + { - 3.3 * pow(10,38) }, { -1.3 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 } + ) + ''' + ) + + for i in range(rows): + insert_data = f'''insert into t1 values + ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, + "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } ) + ''' + tdSql.execute(insert_data) + tdSql.execute( + f'''insert into t1 values + ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time + 7200000 }, { pow(2,31) - pow(2,15) }, { pow(2,63) - pow(2,30) }, 32767, 127, + { 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, + "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 } + ) + ( + { now_time + 3600000 } , { pow(2,31) - pow(2,16) }, { pow(2,63) - pow(2,31) }, 32766, 126, + { 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, + "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 } + ) + ''' + ) + + + def run(self): + tdSql.prepare() + + tdLog.printNoPrefix("==========step1:create table") + self.__create_tb() + + tdLog.printNoPrefix("==========step2:insert data") + self.rows = 10 + self.__insert_data(self.rows) + + tdLog.printNoPrefix("==========step3:all check") + self.all_test() + + tdDnodes.stop(1) + tdDnodes.start(1) + + tdSql.execute("use db") + + tdLog.printNoPrefix("==========step4:after wal, all check again ") + self.all_test() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/2-query/tail.py b/tests/system-test/2-query/tail.py new file mode 100644 index 0000000000..6039f3effa --- /dev/null +++ b/tests/system-test/2-query/tail.py @@ -0,0 +1,439 @@ +from random import randint, random +from numpy import equal +import taos +import sys +import datetime +import inspect + +from util.log import * +from util.sql import * +from util.cases import * + +class TDTestCase: + updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , + "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + + def prepare_datas(self): + tdSql.execute( + '''create table stb1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + tags (t1 int) + ''' + ) + + tdSql.execute( + ''' + create table t1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + ''' + ) + for i in range(4): + tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + + for i in range(9): + tdSql.execute( + f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + ) + tdSql.execute( + f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + ) + tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + + tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + + tdSql.execute( + f'''insert into t1 values + ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a ) + ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a ) + ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a ) + ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a ) + ( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a ) + ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a ) + ( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) + ( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) + ( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" ) + ( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ''' + ) + + def test_errors(self): + error_sql_lists = [ + "select tail from t1", + "select tail(123--123)==1 from t1", + "select tail(123,123) from t1", + "select tail(c1,ts) from t1", + "select tail(c1,c1,ts) from t1", + "select tail(c1) as 'd1' from t1", + "select tail(c1 ,c2 ) from t1", + "select tail(c1 ,NULL) from t1", + "select tail(,) from t1;", + "select tail(tail(c1) ab from t1)", + "select tail(c1) as int from t1", + "select tail('c1') from t1", + "select tail(NULL) from t1", + "select tail('') from t1", + "select tail(c%) from t1", + "select tail(t1) from t1", + "select tail(True) from t1", + "select tail(c1,1) , count(c1) from t1", + "select tail(c1,1) , avg(c1) from t1", + "select tail(c1,1) , min(c1) from t1", + "select tail(c1,1) , spread(c1) from t1", + "select tail(c1,1) , diff(c1) from t1", + "select tail(c1,1) , abs(c1) from t1", + "select tail(c1,1) , c1 from t1", + "select tail from stb1 partition by tbname", + "select tail(123--123)==1 from stb1 partition by tbname", + "select tail(123,123) from stb1 partition by tbname", + "select tail(c1,ts) from stb1 partition by tbname", + "select tail(c1,c1,ts) from stb1 partition by tbname", + "select tail(c1) as 'd1' from stb1 partition by tbname", + "select tail(c1 ,c2 ) from stb1 partition by tbname", + "select tail(c1 ,NULL) from stb1 partition by tbname", + "select tail(,) from stb1 partition by tbname;", + "select tail(tail(c1) ab from stb1 partition by tbname)", + "select tail(c1) as int from stb1 partition by tbname", + "select tail('c1') from stb1 partition by tbname", + "select tail(NULL) from stb1 partition by tbname", + "select tail('') from stb1 partition by tbname", + "select tail(c%) from stb1 partition by tbname", + "select tail(t1) from stb1 partition by tbname", + "select tail(True) from stb1 partition by tbname", + "select tail(c1,1) , count(c1) from stb1 partition by tbname", + "select tail(c1,1) , avg(c1) from stb1 partition by tbname", + "select tail(c1,1) , min(c1) from stb1 partition by tbname", + "select tail(c1,1) , spread(c1) from stb1 partition by tbname", + "select tail(c1,1) , diff(c1) from stb1 partition by tbname", + "select tail(c1,1) , abs(c1) from stb1 partition by tbname", + "select tail(c1,1) , c1 from stb1 partition by tbname" + + ] + for error_sql in error_sql_lists: + tdSql.error(error_sql) + + def support_types(self): + other_no_value_types = [ + "select tail(ts,1) from t1" , + "select tail(c7,1) from t1", + "select tail(c8,1) from t1", + "select tail(c9,1) from t1", + "select tail(ts,1) from ct1" , + "select tail(c7,1) from ct1", + "select tail(c8,1) from ct1", + "select tail(c9,1) from ct1", + "select tail(ts,1) from ct3" , + "select tail(c7,1) from ct3", + "select tail(c8,1) from ct3", + "select tail(c9,1) from ct3", + "select tail(ts,1) from ct4" , + "select tail(c7,1) from ct4", + "select tail(c8,1) from ct4", + "select tail(c9,1) from ct4", + "select tail(ts,1) from stb1 partition by tbname" , + "select tail(c7,1) from stb1 partition by tbname", + "select tail(c8,1) from stb1 partition by tbname", + "select tail(c9,1) from stb1 partition by tbname" + ] + + for type_sql in other_no_value_types: + tdSql.query(type_sql) + + type_sql_lists = [ + "select tail(c1,1) from t1", + "select tail(c2,1) from t1", + "select tail(c3,1) from t1", + "select tail(c4,1) from t1", + "select tail(c5,1) from t1", + "select tail(c6,1) from t1", + + "select tail(c1,1) from ct1", + "select tail(c2,1) from ct1", + "select tail(c3,1) from ct1", + "select tail(c4,1) from ct1", + "select tail(c5,1) from ct1", + "select tail(c6,1) from ct1", + + "select tail(c1,1) from ct3", + "select tail(c2,1) from ct3", + "select tail(c3,1) from ct3", + "select tail(c4,1) from ct3", + "select tail(c5,1) from ct3", + "select tail(c6,1) from ct3", + + "select tail(c1,1) from stb1 partition by tbname", + "select tail(c2,1) from stb1 partition by tbname", + "select tail(c3,1) from stb1 partition by tbname", + "select tail(c4,1) from stb1 partition by tbname", + "select tail(c5,1) from stb1 partition by tbname", + "select tail(c6,1) from stb1 partition by tbname", + + "select tail(c6,1) as alisb from stb1 partition by tbname", + "select tail(c6,1) alisb from stb1 partition by tbname", + ] + + for type_sql in type_sql_lists: + tdSql.query(type_sql) + + def check_tail_table(self , tbname , col_name , tail_rows , offset): + tail_sql = f"select tail({col_name} , {tail_rows} , {offset}) from {tbname}" + equal_sql = f"select {col_name} from (select ts , {col_name} from {tbname} order by ts desc limit {tail_rows} offset {offset}) order by ts" + tdSql.query(tail_sql) + tail_result = tdSql.queryResult + + tdSql.query(equal_sql) + print(equal_sql) + + equal_result = tdSql.queryResult + + if tail_result == equal_result: + tdLog.info(" tail query check pass , tail sql is: %s" %tail_sql) + else: + tdLog.exit(" tail query check fail , tail sql is: %s " %tail_sql) + + def basic_tail_function(self): + + # basic query + tdSql.query("select c1 from ct3") + tdSql.checkRows(0) + tdSql.query("select c1 from t1") + tdSql.checkRows(12) + tdSql.query("select c1 from stb1") + tdSql.checkRows(25) + + # used for empty table , ct3 is empty + tdSql.query("select tail(c1,1) from ct3") + tdSql.checkRows(0) + tdSql.query("select tail(c2,1) from ct3") + tdSql.checkRows(0) + tdSql.query("select tail(c3,1) from ct3") + tdSql.checkRows(0) + tdSql.query("select tail(c4,1) from ct3") + tdSql.checkRows(0) + tdSql.query("select tail(c5,1) from ct3") + tdSql.checkRows(0) + tdSql.query("select tail(c6,1) from ct3") + + # auto check for t1 table + # used for regular table + tdSql.query("select tail(c1,1) from t1") + + tdSql.query("desc t1") + col_lists_rows = tdSql.queryResult + col_lists = [] + for col_name in col_lists_rows: + if col_name[0] =="ts": + continue + + col_lists.append(col_name[0]) + + for col in col_lists: + for loop in range(100): + limit = randint(1,100) + offset = randint(0,100) + self.check_tail_table("t1" , col , limit , offset) + + # tail for invalid params + + tdSql.error("select tail(c1,-10,10) from ct1") + tdSql.error("select tail(c1,10,10000) from ct1") + tdSql.error("select tail(c1,10,-100) from ct1") + tdSql.error("select tail(c1,100/2,10) from ct1") + tdSql.error("select tail(c1,5,10*2) from ct1") + tdSql.query("select tail(c1,100,100) from ct1") + tdSql.checkRows(0) + tdSql.query("select tail(c1,10,100) from ct1") + tdSql.checkRows(0) + tdSql.error("select tail(c1,10,101) from ct1") + tdSql.query("select tail(c1,10,0) from ct1") + tdSql.query("select tail(c1,100,10) from ct1") + tdSql.checkRows(3) + + # tail with super tags + + tdSql.query("select tail(c1,10,10) from ct1") + tdSql.checkRows(3) + + tdSql.error("select tail(c1,10,10),tbname from ct1") + tdSql.error("select tail(c1,10,10),t1 from ct1") + + # tail with common col + tdSql.error("select tail(c1,10,10) ,ts from ct1") + tdSql.error("select tail(c1,10,10) ,c1 from ct1") + + # tail with scalar function + tdSql.error("select tail(c1,10,10) ,abs(c1) from ct1") + tdSql.error("select tail(c1,10,10) , tail(c2,10,10) from ct1") + tdSql.error("select tail(c1,10,10) , abs(c2)+2 from ct1") + + # bug need fix for scalar value or compute again + # tdSql.error(" select tail(c1,10,10) , 123 from ct1") + # tdSql.error(" select abs(tail(c1,10,10)) from ct1") + # tdSql.error(" select abs(tail(c1,10,10)) + 2 from ct1") + + # tail with aggregate function + tdSql.error("select tail(c1,10,10) ,sum(c1) from ct1") + tdSql.error("select tail(c1,10,10) ,max(c1) from ct1") + tdSql.error("select tail(c1,10,10) ,csum(c1) from ct1") + tdSql.error("select tail(c1,10,10) ,count(c1) from ct1") + + # tail with filter where + tdSql.query("select tail(c1,3,1) from ct4 where c1 is null") + tdSql.checkData(0, 0, None) + tdSql.checkData(1, 0, None) + + tdSql.query("select tail(c1,3,2) from ct4 where c1 >2 ") + tdSql.checkData(0, 0, 7) + tdSql.checkData(1, 0, 6) + tdSql.checkData(2, 0, 5) + + tdSql.query("select tail(c1,2,1) from ct4 where c2 between 0 and 99999") + tdSql.checkData(0, 0, 2) + tdSql.checkData(1, 0, 1) + + # tail with union all + tdSql.query("select tail(c1,2,1) from ct4 union all select c1 from ct1") + tdSql.checkRows(15) + tdSql.query("select tail(c1,2,1) from ct4 union all select c1 from ct2") + tdSql.checkRows(2) + tdSql.checkData(0, 0, 1) + tdSql.checkData(1, 0, 0) + tdSql.query("select tail(c2,2,1) from ct4 union all select abs(c2)/2 from ct4") + tdSql.checkRows(14) + + # tail with join + # prepare join datas with same ts + + tdSql.execute(" use db ") + tdSql.execute(" create stable st1 (ts timestamp , num int) tags(ind int)") + tdSql.execute(" create table tb1 using st1 tags(1)") + tdSql.execute(" create table tb2 using st1 tags(2)") + + tdSql.execute(" create stable st2 (ts timestamp , num int) tags(ind int)") + tdSql.execute(" create table ttb1 using st2 tags(1)") + tdSql.execute(" create table ttb2 using st2 tags(2)") + + start_ts = 1622369635000 # 2021-05-30 18:13:55 + + for i in range(10): + ts_value = start_ts+i*1000 + tdSql.execute(f" insert into tb1 values({ts_value} , {i})") + tdSql.execute(f" insert into tb2 values({ts_value} , {i})") + + tdSql.execute(f" insert into ttb1 values({ts_value} , {i})") + tdSql.execute(f" insert into ttb2 values({ts_value} , {i})") + + tdSql.query("select tail(tb2.num,3,2) from tb1, tb2 where tb1.ts=tb2.ts ") + tdSql.checkRows(3) + tdSql.checkData(0,0,5) + tdSql.checkData(1,0,6) + tdSql.checkData(2,0,7) + + # nest query + # tdSql.query("select tail(c1,2) from (select c1 from ct1)") + tdSql.query("select c1 from (select tail(c1,2) c1 from ct4)") + tdSql.checkRows(2) + tdSql.checkData(0, 0, 0) + tdSql.checkData(1, 0, None) + + tdSql.query("select sum(c1) from (select tail(c1,2) c1 from ct1)") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 18) + + tdSql.query("select abs(c1) from (select tail(c1,2) c1 from ct1)") + tdSql.checkRows(2) + tdSql.checkData(0, 0, 9) + + #partition by tbname + tdSql.query(" select tail(c1,5) from stb1 partition by tbname ") + tdSql.checkRows(10) + + tdSql.query(" select tail(c1,3) from stb1 partition by tbname ") + tdSql.checkRows(6) + + # group by + tdSql.error("select tail(c1,2) from ct1 group by c1") + tdSql.error("select tail(c1,2) from ct1 group by tbname") + + # super table + + + + + def check_boundary_values(self): + + tdSql.execute("drop database if exists bound_test") + tdSql.execute("create database if not exists bound_test") + tdSql.execute("use bound_test") + tdSql.execute( + "create table stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);" + ) + tdSql.execute(f'create table sub1_bound using stb_bound tags ( 1 )') + tdSql.execute( + f"insert into sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + ) + tdSql.execute( + f"insert into sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + ) + + tdSql.execute( + f"insert into sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + ) + + tdSql.execute( + f"insert into sub1_bound values ( now(), 2147483643, 9223372036854775803, 32763, 123, 3.39E+38, 1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + ) + + tdSql.execute( + f"insert into sub1_bound values ( now(), -2147483643, -9223372036854775803, -32763, -123, -3.39E+38, -1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + ) + + tdSql.error( + f"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + ) + + tdSql.query("select tail(c2,2) from sub1_bound") + tdSql.checkRows(2) + tdSql.checkData(0,0,9223372036854775803) + + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring + tdSql.prepare() + + tdLog.printNoPrefix("==========step1:create table ==============") + + self.prepare_datas() + + tdLog.printNoPrefix("==========step2:test errors ==============") + + self.test_errors() + + tdLog.printNoPrefix("==========step3:support types ============") + + self.support_types() + + tdLog.printNoPrefix("==========step4: tail basic query ============") + + self.basic_tail_function() + + tdLog.printNoPrefix("==========step5: tail boundary query ============") + + self.check_boundary_values() + + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/5dnode3mnodeDrop.py b/tests/system-test/6-cluster/5dnode3mnodeDrop.py index 1512fc9897..fe85f43ea1 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeDrop.py +++ b/tests/system-test/6-cluster/5dnode3mnodeDrop.py @@ -230,7 +230,7 @@ class TDTestCase: - def five_dnode_three_mnode(self,dnodenumber): + def five_dnode_three_mnode(self): tdSql.query("show dnodes;") tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(4,1,'%s:6430'%self.host) @@ -260,7 +260,9 @@ class TDTestCase: dropcount =0 while dropcount <= 10: for i in range(1,3): + tdLog.debug("drop mnode on dnode %d"%(i+1)) tdSql.execute("drop mnode on dnode %d"%(i+1)) + tdLog.debug("create mnode on dnode %d"%(i+1)) tdSql.execute("create mnode on dnode %d"%(i+1)) dropcount+=1 self.check3mnode() @@ -276,7 +278,7 @@ class TDTestCase: def run(self): # print(self.master_dnode.cfgDict) self.buildcluster(5) - self.five_dnode_three_mnode(5) + self.five_dnode_three_mnode() def stop(self): tdSql.close() diff --git a/tests/system-test/6-cluster/5dnode3mnodeStop.py b/tests/system-test/6-cluster/5dnode3mnodeStop.py index a9784f2d0f..f1fe8e7458 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeStop.py +++ b/tests/system-test/6-cluster/5dnode3mnodeStop.py @@ -145,6 +145,7 @@ class TDTestCase: tdSql.checkData(2,3,'ready') def check3mnode1off(self): + tdSql.error("drop mnode on dnode 1;") count=0 while count < 10: time.sleep(1) @@ -174,6 +175,7 @@ class TDTestCase: tdSql.checkData(2,3,'ready') def check3mnode2off(self): + tdSql.error("drop mnode on dnode 2;") count=0 while count < 10: time.sleep(1) @@ -201,6 +203,7 @@ class TDTestCase: tdSql.checkData(2,3,'ready') def check3mnode3off(self): + tdSql.error("drop mnode on dnode 3;") count=0 while count < 10: time.sleep(1) @@ -255,17 +258,17 @@ class TDTestCase: print(tdSql.queryResult) tdLog.debug("stop and follower of mnode") - # self.TDDnodes.stoptaosd(2) - # self.check3mnode2off() - # self.TDDnodes.starttaosd(2) + self.TDDnodes.stoptaosd(2) + self.check3mnode2off() + self.TDDnodes.starttaosd(2) - # self.TDDnodes.stoptaosd(3) - # self.check3mnode3off() - # self.TDDnodes.starttaosd(2) + self.TDDnodes.stoptaosd(3) + self.check3mnode3off() + self.TDDnodes.starttaosd(2) - # self.TDDnodes.stoptaosd(1) - # self.check3mnode1off() - # self.TDDnodes.starttaosd(1) + self.TDDnodes.stoptaosd(1) + self.check3mnode1off() + self.TDDnodes.starttaosd(1) # self.check3mnode() stopcount =0 diff --git a/tests/system-test/6-cluster/5dnode3mnodeStopInsert.py b/tests/system-test/6-cluster/5dnode3mnodeStopInsert.py index 95cd26dedc..fe569d9b8d 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeStopInsert.py +++ b/tests/system-test/6-cluster/5dnode3mnodeStopInsert.py @@ -13,6 +13,7 @@ import time import socket import subprocess from multiprocessing import Process +import threading as thd class MyDnodes(TDDnodes): def __init__(self ,dnodes_lists): super(MyDnodes,self).__init__() @@ -29,7 +30,6 @@ class TDTestCase: self.depoly_cluster(dnodenumber) self.master_dnode = self.TDDnodes.dnodes[0] self.host=self.master_dnode.cfgDict["fqdn"] - conn1 = taos.connect(self.master_dnode.cfgDict["fqdn"] , config=self.master_dnode.cfgDir) tdSql.init(conn1.cursor()) @@ -50,9 +50,9 @@ class TDTestCase: break return buildPath - def insert_data(self,count): + def insert_data(self,countstart,countstop): # fisrt add data : db\stable\childtable\general table - for couti in count: + for couti in range(countstart,countstop): tdSql.execute("drop database if exists db%d" %couti) tdSql.execute("create database if not exists db%d replica 1 days 300" %couti) tdSql.execute("use db%d" %couti) @@ -138,14 +138,15 @@ class TDTestCase: tdSql.query("show mnodes;") tdSql.checkRows(3) - tdSql.checkData(0,1,'chenhaoran02:6030') + tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,3,'ready') - tdSql.checkData(1,1,'chenhaoran02:6130') + tdSql.checkData(1,1,'%s:6130'%self.host) tdSql.checkData(1,3,'ready') - tdSql.checkData(2,1,'chenhaoran02:6230') + tdSql.checkData(2,1,'%s:6230'%self.host) tdSql.checkData(2,3,'ready') def check3mnode1off(self): + tdSql.error("drop mnode on dnode 1;") count=0 while count < 10: time.sleep(1) @@ -166,17 +167,18 @@ class TDTestCase: tdSql.query("show mnodes;") tdSql.checkRows(3) - tdSql.checkData(0,1,'chenhaoran02:6030') + tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'offline') tdSql.checkData(0,3,'ready') - tdSql.checkData(1,1,'chenhaoran02:6130') + tdSql.checkData(1,1,'%s:6130'%self.host) tdSql.checkData(1,3,'ready') - tdSql.checkData(2,1,'chenhaoran02:6230') + tdSql.checkData(2,1,'%s:6230'%self.host) tdSql.checkData(2,3,'ready') def check3mnode2off(self): + tdSql.error("drop mnode on dnode 2;") count=0 - while count < 10: + while count < 40: time.sleep(1) tdSql.query("show mnodes;") if tdSql.checkRows(3) : @@ -191,17 +193,18 @@ class TDTestCase: tdSql.query("show mnodes;") tdSql.checkRows(3) - tdSql.checkData(0,1,'chenhaoran02:6030') + tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'leader') tdSql.checkData(0,3,'ready') - tdSql.checkData(1,1,'chenhaoran02:6130') + tdSql.checkData(1,1,'%s:6130'%self.host) tdSql.checkData(1,2,'offline') tdSql.checkData(1,3,'ready') - tdSql.checkData(2,1,'chenhaoran02:6230') + tdSql.checkData(2,1,'%s:6230'%self.host) tdSql.checkData(2,2,'follower') tdSql.checkData(2,3,'ready') def check3mnode3off(self): + tdSql.error("drop mnode on dnode 3;") count=0 while count < 10: time.sleep(1) @@ -218,13 +221,13 @@ class TDTestCase: tdSql.query("show mnodes;") tdSql.checkRows(3) - tdSql.checkData(0,1,'chenhaoran02:6030') + tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'leader') tdSql.checkData(0,3,'ready') - tdSql.checkData(1,1,'chenhaoran02:6130') + tdSql.checkData(1,1,'%s:6130'%self.host) tdSql.checkData(1,2,'follower') tdSql.checkData(1,3,'ready') - tdSql.checkData(2,1,'chenhaoran02:6230') + tdSql.checkData(2,1,'%s:6230'%self.host) tdSql.checkData(2,2,'offline') tdSql.checkData(2,3,'ready') @@ -232,13 +235,13 @@ class TDTestCase: def five_dnode_three_mnode(self,dnodenumber): tdSql.query("show dnodes;") - tdSql.checkData(0,1,'chenhaoran02:6030') - tdSql.checkData(4,1,'chenhaoran02:6430') + tdSql.checkData(0,1,'%s:6030'%self.host) + tdSql.checkData(4,1,'%s:6430'%self.host) tdSql.checkData(0,4,'ready') tdSql.checkData(4,4,'ready') tdSql.query("show mnodes;") tdSql.checkRows(1) - tdSql.checkData(0,1,'chenhaoran02:6030') + tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'leader') tdSql.checkData(0,3,'ready') @@ -254,10 +257,27 @@ class TDTestCase: tdSql.query("show dnodes;") print(tdSql.queryResult) - # stop and follower of mnode + + tdLog.debug("stop and follower of mnode") + self.TDDnodes.stoptaosd(2) + self.check3mnode2off() + self.TDDnodes.starttaosd(2) + + self.TDDnodes.stoptaosd(3) + self.check3mnode3off() + self.TDDnodes.starttaosd(3) + + self.TDDnodes.stoptaosd(1) + self.check3mnode1off() + self.TDDnodes.starttaosd(1) + + # self.check3mnode() stopcount =0 while stopcount <= 2: for i in range(dnodenumber): + threads = [] + threads.append(thd.Thread(target=self.insert_data, args=(i*2,i*2+2))) + threads[0].start() self.TDDnodes.stoptaosd(i+1) # if i == 1 : # self.check3mnode2off() @@ -267,6 +287,8 @@ class TDTestCase: # self.check3mnode1off() self.TDDnodes.starttaosd(i+1) + threads[0].join() + # self.check3mnode() stopcount+=1 self.check3mnode() diff --git a/tests/system-test/7-tmq/subscribeDb1.py b/tests/system-test/7-tmq/subscribeDb1.py index 44c24eb616..ed92a429ae 100644 --- a/tests/system-test/7-tmq/subscribeDb1.py +++ b/tests/system-test/7-tmq/subscribeDb1.py @@ -437,12 +437,12 @@ class TDTestCase: event.wait() tdLog.info("start consume processor") - pollDelay = 100 + pollDelay = 20 showMsg = 1 showRow = 1 self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) - time.sleep(5) + time.sleep(3) tdLog.info("pkill consume processor") if (platform.system().lower() == 'windows'): os.system("TASKKILL /F /IM tmq_sim.exe") @@ -465,7 +465,7 @@ class TDTestCase: totalConsumeRows += resultList[i] if totalConsumeRows >= expectrowcnt or totalConsumeRows <= 0: - tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) + tdLog.info("act consume rows: %d, expect consume rows between %d and 0"%(totalConsumeRows, expectrowcnt)) tdLog.exit("tmq consume rows error!") time.sleep(15) diff --git a/tests/system-test/7-tmq/tmqError.py b/tests/system-test/7-tmq/tmqError.py new file mode 100644 index 0000000000..907d69bb7b --- /dev/null +++ b/tests/system-test/7-tmq/tmqError.py @@ -0,0 +1,315 @@ + +import taos +import sys +import time +import socket +import os +import threading +from enum import Enum + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * + +class actionType(Enum): + CREATE_DATABASE = 0 + CREATE_STABLE = 1 + CREATE_CTABLE = 2 + INSERT_DATA = 3 + +class TDTestCase: + hostname = socket.gethostname() + #rpcDebugFlagVal = '143' + #clientCfgDict = {'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''} + #clientCfgDict["rpcDebugFlag"] = rpcDebugFlagVal + #updatecfgDict = {'clientCfg': {}, 'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''} + #updatecfgDict["rpcDebugFlag"] = rpcDebugFlagVal + #print ("===================: ", updatecfgDict) + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + #tdSql.init(conn.cursor(), logSql) # output sql.txt file + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files or "taosd.exe" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def newcur(self,cfg,host,port): + user = "root" + password = "taosdata" + con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port) + cur=con.cursor() + print(cur) + return cur + + def initConsumerTable(self,cdbName='cdb'): + tdLog.info("create consume database, and consume info table, and consume result table") + tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) + # tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) + # tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) + + tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) + tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName) + + def initConsumerInfoTable(self,cdbName='cdb'): + tdLog.info("drop consumeinfo table") + tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) + tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) + + def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): + sql = "insert into %s.consumeinfo values "%cdbName + sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) + tdLog.info("consume info sql: %s"%sql) + tdSql.query(sql) + + def selectConsumeResult(self,expectRows,cdbName='cdb'): + resultList=[] + while 1: + tdSql.query("select * from %s.consumeresult"%cdbName) + #tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3)) + if tdSql.getRows() == expectRows: + break + else: + time.sleep(5) + + for i in range(expectRows): + tdLog.info ("consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3))) + resultList.append(tdSql.getData(i , 3)) + + return resultList + + def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): + if valgrind == 1: + logFile = cfgPath + '/../log/valgrind-tmq.log' + shellCmd = 'nohup valgrind --log-file=' + logFile + shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' + + if (platform.system().lower() == 'windows'): + shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> nul 2>&1 &" + else: + shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath + shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) + shellCmd += "> /dev/null 2>&1 &" + tdLog.info(shellCmd) + os.system(shellCmd) + + def create_database(self,tsql, dbName,dropFlag=1,vgroups=4,replica=1): + if dropFlag == 1: + tsql.execute("drop database if exists %s"%(dbName)) + + tsql.execute("create database if not exists %s vgroups %d replica %d"%(dbName, vgroups, replica)) + tdLog.debug("complete to create database %s"%(dbName)) + return + + def create_stable(self,tsql, dbName,stbName): + tsql.execute("create table if not exists %s.%s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%(dbName, stbName)) + tdLog.debug("complete to create %s.%s" %(dbName, stbName)) + return + + def create_ctables(self,tsql, dbName,stbName,ctbNum): + tsql.execute("use %s" %dbName) + pre_create = "create table" + sql = pre_create + #tdLog.debug("doing create one stable %s and %d child table in %s ..." %(stbname, count ,dbname)) + for i in range(ctbNum): + sql += " %s_%d using %s tags(%d)"%(stbName,i,stbName,i+1) + if (i > 0) and (i%100 == 0): + tsql.execute(sql) + sql = pre_create + if sql != pre_create: + tsql.execute(sql) + + tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName)) + return + + def insert_data(self,tsql,dbName,stbName,ctbNum,rowsPerTbl,batchNum,startTs=0): + tdLog.debug("start to insert data ............") + tsql.execute("use %s" %dbName) + pre_insert = "insert into " + sql = pre_insert + + if startTs == 0: + t = time.time() + startTs = int(round(t * 1000)) + + #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) + rowsOfSql = 0 + for i in range(ctbNum): + sql += " %s_%d values "%(stbName,i) + for j in range(rowsPerTbl): + sql += "(%d, %d, 'tmqrow_%d') "%(startTs + j, j, j) + rowsOfSql += 1 + if (j > 0) and ((rowsOfSql == batchNum) or (j == rowsPerTbl - 1)): + tsql.execute(sql) + rowsOfSql = 0 + if j < rowsPerTbl - 1: + sql = "insert into %s_%d values " %(stbName,i) + else: + sql = "insert into " + #end sql + if sql != pre_insert: + #print("insert sql:%s"%sql) + tsql.execute(sql) + tdLog.debug("insert data ............ [OK]") + return + + def prepareEnv(self, **parameterDict): + # create new connector for my thread + tsql=self.newcur(parameterDict['cfg'], 'localhost', 6030) + + if parameterDict["actionType"] == actionType.CREATE_DATABASE: + self.create_database(tsql, parameterDict["dbName"]) + elif parameterDict["actionType"] == actionType.CREATE_STABLE: + self.create_stable(tsql, parameterDict["dbName"], parameterDict["stbName"]) + elif parameterDict["actionType"] == actionType.CREATE_CTABLE: + self.create_ctables(tsql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) + elif parameterDict["actionType"] == actionType.INSERT_DATA: + self.insert_data(tsql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"],\ + parameterDict["rowsPerTbl"],parameterDict["batchNum"]) + else: + tdLog.exit("not support's action: ", parameterDict["actionType"]) + + return + + def tmqCase1(self, cfgPath, buildPath): + ''' + Leave a TMQ process. Stop taosd, delete the data directory, restart taosd, + and restart a consumption process to complete a consumption + ''' + tdLog.printNoPrefix("======== test case 1: ") + + self.initConsumerTable() + + # create and start thread + parameterDict = {'cfg': '', \ + 'actionType': 0, \ + 'dbName': 'db3', \ + 'dropFlag': 1, \ + 'vgroups': 4, \ + 'replica': 1, \ + 'stbName': 'stb1', \ + 'ctbNum': 10, \ + 'rowsPerTbl': 20000, \ + 'batchNum': 100, \ + 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 + parameterDict['cfg'] = cfgPath + + self.create_database(tdSql, parameterDict["dbName"]) + self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) + self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) + self.insert_data(tdSql,parameterDict["dbName"],parameterDict["stbName"],parameterDict["ctbNum"],parameterDict["rowsPerTbl"],parameterDict["batchNum"]) + + tdLog.info("create topics from stb1") + topicFromStb1 = 'topic_stb1' + + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) + consumerId = 0 + # expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + expectrowcnt = 90000000000 + topicList = topicFromStb1 + ifcheckdata = 0 + ifManualCommit = 0 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:false,\ + auto.commit.interval.ms:6000,\ + auto.offset.reset:earliest' + self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + pollDelay = 9000000 # Forever loop + showMsg = 1 + showRow = 1 + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + time.sleep(3) + tdLog.info("================= stop dnode, and remove data file, then start dnode ===========================") + tdDnodes.stop(1) + # time.sleep(5) + dataPath = buildPath + "/../sim/dnode1/data/*" + shellCmd = 'rm -rf ' + dataPath + tdLog.info(shellCmd) + os.system(shellCmd) + tdDnodes.start(1) + time.sleep(2) + + ######### redo to consume + self.initConsumerTable() + + self.create_database(tdSql, parameterDict["dbName"]) + self.create_stable(tdSql, parameterDict["dbName"], parameterDict["stbName"]) + self.create_ctables(tdSql, parameterDict["dbName"], parameterDict["stbName"], parameterDict["ctbNum"]) + self.insert_data(tdSql,parameterDict["dbName"],parameterDict["stbName"],parameterDict["ctbNum"],parameterDict["rowsPerTbl"],parameterDict["batchNum"]) + + tdLog.info("create topics from stb1") + topicFromStb1 = 'topic_stb1' + + tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb1, parameterDict['dbName'], parameterDict['stbName'])) + consumerId = 0 + expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + topicList = topicFromStb1 + ifcheckdata = 0 + ifManualCommit = 0 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:false,\ + auto.commit.interval.ms:6000,\ + auto.offset.reset:earliest' + self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + pollDelay = 20 + showMsg = 1 + showRow = 1 + self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow) + + expectRows = 1 + resultList = self.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) + if not (totalConsumeRows == expectrowcnt): + tdLog.exit("tmq consume rows error!") + + tdSql.query("drop topic %s"%topicFromStb1) + os.system('pkill tmq_sim') + + tdLog.printNoPrefix("======== test case 1 end ...... ") + + def run(self): + tdSql.prepare() + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + cfgPath = buildPath + "/../sim/psim/cfg" + tdLog.info("cfgPath: %s" % cfgPath) + + self.tmqCase1(cfgPath, buildPath) + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +event = threading.Event() + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/fulltest.bat b/tests/system-test/fulltest.bat index db8c8299eb..59ddd3fb7d 100644 --- a/tests/system-test/fulltest.bat +++ b/tests/system-test/fulltest.bat @@ -6,7 +6,7 @@ python3 .\test.py -f 0-others\telemetry.py python3 .\test.py -f 0-others\taosdMonitor.py python3 .\test.py -f 0-others\udfTest.py python3 .\test.py -f 0-others\udf_create.py -@REM python3 .\test.py -f 0-others\udf_restart_taosd.py +python3 .\test.py -f 0-others\udf_restart_taosd.py python3 .\test.py -f 0-others\cachelast.py python3 .\test.py -f 0-others\user_control.py @@ -38,7 +38,7 @@ python3 .\test.py -f 2-query\concat_ws.py python3 .\test.py -f 2-query\concat_ws2.py python3 .\test.py -f 2-query\check_tsdb.py python3 .\test.py -f 2-query\spread.py -@REM python3 .\test.py -f 2-query\hyperloglog.py +python3 .\test.py -f 2-query\hyperloglog.py python3 .\test.py -f 2-query\timezone.py python3 .\test.py -f 2-query\Now.py @@ -82,7 +82,7 @@ python3 .\test.py -f 2-query\elapsed.py python3 .\test.py -f 2-query\csum.py python3 .\test.py -f 2-query\mavg.py python3 .\test.py -f 2-query\diff.py -@REM python3 .\test.py -f 2-query\sample.py +python3 .\test.py -f 2-query\sample.py python3 .\test.py -f 2-query\function_diff.py python3 .\test.py -f 2-query\unique.py python3 .\test.py -f 2-query\stateduration.py @@ -91,7 +91,7 @@ python3 .\test.py -f 2-query\statecount.py python3 .\test.py -f 7-tmq\basic5.py python3 .\test.py -f 7-tmq\subscribeDb.py -@REM python3 .\test.py -f 7-tmq\subscribeDb0.py +python3 .\test.py -f 7-tmq\subscribeDb0.py python3 .\test.py -f 7-tmq\subscribeDb1.py python3 .\test.py -f 7-tmq\subscribeStb.py python3 .\test.py -f 7-tmq\subscribeStb0.py diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index 5149994228..676f2da788 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -18,7 +18,7 @@ python3 ./test.py -f 0-others/fsync.py python3 ./test.py -f 1-insert/influxdb_line_taosc_insert.py python3 ./test.py -f 1-insert/opentsdb_telnet_line_taosc_insert.py python3 ./test.py -f 1-insert/opentsdb_json_taosc_insert.py -# python3 ./test.py -f 1-insert/test_stmt_muti_insert_query.py +# BUG python3 ./test.py -f 1-insert/test_stmt_muti_insert_query.py python3 ./test.py -f 1-insert/alter_stable.py python3 ./test.py -f 1-insert/alter_table.py python3 ./test.py -f 1-insert/insertWithMoreVgroup.py @@ -44,6 +44,8 @@ python3 ./test.py -f 2-query/concat_ws2.py python3 ./test.py -f 2-query/check_tsdb.py python3 ./test.py -f 2-query/spread.py python3 ./test.py -f 2-query/hyperloglog.py +python3 ./test.py -f 2-query/explain.py +python3 ./test.py -f 2-query/leastsquares.py python3 ./test.py -f 2-query/timezone.py @@ -80,7 +82,7 @@ python3 ./test.py -f 2-query/arccos.py python3 ./test.py -f 2-query/arctan.py python3 ./test.py -f 2-query/query_cols_tags_and_or.py # python3 ./test.py -f 2-query/nestedQuery.py -# TD-15983 subquery output duplicate name column. +# TD-15983 subquery output duplicate name column. # Please Xiangyang Guo modify the following script # python3 ./test.py -f 2-query/nestedQuery_str.py @@ -95,15 +97,18 @@ python3 ./test.py -f 2-query/unique.py python3 ./test.py -f 2-query/stateduration.py python3 ./test.py -f 2-query/function_stateduration.py python3 ./test.py -f 2-query/statecount.py +python3 ./test.py -f 2-query/tail.py python3 ./test.py -f 6-cluster/5dnode1mnode.py python3 ./test.py -f 6-cluster/5dnode2mnode.py -python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py +# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py +python3 ./test.py -f 6-cluster/5dnode3mnodeDrop.py +# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeStopInsert.py python3 ./test.py -f 7-tmq/basic5.py python3 ./test.py -f 7-tmq/subscribeDb.py python3 ./test.py -f 7-tmq/subscribeDb0.py -# python3 ./test.py -f 7-tmq/subscribeDb1.py +python3 ./test.py -f 7-tmq/subscribeDb1.py python3 ./test.py -f 7-tmq/subscribeStb.py python3 ./test.py -f 7-tmq/subscribeStb0.py python3 ./test.py -f 7-tmq/subscribeStb1.py @@ -111,3 +116,4 @@ python3 ./test.py -f 7-tmq/subscribeStb2.py python3 ./test.py -f 7-tmq/subscribeStb3.py python3 ./test.py -f 7-tmq/subscribeStb4.py python3 ./test.py -f 7-tmq/db.py +python3 ./test.py -f 7-tmq/tmqError.py