Merge remote-tracking branch 'origin/3.0' into fix/mnode
This commit is contained in:
commit
40a84f9f0a
|
@ -70,5 +70,46 @@ ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||||
|
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
IF ("${CPUTYPE}" STREQUAL "")
|
||||||
|
MESSAGE(STATUS "The current platform " ${CMAKE_SYSTEM_PROCESSOR} " is detected")
|
||||||
|
|
||||||
|
IF (CMAKE_SYSTEM_PROCESSOR MATCHES "(amd64)|(AMD64)")
|
||||||
|
MESSAGE(STATUS "The current platform is amd64")
|
||||||
|
SET(PLATFORM_ARCH_STR "amd64")
|
||||||
|
ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)")
|
||||||
|
MESSAGE(STATUS "The current platform is x86")
|
||||||
|
SET(PLATFORM_ARCH_STR "i386")
|
||||||
|
ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "armv7l")
|
||||||
|
MESSAGE(STATUS "The current platform is aarch32")
|
||||||
|
SET(PLATFORM_ARCH_STR "arm")
|
||||||
|
ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
|
||||||
|
MESSAGE(STATUS "The current platform is aarch64")
|
||||||
|
SET(PLATFORM_ARCH_STR "arm64")
|
||||||
|
ENDIF ()
|
||||||
|
ELSE ()
|
||||||
|
# if generate ARM version:
|
||||||
|
# cmake -DCPUTYPE=aarch32 .. or cmake -DCPUTYPE=aarch64
|
||||||
|
IF (${CPUTYPE} MATCHES "aarch32")
|
||||||
|
SET(PLATFORM_ARCH_STR "arm")
|
||||||
|
MESSAGE(STATUS "input cpuType: aarch32")
|
||||||
|
ELSEIF (${CPUTYPE} MATCHES "aarch64")
|
||||||
|
SET(PLATFORM_ARCH_STR "arm64")
|
||||||
|
MESSAGE(STATUS "input cpuType: aarch64")
|
||||||
|
ELSEIF (${CPUTYPE} MATCHES "mips64")
|
||||||
|
SET(PLATFORM_ARCH_STR "mips")
|
||||||
|
MESSAGE(STATUS "input cpuType: mips64")
|
||||||
|
ELSEIF (${CPUTYPE} MATCHES "x64")
|
||||||
|
SET(PLATFORM_ARCH_STR "amd64")
|
||||||
|
MESSAGE(STATUS "input cpuType: x64")
|
||||||
|
ELSEIF (${CPUTYPE} MATCHES "x86")
|
||||||
|
SET(PLATFORM_ARCH_STR "i386")
|
||||||
|
MESSAGE(STATUS "input cpuType: x86")
|
||||||
|
ELSE ()
|
||||||
|
MESSAGE(STATUS "input cpuType unknown " ${CPUTYPE})
|
||||||
|
ENDIF ()
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
|
MESSAGE(STATUS "platform arch:" ${PLATFORM_ARCH_STR})
|
||||||
|
|
||||||
MESSAGE("C Compiler ID: ${CMAKE_C_COMPILER_ID}")
|
MESSAGE("C Compiler ID: ${CMAKE_C_COMPILER_ID}")
|
||||||
MESSAGE("CXX Compiler ID: ${CMAKE_CXX_COMPILER_ID}")
|
MESSAGE("CXX Compiler ID: ${CMAKE_CXX_COMPILER_ID}")
|
||||||
|
|
|
@ -21,7 +21,7 @@ The following example is in an Ubuntu environment and uses the `curl` tool to ve
|
||||||
The following example lists all databases on the host h1.taosdata.com. To use it in your environment, replace `h1.taosdata.com` and `6041` (the default port) with the actual running TDengine service FQDN and port number.
|
The following example lists all databases on the host h1.taosdata.com. To use it in your environment, replace `h1.taosdata.com` and `6041` (the default port) with the actual running TDengine service FQDN and port number.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' h1.taosdata.com:6041/rest/sql
|
curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "show databases;" h1.taosdata.com:6041/rest/sql
|
||||||
```
|
```
|
||||||
|
|
||||||
The following return value results indicate that the verification passed.
|
The following return value results indicate that the verification passed.
|
||||||
|
@ -106,13 +106,13 @@ The HTTP request's BODY is a complete SQL command, and the data table in the SQL
|
||||||
Use `curl` to initiate an HTTP request with a custom authentication method, with the following syntax.
|
Use `curl` to initiate an HTTP request with a custom authentication method, with the following syntax.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -H 'Authorization: Basic <TOKEN>' -d '<SQL>' <ip>:<PORT>/rest/sql/[db_name]
|
curl -L -H "Authorization: Basic <TOKEN>" -d "<SQL>" <ip>:<PORT>/rest/sql/[db_name]
|
||||||
```
|
```
|
||||||
|
|
||||||
Or
|
Or
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -u username:password -d '<SQL>' <ip>:<PORT>/rest/sql/[db_name]
|
curl -L -u username:password -d "<SQL>" <ip>:<PORT>/rest/sql/[db_name]
|
||||||
```
|
```
|
||||||
|
|
||||||
where `TOKEN` is the string after Base64 encoding of `{username}:{password}`, e.g. `root:taosdata` is encoded as `cm9vdDp0YW9zZGF0YQ==`.
|
where `TOKEN` is the string after Base64 encoding of `{username}:{password}`, e.g. `root:taosdata` is encoded as `cm9vdDp0YW9zZGF0YQ==`.
|
||||||
|
@ -192,7 +192,7 @@ Response body:
|
||||||
- query all records from table d1001 of database demo
|
- query all records from table d1001 of database demo
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001' 192.168.0.1:6041/rest/sql
|
curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "select * from demo.d1001" 192.168.0.1:6041/rest/sql
|
||||||
```
|
```
|
||||||
|
|
||||||
Response body:
|
Response body:
|
||||||
|
@ -218,7 +218,7 @@ Response body:
|
||||||
- Create database demo:
|
- Create database demo:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'create database demo' 192.168.0.1:6041/rest/sql
|
curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "create database demo" 192.168.0.1:6041/rest/sql
|
||||||
```
|
```
|
||||||
|
|
||||||
Response body:
|
Response body:
|
||||||
|
@ -240,7 +240,7 @@ Response body:
|
||||||
When the HTTP request URL uses `/rest/sqlt`, the returned result set's timestamp value will be in Unix timestamp format, for example:
|
When the HTTP request URL uses `/rest/sqlt`, the returned result set's timestamp value will be in Unix timestamp format, for example:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001' 192.168.0.1:6041/rest/sqlt
|
curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "select * from demo.d1001" 192.168.0.1:6041/rest/sqlt
|
||||||
```
|
```
|
||||||
|
|
||||||
Response body:
|
Response body:
|
||||||
|
@ -268,7 +268,7 @@ Response body:
|
||||||
When the HTTP request URL uses `/rest/sqlutc`, the timestamp of the returned result set will be expressed as a UTC format, for example:
|
When the HTTP request URL uses `/rest/sqlutc`, the timestamp of the returned result set will be expressed as a UTC format, for example:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.t1' 192.168.0.1:6041/rest/sqlutc
|
curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "select * from demo.t1" 192.168.0.1:6041/rest/sqlutc
|
||||||
```
|
```
|
||||||
|
|
||||||
Response body:
|
Response body:
|
||||||
|
|
|
@ -26,7 +26,6 @@ All executable files of TDengine are in the _/usr/local/taos/bin_ directory by d
|
||||||
- _remove.sh_: script to uninstall TDengine, please execute it carefully, link to the **rmtaos** command in the /usr/bin directory. Will remove the TDengine installation directory `/usr/local/taos`, but will keep `/etc/taos`, `/var/lib/taos`, `/var/log/taos`
|
- _remove.sh_: script to uninstall TDengine, please execute it carefully, link to the **rmtaos** command in the /usr/bin directory. Will remove the TDengine installation directory `/usr/local/taos`, but will keep `/etc/taos`, `/var/lib/taos`, `/var/log/taos`
|
||||||
- _taosadapter_: server-side executable that provides RESTful services and accepts writing requests from a variety of other softwares
|
- _taosadapter_: server-side executable that provides RESTful services and accepts writing requests from a variety of other softwares
|
||||||
- _tarbitrator_: provides arbitration for two-node cluster deployments
|
- _tarbitrator_: provides arbitration for two-node cluster deployments
|
||||||
- _run_taosd_and_taosadapter.sh_: script to start both taosd and taosAdapter
|
|
||||||
- _TDinsight.sh_: script to download TDinsight and install it
|
- _TDinsight.sh_: script to download TDinsight and install it
|
||||||
- _set_core.sh_: script for setting up the system to generate core dump files for easy debugging
|
- _set_core.sh_: script for setting up the system to generate core dump files for easy debugging
|
||||||
- _taosd-dump-cfg.gdb_: script to facilitate debugging of taosd's gdb execution.
|
- _taosd-dump-cfg.gdb_: script to facilitate debugging of taosd's gdb execution.
|
||||||
|
|
|
@ -109,7 +109,7 @@ taos>
|
||||||
It's also able to access the REST interface provided by TDengine in container from the host.
|
It's also able to access the REST interface provided by TDengine in container from the host.
|
||||||
|
|
||||||
```
|
```
|
||||||
curl -u root:taosdata -d 'show databases' 127.0.0.1:6041/rest/sql
|
curl -L -u root:taosdata -d "show databases" 127.0.0.1:6041/rest/sql
|
||||||
```
|
```
|
||||||
|
|
||||||
Output is like below:
|
Output is like below:
|
||||||
|
@ -147,7 +147,7 @@ docker run -d --name tdengine-taosd -p 6030-6042:6030-6042 -p 6030-6042:6030-604
|
||||||
- Verify the REST interface:
|
- Verify the REST interface:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' 127.0.0.1:6041/rest/sql
|
curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "show databases;" 127.0.0.1:6041/rest/sql
|
||||||
```
|
```
|
||||||
|
|
||||||
Below is an example output:
|
Below is an example output:
|
||||||
|
|
|
@ -21,7 +21,7 @@ RESTful 接口不依赖于任何 TDengine 的库,因此客户端不需要安
|
||||||
下面示例是列出所有的数据库,请把 h1.taosdata.com 和 6041(缺省值)替换为实际运行的 TDengine 服务 FQDN 和端口号:
|
下面示例是列出所有的数据库,请把 h1.taosdata.com 和 6041(缺省值)替换为实际运行的 TDengine 服务 FQDN 和端口号:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' h1.taosdata.com:6041/rest/sql
|
curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "show databases;" h1.taosdata.com:6041/rest/sql
|
||||||
```
|
```
|
||||||
|
|
||||||
返回值结果如下表示验证通过:
|
返回值结果如下表示验证通过:
|
||||||
|
@ -106,13 +106,13 @@ HTTP 请求的 BODY 里就是一个完整的 SQL 语句,SQL 语句中的数据
|
||||||
使用 `curl` 通过自定义身份认证方式来发起一个 HTTP Request,语法如下:
|
使用 `curl` 通过自定义身份认证方式来发起一个 HTTP Request,语法如下:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -H 'Authorization: Basic <TOKEN>' -d '<SQL>' <ip>:<PORT>/rest/sql/[db_name]
|
curl -L -H "Authorization: Basic <TOKEN>" -d "<SQL>" <ip>:<PORT>/rest/sql/[db_name]
|
||||||
```
|
```
|
||||||
|
|
||||||
或者
|
或者
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -u username:password -d '<SQL>' <ip>:<PORT>/rest/sql/[db_name]
|
curl -L -u username:password -d "<SQL>" <ip>:<PORT>/rest/sql/[db_name]
|
||||||
```
|
```
|
||||||
|
|
||||||
其中,`TOKEN` 为 `{username}:{password}` 经过 Base64 编码之后的字符串,例如 `root:taosdata` 编码后为 `cm9vdDp0YW9zZGF0YQ==`
|
其中,`TOKEN` 为 `{username}:{password}` 经过 Base64 编码之后的字符串,例如 `root:taosdata` 编码后为 `cm9vdDp0YW9zZGF0YQ==`
|
||||||
|
@ -192,7 +192,7 @@ curl http://192.168.0.1:6041/rest/login/root/taosdata
|
||||||
- 在 demo 库里查询表 d1001 的所有记录:
|
- 在 demo 库里查询表 d1001 的所有记录:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001' 192.168.0.1:6041/rest/sql
|
curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "select * from demo.d1001" 192.168.0.1:6041/rest/sql
|
||||||
```
|
```
|
||||||
|
|
||||||
返回值:
|
返回值:
|
||||||
|
@ -218,7 +218,7 @@ curl http://192.168.0.1:6041/rest/login/root/taosdata
|
||||||
- 创建库 demo:
|
- 创建库 demo:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'create database demo' 192.168.0.1:6041/rest/sql
|
curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "create database demo" 192.168.0.1:6041/rest/sql
|
||||||
```
|
```
|
||||||
|
|
||||||
返回值:
|
返回值:
|
||||||
|
@ -240,7 +240,7 @@ curl http://192.168.0.1:6041/rest/login/root/taosdata
|
||||||
HTTP 请求 URL 采用 `/rest/sqlt` 时,返回结果集的时间戳将采用 Unix 时间戳格式表示,例如
|
HTTP 请求 URL 采用 `/rest/sqlt` 时,返回结果集的时间戳将采用 Unix 时间戳格式表示,例如
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001' 192.168.0.1:6041/rest/sqlt
|
curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "select * from demo.d1001" 192.168.0.1:6041/rest/sqlt
|
||||||
```
|
```
|
||||||
|
|
||||||
返回结果:
|
返回结果:
|
||||||
|
@ -268,7 +268,7 @@ curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001
|
||||||
HTTP 请求 URL 采用 `/rest/sqlutc` 时,返回结果集的时间戳将采用 UTC 时间字符串表示,例如
|
HTTP 请求 URL 采用 `/rest/sqlutc` 时,返回结果集的时间戳将采用 UTC 时间字符串表示,例如
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.t1' 192.168.0.1:6041/rest/sqlutc
|
curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "select * from demo.t1" 192.168.0.1:6041/rest/sqlutc
|
||||||
```
|
```
|
||||||
|
|
||||||
返回值:
|
返回值:
|
||||||
|
|
|
@ -26,7 +26,6 @@ TDengine 的所有可执行文件默认存放在 _/usr/local/taos/bin_ 目录下
|
||||||
- _remove.sh_:卸载 TDengine 的脚本,请谨慎执行,链接到/usr/bin 目录下的**rmtaos**命令。会删除 TDengine 的安装目录/usr/local/taos,但会保留/etc/taos、/var/lib/taos、/var/log/taos
|
- _remove.sh_:卸载 TDengine 的脚本,请谨慎执行,链接到/usr/bin 目录下的**rmtaos**命令。会删除 TDengine 的安装目录/usr/local/taos,但会保留/etc/taos、/var/lib/taos、/var/log/taos
|
||||||
- _taosadapter_: 提供 RESTful 服务和接受其他多种软件写入请求的服务端可执行文件
|
- _taosadapter_: 提供 RESTful 服务和接受其他多种软件写入请求的服务端可执行文件
|
||||||
- _tarbitrator_: 提供双节点集群部署的仲裁功能
|
- _tarbitrator_: 提供双节点集群部署的仲裁功能
|
||||||
- _run_taosd_and_taosadapter.sh_:同时启动 taosd 和 taosAdapter 的脚本
|
|
||||||
- _TDinsight.sh_:用于下载 TDinsight 并安装的脚本
|
- _TDinsight.sh_:用于下载 TDinsight 并安装的脚本
|
||||||
- _set_core.sh_:用于方便调试设置系统生成 core dump 文件的脚本
|
- _set_core.sh_:用于方便调试设置系统生成 core dump 文件的脚本
|
||||||
- _taosd-dump-cfg.gdb_:用于方便调试 taosd 的 gdb 执行脚本。
|
- _taosd-dump-cfg.gdb_:用于方便调试 taosd 的 gdb 执行脚本。
|
||||||
|
|
|
@ -108,7 +108,7 @@ taos>
|
||||||
也可以在宿主机使用 curl 通过 RESTful 端口访问 Docker 容器内的 TDengine server。
|
也可以在宿主机使用 curl 通过 RESTful 端口访问 Docker 容器内的 TDengine server。
|
||||||
|
|
||||||
```
|
```
|
||||||
curl -u root:taosdata -d 'show databases' 127.0.0.1:6041/rest/sql
|
curl -L -u root:taosdata -d "show databases" 127.0.0.1:6041/rest/sql
|
||||||
```
|
```
|
||||||
|
|
||||||
输出示例如下:
|
输出示例如下:
|
||||||
|
@ -148,7 +148,7 @@ docker run -d --name tdengine-taosd -p 6030-6042:6030-6042 -p 6030-6042:6030-604
|
||||||
使用 curl 命令验证 RESTful 接口可以正常工作:
|
使用 curl 命令验证 RESTful 接口可以正常工作:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' 127.0.0.1:6041/rest/sql
|
curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "show databases;" 127.0.0.1:6041/rest/sql
|
||||||
```
|
```
|
||||||
|
|
||||||
输出示例如下:
|
输出示例如下:
|
||||||
|
|
|
@ -252,6 +252,16 @@ DLL_EXPORT void tmq_conf_set_auto_commit_cb(tmq_conf_t *conf, tmq_comm
|
||||||
|
|
||||||
/* -------------------------TMQ MSG HANDLE INTERFACE---------------------- */
|
/* -------------------------TMQ MSG HANDLE INTERFACE---------------------- */
|
||||||
|
|
||||||
|
enum tmq_res_t {
|
||||||
|
TMQ_RES_INVALID = -1,
|
||||||
|
TMQ_RES_DATA = 1,
|
||||||
|
TMQ_RES_TABLE_META = 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef enum tmq_res_t tmq_res_t;
|
||||||
|
|
||||||
|
DLL_EXPORT tmq_res_t tmq_get_res_type(TAOS_RES *res);
|
||||||
|
DLL_EXPORT int32_t tmq_get_raw_meta(TAOS_RES *res, const void **raw_meta, int32_t *raw_meta_len);
|
||||||
DLL_EXPORT const char *tmq_get_topic_name(TAOS_RES *res);
|
DLL_EXPORT const char *tmq_get_topic_name(TAOS_RES *res);
|
||||||
DLL_EXPORT const char *tmq_get_db_name(TAOS_RES *res);
|
DLL_EXPORT const char *tmq_get_db_name(TAOS_RES *res);
|
||||||
DLL_EXPORT int32_t tmq_get_vgroup_id(TAOS_RES *res);
|
DLL_EXPORT int32_t tmq_get_vgroup_id(TAOS_RES *res);
|
||||||
|
|
|
@ -34,6 +34,7 @@ enum {
|
||||||
enum {
|
enum {
|
||||||
TMQ_MSG_TYPE__DUMMY = 0,
|
TMQ_MSG_TYPE__DUMMY = 0,
|
||||||
TMQ_MSG_TYPE__POLL_RSP,
|
TMQ_MSG_TYPE__POLL_RSP,
|
||||||
|
TMQ_MSG_TYPE__POLL_META_RSP,
|
||||||
TMQ_MSG_TYPE__EP_RSP,
|
TMQ_MSG_TYPE__EP_RSP,
|
||||||
TMQ_MSG_TYPE__END_RSP,
|
TMQ_MSG_TYPE__END_RSP,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1560,6 +1560,7 @@ typedef struct {
|
||||||
char name[TSDB_TOPIC_FNAME_LEN]; // accout.topic
|
char name[TSDB_TOPIC_FNAME_LEN]; // accout.topic
|
||||||
int8_t igExists;
|
int8_t igExists;
|
||||||
int8_t subType;
|
int8_t subType;
|
||||||
|
int8_t withMeta;
|
||||||
char* sql;
|
char* sql;
|
||||||
char subDbName[TSDB_DB_FNAME_LEN];
|
char subDbName[TSDB_DB_FNAME_LEN];
|
||||||
union {
|
union {
|
||||||
|
@ -2306,6 +2307,7 @@ typedef struct {
|
||||||
int64_t newConsumerId;
|
int64_t newConsumerId;
|
||||||
char subKey[TSDB_SUBSCRIBE_KEY_LEN];
|
char subKey[TSDB_SUBSCRIBE_KEY_LEN];
|
||||||
int8_t subType;
|
int8_t subType;
|
||||||
|
int8_t withMeta;
|
||||||
char* qmsg;
|
char* qmsg;
|
||||||
int64_t suid;
|
int64_t suid;
|
||||||
} SMqRebVgReq;
|
} SMqRebVgReq;
|
||||||
|
@ -2318,6 +2320,7 @@ static FORCE_INLINE int32_t tEncodeSMqRebVgReq(void** buf, const SMqRebVgReq* pR
|
||||||
tlen += taosEncodeFixedI64(buf, pReq->newConsumerId);
|
tlen += taosEncodeFixedI64(buf, pReq->newConsumerId);
|
||||||
tlen += taosEncodeString(buf, pReq->subKey);
|
tlen += taosEncodeString(buf, pReq->subKey);
|
||||||
tlen += taosEncodeFixedI8(buf, pReq->subType);
|
tlen += taosEncodeFixedI8(buf, pReq->subType);
|
||||||
|
tlen += taosEncodeFixedI8(buf, pReq->withMeta);
|
||||||
if (pReq->subType == TOPIC_SUB_TYPE__COLUMN) {
|
if (pReq->subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||||
tlen += taosEncodeString(buf, pReq->qmsg);
|
tlen += taosEncodeString(buf, pReq->qmsg);
|
||||||
} else if (pReq->subType == TOPIC_SUB_TYPE__TABLE) {
|
} else if (pReq->subType == TOPIC_SUB_TYPE__TABLE) {
|
||||||
|
@ -2333,6 +2336,7 @@ static FORCE_INLINE void* tDecodeSMqRebVgReq(const void* buf, SMqRebVgReq* pReq)
|
||||||
buf = taosDecodeFixedI64(buf, &pReq->newConsumerId);
|
buf = taosDecodeFixedI64(buf, &pReq->newConsumerId);
|
||||||
buf = taosDecodeStringTo(buf, pReq->subKey);
|
buf = taosDecodeStringTo(buf, pReq->subKey);
|
||||||
buf = taosDecodeFixedI8(buf, &pReq->subType);
|
buf = taosDecodeFixedI8(buf, &pReq->subType);
|
||||||
|
buf = taosDecodeFixedI8(buf, &pReq->withMeta);
|
||||||
if (pReq->subType == TOPIC_SUB_TYPE__COLUMN) {
|
if (pReq->subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||||
buf = taosDecodeString(buf, &pReq->qmsg);
|
buf = taosDecodeString(buf, &pReq->qmsg);
|
||||||
} else if (pReq->subType == TOPIC_SUB_TYPE__TABLE) {
|
} else if (pReq->subType == TOPIC_SUB_TYPE__TABLE) {
|
||||||
|
@ -2677,6 +2681,34 @@ static FORCE_INLINE void tDeleteSMqSubTopicEp(SMqSubTopicEp* pSubTopicEp) {
|
||||||
taosArrayDestroy(pSubTopicEp->vgs);
|
taosArrayDestroy(pSubTopicEp->vgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
SMqRspHead head;
|
||||||
|
int64_t reqOffset;
|
||||||
|
int64_t rspOffset;
|
||||||
|
int16_t resMsgType;
|
||||||
|
int32_t metaRspLen;
|
||||||
|
void* metaRsp;
|
||||||
|
} SMqMetaRsp;
|
||||||
|
|
||||||
|
static FORCE_INLINE int32_t tEncodeSMqMetaRsp(void** buf, const SMqMetaRsp* pRsp) {
|
||||||
|
int32_t tlen = 0;
|
||||||
|
tlen += taosEncodeFixedI64(buf, pRsp->reqOffset);
|
||||||
|
tlen += taosEncodeFixedI64(buf, pRsp->rspOffset);
|
||||||
|
tlen += taosEncodeFixedI16(buf, pRsp->resMsgType);
|
||||||
|
tlen += taosEncodeFixedI32(buf, pRsp->metaRspLen);
|
||||||
|
tlen += taosEncodeBinary(buf, pRsp->metaRsp, pRsp->metaRspLen);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE void* tDecodeSMqMetaRsp(const void* buf, SMqMetaRsp* pRsp) {
|
||||||
|
buf = taosDecodeFixedI64(buf, &pRsp->reqOffset);
|
||||||
|
buf = taosDecodeFixedI64(buf, &pRsp->rspOffset);
|
||||||
|
buf = taosDecodeFixedI16(buf, &pRsp->resMsgType);
|
||||||
|
buf = taosDecodeFixedI32(buf, &pRsp->metaRspLen);
|
||||||
|
buf = taosDecodeBinary(buf, &pRsp->metaRsp, pRsp->metaRspLen);
|
||||||
|
return (void*)buf;
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SMqRspHead head;
|
SMqRspHead head;
|
||||||
int64_t reqOffset;
|
int64_t reqOffset;
|
||||||
|
|
|
@ -187,7 +187,6 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_CONSUME, "vnode-consume", SMqPollReq, SMqDataBlkRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_CONSUME, "vnode-consume", SMqPollReq, SMqDataBlkRsp)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TRIGGER, "vnode-stream-trigger", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TRIGGER, "vnode-stream-trigger", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_DISPATCH_WRITE, "vnode-stream-task-dispatch-write", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_DISPATCH_WRITE, "vnode-stream-task-dispatch-write", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TASK_DROP, "vnode-stream-task-drop", NULL, NULL)
|
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_SMA, "vnode-create-sma", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_SMA, "vnode-create-sma", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_CANCEL_SMA, "vnode-cancel-sma", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_CANCEL_SMA, "vnode-cancel-sma", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_DROP_SMA, "vnode-drop-sma", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_DROP_SMA, "vnode-drop-sma", NULL, NULL)
|
||||||
|
@ -204,6 +203,7 @@ enum {
|
||||||
//shared by snode and vnode
|
//shared by snode and vnode
|
||||||
TD_NEW_MSG_SEG(TDMT_STREAM_MSG)
|
TD_NEW_MSG_SEG(TDMT_STREAM_MSG)
|
||||||
TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_DEPLOY, "stream-task-deploy", SStreamTaskDeployReq, SStreamTaskDeployRsp)
|
TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_DEPLOY, "stream-task-deploy", SStreamTaskDeployReq, SStreamTaskDeployRsp)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_DROP, "stream-task-drop", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_RUN, "stream-task-run", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_RUN, "stream-task-run", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_DISPATCH, "stream-task-dispatch", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_DISPATCH, "stream-task-dispatch", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_RECOVER, "stream-task-recover", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_RECOVER, "stream-task-recover", NULL, NULL)
|
||||||
|
|
|
@ -30,9 +30,14 @@ extern "C" {
|
||||||
typedef struct SStreamTask SStreamTask;
|
typedef struct SStreamTask SStreamTask;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
TASK_STATUS__IDLE = 1,
|
TASK_STATUS__NORMAL = 0,
|
||||||
TASK_STATUS__EXECUTING,
|
TASK_STATUS__DROPPING,
|
||||||
TASK_STATUS__CLOSING,
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
TASK_EXEC_STATUS__IDLE = 1,
|
||||||
|
TASK_EXEC_STATUS__EXECUTING,
|
||||||
|
TASK_EXEC_STATUS__CLOSING,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -50,16 +55,12 @@ enum {
|
||||||
TASK_OUTPUT_STATUS__BLOCKED,
|
TASK_OUTPUT_STATUS__BLOCKED,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
|
||||||
STREAM_CREATED_BY__USER = 1,
|
|
||||||
STREAM_CREATED_BY__SMA,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
STREAM_INPUT__DATA_SUBMIT = 1,
|
STREAM_INPUT__DATA_SUBMIT = 1,
|
||||||
STREAM_INPUT__DATA_BLOCK,
|
STREAM_INPUT__DATA_BLOCK,
|
||||||
STREAM_INPUT__TRIGGER,
|
STREAM_INPUT__TRIGGER,
|
||||||
STREAM_INPUT__CHECKPOINT,
|
STREAM_INPUT__CHECKPOINT,
|
||||||
|
STREAM_INPUT__DROP,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -237,7 +238,9 @@ struct SStreamTask {
|
||||||
int64_t streamId;
|
int64_t streamId;
|
||||||
int32_t taskId;
|
int32_t taskId;
|
||||||
int8_t inputType;
|
int8_t inputType;
|
||||||
int8_t status;
|
int8_t taskStatus;
|
||||||
|
|
||||||
|
int8_t execStatus;
|
||||||
|
|
||||||
int8_t execType;
|
int8_t execType;
|
||||||
int8_t sinkType;
|
int8_t sinkType;
|
||||||
|
|
|
@ -88,7 +88,6 @@ else
|
||||||
${build_dir}/bin/tarbitrator\
|
${build_dir}/bin/tarbitrator\
|
||||||
${script_dir}/remove.sh \
|
${script_dir}/remove.sh \
|
||||||
${script_dir}/set_core.sh \
|
${script_dir}/set_core.sh \
|
||||||
${script_dir}/run_taosd_and_taosadapter.sh \
|
|
||||||
${script_dir}/startPre.sh \
|
${script_dir}/startPre.sh \
|
||||||
${script_dir}/taosd-dump-cfg.gdb"
|
${script_dir}/taosd-dump-cfg.gdb"
|
||||||
fi
|
fi
|
||||||
|
@ -152,7 +151,6 @@ if [ $adapterName != "taosadapter" ]; then
|
||||||
sed -i "s/taosadapter/${adapterName}/g" ${install_dir}/cfg/$adapterName.service
|
sed -i "s/taosadapter/${adapterName}/g" ${install_dir}/cfg/$adapterName.service
|
||||||
|
|
||||||
mv ${install_dir}/bin/taosadapter ${install_dir}/bin/${adapterName}
|
mv ${install_dir}/bin/taosadapter ${install_dir}/bin/${adapterName}
|
||||||
mv ${install_dir}/bin/run_taosd_and_taosadapter.sh ${install_dir}/bin/run_${serverName}_and_${adapterName}.sh
|
|
||||||
mv ${install_dir}/bin/taosd-dump-cfg.gdb ${install_dir}/bin/${serverName}-dump-cfg.gdb
|
mv ${install_dir}/bin/taosd-dump-cfg.gdb ${install_dir}/bin/${serverName}-dump-cfg.gdb
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
[[ -x /usr/bin/taosadapter ]] && /usr/bin/taosadapter &
|
|
||||||
taosd
|
|
|
@ -20,9 +20,9 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "catalog.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "planner.h"
|
#include "planner.h"
|
||||||
#include "catalog.h"
|
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
#include "tcommon.h"
|
#include "tcommon.h"
|
||||||
|
@ -51,10 +51,12 @@ extern "C" {
|
||||||
enum {
|
enum {
|
||||||
RES_TYPE__QUERY = 1,
|
RES_TYPE__QUERY = 1,
|
||||||
RES_TYPE__TMQ,
|
RES_TYPE__TMQ,
|
||||||
|
RES_TYPE__TMQ_META,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY)
|
#define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY)
|
||||||
#define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ)
|
#define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ)
|
||||||
|
#define TD_RES_TMQ_META(res) (*(int8_t*)res == RES_TYPE__TMQ_META)
|
||||||
|
|
||||||
typedef struct SAppInstInfo SAppInstInfo;
|
typedef struct SAppInstInfo SAppInstInfo;
|
||||||
|
|
||||||
|
@ -66,9 +68,9 @@ typedef struct {
|
||||||
int64_t reportBytes; // not implemented
|
int64_t reportBytes; // not implemented
|
||||||
int64_t startTime;
|
int64_t startTime;
|
||||||
// ctl
|
// ctl
|
||||||
SRWLatch lock; // lock is used in serialization
|
SRWLatch lock; // lock is used in serialization
|
||||||
SAppInstInfo* pAppInstInfo;
|
SAppInstInfo* pAppInstInfo;
|
||||||
SHashObj* activeInfo; // hash<SClientHbKey, SClientHbReq>
|
SHashObj* activeInfo; // hash<SClientHbKey, SClientHbReq>
|
||||||
} SAppHbMgr;
|
} SAppHbMgr;
|
||||||
|
|
||||||
typedef int32_t (*FHbRspHandle)(SAppHbMgr* pAppHbMgr, SClientHbRsp* pRsp);
|
typedef int32_t (*FHbRspHandle)(SAppHbMgr* pAppHbMgr, SClientHbRsp* pRsp);
|
||||||
|
@ -76,13 +78,13 @@ typedef int32_t (*FHbRspHandle)(SAppHbMgr* pAppHbMgr, SClientHbRsp* pRsp);
|
||||||
typedef int32_t (*FHbReqHandle)(SClientHbKey* connKey, void* param, SClientHbReq* req);
|
typedef int32_t (*FHbReqHandle)(SClientHbKey* connKey, void* param, SClientHbReq* req);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t inited;
|
int8_t inited;
|
||||||
int64_t appId;
|
int64_t appId;
|
||||||
// ctl
|
// ctl
|
||||||
int8_t threadStop;
|
int8_t threadStop;
|
||||||
TdThread thread;
|
TdThread thread;
|
||||||
TdThreadMutex lock; // used when app init and cleanup
|
TdThreadMutex lock; // used when app init and cleanup
|
||||||
SHashObj *appSummary;
|
SHashObj* appSummary;
|
||||||
SArray* appHbMgrs; // SArray<SAppHbMgr*> one for each cluster
|
SArray* appHbMgrs; // SArray<SAppHbMgr*> one for each cluster
|
||||||
FHbReqHandle reqHandle[CONN_TYPE__MAX];
|
FHbReqHandle reqHandle[CONN_TYPE__MAX];
|
||||||
FHbRspHandle rspHandle[CONN_TYPE__MAX];
|
FHbRspHandle rspHandle[CONN_TYPE__MAX];
|
||||||
|
@ -129,7 +131,7 @@ typedef struct STscObj {
|
||||||
int8_t connType;
|
int8_t connType;
|
||||||
int32_t acctId;
|
int32_t acctId;
|
||||||
uint32_t connId;
|
uint32_t connId;
|
||||||
TAOS *id; // ref ID returned by taosAddRef
|
TAOS* id; // ref ID returned by taosAddRef
|
||||||
TdThreadMutex mutex; // used to protect the operation on db
|
TdThreadMutex mutex; // used to protect the operation on db
|
||||||
int32_t numOfReqs; // number of sqlObj bound to this connection
|
int32_t numOfReqs; // number of sqlObj bound to this connection
|
||||||
SAppInstInfo* pAppInfo;
|
SAppInstInfo* pAppInfo;
|
||||||
|
@ -188,6 +190,14 @@ typedef struct {
|
||||||
SReqResultInfo resInfo;
|
SReqResultInfo resInfo;
|
||||||
} SMqRspObj;
|
} SMqRspObj;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int8_t resType;
|
||||||
|
char topic[TSDB_TOPIC_FNAME_LEN];
|
||||||
|
char db[TSDB_DB_FNAME_LEN];
|
||||||
|
int32_t vgId;
|
||||||
|
SMqMetaRsp metaRsp;
|
||||||
|
} SMqMetaRspObj;
|
||||||
|
|
||||||
typedef struct SRequestObj {
|
typedef struct SRequestObj {
|
||||||
int8_t resType; // query or tmq
|
int8_t resType; // query or tmq
|
||||||
uint64_t requestId;
|
uint64_t requestId;
|
||||||
|
@ -206,9 +216,9 @@ typedef struct SRequestObj {
|
||||||
SRequestSendRecvBody body;
|
SRequestSendRecvBody body;
|
||||||
bool stableQuery;
|
bool stableQuery;
|
||||||
|
|
||||||
bool killed;
|
bool killed;
|
||||||
uint32_t prevCode; //previous error code: todo refactor, add update flag for catalog
|
uint32_t prevCode; // previous error code: todo refactor, add update flag for catalog
|
||||||
uint32_t retry;
|
uint32_t retry;
|
||||||
} SRequestObj;
|
} SRequestObj;
|
||||||
|
|
||||||
typedef struct SSyncQueryParam {
|
typedef struct SSyncQueryParam {
|
||||||
|
@ -216,15 +226,15 @@ typedef struct SSyncQueryParam {
|
||||||
SRequestObj* pRequest;
|
SRequestObj* pRequest;
|
||||||
} SSyncQueryParam;
|
} SSyncQueryParam;
|
||||||
|
|
||||||
void* doAsyncFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4);
|
void* doAsyncFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4);
|
||||||
void* doFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4);
|
void* doFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4);
|
||||||
|
|
||||||
void doSetOneRowPtr(SReqResultInfo* pResultInfo);
|
void doSetOneRowPtr(SReqResultInfo* pResultInfo);
|
||||||
void setResPrecision(SReqResultInfo* pResInfo, int32_t precision);
|
void setResPrecision(SReqResultInfo* pResInfo, int32_t precision);
|
||||||
int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp, bool convertUcs4,
|
int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp, bool convertUcs4,
|
||||||
bool freeAfterUse);
|
bool freeAfterUse);
|
||||||
void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols);
|
void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols);
|
||||||
void doFreeReqResultInfo(SReqResultInfo* pResInfo);
|
void doFreeReqResultInfo(SReqResultInfo* pResInfo);
|
||||||
SRequestObj* execQuery(STscObj* pTscObj, const char* sql, int sqlLen);
|
SRequestObj* execQuery(STscObj* pTscObj, const char* sql, int sqlLen);
|
||||||
|
|
||||||
static FORCE_INLINE SReqResultInfo* tmqGetCurResInfo(TAOS_RES* res) {
|
static FORCE_INLINE SReqResultInfo* tmqGetCurResInfo(TAOS_RES* res) {
|
||||||
|
@ -289,7 +299,7 @@ bool persistConnForSpecificMsg(void* parenct, tmsg_t msgType);
|
||||||
void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet);
|
void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet);
|
||||||
|
|
||||||
STscObj* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db,
|
STscObj* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db,
|
||||||
uint16_t port, int connType);
|
uint16_t port, int connType);
|
||||||
|
|
||||||
SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen);
|
SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen);
|
||||||
|
|
||||||
|
@ -299,7 +309,7 @@ int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArra
|
||||||
|
|
||||||
int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj** pRequest);
|
int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj** pRequest);
|
||||||
|
|
||||||
void taos_close_internal(void *taos);
|
void taos_close_internal(void* taos);
|
||||||
|
|
||||||
// --- heartbeat
|
// --- heartbeat
|
||||||
// global, called by mgmt
|
// global, called by mgmt
|
||||||
|
@ -320,12 +330,12 @@ void hbMgrInitMqHbRspHandle();
|
||||||
|
|
||||||
SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQuery, void** res);
|
SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQuery, void** res);
|
||||||
int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList);
|
int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList);
|
||||||
void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData *pResultMeta);
|
void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultMeta);
|
||||||
int32_t refreshMeta(STscObj* pTscObj, SRequestObj* pRequest);
|
int32_t refreshMeta(STscObj* pTscObj, SRequestObj* pRequest);
|
||||||
int32_t updateQnodeList(SAppInstInfo* pInfo, SArray* pNodeList);
|
int32_t updateQnodeList(SAppInstInfo* pInfo, SArray* pNodeList);
|
||||||
void doAsyncQuery(SRequestObj* pRequest, bool forceUpdateMeta);
|
void doAsyncQuery(SRequestObj* pRequest, bool forceUpdateMeta);
|
||||||
int32_t removeMeta(STscObj* pTscObj, SArray* tbList);// todo move to clientImpl.c and become a static function
|
int32_t removeMeta(STscObj* pTscObj, SArray* tbList); // todo move to clientImpl.c and become a static function
|
||||||
int32_t handleAlterTbExecRes(void* res, struct SCatalog* pCatalog);// todo move to xxx
|
int32_t handleAlterTbExecRes(void* res, struct SCatalog* pCatalog); // todo move to xxx
|
||||||
bool qnodeRequired(SRequestObj* pRequest);
|
bool qnodeRequired(SRequestObj* pRequest);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "clientInt.h"
|
#include "clientInt.h"
|
||||||
#include "clientLog.h"
|
#include "clientLog.h"
|
||||||
#include "clientStmt.h"
|
#include "clientStmt.h"
|
||||||
|
#include "functionMgt.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
#include "scheduler.h"
|
#include "scheduler.h"
|
||||||
|
@ -25,7 +26,6 @@
|
||||||
#include "tref.h"
|
#include "tref.h"
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "functionMgt.h"
|
|
||||||
|
|
||||||
#define TSC_VAR_NOT_RELEASE 1
|
#define TSC_VAR_NOT_RELEASE 1
|
||||||
#define TSC_VAR_RELEASED 0
|
#define TSC_VAR_RELEASED 0
|
||||||
|
@ -97,11 +97,11 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
|
||||||
pass = TSDB_DEFAULT_PASS;
|
pass = TSDB_DEFAULT_PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
STscObj* pObj = taos_connect_internal(ip, user, pass, NULL, db, port, CONN_TYPE__QUERY);
|
STscObj *pObj = taos_connect_internal(ip, user, pass, NULL, db, port, CONN_TYPE__QUERY);
|
||||||
if (pObj) {
|
if (pObj) {
|
||||||
return pObj->id;
|
return pObj->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,41 +111,40 @@ void taos_close_internal(void *taos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
STscObj *pTscObj = (STscObj *)taos;
|
STscObj *pTscObj = (STscObj *)taos;
|
||||||
tscDebug("0x%" PRIx64 " try to close connection, numOfReq:%d", *(int64_t*)pTscObj->id, pTscObj->numOfReqs);
|
tscDebug("0x%" PRIx64 " try to close connection, numOfReq:%d", *(int64_t *)pTscObj->id, pTscObj->numOfReqs);
|
||||||
|
|
||||||
taosRemoveRef(clientConnRefPool, *(int64_t*)pTscObj->id);
|
taosRemoveRef(clientConnRefPool, *(int64_t *)pTscObj->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void taos_close(TAOS *taos) {
|
void taos_close(TAOS *taos) {
|
||||||
if (taos == NULL) {
|
if (taos == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
STscObj* pObj = acquireTscObj(*(int64_t*)taos);
|
STscObj *pObj = acquireTscObj(*(int64_t *)taos);
|
||||||
if (NULL == pObj) {
|
if (NULL == pObj) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
taos_close_internal(pObj);
|
taos_close_internal(pObj);
|
||||||
releaseTscObj(*(int64_t*)taos);
|
releaseTscObj(*(int64_t *)taos);
|
||||||
taosMemoryFree(taos);
|
taosMemoryFree(taos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int taos_errno(TAOS_RES *res) {
|
||||||
int taos_errno(TAOS_RES *tres) {
|
if (res == NULL || TD_RES_TMQ_META(res)) {
|
||||||
if (tres == NULL) {
|
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TD_RES_TMQ(tres)) {
|
if (TD_RES_TMQ(res)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ((SRequestObj *)tres)->code;
|
return ((SRequestObj *)res)->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *taos_errstr(TAOS_RES *res) {
|
const char *taos_errstr(TAOS_RES *res) {
|
||||||
if (res == NULL) {
|
if (res == NULL || TD_RES_TMQ_META(res)) {
|
||||||
return (const char *)tstrerror(terrno);
|
return (const char *)tstrerror(terrno);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,11 +178,15 @@ void taos_free_result(TAOS_RES *res) {
|
||||||
if (pRsp->rsp.withSchema) taosArrayDestroyP(pRsp->rsp.blockSchema, (FDelete)tDeleteSSchemaWrapper);
|
if (pRsp->rsp.withSchema) taosArrayDestroyP(pRsp->rsp.blockSchema, (FDelete)tDeleteSSchemaWrapper);
|
||||||
pRsp->resInfo.pRspMsg = NULL;
|
pRsp->resInfo.pRspMsg = NULL;
|
||||||
doFreeReqResultInfo(&pRsp->resInfo);
|
doFreeReqResultInfo(&pRsp->resInfo);
|
||||||
|
} else if (TD_RES_TMQ_META(res)) {
|
||||||
|
SMqMetaRspObj *pRspObj = (SMqMetaRspObj *)res;
|
||||||
|
taosMemoryFree(pRspObj->metaRsp.metaRsp);
|
||||||
|
taosMemoryFree(pRspObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_field_count(TAOS_RES *res) {
|
int taos_field_count(TAOS_RES *res) {
|
||||||
if (res == NULL) {
|
if (res == NULL || TD_RES_TMQ_META(res)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +197,7 @@ int taos_field_count(TAOS_RES *res) {
|
||||||
int taos_num_fields(TAOS_RES *res) { return taos_field_count(res); }
|
int taos_num_fields(TAOS_RES *res) { return taos_field_count(res); }
|
||||||
|
|
||||||
TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
|
TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
|
||||||
if (taos_num_fields(res) == 0) {
|
if (taos_num_fields(res) == 0 || TD_RES_TMQ_META(res)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,8 +218,8 @@ TAOS_RES *taos_query(TAOS *taos, const char *sql) {
|
||||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
STscObj* pTscObj = acquireTscObj(*(int64_t*)taos);
|
STscObj *pTscObj = acquireTscObj(*(int64_t *)taos);
|
||||||
if (pTscObj == NULL || sql == NULL) {
|
if (pTscObj == NULL || sql == NULL) {
|
||||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -229,21 +232,21 @@ TAOS_RES *taos_query(TAOS *taos, const char *sql) {
|
||||||
taos_query_a(taos, sql, syncQueryFn, param);
|
taos_query_a(taos, sql, syncQueryFn, param);
|
||||||
tsem_wait(¶m->sem);
|
tsem_wait(¶m->sem);
|
||||||
|
|
||||||
releaseTscObj(*(int64_t*)taos);
|
releaseTscObj(*(int64_t *)taos);
|
||||||
|
|
||||||
return param->pRequest;
|
return param->pRequest;
|
||||||
#else
|
#else
|
||||||
size_t sqlLen = strlen(sql);
|
size_t sqlLen = strlen(sql);
|
||||||
if (sqlLen > (size_t)TSDB_MAX_ALLOWED_SQL_LEN) {
|
if (sqlLen > (size_t)TSDB_MAX_ALLOWED_SQL_LEN) {
|
||||||
releaseTscObj(*(int64_t*)taos);
|
releaseTscObj(*(int64_t *)taos);
|
||||||
tscError("sql string exceeds max length:%d", TSDB_MAX_ALLOWED_SQL_LEN);
|
tscError("sql string exceeds max length:%d", TSDB_MAX_ALLOWED_SQL_LEN);
|
||||||
terrno = TSDB_CODE_TSC_EXCEED_SQL_LIMIT;
|
terrno = TSDB_CODE_TSC_EXCEED_SQL_LIMIT;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_RES* pRes = execQuery(pTscObj, sql, sqlLen);
|
TAOS_RES *pRes = execQuery(pTscObj, sql, sqlLen);
|
||||||
|
|
||||||
releaseTscObj(*(int64_t*)taos);
|
releaseTscObj(*(int64_t *)taos);
|
||||||
|
|
||||||
return pRes;
|
return pRes;
|
||||||
#endif
|
#endif
|
||||||
|
@ -380,7 +383,7 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields)
|
||||||
}
|
}
|
||||||
|
|
||||||
int *taos_fetch_lengths(TAOS_RES *res) {
|
int *taos_fetch_lengths(TAOS_RES *res) {
|
||||||
if (res == NULL) {
|
if (res == NULL || TD_RES_TMQ_META(res)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,7 +392,7 @@ int *taos_fetch_lengths(TAOS_RES *res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_ROW *taos_result_block(TAOS_RES *res) {
|
TAOS_ROW *taos_result_block(TAOS_RES *res) {
|
||||||
if (res == NULL) {
|
if (res == NULL || TD_RES_TMQ_META(res)) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -438,7 +441,7 @@ const char *taos_data_type(int type) {
|
||||||
const char *taos_get_client_info() { return version; }
|
const char *taos_get_client_info() { return version; }
|
||||||
|
|
||||||
int taos_affected_rows(TAOS_RES *res) {
|
int taos_affected_rows(TAOS_RES *res) {
|
||||||
if (res == NULL || TD_RES_TMQ(res)) {
|
if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,7 +451,7 @@ int taos_affected_rows(TAOS_RES *res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_result_precision(TAOS_RES *res) {
|
int taos_result_precision(TAOS_RES *res) {
|
||||||
if (res == NULL) {
|
if (res == NULL || TD_RES_TMQ_META(res)) {
|
||||||
return TSDB_TIME_PRECISION_MILLI;
|
return TSDB_TIME_PRECISION_MILLI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,15 +466,15 @@ int taos_result_precision(TAOS_RES *res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_select_db(TAOS *taos, const char *db) {
|
int taos_select_db(TAOS *taos, const char *db) {
|
||||||
STscObj* pObj = acquireTscObj(*(int64_t*)taos);
|
STscObj *pObj = acquireTscObj(*(int64_t *)taos);
|
||||||
if (pObj == NULL) {
|
if (pObj == NULL) {
|
||||||
releaseTscObj(*(int64_t*)taos);
|
releaseTscObj(*(int64_t *)taos);
|
||||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
return TSDB_CODE_TSC_DISCONNECTED;
|
return TSDB_CODE_TSC_DISCONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (db == NULL || strlen(db) == 0) {
|
if (db == NULL || strlen(db) == 0) {
|
||||||
releaseTscObj(*(int64_t*)taos);
|
releaseTscObj(*(int64_t *)taos);
|
||||||
terrno = TSDB_CODE_TSC_INVALID_INPUT;
|
terrno = TSDB_CODE_TSC_INVALID_INPUT;
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
@ -483,19 +486,19 @@ int taos_select_db(TAOS *taos, const char *db) {
|
||||||
int32_t code = taos_errno(pRequest);
|
int32_t code = taos_errno(pRequest);
|
||||||
|
|
||||||
taos_free_result(pRequest);
|
taos_free_result(pRequest);
|
||||||
releaseTscObj(*(int64_t*)taos);
|
releaseTscObj(*(int64_t *)taos);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void taos_stop_query(TAOS_RES *res) {
|
void taos_stop_query(TAOS_RES *res) {
|
||||||
if (res == NULL) {
|
if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRequestObj *pRequest = (SRequestObj *)res;
|
SRequestObj *pRequest = (SRequestObj *)res;
|
||||||
pRequest->killed = true;
|
pRequest->killed = true;
|
||||||
|
|
||||||
int32_t numOfFields = taos_num_fields(pRequest);
|
int32_t numOfFields = taos_num_fields(pRequest);
|
||||||
// It is not a query, no need to stop.
|
// It is not a query, no need to stop.
|
||||||
if (numOfFields == 0) {
|
if (numOfFields == 0) {
|
||||||
tscDebug("request %" PRIx64 " no need to be killed since not query", pRequest->requestId);
|
tscDebug("request %" PRIx64 " no need to be killed since not query", pRequest->requestId);
|
||||||
|
@ -510,6 +513,9 @@ void taos_stop_query(TAOS_RES *res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col) {
|
bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col) {
|
||||||
|
if (res == NULL || TD_RES_TMQ_META(res)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
SReqResultInfo *pResultInfo = tscGetCurResInfo(res);
|
SReqResultInfo *pResultInfo = tscGetCurResInfo(res);
|
||||||
if (col >= pResultInfo->numOfCols || col < 0 || row >= pResultInfo->numOfRows || row < 0) {
|
if (col >= pResultInfo->numOfCols || col < 0 || row >= pResultInfo->numOfRows || row < 0) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -532,7 +538,7 @@ int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_fetch_block_s(TAOS_RES *res, int *numOfRows, TAOS_ROW *rows) {
|
int taos_fetch_block_s(TAOS_RES *res, int *numOfRows, TAOS_ROW *rows) {
|
||||||
if (res == NULL) {
|
if (res == NULL || TD_RES_TMQ_META(res)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,7 +581,7 @@ int taos_fetch_block_s(TAOS_RES *res, int *numOfRows, TAOS_ROW *rows) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData) {
|
int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData) {
|
||||||
if (res == NULL) {
|
if (res == NULL || TD_RES_TMQ_META(res)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -615,7 +621,7 @@ int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex) {
|
int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex) {
|
||||||
if (res == NULL) {
|
if (res == NULL || TD_RES_TMQ_META(res)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -636,7 +642,7 @@ int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex) {
|
||||||
int taos_validate_sql(TAOS *taos, const char *sql) { return true; }
|
int taos_validate_sql(TAOS *taos, const char *sql) { return true; }
|
||||||
|
|
||||||
void taos_reset_current_db(TAOS *taos) {
|
void taos_reset_current_db(TAOS *taos) {
|
||||||
STscObj* pTscObj = acquireTscObj(*(int64_t*)taos);
|
STscObj *pTscObj = acquireTscObj(*(int64_t *)taos);
|
||||||
if (pTscObj == NULL) {
|
if (pTscObj == NULL) {
|
||||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
return;
|
return;
|
||||||
|
@ -644,17 +650,17 @@ void taos_reset_current_db(TAOS *taos) {
|
||||||
|
|
||||||
resetConnectDB(pTscObj);
|
resetConnectDB(pTscObj);
|
||||||
|
|
||||||
releaseTscObj(*(int64_t*)taos);
|
releaseTscObj(*(int64_t *)taos);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *taos_get_server_info(TAOS *taos) {
|
const char *taos_get_server_info(TAOS *taos) {
|
||||||
STscObj* pTscObj = acquireTscObj(*(int64_t*)taos);
|
STscObj *pTscObj = acquireTscObj(*(int64_t *)taos);
|
||||||
if (pTscObj == NULL) {
|
if (pTscObj == NULL) {
|
||||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
releaseTscObj(*(int64_t*)taos);
|
releaseTscObj(*(int64_t *)taos);
|
||||||
|
|
||||||
return pTscObj->ver;
|
return pTscObj->ver;
|
||||||
}
|
}
|
||||||
|
@ -682,7 +688,7 @@ static void destorySqlParseWrapper(SqlParseWrapper *pWrapper) {
|
||||||
|
|
||||||
void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) {
|
void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) {
|
||||||
tscDebug("enter meta callback, code %s", tstrerror(code));
|
tscDebug("enter meta callback, code %s", tstrerror(code));
|
||||||
|
|
||||||
SqlParseWrapper *pWrapper = (SqlParseWrapper *)param;
|
SqlParseWrapper *pWrapper = (SqlParseWrapper *)param;
|
||||||
SQuery *pQuery = pWrapper->pQuery;
|
SQuery *pQuery = pWrapper->pQuery;
|
||||||
SRequestObj *pRequest = pWrapper->pRequest;
|
SRequestObj *pRequest = pWrapper->pRequest;
|
||||||
|
@ -723,11 +729,11 @@ void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param) {
|
void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param) {
|
||||||
STscObj* pTscObj = acquireTscObj(*(int64_t*)taos);
|
STscObj *pTscObj = acquireTscObj(*(int64_t *)taos);
|
||||||
if (pTscObj == NULL || sql == NULL || NULL == fp) {
|
if (pTscObj == NULL || sql == NULL || NULL == fp) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
if (pTscObj) {
|
if (pTscObj) {
|
||||||
releaseTscObj(*(int64_t*)taos);
|
releaseTscObj(*(int64_t *)taos);
|
||||||
} else {
|
} else {
|
||||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
}
|
}
|
||||||
|
@ -745,7 +751,7 @@ void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param
|
||||||
}
|
}
|
||||||
|
|
||||||
SRequestObj *pRequest = NULL;
|
SRequestObj *pRequest = NULL;
|
||||||
int32_t code = buildRequest(pTscObj, sql, sqlLen, &pRequest);
|
int32_t code = buildRequest(pTscObj, sql, sqlLen, &pRequest);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
terrno = code;
|
terrno = code;
|
||||||
fp(param, NULL, terrno);
|
fp(param, NULL, terrno);
|
||||||
|
@ -849,8 +855,8 @@ static void fetchCallback(void *pResult, void *param, int32_t code) {
|
||||||
|
|
||||||
SReqResultInfo *pResultInfo = &pRequest->body.resInfo;
|
SReqResultInfo *pResultInfo = &pRequest->body.resInfo;
|
||||||
|
|
||||||
tscDebug("0x%" PRIx64 " enter scheduler fetch cb, code:%d - %s, reqId:0x%" PRIx64,
|
tscDebug("0x%" PRIx64 " enter scheduler fetch cb, code:%d - %s, reqId:0x%" PRIx64, pRequest->self, code,
|
||||||
pRequest->self, code, tstrerror(code), pRequest->requestId);
|
tstrerror(code), pRequest->requestId);
|
||||||
|
|
||||||
pResultInfo->pData = pResult;
|
pResultInfo->pData = pResult;
|
||||||
pResultInfo->numOfRows = 0;
|
pResultInfo->numOfRows = 0;
|
||||||
|
@ -884,6 +890,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) {
|
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);
|
||||||
|
ASSERT(TD_RES_QUERY(res));
|
||||||
|
|
||||||
SRequestObj *pRequest = res;
|
SRequestObj *pRequest = res;
|
||||||
pRequest->body.fetchFp = fp;
|
pRequest->body.fetchFp = fp;
|
||||||
|
@ -910,6 +917,7 @@ void taos_fetch_rows_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) {
|
void taos_fetch_raw_block_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
||||||
ASSERT(res != NULL && fp != NULL);
|
ASSERT(res != NULL && fp != NULL);
|
||||||
|
ASSERT(TD_RES_QUERY(res));
|
||||||
SRequestObj *pRequest = res;
|
SRequestObj *pRequest = res;
|
||||||
|
|
||||||
pRequest->body.resInfo.convertUcs4 = false;
|
pRequest->body.resInfo.convertUcs4 = false;
|
||||||
|
@ -923,6 +931,7 @@ void taos_fetch_raw_block_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
||||||
|
|
||||||
const void *taos_get_raw_block(TAOS_RES *res) {
|
const void *taos_get_raw_block(TAOS_RES *res) {
|
||||||
ASSERT(res != NULL);
|
ASSERT(res != NULL);
|
||||||
|
ASSERT(TD_RES_QUERY(res));
|
||||||
SRequestObj *pRequest = res;
|
SRequestObj *pRequest = res;
|
||||||
|
|
||||||
return pRequest->body.resInfo.pData;
|
return pRequest->body.resInfo.pData;
|
||||||
|
@ -949,16 +958,16 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_STMT *taos_stmt_init(TAOS *taos) {
|
TAOS_STMT *taos_stmt_init(TAOS *taos) {
|
||||||
STscObj* pObj = acquireTscObj(*(int64_t*)taos);
|
STscObj *pObj = acquireTscObj(*(int64_t *)taos);
|
||||||
if (NULL == pObj) {
|
if (NULL == pObj) {
|
||||||
tscError("invalid parameter for %s", __FUNCTION__);
|
tscError("invalid parameter for %s", __FUNCTION__);
|
||||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_STMT* pStmt = stmtInit(pObj);
|
TAOS_STMT *pStmt = stmtInit(pObj);
|
||||||
|
|
||||||
releaseTscObj(*(int64_t*)taos);
|
releaseTscObj(*(int64_t *)taos);
|
||||||
|
|
||||||
return pStmt;
|
return pStmt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,10 @@ typedef struct {
|
||||||
int32_t epoch;
|
int32_t epoch;
|
||||||
SMqClientVg* vgHandle;
|
SMqClientVg* vgHandle;
|
||||||
SMqClientTopic* topicHandle;
|
SMqClientTopic* topicHandle;
|
||||||
SMqDataBlkRsp msg;
|
union {
|
||||||
|
SMqDataBlkRsp dataRsp;
|
||||||
|
SMqMetaRsp metaRsp;
|
||||||
|
};
|
||||||
} SMqPollRspWrapper;
|
} SMqPollRspWrapper;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -1131,6 +1134,11 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
tscWarn("mismatch rsp from vg %d, epoch %d, current epoch %d", vgId, msgEpoch, tmqEpoch);
|
tscWarn("mismatch rsp from vg %d, epoch %d, current epoch %d", vgId, msgEpoch, tmqEpoch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handle meta rsp
|
||||||
|
int8_t rspType = ((SMqRspHead*)pMsg->pData)->mqMsgType;
|
||||||
|
if (rspType == TMQ_MSG_TYPE__POLL_META_RSP) {
|
||||||
|
}
|
||||||
|
|
||||||
SMqPollRspWrapper* pRspWrapper = taosAllocateQitem(sizeof(SMqPollRspWrapper), DEF_QITEM);
|
SMqPollRspWrapper* pRspWrapper = taosAllocateQitem(sizeof(SMqPollRspWrapper), DEF_QITEM);
|
||||||
if (pRspWrapper == NULL) {
|
if (pRspWrapper == NULL) {
|
||||||
taosMemoryFree(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
|
@ -1138,17 +1146,23 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
goto CREATE_MSG_FAIL;
|
goto CREATE_MSG_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pRspWrapper->tmqRspType = TMQ_MSG_TYPE__POLL_RSP;
|
pRspWrapper->tmqRspType = rspType;
|
||||||
pRspWrapper->vgHandle = pVg;
|
pRspWrapper->vgHandle = pVg;
|
||||||
pRspWrapper->topicHandle = pTopic;
|
pRspWrapper->topicHandle = pTopic;
|
||||||
|
|
||||||
memcpy(&pRspWrapper->msg, pMsg->pData, sizeof(SMqRspHead));
|
memcpy(&pRspWrapper->dataRsp, pMsg->pData, sizeof(SMqRspHead));
|
||||||
|
|
||||||
|
if (rspType == TMQ_MSG_TYPE__POLL_RSP) {
|
||||||
|
tDecodeSMqDataBlkRsp(POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), &pRspWrapper->dataRsp);
|
||||||
|
} else {
|
||||||
|
ASSERT(rspType == TMQ_MSG_TYPE__POLL_META_RSP);
|
||||||
|
tDecodeSMqMetaRsp(POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), &pRspWrapper->metaRsp);
|
||||||
|
}
|
||||||
|
|
||||||
tDecodeSMqDataBlkRsp(POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), &pRspWrapper->msg);
|
|
||||||
taosMemoryFree(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
|
|
||||||
tscDebug("consumer %ld recv poll: vg %d, req offset %ld, rsp offset %ld", tmq->consumerId, pVg->vgId,
|
tscDebug("consumer %ld recv poll: vg %d, req offset %ld, rsp offset %ld", tmq->consumerId, pVg->vgId,
|
||||||
pRspWrapper->msg.reqOffset, pRspWrapper->msg.rspOffset);
|
pRspWrapper->dataRsp.reqOffset, pRspWrapper->dataRsp.rspOffset);
|
||||||
|
|
||||||
taosWriteQitem(tmq->mqueue, pRspWrapper);
|
taosWriteQitem(tmq->mqueue, pRspWrapper);
|
||||||
tsem_post(&tmq->rspSem);
|
tsem_post(&tmq->rspSem);
|
||||||
|
@ -1516,6 +1530,17 @@ SMqPollReq* tmqBuildConsumeReqImpl(tmq_t* tmq, int64_t timeout, SMqClientTopic*
|
||||||
return pReq;
|
return pReq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SMqMetaRspObj* tmqBuildMetaRspFromWrapper(SMqPollRspWrapper* pWrapper) {
|
||||||
|
SMqMetaRspObj* pRspObj = taosMemoryCalloc(1, sizeof(SMqMetaRspObj));
|
||||||
|
pRspObj->resType = RES_TYPE__TMQ;
|
||||||
|
tstrncpy(pRspObj->topic, pWrapper->topicHandle->topicName, TSDB_TOPIC_FNAME_LEN);
|
||||||
|
tstrncpy(pRspObj->db, pWrapper->topicHandle->db, TSDB_DB_FNAME_LEN);
|
||||||
|
pRspObj->vgId = pWrapper->vgHandle->vgId;
|
||||||
|
|
||||||
|
memcpy(&pRspObj->metaRsp, &pWrapper->metaRsp, sizeof(SMqMetaRsp));
|
||||||
|
return pRspObj;
|
||||||
|
}
|
||||||
|
|
||||||
SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper) {
|
SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper) {
|
||||||
SMqRspObj* pRspObj = taosMemoryCalloc(1, sizeof(SMqRspObj));
|
SMqRspObj* pRspObj = taosMemoryCalloc(1, sizeof(SMqRspObj));
|
||||||
pRspObj->resType = RES_TYPE__TMQ;
|
pRspObj->resType = RES_TYPE__TMQ;
|
||||||
|
@ -1523,11 +1548,11 @@ SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper) {
|
||||||
tstrncpy(pRspObj->db, pWrapper->topicHandle->db, TSDB_DB_FNAME_LEN);
|
tstrncpy(pRspObj->db, pWrapper->topicHandle->db, TSDB_DB_FNAME_LEN);
|
||||||
pRspObj->vgId = pWrapper->vgHandle->vgId;
|
pRspObj->vgId = pWrapper->vgHandle->vgId;
|
||||||
pRspObj->resIter = -1;
|
pRspObj->resIter = -1;
|
||||||
memcpy(&pRspObj->rsp, &pWrapper->msg, sizeof(SMqDataBlkRsp));
|
memcpy(&pRspObj->rsp, &pWrapper->dataRsp, sizeof(SMqDataBlkRsp));
|
||||||
|
|
||||||
pRspObj->resInfo.totalRows = 0;
|
pRspObj->resInfo.totalRows = 0;
|
||||||
pRspObj->resInfo.precision = TSDB_TIME_PRECISION_MILLI;
|
pRspObj->resInfo.precision = TSDB_TIME_PRECISION_MILLI;
|
||||||
if (!pWrapper->msg.withSchema) {
|
if (!pWrapper->dataRsp.withSchema) {
|
||||||
setResSchemaInfo(&pRspObj->resInfo, pWrapper->topicHandle->schema.pSchema, pWrapper->topicHandle->schema.nCols);
|
setResSchemaInfo(&pRspObj->resInfo, pWrapper->topicHandle->schema.pSchema, pWrapper->topicHandle->schema.nCols);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1643,12 +1668,12 @@ SMqRspObj* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
|
||||||
SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)rspWrapper;
|
SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)rspWrapper;
|
||||||
/*atomic_sub_fetch_32(&tmq->readyRequest, 1);*/
|
/*atomic_sub_fetch_32(&tmq->readyRequest, 1);*/
|
||||||
int32_t consumerEpoch = atomic_load_32(&tmq->epoch);
|
int32_t consumerEpoch = atomic_load_32(&tmq->epoch);
|
||||||
if (pollRspWrapper->msg.head.epoch == consumerEpoch) {
|
if (pollRspWrapper->dataRsp.head.epoch == consumerEpoch) {
|
||||||
SMqClientVg* pVg = pollRspWrapper->vgHandle;
|
SMqClientVg* pVg = pollRspWrapper->vgHandle;
|
||||||
/*printf("vg %d offset %ld up to %ld\n", pVg->vgId, pVg->currentOffset, rspMsg->msg.rspOffset);*/
|
/*printf("vg %d offset %ld up to %ld\n", pVg->vgId, pVg->currentOffset, rspMsg->msg.rspOffset);*/
|
||||||
pVg->currentOffset = pollRspWrapper->msg.rspOffset;
|
pVg->currentOffset = pollRspWrapper->dataRsp.rspOffset;
|
||||||
atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE);
|
atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE);
|
||||||
if (pollRspWrapper->msg.blockNum == 0) {
|
if (pollRspWrapper->dataRsp.blockNum == 0) {
|
||||||
taosFreeQitem(pollRspWrapper);
|
taosFreeQitem(pollRspWrapper);
|
||||||
rspWrapper = NULL;
|
rspWrapper = NULL;
|
||||||
continue;
|
continue;
|
||||||
|
@ -1658,8 +1683,25 @@ SMqRspObj* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
|
||||||
taosFreeQitem(pollRspWrapper);
|
taosFreeQitem(pollRspWrapper);
|
||||||
return pRsp;
|
return pRsp;
|
||||||
} else {
|
} else {
|
||||||
tscDebug("msg discard since epoch mismatch: msg epoch %d, consumer epoch %d\n", pollRspWrapper->msg.head.epoch,
|
tscDebug("msg discard since epoch mismatch: msg epoch %d, consumer epoch %d\n",
|
||||||
consumerEpoch);
|
pollRspWrapper->dataRsp.head.epoch, consumerEpoch);
|
||||||
|
taosFreeQitem(pollRspWrapper);
|
||||||
|
}
|
||||||
|
} else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_META_RSP) {
|
||||||
|
SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)rspWrapper;
|
||||||
|
int32_t consumerEpoch = atomic_load_32(&tmq->epoch);
|
||||||
|
if (pollRspWrapper->dataRsp.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->dataRsp.rspOffset;
|
||||||
|
atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE);
|
||||||
|
// build rsp
|
||||||
|
SMqRspObj* pRsp = tmqBuildRspFromWrapper(pollRspWrapper);
|
||||||
|
taosFreeQitem(pollRspWrapper);
|
||||||
|
return pRsp;
|
||||||
|
} else {
|
||||||
|
tscDebug("msg discard since epoch mismatch: msg epoch %d, consumer epoch %d\n",
|
||||||
|
pollRspWrapper->dataRsp.head.epoch, consumerEpoch);
|
||||||
taosFreeQitem(pollRspWrapper);
|
taosFreeQitem(pollRspWrapper);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1747,10 +1789,23 @@ const char* tmq_err2str(int32_t err) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tmq_res_t tmq_get_res_type(TAOS_RES* res) {
|
||||||
|
if (TD_RES_TMQ(res)) {
|
||||||
|
return TMQ_RES_DATA;
|
||||||
|
} else if (TD_RES_TMQ_META(res)) {
|
||||||
|
return TMQ_RES_TABLE_META;
|
||||||
|
} else {
|
||||||
|
return TMQ_RES_INVALID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const char* tmq_get_topic_name(TAOS_RES* res) {
|
const char* tmq_get_topic_name(TAOS_RES* res) {
|
||||||
if (TD_RES_TMQ(res)) {
|
if (TD_RES_TMQ(res)) {
|
||||||
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
||||||
return strchr(pRspObj->topic, '.') + 1;
|
return strchr(pRspObj->topic, '.') + 1;
|
||||||
|
} else if (TD_RES_TMQ_META(res)) {
|
||||||
|
SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res;
|
||||||
|
return strchr(pMetaRspObj->topic, '.') + 1;
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1760,6 +1815,9 @@ const char* tmq_get_db_name(TAOS_RES* res) {
|
||||||
if (TD_RES_TMQ(res)) {
|
if (TD_RES_TMQ(res)) {
|
||||||
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
||||||
return strchr(pRspObj->db, '.') + 1;
|
return strchr(pRspObj->db, '.') + 1;
|
||||||
|
} else if (TD_RES_TMQ_META(res)) {
|
||||||
|
SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res;
|
||||||
|
return strchr(pMetaRspObj->db, '.') + 1;
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1769,6 +1827,9 @@ int32_t tmq_get_vgroup_id(TAOS_RES* res) {
|
||||||
if (TD_RES_TMQ(res)) {
|
if (TD_RES_TMQ(res)) {
|
||||||
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
||||||
return pRspObj->vgId;
|
return pRspObj->vgId;
|
||||||
|
} else if (TD_RES_TMQ_META(res)) {
|
||||||
|
SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res;
|
||||||
|
return pMetaRspObj->vgId;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1786,6 +1847,16 @@ const char* tmq_get_table_name(TAOS_RES* res) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tmq_get_raw_meta(TAOS_RES* res, const void** raw_meta, int32_t* raw_meta_len) {
|
||||||
|
if (TD_RES_TMQ_META(res)) {
|
||||||
|
SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res;
|
||||||
|
*raw_meta = pMetaRspObj->metaRsp.metaRsp;
|
||||||
|
*raw_meta_len = pMetaRspObj->metaRsp.metaRspLen;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
void tmq_commit_async(tmq_t* tmq, const TAOS_RES* msg, tmq_commit_cb* cb, void* param) {
|
void tmq_commit_async(tmq_t* tmq, const TAOS_RES* msg, tmq_commit_cb* cb, void* param) {
|
||||||
tmqCommitInner2(tmq, msg, 0, 1, cb, param);
|
tmqCommitInner2(tmq, msg, 0, 1, cb, param);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2956,6 +2956,7 @@ int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTo
|
||||||
if (tEncodeCStr(&encoder, pReq->name) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->name) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->igExists) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->igExists) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->subType) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->subType) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->withMeta) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->subDbName) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->subDbName) < 0) return -1;
|
||||||
if (TOPIC_SUB_TYPE__DB == pReq->subType) {
|
if (TOPIC_SUB_TYPE__DB == pReq->subType) {
|
||||||
} else if (TOPIC_SUB_TYPE__TABLE == pReq->subType) {
|
} else if (TOPIC_SUB_TYPE__TABLE == pReq->subType) {
|
||||||
|
@ -2985,6 +2986,7 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR
|
||||||
if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->igExists) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->igExists) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->subType) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->subType) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &pReq->withMeta) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->subDbName) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->subDbName) < 0) return -1;
|
||||||
if (TOPIC_SUB_TYPE__DB == pReq->subType) {
|
if (TOPIC_SUB_TYPE__DB == pReq->subType) {
|
||||||
} else if (TOPIC_SUB_TYPE__TABLE == pReq->subType) {
|
} else if (TOPIC_SUB_TYPE__TABLE == pReq->subType) {
|
||||||
|
|
|
@ -218,7 +218,7 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_DELETE_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, mmPutMsgToFetchQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TASK, mmPutMsgToFetchQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_DROP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DROP_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_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_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_CONFIRM_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
|
@ -95,7 +95,7 @@ SArray *smGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MON_SM_INFO, smPutNodeMsgToMonitorQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MON_SM_INFO, smPutNodeMsgToMonitorQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_DROP, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DROP, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RUN, smPutNodeMsgToSharedQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RUN, smPutNodeMsgToSharedQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DISPATCH, smPutNodeMsgToSharedQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DISPATCH, smPutNodeMsgToSharedQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DISPATCH_RSP, smPutNodeMsgToSharedQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DISPATCH_RSP, smPutNodeMsgToSharedQueue, 1) == NULL) goto _OVER;
|
||||||
|
|
|
@ -351,7 +351,7 @@ SArray *vmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_HEARTBEAT, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_HEARTBEAT, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TRIGGER, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TRIGGER, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_DROP, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DROP, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RUN, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RUN, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DISPATCH, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DISPATCH, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
|
@ -420,7 +420,8 @@ typedef struct {
|
||||||
int64_t uid;
|
int64_t uid;
|
||||||
int64_t dbUid;
|
int64_t dbUid;
|
||||||
int32_t version;
|
int32_t version;
|
||||||
int8_t subType; // column, db or stable
|
int8_t subType; // column, db or stable
|
||||||
|
int8_t withMeta; // TODO
|
||||||
SRWLatch lock;
|
SRWLatch lock;
|
||||||
int32_t sqlLen;
|
int32_t sqlLen;
|
||||||
int32_t astLen;
|
int32_t astLen;
|
||||||
|
@ -487,6 +488,7 @@ typedef struct {
|
||||||
int64_t dbUid;
|
int64_t dbUid;
|
||||||
int32_t vgNum;
|
int32_t vgNum;
|
||||||
int8_t subType;
|
int8_t subType;
|
||||||
|
int8_t withMeta;
|
||||||
int64_t stbUid;
|
int64_t stbUid;
|
||||||
SHashObj* consumerHash; // consumerId -> SMqConsumerEp
|
SHashObj* consumerHash; // consumerId -> SMqConsumerEp
|
||||||
SArray* unassignedVgs; // SArray<SMqVgEp*>
|
SArray* unassignedVgs; // SArray<SMqVgEp*>
|
||||||
|
|
|
@ -381,6 +381,7 @@ SMqSubscribeObj *tCloneSubscribeObj(const SMqSubscribeObj *pSub) {
|
||||||
pSubNew->dbUid = pSub->dbUid;
|
pSubNew->dbUid = pSub->dbUid;
|
||||||
pSubNew->stbUid = pSub->stbUid;
|
pSubNew->stbUid = pSub->stbUid;
|
||||||
pSubNew->subType = pSub->subType;
|
pSubNew->subType = pSub->subType;
|
||||||
|
pSubNew->withMeta = pSub->withMeta;
|
||||||
|
|
||||||
pSubNew->vgNum = pSub->vgNum;
|
pSubNew->vgNum = pSub->vgNum;
|
||||||
pSubNew->consumerHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
pSubNew->consumerHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||||
|
@ -414,6 +415,7 @@ int32_t tEncodeSubscribeObj(void **buf, const SMqSubscribeObj *pSub) {
|
||||||
tlen += taosEncodeFixedI64(buf, pSub->dbUid);
|
tlen += taosEncodeFixedI64(buf, pSub->dbUid);
|
||||||
tlen += taosEncodeFixedI32(buf, pSub->vgNum);
|
tlen += taosEncodeFixedI32(buf, pSub->vgNum);
|
||||||
tlen += taosEncodeFixedI8(buf, pSub->subType);
|
tlen += taosEncodeFixedI8(buf, pSub->subType);
|
||||||
|
tlen += taosEncodeFixedI8(buf, pSub->withMeta);
|
||||||
tlen += taosEncodeFixedI64(buf, pSub->stbUid);
|
tlen += taosEncodeFixedI64(buf, pSub->stbUid);
|
||||||
|
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
|
@ -440,6 +442,7 @@ void *tDecodeSubscribeObj(const void *buf, SMqSubscribeObj *pSub) {
|
||||||
buf = taosDecodeFixedI64(buf, &pSub->dbUid);
|
buf = taosDecodeFixedI64(buf, &pSub->dbUid);
|
||||||
buf = taosDecodeFixedI32(buf, &pSub->vgNum);
|
buf = taosDecodeFixedI32(buf, &pSub->vgNum);
|
||||||
buf = taosDecodeFixedI8(buf, &pSub->subType);
|
buf = taosDecodeFixedI8(buf, &pSub->subType);
|
||||||
|
buf = taosDecodeFixedI8(buf, &pSub->withMeta);
|
||||||
buf = taosDecodeFixedI64(buf, &pSub->stbUid);
|
buf = taosDecodeFixedI64(buf, &pSub->stbUid);
|
||||||
|
|
||||||
int32_t sz;
|
int32_t sz;
|
||||||
|
|
|
@ -54,9 +54,10 @@ int32_t mndInitStream(SMnode *pMnode) {
|
||||||
};
|
};
|
||||||
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_STREAM, mndProcessCreateStreamReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_STREAM, mndProcessCreateStreamReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_STREAM_TASK_DEPLOY_RSP, mndTransProcessRsp);
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM, mndProcessDropStreamReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM, mndProcessDropStreamReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM_RSP, mndTransProcessRsp);
|
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_STREAM_TASK_DEPLOY_RSP, mndTransProcessRsp);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_STREAM_TASK_DROP_RSP, mndTransProcessRsp);
|
||||||
|
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_STREAMS, mndRetrieveStream);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_STREAMS, mndRetrieveStream);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_STREAMS, mndCancelGetNextStream);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_STREAMS, mndCancelGetNextStream);
|
||||||
|
@ -477,7 +478,7 @@ static int32_t mndPersistTaskDropReq(STrans *pTrans, SStreamTask *pTask) {
|
||||||
memcpy(&action.epSet, &pTask->epSet, sizeof(SEpSet));
|
memcpy(&action.epSet, &pTask->epSet, sizeof(SEpSet));
|
||||||
action.pCont = pReq;
|
action.pCont = pReq;
|
||||||
action.contLen = sizeof(SVDropStreamTaskReq);
|
action.contLen = sizeof(SVDropStreamTaskReq);
|
||||||
action.msgType = TDMT_VND_STREAM_TASK_DROP;
|
action.msgType = TDMT_STREAM_TASK_DROP;
|
||||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
taosMemoryFree(pReq);
|
taosMemoryFree(pReq);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -670,20 +671,24 @@ _OVER:
|
||||||
|
|
||||||
static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
|
||||||
SStreamObj *pStream = NULL;
|
SStreamObj *pStream = NULL;
|
||||||
/*SDbObj *pDb = NULL;*/
|
/*SDbObj *pDb = NULL;*/
|
||||||
/*SUserObj *pUser = NULL;*/
|
/*SUserObj *pUser = NULL;*/
|
||||||
|
|
||||||
SMDropStreamReq dropReq = *(SMDropStreamReq *)pReq->pCont;
|
SMDropStreamReq dropReq = {0};
|
||||||
|
if (tDeserializeSMDropStreamReq(pReq->pCont, pReq->contLen, &dropReq) < 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
pStream = mndAcquireStream(pMnode, dropReq.name);
|
pStream = mndAcquireStream(pMnode, dropReq.name);
|
||||||
|
|
||||||
if (pStream == NULL) {
|
if (pStream == NULL) {
|
||||||
if (dropReq.igNotExists) {
|
if (dropReq.igNotExists) {
|
||||||
mDebug("stream:%s, not exist, ignore not exist is set", dropReq.name);
|
mDebug("stream:%s, not exist, ignore not exist is set", dropReq.name);
|
||||||
code = 0;
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
goto DROP_STREAM_OVER;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
terrno = TSDB_CODE_MND_STREAM_NOT_EXIST;
|
terrno = TSDB_CODE_MND_STREAM_NOT_EXIST;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -701,14 +706,16 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
||||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq);
|
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq);
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
mError("stream:%s, failed to drop since %s", dropReq.name, terrstr());
|
mError("stream:%s, failed to drop since %s", dropReq.name, terrstr());
|
||||||
return code;
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
mDebug("trans:%d, used to drop stream:%s", pTrans->id, dropReq.name);
|
mDebug("trans:%d, used to drop stream:%s", pTrans->id, dropReq.name);
|
||||||
|
|
||||||
// drop all tasks
|
// drop all tasks
|
||||||
if (mndDropStreamTasks(pMnode, pTrans, pStream) < 0) {
|
if (mndDropStreamTasks(pMnode, pTrans, pStream) < 0) {
|
||||||
mError("stream:%s, failed to drop task since %s", dropReq.name, terrstr());
|
mError("stream:%s, failed to drop task since %s", dropReq.name, terrstr());
|
||||||
return code;
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// drop stream
|
// drop stream
|
||||||
|
@ -717,8 +724,16 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
DROP_STREAM_OVER:
|
if (mndTransPrepare(pMnode, pTrans) != 0) {
|
||||||
return code;
|
mError("trans:%d, failed to prepare drop stream trans since %s", pTrans->id, terrstr());
|
||||||
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
|
|
||||||
|
return TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndDropStreamByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
|
int32_t mndDropStreamByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
|
||||||
|
|
|
@ -96,6 +96,7 @@ static SMqSubscribeObj *mndCreateSub(SMnode *pMnode, const SMqTopicObj *pTopic,
|
||||||
pSub->dbUid = pTopic->dbUid;
|
pSub->dbUid = pTopic->dbUid;
|
||||||
pSub->stbUid = pTopic->stbUid;
|
pSub->stbUid = pTopic->stbUid;
|
||||||
pSub->subType = pTopic->subType;
|
pSub->subType = pTopic->subType;
|
||||||
|
pSub->withMeta = pTopic->withMeta;
|
||||||
|
|
||||||
ASSERT(pSub->unassignedVgs->size == 0);
|
ASSERT(pSub->unassignedVgs->size == 0);
|
||||||
ASSERT(taosHashGetSize(pSub->consumerHash) == 0);
|
ASSERT(taosHashGetSize(pSub->consumerHash) == 0);
|
||||||
|
@ -120,6 +121,7 @@ static int32_t mndBuildSubChangeReq(void **pBuf, int32_t *pLen, const SMqSubscri
|
||||||
req.vgId = pRebVg->pVgEp->vgId;
|
req.vgId = pRebVg->pVgEp->vgId;
|
||||||
req.qmsg = pRebVg->pVgEp->qmsg;
|
req.qmsg = pRebVg->pVgEp->qmsg;
|
||||||
req.subType = pSub->subType;
|
req.subType = pSub->subType;
|
||||||
|
req.withMeta = pSub->withMeta;
|
||||||
req.suid = pSub->stbUid;
|
req.suid = pSub->stbUid;
|
||||||
strncpy(req.subKey, pSub->key, TSDB_SUBSCRIBE_KEY_LEN);
|
strncpy(req.subKey, pSub->key, TSDB_SUBSCRIBE_KEY_LEN);
|
||||||
|
|
||||||
|
|
|
@ -141,6 +141,7 @@ SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) {
|
||||||
SDB_SET_INT64(pRaw, dataPos, pTopic->dbUid, TOPIC_ENCODE_OVER);
|
SDB_SET_INT64(pRaw, dataPos, pTopic->dbUid, TOPIC_ENCODE_OVER);
|
||||||
SDB_SET_INT32(pRaw, dataPos, pTopic->version, TOPIC_ENCODE_OVER);
|
SDB_SET_INT32(pRaw, dataPos, pTopic->version, TOPIC_ENCODE_OVER);
|
||||||
SDB_SET_INT8(pRaw, dataPos, pTopic->subType, TOPIC_ENCODE_OVER);
|
SDB_SET_INT8(pRaw, dataPos, pTopic->subType, TOPIC_ENCODE_OVER);
|
||||||
|
SDB_SET_INT8(pRaw, dataPos, pTopic->withMeta, TOPIC_ENCODE_OVER);
|
||||||
|
|
||||||
SDB_SET_INT64(pRaw, dataPos, pTopic->stbUid, TOPIC_ENCODE_OVER);
|
SDB_SET_INT64(pRaw, dataPos, pTopic->stbUid, TOPIC_ENCODE_OVER);
|
||||||
SDB_SET_INT32(pRaw, dataPos, pTopic->sqlLen, TOPIC_ENCODE_OVER);
|
SDB_SET_INT32(pRaw, dataPos, pTopic->sqlLen, TOPIC_ENCODE_OVER);
|
||||||
|
@ -208,6 +209,7 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pTopic->dbUid, TOPIC_DECODE_OVER);
|
SDB_GET_INT64(pRaw, dataPos, &pTopic->dbUid, TOPIC_DECODE_OVER);
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pTopic->version, TOPIC_DECODE_OVER);
|
SDB_GET_INT32(pRaw, dataPos, &pTopic->version, TOPIC_DECODE_OVER);
|
||||||
SDB_GET_INT8(pRaw, dataPos, &pTopic->subType, TOPIC_DECODE_OVER);
|
SDB_GET_INT8(pRaw, dataPos, &pTopic->subType, TOPIC_DECODE_OVER);
|
||||||
|
SDB_GET_INT8(pRaw, dataPos, &pTopic->withMeta, TOPIC_DECODE_OVER);
|
||||||
|
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pTopic->stbUid, TOPIC_DECODE_OVER);
|
SDB_GET_INT64(pRaw, dataPos, &pTopic->stbUid, TOPIC_DECODE_OVER);
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pTopic->sqlLen, TOPIC_DECODE_OVER);
|
SDB_GET_INT32(pRaw, dataPos, &pTopic->sqlLen, TOPIC_DECODE_OVER);
|
||||||
|
@ -357,6 +359,10 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
|
||||||
topicObj.sql = strdup(pCreate->sql);
|
topicObj.sql = strdup(pCreate->sql);
|
||||||
topicObj.sqlLen = strlen(pCreate->sql) + 1;
|
topicObj.sqlLen = strlen(pCreate->sql) + 1;
|
||||||
topicObj.subType = pCreate->subType;
|
topicObj.subType = pCreate->subType;
|
||||||
|
topicObj.withMeta = pCreate->withMeta;
|
||||||
|
if (topicObj.withMeta) {
|
||||||
|
ASSERT(topicObj.subType != TOPIC_SUB_TYPE__COLUMN);
|
||||||
|
}
|
||||||
|
|
||||||
if (pCreate->subType == TOPIC_SUB_TYPE__COLUMN) {
|
if (pCreate->subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||||
topicObj.ast = strdup(pCreate->ast);
|
topicObj.ast = strdup(pCreate->ast);
|
||||||
|
|
|
@ -92,7 +92,7 @@ static int32_t sndProcessTaskDeployReq(SSnode *pNode, SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
|
||||||
pTask->status = TASK_STATUS__IDLE;
|
pTask->execStatus = TASK_EXEC_STATUS__IDLE;
|
||||||
|
|
||||||
pTask->inputQueue = streamQueueOpen();
|
pTask->inputQueue = streamQueueOpen();
|
||||||
pTask->outputQueue = streamQueueOpen();
|
pTask->outputQueue = streamQueueOpen();
|
||||||
|
@ -205,7 +205,7 @@ int32_t sndProcessUMsg(SSnode *pSnode, SRpcMsg *pMsg) {
|
||||||
switch (pMsg->msgType) {
|
switch (pMsg->msgType) {
|
||||||
case TDMT_STREAM_TASK_DEPLOY:
|
case TDMT_STREAM_TASK_DEPLOY:
|
||||||
return sndProcessTaskDeployReq(pSnode, pMsg);
|
return sndProcessTaskDeployReq(pSnode, pMsg);
|
||||||
case TDMT_VND_STREAM_TASK_DROP:
|
case TDMT_STREAM_TASK_DROP:
|
||||||
return sndProcessTaskDropReq(pSnode, pMsg);
|
return sndProcessTaskDropReq(pSnode, pMsg);
|
||||||
default:
|
default:
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
|
|
|
@ -114,6 +114,7 @@ typedef struct {
|
||||||
char subKey[TSDB_SUBSCRIBE_KEY_LEN];
|
char subKey[TSDB_SUBSCRIBE_KEY_LEN];
|
||||||
int64_t consumerId;
|
int64_t consumerId;
|
||||||
int32_t epoch;
|
int32_t epoch;
|
||||||
|
int8_t fetchMeta;
|
||||||
|
|
||||||
// reader
|
// reader
|
||||||
SWalReadHandle* pWalReader;
|
SWalReadHandle* pWalReader;
|
||||||
|
|
|
@ -85,6 +85,34 @@ void tqClose(STQ* pTq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tqSendMetaPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqMetaRsp* pRsp) {
|
||||||
|
int32_t tlen = sizeof(SMqRspHead) + tEncodeSMqMetaRsp(NULL, pRsp);
|
||||||
|
void* buf = rpcMallocCont(tlen);
|
||||||
|
if (buf == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
((SMqRspHead*)buf)->mqMsgType = TMQ_MSG_TYPE__POLL_META_RSP;
|
||||||
|
((SMqRspHead*)buf)->epoch = pReq->epoch;
|
||||||
|
((SMqRspHead*)buf)->consumerId = pReq->consumerId;
|
||||||
|
|
||||||
|
void* abuf = POINTER_SHIFT(buf, sizeof(SMqRspHead));
|
||||||
|
tEncodeSMqMetaRsp(&abuf, pRsp);
|
||||||
|
|
||||||
|
SRpcMsg resp = {
|
||||||
|
.info = pMsg->info,
|
||||||
|
.pCont = buf,
|
||||||
|
.contLen = tlen,
|
||||||
|
.code = 0,
|
||||||
|
};
|
||||||
|
tmsgSendRsp(&resp);
|
||||||
|
|
||||||
|
tqDebug("vg %d from consumer %ld (epoch %d) send rsp, res msg type %d, reqOffset: %ld, rspOffset: %ld",
|
||||||
|
TD_VID(pTq->pVnode), pReq->consumerId, pReq->epoch, pRsp->resMsgType, pRsp->reqOffset, pRsp->rspOffset);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tqSendPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataBlkRsp* pRsp) {
|
int32_t tqSendPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataBlkRsp* pRsp) {
|
||||||
int32_t tlen = sizeof(SMqRspHead) + tEncodeSMqDataBlkRsp(NULL, pRsp);
|
int32_t tlen = sizeof(SMqRspHead) + tEncodeSMqDataBlkRsp(NULL, pRsp);
|
||||||
void* buf = rpcMallocCont(tlen);
|
void* buf = rpcMallocCont(tlen);
|
||||||
|
@ -250,8 +278,23 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
/*ASSERT(0);*/
|
/*ASSERT(0);*/
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// TODO
|
ASSERT(pHandle->fetchMeta);
|
||||||
ASSERT(0);
|
ASSERT(pHead->msgType == TDMT_VND_CREATE_STB || pHead->msgType == TDMT_VND_ALTER_STB ||
|
||||||
|
pHead->msgType == TDMT_VND_DROP_STB || pHead->msgType == TDMT_VND_CREATE_TABLE ||
|
||||||
|
pHead->msgType == TDMT_VND_ALTER_TABLE || pHead->msgType == TDMT_VND_DROP_TABLE ||
|
||||||
|
pHead->msgType == TDMT_VND_DROP_TTL_TABLE);
|
||||||
|
// return
|
||||||
|
SMqMetaRsp metaRsp = {0};
|
||||||
|
metaRsp.reqOffset = pReq->currentOffset;
|
||||||
|
metaRsp.rspOffset = fetchOffset;
|
||||||
|
metaRsp.resMsgType = pHead->msgType;
|
||||||
|
metaRsp.metaRspLen = pHead->bodyLen;
|
||||||
|
metaRsp.metaRsp = pHead->body;
|
||||||
|
if (tqSendMetaPollRsp(pTq, pMsg, pReq, &metaRsp) < 0) {
|
||||||
|
code = -1;
|
||||||
|
}
|
||||||
|
code = 0;
|
||||||
|
goto OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO batch optimization:
|
// TODO batch optimization:
|
||||||
|
@ -276,7 +319,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
if (tqSendPollRsp(pTq, pMsg, pReq, &rsp) < 0) {
|
if (tqSendPollRsp(pTq, pMsg, pReq, &rsp) < 0) {
|
||||||
code = -1;
|
code = -1;
|
||||||
}
|
}
|
||||||
|
OVER:
|
||||||
// TODO wrap in destroy func
|
// TODO wrap in destroy func
|
||||||
taosArrayDestroy(rsp.blockDataLen);
|
taosArrayDestroy(rsp.blockDataLen);
|
||||||
taosArrayDestroyP(rsp.blockData, (FDelete)taosMemoryFree);
|
taosArrayDestroyP(rsp.blockData, (FDelete)taosMemoryFree);
|
||||||
|
@ -384,7 +427,7 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||||
}
|
}
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
|
||||||
pTask->status = TASK_STATUS__IDLE;
|
pTask->execStatus = TASK_EXEC_STATUS__IDLE;
|
||||||
|
|
||||||
pTask->inputQueue = streamQueueOpen();
|
pTask->inputQueue = streamQueueOpen();
|
||||||
pTask->outputQueue = streamQueueOpen();
|
pTask->outputQueue = streamQueueOpen();
|
||||||
|
@ -459,6 +502,9 @@ int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* pReq) {
|
||||||
pIter = taosHashIterate(pTq->pStreamTasks, pIter);
|
pIter = taosHashIterate(pTq->pStreamTasks, pIter);
|
||||||
if (pIter == NULL) break;
|
if (pIter == NULL) break;
|
||||||
SStreamTask* pTask = *(SStreamTask**)pIter;
|
SStreamTask* pTask = *(SStreamTask**)pIter;
|
||||||
|
if (atomic_load_8(&pTask->taskStatus) == TASK_STATUS__DROPPING) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (pTask->inputType != STREAM_INPUT__DATA_SUBMIT) continue;
|
if (pTask->inputType != STREAM_INPUT__DATA_SUBMIT) continue;
|
||||||
|
|
||||||
if (!failed) {
|
if (!failed) {
|
||||||
|
@ -487,6 +533,9 @@ int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
SStreamTaskRunReq* pReq = pMsg->pCont;
|
SStreamTaskRunReq* pReq = pMsg->pCont;
|
||||||
int32_t taskId = pReq->taskId;
|
int32_t taskId = pReq->taskId;
|
||||||
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||||
|
if (atomic_load_8(&pTask->taskStatus) != TASK_STATUS__NORMAL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
streamProcessRunReq(pTask);
|
streamProcessRunReq(pTask);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -501,9 +550,12 @@ int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
tDecodeStreamDispatchReq(&decoder, &req);
|
tDecodeStreamDispatchReq(&decoder, &req);
|
||||||
int32_t taskId = req.taskId;
|
int32_t taskId = req.taskId;
|
||||||
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||||
SRpcMsg rsp = {
|
if (atomic_load_8(&pTask->taskStatus) != TASK_STATUS__NORMAL) {
|
||||||
.info = pMsg->info,
|
return 0;
|
||||||
.code = 0,
|
}
|
||||||
|
SRpcMsg rsp = {
|
||||||
|
.info = pMsg->info,
|
||||||
|
.code = 0,
|
||||||
};
|
};
|
||||||
streamProcessDispatchReq(pTask, &req, &rsp);
|
streamProcessDispatchReq(pTask, &req, &rsp);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -513,6 +565,9 @@ int32_t tqProcessTaskRecoverReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
SStreamTaskRecoverReq* pReq = pMsg->pCont;
|
SStreamTaskRecoverReq* pReq = pMsg->pCont;
|
||||||
int32_t taskId = pReq->taskId;
|
int32_t taskId = pReq->taskId;
|
||||||
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||||
|
if (atomic_load_8(&pTask->taskStatus) != TASK_STATUS__NORMAL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
streamProcessRecoverReq(pTask, pReq, pMsg);
|
streamProcessRecoverReq(pTask, pReq, pMsg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -521,6 +576,9 @@ int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
SStreamDispatchRsp* pRsp = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
SStreamDispatchRsp* pRsp = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
||||||
int32_t taskId = pRsp->taskId;
|
int32_t taskId = pRsp->taskId;
|
||||||
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||||
|
if (atomic_load_8(&pTask->taskStatus) != TASK_STATUS__NORMAL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
streamProcessDispatchRsp(pTask, pRsp);
|
streamProcessDispatchRsp(pTask, pRsp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -529,16 +587,32 @@ int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
SStreamTaskRecoverRsp* pRsp = pMsg->pCont;
|
SStreamTaskRecoverRsp* pRsp = pMsg->pCont;
|
||||||
int32_t taskId = pRsp->taskId;
|
int32_t taskId = pRsp->taskId;
|
||||||
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||||
|
if (atomic_load_8(&pTask->taskStatus) != TASK_STATUS__NORMAL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
streamProcessRecoverRsp(pTask, pRsp);
|
streamProcessRecoverRsp(pTask, pRsp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqProcessTaskDropReq(STQ* pTq, char* msg, int32_t msgLen) {
|
int32_t tqProcessTaskDropReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||||
SVDropStreamTaskReq* pReq = (SVDropStreamTaskReq*)msg;
|
SVDropStreamTaskReq* pReq = (SVDropStreamTaskReq*)msg;
|
||||||
|
|
||||||
|
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &pReq->taskId, sizeof(int32_t));
|
||||||
|
atomic_store_8(&pTask->taskStatus, TASK_STATUS__DROPPING);
|
||||||
|
// todo
|
||||||
|
// clear queue
|
||||||
|
// push drop req into queue
|
||||||
|
// launch exec to free memory
|
||||||
|
// remove from hash
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#if 0
|
||||||
int32_t code = taosHashRemove(pTq->pStreamTasks, &pReq->taskId, sizeof(int32_t));
|
int32_t code = taosHashRemove(pTq->pStreamTasks, &pReq->taskId, sizeof(int32_t));
|
||||||
|
// set status dropping
|
||||||
ASSERT(code == 0);
|
ASSERT(code == 0);
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
// sendrsp
|
// sendrsp
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,9 +45,9 @@ static int32_t tqLoopExecFromQueue(STQ* pTq, STqHandle* pHandle, SStreamDataSubm
|
||||||
int32_t tqExecFromInputQ(STQ* pTq, STqHandle* pHandle) {
|
int32_t tqExecFromInputQ(STQ* pTq, STqHandle* pHandle) {
|
||||||
SMqDataBlkRsp rsp = {0};
|
SMqDataBlkRsp rsp = {0};
|
||||||
// 1. guard and set status executing
|
// 1. guard and set status executing
|
||||||
int8_t execStatus =
|
int8_t execStatus = atomic_val_compare_exchange_8(&pHandle->pushHandle.execStatus, TASK_EXEC_STATUS__IDLE,
|
||||||
atomic_val_compare_exchange_8(&pHandle->pushHandle.execStatus, TASK_STATUS__IDLE, TASK_STATUS__EXECUTING);
|
TASK_EXEC_STATUS__EXECUTING);
|
||||||
if (execStatus == TASK_STATUS__IDLE) {
|
if (execStatus == TASK_EXEC_STATUS__IDLE) {
|
||||||
SStreamDataSubmit* pSubmit = NULL;
|
SStreamDataSubmit* pSubmit = NULL;
|
||||||
// 2. check processedVer
|
// 2. check processedVer
|
||||||
// 2.1. if not missed, get msg from queue
|
// 2.1. if not missed, get msg from queue
|
||||||
|
@ -68,18 +68,18 @@ int32_t tqExecFromInputQ(STQ* pTq, STqHandle* pHandle) {
|
||||||
goto SEND_RSP;
|
goto SEND_RSP;
|
||||||
}
|
}
|
||||||
// set exec status closing
|
// set exec status closing
|
||||||
atomic_store_8(&pHandle->pushHandle.execStatus, TASK_STATUS__CLOSING);
|
atomic_store_8(&pHandle->pushHandle.execStatus, TASK_EXEC_STATUS__CLOSING);
|
||||||
// second run
|
// second run
|
||||||
if (tqLoopExecFromQueue(pTq, pHandle, &pSubmit, &rsp) == 0) {
|
if (tqLoopExecFromQueue(pTq, pHandle, &pSubmit, &rsp) == 0) {
|
||||||
goto SEND_RSP;
|
goto SEND_RSP;
|
||||||
}
|
}
|
||||||
// set exec status idle
|
// set exec status idle
|
||||||
atomic_store_8(&pHandle->pushHandle.execStatus, TASK_STATUS__IDLE);
|
atomic_store_8(&pHandle->pushHandle.execStatus, TASK_EXEC_STATUS__IDLE);
|
||||||
}
|
}
|
||||||
SEND_RSP:
|
SEND_RSP:
|
||||||
// 4. if get result
|
// 4. if get result
|
||||||
// 4.1 set exec input status blocked and exec status idle
|
// 4.1 set exec input status blocked and exec status idle
|
||||||
atomic_store_8(&pHandle->pushHandle.execStatus, TASK_STATUS__IDLE);
|
atomic_store_8(&pHandle->pushHandle.execStatus, TASK_EXEC_STATUS__IDLE);
|
||||||
// 4.2 rpc send
|
// 4.2 rpc send
|
||||||
rsp.rspOffset = pHandle->pushHandle.processedVer;
|
rsp.rspOffset = pHandle->pushHandle.processedVer;
|
||||||
/*if (tqSendPollRsp(pTq, pMsg, pReq, &rsp) < 0) {*/
|
/*if (tqSendPollRsp(pTq, pMsg, pReq, &rsp) < 0) {*/
|
||||||
|
@ -150,7 +150,7 @@ int32_t tqEnqueueAll(STQ* pTq, SSubmitReq* pReq) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int8_t execStatus = atomic_load_8(&pHandle->pushHandle.execStatus);
|
int8_t execStatus = atomic_load_8(&pHandle->pushHandle.execStatus);
|
||||||
if (execStatus == TASK_STATUS__IDLE || execStatus == TASK_STATUS__CLOSING) {
|
if (execStatus == TASK_EXEC_STATUS__IDLE || execStatus == TASK_EXEC_STATUS__CLOSING) {
|
||||||
tqSendExecReq(pTq, pHandle);
|
tqSendExecReq(pTq, pHandle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,25 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalHead*
|
||||||
code = 0;
|
code = 0;
|
||||||
goto END;
|
goto END;
|
||||||
} else {
|
} else {
|
||||||
|
if (pHandle->fetchMeta) {
|
||||||
|
SWalReadHead* pHead = &((*ppHeadWithCkSum)->head);
|
||||||
|
if (pHead->msgType == TDMT_VND_CREATE_STB || pHead->msgType == TDMT_VND_ALTER_STB ||
|
||||||
|
pHead->msgType == TDMT_VND_DROP_STB || pHead->msgType == TDMT_VND_CREATE_TABLE ||
|
||||||
|
pHead->msgType == TDMT_VND_ALTER_TABLE || pHead->msgType == TDMT_VND_DROP_TABLE ||
|
||||||
|
pHead->msgType == TDMT_VND_DROP_TTL_TABLE) {
|
||||||
|
code = walFetchBody(pHandle->pWalReader, ppHeadWithCkSum);
|
||||||
|
|
||||||
|
if (code < 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
*fetchOffset = offset;
|
||||||
|
code = -1;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
*fetchOffset = offset;
|
||||||
|
code = 0;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
}
|
||||||
code = walSkipFetchBody(pHandle->pWalReader, *ppHeadWithCkSum);
|
code = walSkipFetchBody(pHandle->pWalReader, *ppHeadWithCkSum);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
|
|
|
@ -172,7 +172,7 @@ int32_t vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case TDMT_VND_STREAM_TASK_DROP: {
|
case TDMT_STREAM_TASK_DROP: {
|
||||||
if (tqProcessTaskDropReq(pVnode->pTq, pMsg->pCont, pMsg->contLen) < 0) {
|
if (tqProcessTaskDropReq(pVnode->pTq, pMsg->pCont, pMsg->contLen) < 0) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,10 @@ void streamCleanUp() {
|
||||||
void streamTriggerByTimer(void* param, void* tmrId) {
|
void streamTriggerByTimer(void* param, void* tmrId) {
|
||||||
SStreamTask* pTask = (void*)param;
|
SStreamTask* pTask = (void*)param;
|
||||||
|
|
||||||
|
if (atomic_load_8(&pTask->taskStatus) == TASK_STATUS__DROPPING) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (atomic_load_8(&pTask->triggerStatus) == TASK_TRIGGER_STATUS__ACTIVE) {
|
if (atomic_load_8(&pTask->triggerStatus) == TASK_TRIGGER_STATUS__ACTIVE) {
|
||||||
SStreamTrigger* trigger = taosAllocateQitem(sizeof(SStreamTrigger), DEF_QITEM);
|
SStreamTrigger* trigger = taosAllocateQitem(sizeof(SStreamTrigger), DEF_QITEM);
|
||||||
if (trigger == NULL) return;
|
if (trigger == NULL) return;
|
||||||
|
@ -82,8 +86,8 @@ int32_t streamSetupTrigger(SStreamTask* pTask) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t streamLaunchByWrite(SStreamTask* pTask, int32_t vgId) {
|
int32_t streamLaunchByWrite(SStreamTask* pTask, int32_t vgId) {
|
||||||
int8_t execStatus = atomic_load_8(&pTask->status);
|
int8_t execStatus = atomic_load_8(&pTask->execStatus);
|
||||||
if (execStatus == TASK_STATUS__IDLE || execStatus == TASK_STATUS__CLOSING) {
|
if (execStatus == TASK_EXEC_STATUS__IDLE || execStatus == TASK_EXEC_STATUS__CLOSING) {
|
||||||
SStreamTaskRunReq* pRunReq = rpcMallocCont(sizeof(SStreamTaskRunReq));
|
SStreamTaskRunReq* pRunReq = rpcMallocCont(sizeof(SStreamTaskRunReq));
|
||||||
if (pRunReq == NULL) return -1;
|
if (pRunReq == NULL) return -1;
|
||||||
|
|
||||||
|
@ -188,6 +192,7 @@ int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp) {
|
||||||
|
|
||||||
int32_t streamProcessRunReq(SStreamTask* pTask) {
|
int32_t streamProcessRunReq(SStreamTask* pTask) {
|
||||||
streamExec(pTask, pTask->pMsgCb);
|
streamExec(pTask, pTask->pMsgCb);
|
||||||
|
|
||||||
if (pTask->dispatchType != TASK_DISPATCH__NONE) {
|
if (pTask->dispatchType != TASK_DISPATCH__NONE) {
|
||||||
streamDispatch(pTask, pTask->pMsgCb);
|
streamDispatch(pTask, pTask->pMsgCb);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,9 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, void* data, SArray* pRes)
|
||||||
ASSERT(pTask->inputType == STREAM_INPUT__DATA_BLOCK);
|
ASSERT(pTask->inputType == STREAM_INPUT__DATA_BLOCK);
|
||||||
SArray* blocks = pBlock->blocks;
|
SArray* blocks = pBlock->blocks;
|
||||||
qSetMultiStreamInput(exec, blocks->pData, blocks->size, STREAM_DATA_TYPE_SSDATA_BLOCK, false);
|
qSetMultiStreamInput(exec, blocks->pData, blocks->size, STREAM_DATA_TYPE_SSDATA_BLOCK, false);
|
||||||
|
} else if (pItem->type == STREAM_INPUT__DROP) {
|
||||||
|
// TODO exec drop
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// exec
|
// exec
|
||||||
|
@ -58,6 +61,10 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) {
|
||||||
|
|
||||||
streamTaskExecImpl(pTask, data, pRes);
|
streamTaskExecImpl(pTask, data, pRes);
|
||||||
|
|
||||||
|
if (pTask->taskStatus == TASK_STATUS__DROPPING) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (taosArrayGetSize(pRes) != 0) {
|
if (taosArrayGetSize(pRes) != 0) {
|
||||||
SStreamDataBlock* qRes = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM);
|
SStreamDataBlock* qRes = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM);
|
||||||
if (qRes == NULL) {
|
if (qRes == NULL) {
|
||||||
|
@ -75,12 +82,17 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTask->inputType == STREAM_INPUT__DATA_SUBMIT) {
|
if (((SStreamQueueItem*)data)->type == STREAM_INPUT__TRIGGER) {
|
||||||
streamDataSubmitRefDec((SStreamDataSubmit*)data);
|
blockDataDestroy(((SStreamTrigger*)data)->pBlock);
|
||||||
taosFreeQitem(data);
|
taosFreeQitem(data);
|
||||||
} else {
|
} else {
|
||||||
taosArrayDestroyEx(((SStreamDataBlock*)data)->blocks, (FDelete)tDeleteSSDataBlock);
|
if (pTask->inputType == STREAM_INPUT__DATA_SUBMIT) {
|
||||||
taosFreeQitem(data);
|
streamDataSubmitRefDec((SStreamDataSubmit*)data);
|
||||||
|
taosFreeQitem(data);
|
||||||
|
} else {
|
||||||
|
taosArrayDestroyEx(((SStreamDataBlock*)data)->blocks, (FDelete)tDeleteSSDataBlock);
|
||||||
|
taosFreeQitem(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
streamQueueProcessSuccess(pTask->inputQueue);
|
streamQueueProcessSuccess(pTask->inputQueue);
|
||||||
return taosArrayInit(0, sizeof(SSDataBlock));
|
return taosArrayInit(0, sizeof(SSDataBlock));
|
||||||
|
@ -94,25 +106,26 @@ int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb) {
|
||||||
SArray* pRes = taosArrayInit(0, sizeof(SSDataBlock));
|
SArray* pRes = taosArrayInit(0, sizeof(SSDataBlock));
|
||||||
if (pRes == NULL) return -1;
|
if (pRes == NULL) return -1;
|
||||||
while (1) {
|
while (1) {
|
||||||
int8_t execStatus = atomic_val_compare_exchange_8(&pTask->status, TASK_STATUS__IDLE, TASK_STATUS__EXECUTING);
|
int8_t execStatus =
|
||||||
if (execStatus == TASK_STATUS__IDLE) {
|
atomic_val_compare_exchange_8(&pTask->execStatus, TASK_EXEC_STATUS__IDLE, TASK_EXEC_STATUS__EXECUTING);
|
||||||
|
if (execStatus == TASK_EXEC_STATUS__IDLE) {
|
||||||
// first run
|
// first run
|
||||||
pRes = streamExecForQall(pTask, pRes);
|
pRes = streamExecForQall(pTask, pRes);
|
||||||
if (pRes == NULL) goto FAIL;
|
if (pRes == NULL) goto FAIL;
|
||||||
|
|
||||||
// set status closing
|
// set status closing
|
||||||
atomic_store_8(&pTask->status, TASK_STATUS__CLOSING);
|
atomic_store_8(&pTask->execStatus, TASK_EXEC_STATUS__CLOSING);
|
||||||
|
|
||||||
// second run, make sure inputQ and qall are cleared
|
// second run, make sure inputQ and qall are cleared
|
||||||
pRes = streamExecForQall(pTask, pRes);
|
pRes = streamExecForQall(pTask, pRes);
|
||||||
if (pRes == NULL) goto FAIL;
|
if (pRes == NULL) goto FAIL;
|
||||||
|
|
||||||
taosArrayDestroy(pRes);
|
taosArrayDestroy(pRes);
|
||||||
atomic_store_8(&pTask->status, TASK_STATUS__IDLE);
|
atomic_store_8(&pTask->execStatus, TASK_EXEC_STATUS__IDLE);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (execStatus == TASK_STATUS__CLOSING) {
|
} else if (execStatus == TASK_EXEC_STATUS__CLOSING) {
|
||||||
continue;
|
continue;
|
||||||
} else if (execStatus == TASK_STATUS__EXECUTING) {
|
} else if (execStatus == TASK_EXEC_STATUS__EXECUTING) {
|
||||||
ASSERT(taosArrayGetSize(pRes) == 0);
|
ASSERT(taosArrayGetSize(pRes) == 0);
|
||||||
taosArrayDestroy(pRes);
|
taosArrayDestroy(pRes);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -122,7 +135,7 @@ int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb) {
|
||||||
}
|
}
|
||||||
FAIL:
|
FAIL:
|
||||||
if (pRes) taosArrayDestroy(pRes);
|
if (pRes) taosArrayDestroy(pRes);
|
||||||
atomic_store_8(&pTask->status, TASK_STATUS__IDLE);
|
atomic_store_8(&pTask->execStatus, TASK_EXEC_STATUS__IDLE);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ SStreamTask* tNewSStreamTask(int64_t streamId) {
|
||||||
}
|
}
|
||||||
pTask->taskId = tGenIdPI32();
|
pTask->taskId = tGenIdPI32();
|
||||||
pTask->streamId = streamId;
|
pTask->streamId = streamId;
|
||||||
pTask->status = TASK_STATUS__IDLE;
|
pTask->execStatus = TASK_EXEC_STATUS__IDLE;
|
||||||
pTask->inputStatus = TASK_INPUT_STATUS__NORMAL;
|
pTask->inputStatus = TASK_INPUT_STATUS__NORMAL;
|
||||||
pTask->outputStatus = TASK_OUTPUT_STATUS__NORMAL;
|
pTask->outputStatus = TASK_OUTPUT_STATUS__NORMAL;
|
||||||
|
|
||||||
|
@ -35,7 +35,8 @@ int32_t tEncodeSStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) {
|
||||||
if (tEncodeI64(pEncoder, pTask->streamId) < 0) return -1;
|
if (tEncodeI64(pEncoder, pTask->streamId) < 0) return -1;
|
||||||
if (tEncodeI32(pEncoder, pTask->taskId) < 0) return -1;
|
if (tEncodeI32(pEncoder, pTask->taskId) < 0) return -1;
|
||||||
if (tEncodeI8(pEncoder, pTask->inputType) < 0) return -1;
|
if (tEncodeI8(pEncoder, pTask->inputType) < 0) return -1;
|
||||||
if (tEncodeI8(pEncoder, pTask->status) < 0) return -1;
|
if (tEncodeI8(pEncoder, pTask->taskStatus) < 0) return -1;
|
||||||
|
if (tEncodeI8(pEncoder, pTask->execStatus) < 0) return -1;
|
||||||
if (tEncodeI8(pEncoder, pTask->execType) < 0) return -1;
|
if (tEncodeI8(pEncoder, pTask->execType) < 0) return -1;
|
||||||
if (tEncodeI8(pEncoder, pTask->sinkType) < 0) return -1;
|
if (tEncodeI8(pEncoder, pTask->sinkType) < 0) return -1;
|
||||||
if (tEncodeI8(pEncoder, pTask->dispatchType) < 0) return -1;
|
if (tEncodeI8(pEncoder, pTask->dispatchType) < 0) return -1;
|
||||||
|
@ -83,7 +84,8 @@ int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
|
||||||
if (tDecodeI64(pDecoder, &pTask->streamId) < 0) return -1;
|
if (tDecodeI64(pDecoder, &pTask->streamId) < 0) return -1;
|
||||||
if (tDecodeI32(pDecoder, &pTask->taskId) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pTask->taskId) < 0) return -1;
|
||||||
if (tDecodeI8(pDecoder, &pTask->inputType) < 0) return -1;
|
if (tDecodeI8(pDecoder, &pTask->inputType) < 0) return -1;
|
||||||
if (tDecodeI8(pDecoder, &pTask->status) < 0) return -1;
|
if (tDecodeI8(pDecoder, &pTask->taskStatus) < 0) return -1;
|
||||||
|
if (tDecodeI8(pDecoder, &pTask->execStatus) < 0) return -1;
|
||||||
if (tDecodeI8(pDecoder, &pTask->execType) < 0) return -1;
|
if (tDecodeI8(pDecoder, &pTask->execType) < 0) return -1;
|
||||||
if (tDecodeI8(pDecoder, &pTask->sinkType) < 0) return -1;
|
if (tDecodeI8(pDecoder, &pTask->sinkType) < 0) return -1;
|
||||||
if (tDecodeI8(pDecoder, &pTask->dispatchType) < 0) return -1;
|
if (tDecodeI8(pDecoder, &pTask->dispatchType) < 0) return -1;
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# basic data type boundary
|
||||||
|
TINYINT_MAX = 127
|
||||||
|
TINYINT_MIN = -128
|
||||||
|
|
||||||
|
TINYINT_UN_MAX = 255
|
||||||
|
TINYINT_UN_MIN = 0
|
||||||
|
|
||||||
|
SMALLINT_MAX = 32767
|
||||||
|
SMALLINT_MIN = -32768
|
||||||
|
|
||||||
|
SMALLINT_UN_MAX = 65535
|
||||||
|
MALLINT_UN_MIN = 0
|
||||||
|
|
||||||
|
INT_MAX = 2147483647
|
||||||
|
INT_MIN = -2147483648
|
||||||
|
|
||||||
|
INT_UN_MAX = 4294967295
|
||||||
|
INT_UN_MIN = 0
|
||||||
|
|
||||||
|
BIGINT_MAX = 9223372036854775807
|
||||||
|
BIGINT_MIN = -9223372036854775808
|
||||||
|
|
||||||
|
BIGINT_UN_MAX = 18446744073709551615
|
||||||
|
BIGINT_UN_MIN = 0
|
||||||
|
|
||||||
|
FLOAT_MAX = 3.40E+38
|
||||||
|
FLOAT_MIN = -3.40E+38
|
||||||
|
|
||||||
|
DOUBLE_MAX = 1.7E+308
|
||||||
|
DOUBLE_MIN = -1.7E+308
|
||||||
|
|
||||||
|
# schema boundary
|
||||||
|
BINARY_LENGTH_MAX = 16374
|
||||||
|
NCAHR_LENGTH_MAX_ = 4093
|
||||||
|
DBNAME_LENGTH_MAX_ = 64
|
||||||
|
|
||||||
|
STBNAME_LENGTH_MAX = 192
|
||||||
|
STBNAME_LENGTH_MIN = 1
|
||||||
|
|
||||||
|
TBNAME_LENGTH_MAX = 192
|
||||||
|
TBNAME_LENGTH_MIN = 1
|
||||||
|
|
||||||
|
CHILD_TBNAME_LENGTH_MAX = 192
|
||||||
|
CHILD_TBNAME_LENGTH_MIN = 1
|
||||||
|
|
||||||
|
TAG_NAME_LENGTH_MAX = 64
|
||||||
|
TAG_NAME_LENGTH_MIN = 1
|
||||||
|
|
||||||
|
COL_NAME_LENGTH_MAX = 64
|
||||||
|
COL_NAME_LENGTH_MIN = 1
|
||||||
|
|
||||||
|
TAG_COUNT_MAX = 128
|
||||||
|
TAG_COUNT_MIN = 1
|
||||||
|
|
||||||
|
COL_COUNT_MAX = 4096
|
||||||
|
COL_COUNT_MIN = 2
|
||||||
|
|
||||||
|
TAG_COL_COUNT_MAX = 4096
|
||||||
|
TAG_COL_COUNT_MIN = 3
|
||||||
|
|
||||||
|
MNODE_SHM_SIZE_MAX = 2147483647
|
||||||
|
MNODE_SHM_SIZE_MIN = 6292480
|
||||||
|
MNODE_SHM_SIZE_DEFAULT = 6292480
|
||||||
|
|
||||||
|
VNODE_SHM_SIZE_MAX = 2147483647
|
||||||
|
VNODE_SHM_SIZE_MIN = 6292480
|
||||||
|
VNODE_SHM_SIZE_DEFAULT = 31458304
|
|
@ -61,7 +61,7 @@ class TDSql:
|
||||||
self.cursor.execute(s)
|
self.cursor.execute(s)
|
||||||
s = 'use db'
|
s = 'use db'
|
||||||
self.cursor.execute(s)
|
self.cursor.execute(s)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
def error(self, sql):
|
def error(self, sql):
|
||||||
expectErrNotOccured = True
|
expectErrNotOccured = True
|
||||||
|
@ -249,7 +249,7 @@ class TDSql:
|
||||||
raise Exception(repr(e))
|
raise Exception(repr(e))
|
||||||
return self.queryResult
|
return self.queryResult
|
||||||
|
|
||||||
|
|
||||||
def executeTimes(self, sql, times):
|
def executeTimes(self, sql, times):
|
||||||
for i in range(times):
|
for i in range(times):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
from dataclasses import dataclass
|
||||||
|
from typing import List
|
||||||
from util.log import *
|
from util.log import *
|
||||||
from util.sql import *
|
from util.sql import *
|
||||||
from util.cases import *
|
from util.cases import *
|
||||||
|
@ -28,6 +30,28 @@ CHAR_COL = [ BINARY_COL, NCHAR_COL, ]
|
||||||
BOOLEAN_COL = [ BOOL_COL, ]
|
BOOLEAN_COL = [ BOOL_COL, ]
|
||||||
TS_TYPE_COL = [ TS_COL, ]
|
TS_TYPE_COL = [ TS_COL, ]
|
||||||
|
|
||||||
|
## insert data args:
|
||||||
|
TIME_STEP = 10000
|
||||||
|
NOW = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class DataSet:
|
||||||
|
ts_data : List[int] = None
|
||||||
|
int_data : List[int] = None
|
||||||
|
bint_data : List[int] = None
|
||||||
|
sint_data : List[int] = None
|
||||||
|
tint_data : List[int] = None
|
||||||
|
int_un_data : List[int] = None
|
||||||
|
bint_un_data : List[int] = None
|
||||||
|
sint_un_data : List[int] = None
|
||||||
|
tint_un_data : List[int] = None
|
||||||
|
float_data : List[float] = None
|
||||||
|
double_data : List[float] = None
|
||||||
|
bool_data : List[int] = None
|
||||||
|
binary_data : List[str] = None
|
||||||
|
nchar_data : List[str] = None
|
||||||
|
|
||||||
|
|
||||||
class TDTestCase:
|
class TDTestCase:
|
||||||
|
|
||||||
def init(self, conn, logSql):
|
def init(self, conn, logSql):
|
||||||
|
@ -37,10 +61,13 @@ class TDTestCase:
|
||||||
@property
|
@property
|
||||||
def create_databases_sql_err(self):
|
def create_databases_sql_err(self):
|
||||||
return [
|
return [
|
||||||
"create database if not exists db1 retentions 0s:1d",
|
"create database db1 retentions 0s:1d",
|
||||||
"create database if not exists db1 retentions 1s:1y",
|
"create database db3 retentions 1s:0d",
|
||||||
"create database if not exists db1 retentions 1s:1n",
|
"create database db1 retentions 1s:1y",
|
||||||
"create database if not exists db1 retentions 1s:1n,2s:2d,3s:3d,4s:4d",
|
"create database db1 retentions 1s:1n",
|
||||||
|
"create database db2 retentions 1w:1d ;",
|
||||||
|
"create database db5 retentions 1s:1d,3s:3d,2s:2d",
|
||||||
|
"create database db1 retentions 1s:1n,2s:2d,3s:3d,4s:4d",
|
||||||
]
|
]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -60,16 +87,41 @@ class TDTestCase:
|
||||||
@property
|
@property
|
||||||
def create_stable_sql_err(self):
|
def create_stable_sql_err(self):
|
||||||
return [
|
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(ceil) watermark 1s maxdelay 1m",
|
||||||
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(count) delay 1",
|
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(count) watermark 1min",
|
||||||
f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} binary(16)) tags (tag1 int) rollup(avg) delay 1",
|
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay -1s",
|
||||||
f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) tags (tag1 int) rollup(avg) delay 1",
|
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark -1m",
|
||||||
|
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) watermark 1m ",
|
||||||
|
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) maxdelay 1m ",
|
||||||
|
f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} binary(16)) tags (tag1 int) rollup(avg) watermark 1s",
|
||||||
|
f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) tags (tag1 int) rollup(avg) maxdelay 1m",
|
||||||
|
# f"create table ntb_1 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) rollup(avg) watermark 1s maxdelay 1s",
|
||||||
|
# f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) tags (tag1 int) " ,
|
||||||
|
# f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) " ,
|
||||||
|
# f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int) " ,
|
||||||
|
# f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) " ,
|
||||||
|
|
||||||
|
# watermark, maxdelay: [0, 900000], [ms, s, m, ?]
|
||||||
|
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay 1u",
|
||||||
|
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 1b",
|
||||||
|
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 900001ms",
|
||||||
|
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay 16m",
|
||||||
|
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay 901s",
|
||||||
|
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay 1h",
|
||||||
|
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay 0.2h",
|
||||||
|
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 0.002d",
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def create_stable_sql_current(self):
|
def create_stable_sql_current(self):
|
||||||
return [
|
return [
|
||||||
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(avg) delay 5",
|
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(avg)",
|
||||||
|
f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 5s maxdelay 1m",
|
||||||
|
f"create stable stb3 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(max) watermark 5s maxdelay 1m",
|
||||||
|
f"create stable stb4 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(sum) watermark 5s maxdelay 1m",
|
||||||
|
# f"create stable stb5 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(last) watermark 5s maxdelay 1m",
|
||||||
|
# f"create stable stb6 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(first) watermark 5s maxdelay 1m",
|
||||||
]
|
]
|
||||||
|
|
||||||
def test_create_stb(self):
|
def test_create_stb(self):
|
||||||
|
@ -79,14 +131,19 @@ class TDTestCase:
|
||||||
for cur_sql in self.create_stable_sql_current:
|
for cur_sql in self.create_stable_sql_current:
|
||||||
tdSql.execute(cur_sql)
|
tdSql.execute(cur_sql)
|
||||||
tdSql.query("show stables")
|
tdSql.query("show stables")
|
||||||
|
# assert "rollup" in tdSql.description
|
||||||
tdSql.checkRows(len(self.create_stable_sql_current))
|
tdSql.checkRows(len(self.create_stable_sql_current))
|
||||||
|
|
||||||
|
# tdSql.execute("use db") # because db is a noraml database, not a rollup database, should not be able to create a rollup database
|
||||||
|
# tdSql.error(f"create stable nor_db_rollup_stb ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) file_factor 5.0")
|
||||||
|
|
||||||
|
|
||||||
def test_create_databases(self):
|
def test_create_databases(self):
|
||||||
for err_sql in self.create_databases_sql_err:
|
for err_sql in self.create_databases_sql_err:
|
||||||
tdSql.error(err_sql)
|
tdSql.error(err_sql)
|
||||||
for cur_sql in self.create_databases_sql_current:
|
for cur_sql in self.create_databases_sql_current:
|
||||||
tdSql.execute(cur_sql)
|
tdSql.execute(cur_sql)
|
||||||
tdSql.query("show databases")
|
# tdSql.query("show databases")
|
||||||
for alter_sql in self.alter_database_sql:
|
for alter_sql in self.alter_database_sql:
|
||||||
tdSql.error(alter_sql)
|
tdSql.error(alter_sql)
|
||||||
|
|
||||||
|
@ -95,9 +152,7 @@ class TDTestCase:
|
||||||
self.test_create_stb()
|
self.test_create_stb()
|
||||||
|
|
||||||
def __create_tb(self):
|
def __create_tb(self):
|
||||||
tdSql.prepare()
|
tdLog.printNoPrefix("==========step: create table")
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step1:create table")
|
|
||||||
create_stb_sql = f'''create table stb1(
|
create_stb_sql = f'''create table stb1(
|
||||||
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
||||||
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
|
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
|
||||||
|
@ -120,129 +175,118 @@ class TDTestCase:
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
|
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
|
||||||
|
|
||||||
def __create_data_set(self, rows):
|
def __data_set(self, rows):
|
||||||
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
|
data_set = DataSet()
|
||||||
pos_data = []
|
# neg_data_set = DataSet()
|
||||||
neg_data = []
|
data_set.ts_data = []
|
||||||
spec_data = []
|
data_set.int_data = []
|
||||||
for i in range(rows):
|
data_set.bint_data = []
|
||||||
pos_data.append(
|
data_set.sint_data = []
|
||||||
(
|
data_set.tint_data = []
|
||||||
now_time - i * 1000, i, 11111 * i, 111 * i % 32767 , 11 * i % 127, 1.11 * i, 1100.0011 * i,
|
data_set.int_un_data = []
|
||||||
i % 2, f'binary{i}', f'nchar_测试_{i}', now_time + 1 * i, 11 * i % 127, 111 * i % 32767, i, 11111 * i
|
data_set.bint_un_data = []
|
||||||
)
|
data_set.sint_un_data = []
|
||||||
)
|
data_set.tint_un_data = []
|
||||||
neg_data.append(
|
data_set.float_data = []
|
||||||
(
|
data_set.double_data = []
|
||||||
now_time - i * 7776000000, -i, -11111 * i, -111 * i % 32767, -11 * i % 127, -1.11 * i, -1100.0011 * i,
|
data_set.bool_data = []
|
||||||
i % 2, f'binary{i}', f'nchar_测试_{i}', now_time + 1 * i, 11 * i % 127, 111 * i % 32767, i, 11111 * i
|
data_set.binary_data = []
|
||||||
)
|
data_set.nchar_data = []
|
||||||
)
|
|
||||||
|
|
||||||
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):
|
for i in range(rows):
|
||||||
insert_data = f'''insert into t1 values
|
data_set.ts_data.append(NOW + 1 * (rows - i))
|
||||||
( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2},
|
data_set.int_data.append(rows - i)
|
||||||
"binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i }, {i % 127}, {i % 32767}, {i}, {i * 11111})
|
data_set.bint_data.append(11111 * (rows - i))
|
||||||
'''
|
data_set.sint_data.append(111 * (rows - i) % 32767)
|
||||||
tdSql.execute(insert_data)
|
data_set.tint_data.append(11 * (rows - i) % 127)
|
||||||
tdSql.execute(
|
data_set.int_un_data.append(rows - i)
|
||||||
f'''insert into t1 values
|
data_set.bint_un_data.append(11111 * (rows - i))
|
||||||
( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
data_set.sint_un_data.append(111 * (rows - i) % 32767)
|
||||||
( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
|
data_set.tint_un_data.append(11 * (rows - i) % 127)
|
||||||
( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
data_set.float_data.append(1.11 * (rows - i))
|
||||||
(
|
data_set.double_data.append(1100.0011 * (rows - i))
|
||||||
{ now_time + 7200000 }, { pow(2,31) - pow(2,15) }, { pow(2,63) - pow(2,30) }, 32767, 127, { 3.3 * pow(10,38) },
|
data_set.bool_data.append((rows - i) % 2)
|
||||||
{ 1.3 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 },
|
data_set.binary_data.append(f'binary{(rows - i)}')
|
||||||
254, 65534, {pow(2,32)-pow(2,16)}, {pow(2,64)-pow(2,31)}
|
data_set.nchar_data.append(f'nchar_测试_{(rows - i)}')
|
||||||
)
|
|
||||||
(
|
# neg_data_set.ts_data.append(-1 * i)
|
||||||
{ now_time + 3600000 } , { pow(2,31) - pow(2,16) }, { pow(2,63) - pow(2,31) }, 32766, 126, { 3.2 * pow(10,38) },
|
# neg_data_set.int_data.append(-i)
|
||||||
{ 1.2 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 },
|
# neg_data_set.bint_data.append(-11111 * i)
|
||||||
255, 65535, {pow(2,32)-pow(2,15)}, {pow(2,64)-pow(2,30)}
|
# neg_data_set.sint_data.append(-111 * i % 32767)
|
||||||
)
|
# neg_data_set.tint_data.append(-11 * i % 127)
|
||||||
|
# neg_data_set.int_un_data.append(-i)
|
||||||
|
# neg_data_set.bint_un_data.append(-11111 * i)
|
||||||
|
# neg_data_set.sint_un_data.append(-111 * i % 32767)
|
||||||
|
# neg_data_set.tint_un_data.append(-11 * i % 127)
|
||||||
|
# neg_data_set.float_data.append(-1.11 * i)
|
||||||
|
# neg_data_set.double_data.append(-1100.0011 * i)
|
||||||
|
# neg_data_set.binary_data.append(f'binary{i}')
|
||||||
|
# neg_data_set.nchar_data.append(f'nchar_测试_{i}')
|
||||||
|
|
||||||
|
return data_set
|
||||||
|
|
||||||
|
def __insert_data(self):
|
||||||
|
data = self.__data_set(rows=self.rows)
|
||||||
|
|
||||||
|
# now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
|
||||||
|
null_data = '''null, null, null, null, null, null, null, null, null, null, null, null, null, null'''
|
||||||
|
zero_data = "0, 0, 0, 0, 0, 0, 0, 'binary_0', 'nchar_0', 0, 0, 0, 0, 0"
|
||||||
|
|
||||||
|
for i in range(self.rows):
|
||||||
|
row_data = f'''
|
||||||
|
{data.int_data[i]}, {data.bint_data[i]}, {data.sint_data[i]}, {data.tint_data[i]}, {data.float_data[i]}, {data.double_data[i]},
|
||||||
|
{data.bool_data[i]}, '{data.binary_data[i]}', '{data.nchar_data[i]}', {data.ts_data[i]}, {data.tint_un_data[i]},
|
||||||
|
{data.sint_un_data[i]}, {data.int_un_data[i]}, {data.bint_un_data[i]}
|
||||||
'''
|
'''
|
||||||
)
|
neg_row_data = f'''
|
||||||
|
{-1 * data.int_data[i]}, {-1 * data.bint_data[i]}, {-1 * data.sint_data[i]}, {-1 * data.tint_data[i]}, {-1 * data.float_data[i]}, {-1 * data.double_data[i]},
|
||||||
|
{data.bool_data[i]}, '{data.binary_data[i]}', '{data.nchar_data[i]}', {data.ts_data[i]}, {1 * data.tint_un_data[i]},
|
||||||
|
{1 * data.sint_un_data[i]}, {1 * data.int_un_data[i]}, {1 * data.bint_un_data[i]}
|
||||||
|
'''
|
||||||
|
|
||||||
|
tdSql.execute( f"insert into ct1 values ( {NOW - i * TIME_STEP}, {row_data} )" )
|
||||||
|
tdSql.execute( f"insert into ct2 values ( {NOW - i * int(TIME_STEP * 0.6)}, {neg_row_data} )" )
|
||||||
|
tdSql.execute( f"insert into ct4 values ( {NOW - i * int(TIME_STEP * 0.8) }, {row_data} )" )
|
||||||
|
tdSql.execute( f"insert into t1 values ( {NOW - i * int(TIME_STEP * 1.2)}, {row_data} )" )
|
||||||
|
|
||||||
|
tdSql.execute( f"insert into ct2 values ( {NOW + int(TIME_STEP * 0.6)}, {null_data} )" )
|
||||||
|
tdSql.execute( f"insert into ct2 values ( {NOW - (self.rows + 1) * int(TIME_STEP * 0.6)}, {null_data} )" )
|
||||||
|
tdSql.execute( f"insert into ct2 values ( {NOW - self.rows * int(TIME_STEP * 0.29) }, {null_data} )" )
|
||||||
|
|
||||||
|
tdSql.execute( f"insert into ct4 values ( {NOW + int(TIME_STEP * 0.8)}, {null_data} )" )
|
||||||
|
tdSql.execute( f"insert into ct4 values ( {NOW - (self.rows + 1) * int(TIME_STEP * 0.8)}, {null_data} )" )
|
||||||
|
tdSql.execute( f"insert into ct4 values ( {NOW - self.rows * int(TIME_STEP * 0.39)}, {null_data} )" )
|
||||||
|
|
||||||
|
tdSql.execute( f"insert into t1 values ( {NOW + int(TIME_STEP * 1.2)}, {null_data} )" )
|
||||||
|
tdSql.execute( f"insert into t1 values ( {NOW - (self.rows + 1) * int(TIME_STEP * 1.2)}, {null_data} )" )
|
||||||
|
tdSql.execute( f"insert into t1 values ( {NOW - self.rows * int(TIME_STEP * 0.59)}, {null_data} )" )
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
tdSql.prepare()
|
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step1:create table")
|
|
||||||
self.__create_tb()
|
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step2:insert data")
|
|
||||||
self.rows = 10
|
self.rows = 10
|
||||||
self.__insert_data(self.rows)
|
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step3:all check")
|
|
||||||
self.all_test()
|
tdLog.printNoPrefix("==========step0:all check")
|
||||||
|
# self.all_test()
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("==========step1:create table in normal database")
|
||||||
|
tdSql.prepare()
|
||||||
|
self.__create_tb()
|
||||||
|
self.__insert_data()
|
||||||
|
# return
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("==========step2:create table in rollup database")
|
||||||
|
tdSql.execute("create database db3 retentions 1s:4m,2s:8m,3s:12m")
|
||||||
|
tdSql.execute("use db3")
|
||||||
|
self.__create_tb()
|
||||||
|
self.__insert_data()
|
||||||
|
|
||||||
tdSql.execute("drop database if exists db1 ")
|
tdSql.execute("drop database if exists db1 ")
|
||||||
tdSql.execute("drop database if exists db2 ")
|
tdSql.execute("drop database if exists db2 ")
|
||||||
|
|
||||||
tdDnodes.stop(1)
|
tdDnodes.stop(1)
|
||||||
tdDnodes.start(1)
|
tdDnodes.start(1)
|
||||||
|
|
||||||
tdSql.execute("use db")
|
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
||||||
self.all_test()
|
self.all_test()
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,343 @@
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
from dataclasses import dataclass
|
||||||
|
from typing import List, Any, Tuple
|
||||||
|
from util.log import *
|
||||||
|
from util.sql import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.dnodes import *
|
||||||
|
from util.constant 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 = "c_binary"
|
||||||
|
NCHAR_COL = "c_nchar"
|
||||||
|
TS_COL = "c_ts"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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, ]
|
||||||
|
|
||||||
|
# insert data args:
|
||||||
|
TIME_STEP = 10000
|
||||||
|
NOW = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class DataSet:
|
||||||
|
ts_data : List[int] = None
|
||||||
|
int_data : List[int] = None
|
||||||
|
bint_data : List[int] = None
|
||||||
|
sint_data : List[int] = None
|
||||||
|
tint_data : List[int] = None
|
||||||
|
int_un_data : List[int] = None
|
||||||
|
bint_un_data: List[int] = None
|
||||||
|
sint_un_data: List[int] = None
|
||||||
|
tint_un_data: List[int] = None
|
||||||
|
float_data : List[float] = None
|
||||||
|
double_data : List[float] = None
|
||||||
|
bool_data : List[int] = None
|
||||||
|
binary_data : List[str] = None
|
||||||
|
nchar_data : List[str] = None
|
||||||
|
|
||||||
|
def __post_init__(self):
|
||||||
|
self.ts_data = []
|
||||||
|
self.int_data = []
|
||||||
|
self.bint_data = []
|
||||||
|
self.sint_data = []
|
||||||
|
self.tint_data = []
|
||||||
|
self.int_un_data = []
|
||||||
|
self.bint_un_data = []
|
||||||
|
self.sint_un_data = []
|
||||||
|
self.tint_un_data = []
|
||||||
|
self.float_data = []
|
||||||
|
self.double_data = []
|
||||||
|
self.bool_data = []
|
||||||
|
self.binary_data = []
|
||||||
|
self.nchar_data = []
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class SMAschema:
|
||||||
|
creation : str = "CREATE"
|
||||||
|
index_name : str = "sma_index_1"
|
||||||
|
index_flag : str = "SMA INDEX"
|
||||||
|
operator : str = "ON"
|
||||||
|
tbname : str = None
|
||||||
|
watermark : str = None
|
||||||
|
maxdelay : str = None
|
||||||
|
func : Tuple[str] = None
|
||||||
|
interval : Tuple[str] = None
|
||||||
|
sliding : str = None
|
||||||
|
other : Any = None
|
||||||
|
drop : str = "DROP"
|
||||||
|
drop_flag : str = "INDEX"
|
||||||
|
|
||||||
|
def __post_init__(self):
|
||||||
|
if isinstance(self.other, dict):
|
||||||
|
for k,v in self.other.items():
|
||||||
|
|
||||||
|
if k.lower() == "index_name" and isinstance(v, str) and not self.index_name:
|
||||||
|
self.index_name = v
|
||||||
|
del self.other[k]
|
||||||
|
|
||||||
|
if k.lower() == "index_flag" and isinstance(v, str) and not self.index_flag:
|
||||||
|
self.index_flag = v
|
||||||
|
del self.other[k]
|
||||||
|
|
||||||
|
if k.lower() == "operator" and isinstance(v, str) and not self.operator:
|
||||||
|
self.operator = v
|
||||||
|
del self.other[k]
|
||||||
|
|
||||||
|
if k.lower() == "tbname" and isinstance(v, str) and not self.tbname:
|
||||||
|
self.tbname = v
|
||||||
|
del self.other[k]
|
||||||
|
|
||||||
|
if k.lower() == "watermark" and isinstance(v, str) and not self.watermark:
|
||||||
|
self.watermark = v
|
||||||
|
del self.other[k]
|
||||||
|
|
||||||
|
if k.lower() == "maxdelay" and isinstance(v, str) and not self.maxdelay:
|
||||||
|
self.maxdelay = v
|
||||||
|
del self.other[k]
|
||||||
|
|
||||||
|
if k.lower() == "functions" and isinstance(v, tuple) and not self.func:
|
||||||
|
self.func = v
|
||||||
|
del self.other[k]
|
||||||
|
|
||||||
|
if k.lower() == "interval" and isinstance(v, tuple) and not self.interval:
|
||||||
|
self.interval = v
|
||||||
|
del self.other[k]
|
||||||
|
|
||||||
|
if k.lower() == "sliding" and isinstance(v, str) and not self.sliding:
|
||||||
|
self.sliding = v
|
||||||
|
del self.other[k]
|
||||||
|
|
||||||
|
if k.lower() == "drop_flag" and isinstance(v, str) and not self.drop_flag:
|
||||||
|
self.drop_flag = v
|
||||||
|
del self.other[k]
|
||||||
|
|
||||||
|
|
||||||
|
class TDTestCase:
|
||||||
|
|
||||||
|
def init(self, conn, logSql):
|
||||||
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
tdSql.init(conn.cursor(), False)
|
||||||
|
|
||||||
|
"""
|
||||||
|
create sma index :
|
||||||
|
1. only create on stable, err_type: [child-table, normal-table]
|
||||||
|
2. one taosd, one sma index , err_type: [
|
||||||
|
one stb --> multi sma index,
|
||||||
|
multi stb in one db--> multi sma index,
|
||||||
|
multi stb in multi db --> multi sma index
|
||||||
|
]
|
||||||
|
3. arg of (interval/sliding) in query sql is equal to this arg in sma index
|
||||||
|
4. client timezone is equal to timezone of sma index
|
||||||
|
5. does not take effect unless querySmaOptimize flag is turned on,
|
||||||
|
"""
|
||||||
|
def __create_sma_index(self, sma:SMAschema):
|
||||||
|
sql = f"{sma.creation} {sma.index_flag} {sma.index_name} {sma.operator} {sma.tbname}"
|
||||||
|
if sma.func:
|
||||||
|
sql += f" function({', '.join(sma.func)})"
|
||||||
|
if sma.interval:
|
||||||
|
sql += f" interval({', '.join(sma.interval)})"
|
||||||
|
if sma.sliding:
|
||||||
|
sql += f" sliding({sma.sliding})"
|
||||||
|
if sma.watermark:
|
||||||
|
sql += f" watermark {sma.watermark}"
|
||||||
|
if sma.maxdelay:
|
||||||
|
sql += f" maxdelay {sma.maxdelay}"
|
||||||
|
if isinstance(sma.other, dict):
|
||||||
|
for k,v in sma.other.items():
|
||||||
|
if isinstance(v,tuple) or isinstance(v, list):
|
||||||
|
sql += f" {k} ({' '.join(v)})"
|
||||||
|
else:
|
||||||
|
sql += f" {k} {v}"
|
||||||
|
if isinstance(sma.other, tuple) or isinstance(sma.other, list):
|
||||||
|
sql += " ".join(sma.other)
|
||||||
|
if isinstance(sma.other, int) or isinstance(sma.other, float) or isinstance(sma.other, str):
|
||||||
|
sql += sma.other
|
||||||
|
|
||||||
|
return sql
|
||||||
|
|
||||||
|
def sma_create_check(self, sma:SMAschema):
|
||||||
|
tdSql.query("show stables")
|
||||||
|
stb_in_list = False
|
||||||
|
for row in tdSql.queryResult:
|
||||||
|
if sma.tbname == row[0]:
|
||||||
|
stb_in_list = True
|
||||||
|
break
|
||||||
|
if not stb_in_list:
|
||||||
|
tdSql.error(self.__create_sma_index(sma))
|
||||||
|
if not sma.creation:
|
||||||
|
tdSql.error(self.__create_sma_index(sma))
|
||||||
|
if not sma.index_flag:
|
||||||
|
tdSql.error(self.__create_sma_index(sma))
|
||||||
|
if not sma.index_name:
|
||||||
|
tdSql.error(self.__create_sma_index(sma))
|
||||||
|
if not sma.operator:
|
||||||
|
tdSql.error(self.__create_sma_index(sma))
|
||||||
|
if not sma.tbname:
|
||||||
|
tdSql.error(self.__create_sma_index(sma))
|
||||||
|
if not sma.func:
|
||||||
|
tdSql.error(self.__create_sma_index(sma))
|
||||||
|
if not sma.interval:
|
||||||
|
tdSql.error(self.__create_sma_index(sma))
|
||||||
|
if not sma.sliding:
|
||||||
|
tdSql.error(self.__create_sma_index(sma))
|
||||||
|
if sma.other:
|
||||||
|
tdSql.error(self.__create_sma_index(sma))
|
||||||
|
|
||||||
|
|
||||||
|
def all_test(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def __create_tb(self):
|
||||||
|
tdLog.printNoPrefix("==========step: 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 (tag1 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 __data_set(self, rows):
|
||||||
|
data_set = DataSet()
|
||||||
|
|
||||||
|
for i in range(rows):
|
||||||
|
data_set.ts_data.append(NOW + 1 * (rows - i))
|
||||||
|
data_set.int_data.append(rows - i)
|
||||||
|
data_set.bint_data.append(11111 * (rows - i))
|
||||||
|
data_set.sint_data.append(111 * (rows - i) % 32767)
|
||||||
|
data_set.tint_data.append(11 * (rows - i) % 127)
|
||||||
|
data_set.int_un_data.append(rows - i)
|
||||||
|
data_set.bint_un_data.append(11111 * (rows - i))
|
||||||
|
data_set.sint_un_data.append(111 * (rows - i) % 32767)
|
||||||
|
data_set.tint_un_data.append(11 * (rows - i) % 127)
|
||||||
|
data_set.float_data.append(1.11 * (rows - i))
|
||||||
|
data_set.double_data.append(1100.0011 * (rows - i))
|
||||||
|
data_set.bool_data.append((rows - i) % 2)
|
||||||
|
data_set.binary_data.append(f'binary{(rows - i)}')
|
||||||
|
data_set.nchar_data.append(f'nchar_测试_{(rows - i)}')
|
||||||
|
|
||||||
|
return data_set
|
||||||
|
|
||||||
|
def __insert_data(self):
|
||||||
|
data = self.__data_set(rows=self.rows)
|
||||||
|
|
||||||
|
# now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
|
||||||
|
null_data = '''null, null, null, null, null, null, null, null, null, null, null, null, null, null'''
|
||||||
|
zero_data = "0, 0, 0, 0, 0, 0, 0, 'binary_0', 'nchar_0', 0, 0, 0, 0, 0"
|
||||||
|
|
||||||
|
for i in range(self.rows):
|
||||||
|
row_data = f'''
|
||||||
|
{data.int_data[i]}, {data.bint_data[i]}, {data.sint_data[i]}, {data.tint_data[i]}, {data.float_data[i]}, {data.double_data[i]},
|
||||||
|
{data.bool_data[i]}, '{data.binary_data[i]}', '{data.nchar_data[i]}', {data.ts_data[i]}, {data.tint_un_data[i]},
|
||||||
|
{data.sint_un_data[i]}, {data.int_un_data[i]}, {data.bint_un_data[i]}
|
||||||
|
'''
|
||||||
|
neg_row_data = f'''
|
||||||
|
{-1 * data.int_data[i]}, {-1 * data.bint_data[i]}, {-1 * data.sint_data[i]}, {-1 * data.tint_data[i]}, {-1 * data.float_data[i]}, {-1 * data.double_data[i]},
|
||||||
|
{data.bool_data[i]}, '{data.binary_data[i]}', '{data.nchar_data[i]}', {data.ts_data[i]}, {1 * data.tint_un_data[i]},
|
||||||
|
{1 * data.sint_un_data[i]}, {1 * data.int_un_data[i]}, {1 * data.bint_un_data[i]}
|
||||||
|
'''
|
||||||
|
|
||||||
|
tdSql.execute(
|
||||||
|
f"insert into ct1 values ( {NOW - i * TIME_STEP}, {row_data} )")
|
||||||
|
tdSql.execute(
|
||||||
|
f"insert into ct2 values ( {NOW - i * int(TIME_STEP * 0.6)}, {neg_row_data} )")
|
||||||
|
tdSql.execute(
|
||||||
|
f"insert into ct4 values ( {NOW - i * int(TIME_STEP * 0.8) }, {row_data} )")
|
||||||
|
tdSql.execute(
|
||||||
|
f"insert into t1 values ( {NOW - i * int(TIME_STEP * 1.2)}, {row_data} )")
|
||||||
|
|
||||||
|
tdSql.execute(
|
||||||
|
f"insert into ct2 values ( {NOW + int(TIME_STEP * 0.6)}, {null_data} )")
|
||||||
|
tdSql.execute(
|
||||||
|
f"insert into ct2 values ( {NOW - (self.rows + 1) * int(TIME_STEP * 0.6)}, {null_data} )")
|
||||||
|
tdSql.execute(
|
||||||
|
f"insert into ct2 values ( {NOW - self.rows * int(TIME_STEP * 0.29) }, {null_data} )")
|
||||||
|
|
||||||
|
tdSql.execute(
|
||||||
|
f"insert into ct4 values ( {NOW + int(TIME_STEP * 0.8)}, {null_data} )")
|
||||||
|
tdSql.execute(
|
||||||
|
f"insert into ct4 values ( {NOW - (self.rows + 1) * int(TIME_STEP * 0.8)}, {null_data} )")
|
||||||
|
tdSql.execute(
|
||||||
|
f"insert into ct4 values ( {NOW - self.rows * int(TIME_STEP * 0.39)}, {null_data} )")
|
||||||
|
|
||||||
|
tdSql.execute(
|
||||||
|
f"insert into t1 values ( {NOW + int(TIME_STEP * 1.2)}, {null_data} )")
|
||||||
|
tdSql.execute(
|
||||||
|
f"insert into t1 values ( {NOW - (self.rows + 1) * int(TIME_STEP * 1.2)}, {null_data} )")
|
||||||
|
tdSql.execute(
|
||||||
|
f"insert into t1 values ( {NOW - self.rows * int(TIME_STEP * 0.59)}, {null_data} )")
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
sma1 = SMAschema(func=("min(c1)","max(c2)"))
|
||||||
|
sql1 = self.__create_sma_index(sma1)
|
||||||
|
print("================")
|
||||||
|
print(sql1)
|
||||||
|
# a = DataSet()
|
||||||
|
# return
|
||||||
|
self.rows = 10
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("==========step0:all check")
|
||||||
|
# self.all_test()
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("==========step1:create table in normal database")
|
||||||
|
tdSql.prepare()
|
||||||
|
self.__create_tb()
|
||||||
|
self.__insert_data()
|
||||||
|
return
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("==========step2:create table in rollup database")
|
||||||
|
tdSql.execute("create database db3 retentions 1s:4m,2s:8m,3s:12m")
|
||||||
|
tdSql.execute("use db3")
|
||||||
|
self.__create_tb()
|
||||||
|
self.__insert_data()
|
||||||
|
|
||||||
|
tdSql.execute("drop database if exists db1 ")
|
||||||
|
tdSql.execute("drop database if exists db2 ")
|
||||||
|
|
||||||
|
tdDnodes.stop(1)
|
||||||
|
tdDnodes.start(1)
|
||||||
|
|
||||||
|
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())
|
|
@ -0,0 +1,279 @@
|
||||||
|
from util.log import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.sql import *
|
||||||
|
import numpy as np
|
||||||
|
import random ,os ,sys
|
||||||
|
import platform
|
||||||
|
|
||||||
|
|
||||||
|
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,
|
||||||
|
"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 }
|
||||||
|
|
||||||
|
def init(self, conn, logSql):
|
||||||
|
tdLog.debug("start to execute %s" % __file__)
|
||||||
|
tdSql.init(conn.cursor())
|
||||||
|
self.vnode_disbutes = None
|
||||||
|
self.ts = 1537146000000
|
||||||
|
|
||||||
|
|
||||||
|
def check_avg_functions(self, tbname , col_name):
|
||||||
|
|
||||||
|
avg_sql = f"select avg({col_name}) from {tbname};"
|
||||||
|
|
||||||
|
same_sql = f"select {col_name} from {tbname} where {col_name} is not null "
|
||||||
|
|
||||||
|
tdSql.query(same_sql)
|
||||||
|
pre_data = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None]
|
||||||
|
if (platform.system().lower() == 'windows' and pre_data.dtype == 'int32'):
|
||||||
|
pre_data = np.array(pre_data, dtype = 'int64')
|
||||||
|
pre_avg = np.sum(pre_data)/len(pre_data)
|
||||||
|
|
||||||
|
tdSql.query(avg_sql)
|
||||||
|
tdSql.checkData(0,0,pre_avg)
|
||||||
|
|
||||||
|
def prepare_datas_of_distribute(self):
|
||||||
|
|
||||||
|
# prepate datas for 20 tables distributed at different vgroups
|
||||||
|
tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5")
|
||||||
|
tdSql.execute(" use testdb ")
|
||||||
|
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 (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
|
||||||
|
'''
|
||||||
|
)
|
||||||
|
|
||||||
|
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(20):
|
||||||
|
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||||
|
|
||||||
|
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 )"
|
||||||
|
)
|
||||||
|
|
||||||
|
for i in range(1,21):
|
||||||
|
if i ==1 or i == 4:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
tbname = "ct"+f'{i}'
|
||||||
|
for j in range(9):
|
||||||
|
tdSql.execute(
|
||||||
|
f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}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 )
|
||||||
|
'''
|
||||||
|
)
|
||||||
|
|
||||||
|
tdLog.info(" prepare data for distributed_aggregate done! ")
|
||||||
|
|
||||||
|
def check_distribute_datas(self):
|
||||||
|
# get vgroup_ids of all
|
||||||
|
tdSql.query("show vgroups ")
|
||||||
|
vgroups = tdSql.queryResult
|
||||||
|
|
||||||
|
vnode_tables={}
|
||||||
|
|
||||||
|
for vgroup_id in vgroups:
|
||||||
|
vnode_tables[vgroup_id[0]]=[]
|
||||||
|
|
||||||
|
|
||||||
|
# check sub_table of per vnode ,make sure sub_table has been distributed
|
||||||
|
tdSql.query("show tables like 'ct%'")
|
||||||
|
table_names = tdSql.queryResult
|
||||||
|
tablenames = []
|
||||||
|
for table_name in table_names:
|
||||||
|
vnode_tables[table_name[6]].append(table_name[0])
|
||||||
|
self.vnode_disbutes = vnode_tables
|
||||||
|
|
||||||
|
count = 0
|
||||||
|
for k ,v in vnode_tables.items():
|
||||||
|
if len(v)>=2:
|
||||||
|
count+=1
|
||||||
|
if count < 2:
|
||||||
|
tdLog.exit(" the datas of all not satisfy sub_table has been distributed ")
|
||||||
|
|
||||||
|
def check_avg_distribute_diff_vnode(self,col_name):
|
||||||
|
|
||||||
|
vgroup_ids = []
|
||||||
|
for k ,v in self.vnode_disbutes.items():
|
||||||
|
if len(v)>=2:
|
||||||
|
vgroup_ids.append(k)
|
||||||
|
|
||||||
|
distribute_tbnames = []
|
||||||
|
|
||||||
|
for vgroup_id in vgroup_ids:
|
||||||
|
vnode_tables = self.vnode_disbutes[vgroup_id]
|
||||||
|
distribute_tbnames.append(random.sample(vnode_tables,1)[0])
|
||||||
|
tbname_ins = ""
|
||||||
|
for tbname in distribute_tbnames:
|
||||||
|
tbname_ins += "'%s' ,"%tbname
|
||||||
|
|
||||||
|
tbname_filters = tbname_ins[:-1]
|
||||||
|
|
||||||
|
avg_sql = f"select avg({col_name}) from stb1 where tbname in ({tbname_filters});"
|
||||||
|
|
||||||
|
same_sql = f"select {col_name} from stb1 where tbname in ({tbname_filters}) and {col_name} is not null "
|
||||||
|
|
||||||
|
tdSql.query(same_sql)
|
||||||
|
pre_data = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None]
|
||||||
|
if (platform.system().lower() == 'windows' and pre_data.dtype == 'int32'):
|
||||||
|
pre_data = np.array(pre_data, dtype = 'int64')
|
||||||
|
pre_avg = np.sum(pre_data)/len(pre_data)
|
||||||
|
|
||||||
|
tdSql.query(avg_sql)
|
||||||
|
tdSql.checkData(0,0,pre_avg)
|
||||||
|
|
||||||
|
def check_avg_status(self):
|
||||||
|
# check max function work status
|
||||||
|
|
||||||
|
tdSql.query("show tables like 'ct%'")
|
||||||
|
table_names = tdSql.queryResult
|
||||||
|
tablenames = []
|
||||||
|
for table_name in table_names:
|
||||||
|
tablenames.append(table_name[0])
|
||||||
|
|
||||||
|
tdSql.query("desc stb1")
|
||||||
|
col_names = tdSql.queryResult
|
||||||
|
|
||||||
|
colnames = []
|
||||||
|
for col_name in col_names:
|
||||||
|
if col_name[1] in ["INT" ,"BIGINT" ,"SMALLINT" ,"TINYINT" , "FLOAT" ,"DOUBLE"]:
|
||||||
|
colnames.append(col_name[0])
|
||||||
|
|
||||||
|
for tablename in tablenames:
|
||||||
|
for colname in colnames:
|
||||||
|
self.check_avg_functions(tablename,colname)
|
||||||
|
|
||||||
|
# check max function for different vnode
|
||||||
|
|
||||||
|
for colname in colnames:
|
||||||
|
if colname.startswith("c"):
|
||||||
|
self.check_avg_distribute_diff_vnode(colname)
|
||||||
|
else:
|
||||||
|
# self.check_avg_distribute_diff_vnode(colname) # bug for tag
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def distribute_agg_query(self):
|
||||||
|
# basic filter
|
||||||
|
tdSql.query(" select avg(c1) from stb1 ")
|
||||||
|
tdSql.checkData(0,0,14.086956522)
|
||||||
|
|
||||||
|
tdSql.query(" select avg(a) from (select avg(c1) a from stb1 partition by tbname) ")
|
||||||
|
tdSql.checkData(0,0,14.292307692)
|
||||||
|
|
||||||
|
tdSql.query(" select avg(c1) from stb1 where t1=1")
|
||||||
|
tdSql.checkData(0,0,6.000000000)
|
||||||
|
|
||||||
|
tdSql.query("select avg(c1+c2) from stb1 where c1 =1 ")
|
||||||
|
tdSql.checkData(0,0,11112.000000000)
|
||||||
|
|
||||||
|
tdSql.query("select avg(c1) from stb1 where tbname=\"ct2\"")
|
||||||
|
tdSql.checkData(0,0,6.000000000)
|
||||||
|
|
||||||
|
tdSql.query("select avg(c1) from stb1 partition by tbname")
|
||||||
|
tdSql.checkRows(20)
|
||||||
|
|
||||||
|
tdSql.query("select avg(c1) from stb1 where t1> 4 partition by tbname")
|
||||||
|
tdSql.checkRows(15)
|
||||||
|
|
||||||
|
# union all
|
||||||
|
tdSql.query("select avg(c1) from stb1 union all select avg(c1) from stb1 ")
|
||||||
|
tdSql.checkRows(2)
|
||||||
|
tdSql.checkData(0,0,14.086956522)
|
||||||
|
|
||||||
|
tdSql.query("select avg(a) from (select avg(c1) a from stb1 union all select avg(c1) a from stb1)")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0,0,14.086956522)
|
||||||
|
|
||||||
|
# join
|
||||||
|
|
||||||
|
tdSql.execute(" create database if not exists db ")
|
||||||
|
tdSql.execute(" use db ")
|
||||||
|
tdSql.execute(" create stable st (ts timestamp , c1 int ,c2 float) tags(t1 int) ")
|
||||||
|
tdSql.execute(" create table tb1 using st tags(1) ")
|
||||||
|
tdSql.execute(" create table tb2 using st tags(2) ")
|
||||||
|
|
||||||
|
|
||||||
|
for i in range(10):
|
||||||
|
ts = i*10 + self.ts
|
||||||
|
tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)")
|
||||||
|
tdSql.execute(f" insert into tb2 values({ts},{i},{i}.0)")
|
||||||
|
|
||||||
|
tdSql.query("select avg(tb1.c1), avg(tb2.c2) from tb1, tb2 where tb1.ts=tb2.ts")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0,0,4.500000000)
|
||||||
|
tdSql.checkData(0,1,4.500000000)
|
||||||
|
|
||||||
|
# group by
|
||||||
|
tdSql.execute(" use testdb ")
|
||||||
|
|
||||||
|
# partition by tbname or partition by tag
|
||||||
|
tdSql.query("select avg(c1) from stb1 partition by tbname")
|
||||||
|
tdSql.checkRows(20)
|
||||||
|
|
||||||
|
# nest query for support max
|
||||||
|
tdSql.query("select avg(c2+2)+1 from (select avg(c1) c2 from stb1)")
|
||||||
|
tdSql.checkData(0,0,17.086956522)
|
||||||
|
tdSql.query("select avg(c1+2) as c2 from (select ts ,c1 ,c2 from stb1)")
|
||||||
|
tdSql.checkData(0,0,16.086956522)
|
||||||
|
tdSql.query("select avg(a+2) as c2 from (select ts ,abs(c1) a ,c2 from stb1)")
|
||||||
|
tdSql.checkData(0,0,16.086956522)
|
||||||
|
|
||||||
|
# mixup with other functions
|
||||||
|
tdSql.query("select max(c1),count(c1),last(c2,c3),sum(c1+c2),avg(c1) from stb1")
|
||||||
|
tdSql.checkData(0,0,28)
|
||||||
|
tdSql.checkData(0,1,184)
|
||||||
|
tdSql.checkData(0,2,-99999)
|
||||||
|
tdSql.checkData(0,3,-999)
|
||||||
|
tdSql.checkData(0,4,28202310.000000000)
|
||||||
|
tdSql.checkData(0,5,14.086956522)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
|
||||||
|
self.prepare_datas_of_distribute()
|
||||||
|
self.check_distribute_datas()
|
||||||
|
self.check_avg_status()
|
||||||
|
self.distribute_agg_query()
|
||||||
|
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success("%s successfully executed" % __file__)
|
||||||
|
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -245,6 +245,27 @@ class TDTestCase:
|
||||||
tdSql.query(" select max(c1),c2 from stb1 group by c2 ")
|
tdSql.query(" select max(c1),c2 from stb1 group by c2 ")
|
||||||
tdSql.checkRows(31)
|
tdSql.checkRows(31)
|
||||||
|
|
||||||
|
# selective common cols of datas
|
||||||
|
tdSql.query("select max(c1),c2,c3,c5 from stb1")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0,0,28)
|
||||||
|
tdSql.checkData(0,1,311108)
|
||||||
|
tdSql.checkData(0,2,3108)
|
||||||
|
tdSql.checkData(0,3,31.08000)
|
||||||
|
|
||||||
|
tdSql.query("select max(c1),t1,c2,t3 from stb1")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0,0,28)
|
||||||
|
tdSql.checkData(0,1,19)
|
||||||
|
tdSql.checkData(0,2,311108)
|
||||||
|
|
||||||
|
tdSql.query("select max(c1),ceil(t1),pow(c2,1)+2,abs(t3) from stb1")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0,0,28)
|
||||||
|
tdSql.checkData(0,1,19)
|
||||||
|
tdSql.checkData(0,2,311110.000000000)
|
||||||
|
tdSql.checkData(0,3,2109)
|
||||||
|
|
||||||
# partition by tbname or partition by tag
|
# partition by tbname or partition by tag
|
||||||
tdSql.query("select max(c1),tbname from stb1 partition by tbname")
|
tdSql.query("select max(c1),tbname from stb1 partition by tbname")
|
||||||
query_data = tdSql.queryResult
|
query_data = tdSql.queryResult
|
||||||
|
|
|
@ -245,6 +245,24 @@ class TDTestCase:
|
||||||
tdSql.query(" select min(c1),c2 from stb1 group by c2 ")
|
tdSql.query(" select min(c1),c2 from stb1 group by c2 ")
|
||||||
tdSql.checkRows(31)
|
tdSql.checkRows(31)
|
||||||
|
|
||||||
|
# selective common cols of datas
|
||||||
|
tdSql.query("select min(c1),c2,c3,c5 from stb1")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0,0,0)
|
||||||
|
tdSql.checkData(0,1,0)
|
||||||
|
tdSql.checkData(0,2,0)
|
||||||
|
tdSql.checkData(0,3,0)
|
||||||
|
|
||||||
|
tdSql.query("select min(c1),t1,c2,t3 from stb1 where c1 >5")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0,0,6)
|
||||||
|
tdSql.checkData(0,2,66666)
|
||||||
|
|
||||||
|
tdSql.query("select min(c1),ceil(t1),pow(c2,1)+2,abs(t3) from stb1 where c1>12")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0,0,13)
|
||||||
|
tdSql.checkData(0,2,144445.000000000)
|
||||||
|
|
||||||
# partition by tbname or partition by tag
|
# partition by tbname or partition by tag
|
||||||
tdSql.query("select min(c1),tbname from stb1 partition by tbname")
|
tdSql.query("select min(c1),tbname from stb1 partition by tbname")
|
||||||
query_data = tdSql.queryResult
|
query_data = tdSql.queryResult
|
||||||
|
|
|
@ -0,0 +1,304 @@
|
||||||
|
from util.log import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.sql import *
|
||||||
|
import numpy as np
|
||||||
|
import random ,os ,sys
|
||||||
|
import platform
|
||||||
|
import math
|
||||||
|
|
||||||
|
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,
|
||||||
|
"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 }
|
||||||
|
|
||||||
|
def init(self, conn, logSql):
|
||||||
|
tdLog.debug("start to execute %s" % __file__)
|
||||||
|
tdSql.init(conn.cursor())
|
||||||
|
self.vnode_disbutes = None
|
||||||
|
self.ts = 1537146000000
|
||||||
|
|
||||||
|
|
||||||
|
def check_stddev_functions(self, tbname , col_name):
|
||||||
|
|
||||||
|
stddev_sql = f"select stddev({col_name}) from {tbname};"
|
||||||
|
|
||||||
|
same_sql = f"select {col_name} from {tbname} where {col_name} is not null "
|
||||||
|
|
||||||
|
tdSql.query(same_sql)
|
||||||
|
pre_data = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None]
|
||||||
|
if (platform.system().lower() == 'windows' and pre_data.dtype == 'int32'):
|
||||||
|
pre_data = np.array(pre_data, dtype = 'int64')
|
||||||
|
pre_avg = np.sum(pre_data)/len(pre_data)
|
||||||
|
|
||||||
|
# Calculate variance
|
||||||
|
stddev_result = 0
|
||||||
|
for num in tdSql.queryResult:
|
||||||
|
stddev_result += (num-pre_avg)*(num-pre_avg)/len(tdSql.queryResult)
|
||||||
|
|
||||||
|
stddev_result = math.sqrt(stddev_result)
|
||||||
|
|
||||||
|
tdSql.query(stddev_sql)
|
||||||
|
|
||||||
|
if -0.0001 < tdSql.queryResult[0][0]-stddev_result < 0.0001:
|
||||||
|
tdLog.info(" sql:%s; row:0 col:0 data:%d , expect:%d"%(stddev_sql,tdSql.queryResult[0][0],stddev_result))
|
||||||
|
else:
|
||||||
|
tdLog.exit(" sql:%s; row:0 col:0 data:%d , expect:%d"%(stddev_sql,tdSql.queryResult[0][0],stddev_result))
|
||||||
|
|
||||||
|
def prepare_datas_of_distribute(self):
|
||||||
|
|
||||||
|
# prepate datas for 20 tables distributed at different vgroups
|
||||||
|
tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5")
|
||||||
|
tdSql.execute(" use testdb ")
|
||||||
|
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 (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
|
||||||
|
'''
|
||||||
|
)
|
||||||
|
|
||||||
|
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(20):
|
||||||
|
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||||
|
|
||||||
|
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 )"
|
||||||
|
)
|
||||||
|
|
||||||
|
for i in range(1,21):
|
||||||
|
if i ==1 or i == 4:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
tbname = "ct"+f'{i}'
|
||||||
|
for j in range(9):
|
||||||
|
tdSql.execute(
|
||||||
|
f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}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 )
|
||||||
|
'''
|
||||||
|
)
|
||||||
|
|
||||||
|
tdLog.info(" prepare data for distributed_aggregate done! ")
|
||||||
|
|
||||||
|
def check_distribute_datas(self):
|
||||||
|
# get vgroup_ids of all
|
||||||
|
tdSql.query("show vgroups ")
|
||||||
|
vgroups = tdSql.queryResult
|
||||||
|
|
||||||
|
vnode_tables={}
|
||||||
|
|
||||||
|
for vgroup_id in vgroups:
|
||||||
|
vnode_tables[vgroup_id[0]]=[]
|
||||||
|
|
||||||
|
|
||||||
|
# check sub_table of per vnode ,make sure sub_table has been distributed
|
||||||
|
tdSql.query("show tables like 'ct%'")
|
||||||
|
table_names = tdSql.queryResult
|
||||||
|
tablenames = []
|
||||||
|
for table_name in table_names:
|
||||||
|
vnode_tables[table_name[6]].append(table_name[0])
|
||||||
|
self.vnode_disbutes = vnode_tables
|
||||||
|
|
||||||
|
count = 0
|
||||||
|
for k ,v in vnode_tables.items():
|
||||||
|
if len(v)>=2:
|
||||||
|
count+=1
|
||||||
|
if count < 2:
|
||||||
|
tdLog.exit(" the datas of all not satisfy sub_table has been distributed ")
|
||||||
|
|
||||||
|
def check_stddev_distribute_diff_vnode(self,col_name):
|
||||||
|
|
||||||
|
vgroup_ids = []
|
||||||
|
for k ,v in self.vnode_disbutes.items():
|
||||||
|
if len(v)>=2:
|
||||||
|
vgroup_ids.append(k)
|
||||||
|
|
||||||
|
distribute_tbnames = []
|
||||||
|
|
||||||
|
for vgroup_id in vgroup_ids:
|
||||||
|
vnode_tables = self.vnode_disbutes[vgroup_id]
|
||||||
|
distribute_tbnames.append(random.sample(vnode_tables,1)[0])
|
||||||
|
tbname_ins = ""
|
||||||
|
for tbname in distribute_tbnames:
|
||||||
|
tbname_ins += "'%s' ,"%tbname
|
||||||
|
|
||||||
|
tbname_filters = tbname_ins[:-1]
|
||||||
|
|
||||||
|
stddev_sql = f"select stddev({col_name}) from stb1 where tbname in ({tbname_filters});"
|
||||||
|
|
||||||
|
same_sql = f"select {col_name} from stb1 where tbname in ({tbname_filters}) and {col_name} is not null "
|
||||||
|
|
||||||
|
tdSql.query(same_sql)
|
||||||
|
pre_data = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None]
|
||||||
|
if (platform.system().lower() == 'windows' and pre_data.dtype == 'int32'):
|
||||||
|
pre_data = np.array(pre_data, dtype = 'int64')
|
||||||
|
pre_avg = np.sum(pre_data)/len(pre_data)
|
||||||
|
|
||||||
|
# Calculate variance
|
||||||
|
stddev_result = 0
|
||||||
|
for num in tdSql.queryResult:
|
||||||
|
stddev_result += (num-pre_avg)*(num-pre_avg)/len(tdSql.queryResult)
|
||||||
|
|
||||||
|
stddev_result = math.sqrt(stddev_result)
|
||||||
|
|
||||||
|
tdSql.query(stddev_sql)
|
||||||
|
tdSql.checkData(0,0,stddev_result)
|
||||||
|
|
||||||
|
|
||||||
|
def check_stddev_status(self):
|
||||||
|
# check max function work status
|
||||||
|
|
||||||
|
tdSql.query("show tables like 'ct%'")
|
||||||
|
table_names = tdSql.queryResult
|
||||||
|
tablenames = []
|
||||||
|
for table_name in table_names:
|
||||||
|
tablenames.append(table_name[0])
|
||||||
|
|
||||||
|
tdSql.query("desc stb1")
|
||||||
|
col_names = tdSql.queryResult
|
||||||
|
|
||||||
|
colnames = []
|
||||||
|
for col_name in col_names:
|
||||||
|
if col_name[1] in ["INT" ,"BIGINT" ,"SMALLINT" ,"TINYINT" , "FLOAT" ,"DOUBLE"]:
|
||||||
|
colnames.append(col_name[0])
|
||||||
|
|
||||||
|
for tablename in tablenames:
|
||||||
|
for colname in colnames:
|
||||||
|
if colname.startswith("c"):
|
||||||
|
self.check_stddev_functions(tablename,colname)
|
||||||
|
else:
|
||||||
|
# self.check_stddev_functions(tablename,colname)
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
# check max function for different vnode
|
||||||
|
|
||||||
|
for colname in colnames:
|
||||||
|
if colname.startswith("c"):
|
||||||
|
self.check_stddev_distribute_diff_vnode(colname)
|
||||||
|
else:
|
||||||
|
# self.check_stddev_distribute_diff_vnode(colname) # bug for tag
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def distribute_agg_query(self):
|
||||||
|
# basic filter
|
||||||
|
tdSql.query(" select stddev(c1) from stb1 ")
|
||||||
|
tdSql.checkData(0,0,6.694663959)
|
||||||
|
|
||||||
|
tdSql.query(" select stddev(a) from (select stddev(c1) a from stb1 partition by tbname) ")
|
||||||
|
tdSql.checkData(0,0,0.156797505)
|
||||||
|
|
||||||
|
tdSql.query(" select stddev(c1) from stb1 where t1=1")
|
||||||
|
tdSql.checkData(0,0,2.581988897)
|
||||||
|
|
||||||
|
tdSql.query("select stddev(c1+c2) from stb1 where c1 =1 ")
|
||||||
|
tdSql.checkData(0,0,0.000000000)
|
||||||
|
|
||||||
|
tdSql.query("select stddev(c1) from stb1 where tbname=\"ct2\"")
|
||||||
|
tdSql.checkData(0,0,2.581988897)
|
||||||
|
|
||||||
|
tdSql.query("select stddev(c1) from stb1 partition by tbname")
|
||||||
|
tdSql.checkRows(20)
|
||||||
|
|
||||||
|
tdSql.query("select stddev(c1) from stb1 where t1> 4 partition by tbname")
|
||||||
|
tdSql.checkRows(15)
|
||||||
|
|
||||||
|
# union all
|
||||||
|
tdSql.query("select stddev(c1) from stb1 union all select stddev(c1) from stb1 ")
|
||||||
|
tdSql.checkRows(2)
|
||||||
|
tdSql.checkData(0,0,6.694663959)
|
||||||
|
|
||||||
|
tdSql.query("select stddev(a) from (select stddev(c1) a from stb1 union all select stddev(c1) a from stb1)")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0,0,0.000000000)
|
||||||
|
|
||||||
|
# join
|
||||||
|
|
||||||
|
tdSql.execute(" create database if not exists db ")
|
||||||
|
tdSql.execute(" use db ")
|
||||||
|
tdSql.execute(" create stable st (ts timestamp , c1 int ,c2 float) tags(t1 int) ")
|
||||||
|
tdSql.execute(" create table tb1 using st tags(1) ")
|
||||||
|
tdSql.execute(" create table tb2 using st tags(2) ")
|
||||||
|
|
||||||
|
|
||||||
|
for i in range(10):
|
||||||
|
ts = i*10 + self.ts
|
||||||
|
tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)")
|
||||||
|
tdSql.execute(f" insert into tb2 values({ts},{i},{i}.0)")
|
||||||
|
|
||||||
|
tdSql.query("select stddev(tb1.c1), stddev(tb2.c2) from tb1, tb2 where tb1.ts=tb2.ts")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0,0,2.872281323)
|
||||||
|
tdSql.checkData(0,1,2.872281323)
|
||||||
|
|
||||||
|
# group by
|
||||||
|
tdSql.execute(" use testdb ")
|
||||||
|
|
||||||
|
# partition by tbname or partition by tag
|
||||||
|
tdSql.query("select stddev(c1) from stb1 partition by tbname")
|
||||||
|
tdSql.checkRows(20)
|
||||||
|
|
||||||
|
# nest query for support max
|
||||||
|
tdSql.query("select stddev(c2+2)+1 from (select stddev(c1) c2 from stb1)")
|
||||||
|
tdSql.checkData(0,0,1.000000000)
|
||||||
|
tdSql.query("select stddev(c1+2) as c2 from (select ts ,c1 ,c2 from stb1)")
|
||||||
|
tdSql.checkData(0,0,6.694663959)
|
||||||
|
tdSql.query("select stddev(a+2) as c2 from (select ts ,abs(c1) a ,c2 from stb1)")
|
||||||
|
tdSql.checkData(0,0,6.694663959)
|
||||||
|
|
||||||
|
# mixup with other functions
|
||||||
|
tdSql.query("select max(c1),count(c1),last(c2,c3),sum(c1+c2),avg(c1),stddev(c1) from stb1")
|
||||||
|
tdSql.checkData(0,0,28)
|
||||||
|
tdSql.checkData(0,1,184)
|
||||||
|
tdSql.checkData(0,2,-99999)
|
||||||
|
tdSql.checkData(0,3,-999)
|
||||||
|
tdSql.checkData(0,4,28202310.000000000)
|
||||||
|
tdSql.checkData(0,5,14.086956522)
|
||||||
|
tdSql.checkData(0,6,6.694663959)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
|
||||||
|
self.prepare_datas_of_distribute()
|
||||||
|
self.check_distribute_datas()
|
||||||
|
self.check_stddev_status()
|
||||||
|
self.distribute_agg_query()
|
||||||
|
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success("%s successfully executed" % __file__)
|
||||||
|
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -238,7 +238,7 @@ class TDTestCase:
|
||||||
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
||||||
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
|
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
|
||||||
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
|
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
|
||||||
) tags (t1 int)
|
) tags (tag1 int)
|
||||||
'''
|
'''
|
||||||
create_ntb_sql = f'''create table t1(
|
create_ntb_sql = f'''create table t1(
|
||||||
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
||||||
|
|
|
@ -23,6 +23,9 @@ CHAR_COL = [ BINARY_COL, NCHAR_COL, ]
|
||||||
BOOLEAN_COL = [ BOOL_COL, ]
|
BOOLEAN_COL = [ BOOL_COL, ]
|
||||||
TS_TYPE_COL = [ TS_COL, ]
|
TS_TYPE_COL = [ TS_COL, ]
|
||||||
|
|
||||||
|
ERR_POS = 0
|
||||||
|
CURRENT_POS = 1
|
||||||
|
LENS = 6
|
||||||
|
|
||||||
class TDTestCase:
|
class TDTestCase:
|
||||||
|
|
||||||
|
@ -76,6 +79,7 @@ class TDTestCase:
|
||||||
|
|
||||||
if pos < 1:
|
if pos < 1:
|
||||||
tdSql.error(f"select substr( {condition}, {pos}, {lens}) , {condition} from {tbname} ")
|
tdSql.error(f"select substr( {condition}, {pos}, {lens}) , {condition} from {tbname} ")
|
||||||
|
break
|
||||||
|
|
||||||
tdSql.query(f"select substr( {condition}, {pos}, {lens}) , {condition} from {tbname} ")
|
tdSql.query(f"select substr( {condition}, {pos}, {lens}) , {condition} from {tbname} ")
|
||||||
for j in range(tdSql.queryRows):
|
for j in range(tdSql.queryRows):
|
||||||
|
@ -127,7 +131,7 @@ class TDTestCase:
|
||||||
tdLog.printNoPrefix("==========current sql condition check , must return query ok==========")
|
tdLog.printNoPrefix("==========current sql condition check , must return query ok==========")
|
||||||
tbname = ["ct1", "ct2", "ct4", "t1", "stb1"]
|
tbname = ["ct1", "ct2", "ct4", "t1", "stb1"]
|
||||||
for tb in tbname:
|
for tb in tbname:
|
||||||
self.__substr_check(tb, 1, 6)
|
self.__substr_check(tb, CURRENT_POS, LENS)
|
||||||
tdLog.printNoPrefix(f"==========current sql condition check in {tb} over==========")
|
tdLog.printNoPrefix(f"==========current sql condition check in {tb} over==========")
|
||||||
|
|
||||||
def __test_error(self):
|
def __test_error(self):
|
||||||
|
@ -137,7 +141,7 @@ class TDTestCase:
|
||||||
for tb in tbname:
|
for tb in tbname:
|
||||||
for errsql in self.__substr_err_check(tb):
|
for errsql in self.__substr_err_check(tb):
|
||||||
tdSql.error(sql=errsql)
|
tdSql.error(sql=errsql)
|
||||||
self.__substr_check(tb, 0, 6)
|
self.__substr_check(tb, ERR_POS, LENS)
|
||||||
tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========")
|
tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========")
|
||||||
|
|
||||||
|
|
||||||
|
@ -154,7 +158,7 @@ class TDTestCase:
|
||||||
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
||||||
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
|
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
|
||||||
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
|
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
|
||||||
) tags (t1 int)
|
) tags (tag1 int)
|
||||||
'''
|
'''
|
||||||
create_ntb_sql = f'''create table t1(
|
create_ntb_sql = f'''create table t1(
|
||||||
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
||||||
|
|
|
@ -73,7 +73,7 @@ class TDTestCase:
|
||||||
f"select sum(ceil( {un_num_col} )) from {tbanme} ",
|
f"select sum(ceil( {un_num_col} )) from {tbanme} ",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
sqls.extend( f"select sum( {un_num_col} + {un_num_col_2} ) from {tbanme} " for un_num_col_2 in UN_NUM_COL )
|
# sqls.extend( f"select sum( {un_num_col} + {un_num_col_2} ) from {tbanme} " for un_num_col_2 in UN_NUM_COL )
|
||||||
|
|
||||||
sqls.extend( f"select sum( {num_col} + {ts_col} ) from {tbanme} " for num_col in NUM_COL for ts_col in TS_TYPE_COL)
|
sqls.extend( f"select sum( {num_col} + {ts_col} ) from {tbanme} " for num_col in NUM_COL for ts_col in TS_TYPE_COL)
|
||||||
sqls.extend(
|
sqls.extend(
|
||||||
|
|
|
@ -35,6 +35,7 @@ python3 ./test.py -f 2-query/lower.py
|
||||||
python3 ./test.py -f 2-query/join.py
|
python3 ./test.py -f 2-query/join.py
|
||||||
python3 ./test.py -f 2-query/join2.py
|
python3 ./test.py -f 2-query/join2.py
|
||||||
python3 ./test.py -f 2-query/cast.py
|
python3 ./test.py -f 2-query/cast.py
|
||||||
|
python3 ./test.py -f 2-query/substr.py
|
||||||
python3 ./test.py -f 2-query/union.py
|
python3 ./test.py -f 2-query/union.py
|
||||||
python3 ./test.py -f 2-query/union1.py
|
python3 ./test.py -f 2-query/union1.py
|
||||||
python3 ./test.py -f 2-query/concat.py
|
python3 ./test.py -f 2-query/concat.py
|
||||||
|
@ -105,12 +106,14 @@ python3 ./test.py -f 2-query/distribute_agg_min.py
|
||||||
python3 ./test.py -f 2-query/distribute_agg_sum.py
|
python3 ./test.py -f 2-query/distribute_agg_sum.py
|
||||||
python3 ./test.py -f 2-query/distribute_agg_spread.py
|
python3 ./test.py -f 2-query/distribute_agg_spread.py
|
||||||
python3 ./test.py -f 2-query/distribute_agg_apercentile.py
|
python3 ./test.py -f 2-query/distribute_agg_apercentile.py
|
||||||
|
python3 ./test.py -f 2-query/distribute_agg_avg.py
|
||||||
|
python3 ./test.py -f 2-query/distribute_agg_stddev.py
|
||||||
|
|
||||||
python3 ./test.py -f 6-cluster/5dnode1mnode.py
|
python3 ./test.py -f 6-cluster/5dnode1mnode.py
|
||||||
python3 ./test.py -f 6-cluster/5dnode2mnode.py
|
python3 ./test.py -f 6-cluster/5dnode2mnode.py
|
||||||
#python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py
|
#python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py
|
||||||
#python3 ./test.py -f 6-cluster/5dnode3mnodeDrop.py
|
#python3 ./test.py -f 6-cluster/5dnode3mnodeDrop.py
|
||||||
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeStopInsert.py
|
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeStopInsert.py
|
||||||
|
|
||||||
python3 ./test.py -f 7-tmq/basic5.py
|
python3 ./test.py -f 7-tmq/basic5.py
|
||||||
python3 ./test.py -f 7-tmq/subscribeDb.py
|
python3 ./test.py -f 7-tmq/subscribeDb.py
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 29926478edd87533a043f91c1a9ed0e27671e626
|
Subproject commit c1dc11f3cae64adf31dbd9a954ef8372d1e8f671
|
Loading…
Reference in New Issue