Merge remote-tracking branch 'origin/3.0' into enh/updateTbMeta
This commit is contained in:
commit
4ab25b856f
|
@ -103,6 +103,9 @@ IF (TD_WINDOWS)
|
|||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS}")
|
||||
|
||||
ELSE ()
|
||||
IF (${TD_DARWIN})
|
||||
set(CMAKE_MACOSX_RPATH 0)
|
||||
ENDIF ()
|
||||
IF (${COVER} MATCHES "true")
|
||||
MESSAGE(STATUS "Test coverage mode, add extra flags")
|
||||
SET(GCC_COVERAGE_COMPILE_FLAGS "-fprofile-arcs -ftest-coverage")
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# taos-tools
|
||||
ExternalProject_Add(taos-tools
|
||||
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
||||
GIT_TAG 2af2222
|
||||
GIT_TAG 833b721
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -3,7 +3,7 @@ sidebar_label: SHOW Statement
|
|||
title: SHOW Statement for Metadata
|
||||
---
|
||||
|
||||
In addition to running SELECT statements on INFORMATION_SCHEMA, you can also use SHOW to obtain system metadata, information, and status.
|
||||
`SHOW` command can be used to get brief system information. To get details about metatadata, information, and status in the system, please use `select` to query the tables in database `INFORMATION_SCHEMA`.
|
||||
|
||||
## SHOW ACCOUNTS
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ One difference from the native connector is that the REST interface is stateless
|
|||
|
||||
## Installation
|
||||
|
||||
The REST interface does not rely on any TDengine native library, so the client application does not need to install any TDengine libraries. The client application's development language only needs to support the HTTP protocol.
|
||||
The REST interface does not rely on any TDengine native library, so the client application does not need to install any TDengine libraries. The client application's development language only needs to support the HTTP protocol. The REST interface is provided by [taosAdapter](../taosadapter), to use REST interface you need to make sure `taosAdapter` is running properly.
|
||||
|
||||
## Verification
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
---
|
||||
sidebar_position: 1
|
||||
sidebar_label: C/C++
|
||||
title: C/C++ Connector
|
||||
---
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
toc_max_heading_level: 4
|
||||
sidebar_position: 2
|
||||
sidebar_label: Java
|
||||
title: TDengine Java Connector
|
||||
description: The TDengine Java Connector is implemented on the standard JDBC API and provides native and REST connectors.
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
toc_max_heading_level: 4
|
||||
sidebar_position: 4
|
||||
sidebar_label: Go
|
||||
title: TDengine Go Connector
|
||||
---
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
toc_max_heading_level: 4
|
||||
sidebar_position: 5
|
||||
sidebar_label: Rust
|
||||
title: TDengine Rust Connector
|
||||
---
|
|
@ -1,5 +1,4 @@
|
|||
---
|
||||
sidebar_position: 3
|
||||
sidebar_label: Python
|
||||
title: TDengine Python Connector
|
||||
description: "taospy is the official Python connector for TDengine. taospy provides a rich API that makes it easy for Python applications to use TDengine. tasopy wraps both the native and REST interfaces of TDengine, corresponding to the two submodules of tasopy: taos and taosrest. In addition to wrapping the native and REST interfaces, taospy also provides a programming interface that conforms to the Python Data Access Specification (PEP 249), making it easy to integrate taospy with many third-party tools, such as SQLAlchemy and pandas."
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
toc_max_heading_level: 4
|
||||
sidebar_position: 6
|
||||
sidebar_label: Node.js
|
||||
title: TDengine Node.js Connector
|
||||
---
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
toc_max_heading_level: 4
|
||||
sidebar_position: 7
|
||||
sidebar_label: C#
|
||||
title: C# Connector
|
||||
---
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
sidebar_position: 1
|
||||
sidebar_label: PHP (community contribution)
|
||||
sidebar_label: PHP
|
||||
title: PHP Connector
|
||||
---
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
---
|
||||
title: REST API
|
||||
sidebar_label: REST API
|
||||
description: 详细介绍 TDengine 提供的 RESTful API.
|
||||
---
|
||||
|
||||
为支持各种不同类型平台的开发,TDengine 提供符合 REST 设计标准的 API,即 REST API。为最大程度降低学习成本,不同于其他数据库 REST API 的设计方法,TDengine 直接通过 HTTP POST 请求 BODY 中包含的 SQL 语句来操作数据库,仅需要一个 URL。REST 连接器的使用参见 [视频教程](https://www.taosdata.com/blog/2020/11/11/1965.html)。
|
||||
|
@ -10,7 +12,7 @@ title: REST API
|
|||
|
||||
## 安装
|
||||
|
||||
RESTful 接口不依赖于任何 TDengine 的库,因此客户端不需要安装任何 TDengine 的库,只要客户端的开发语言支持 HTTP 协议即可。
|
||||
RESTful 接口不依赖于任何 TDengine 的库,因此客户端不需要安装任何 TDengine 的库,只要客户端的开发语言支持 HTTP 协议即可。TDengine 的 RESTful API 由 [taosAdapter](../../reference/taosadapter) 提供,在使用 RESTful API 之前需要确保 `taosAdapter` 正常运行。
|
||||
|
||||
## 验证
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
---
|
||||
sidebar_position: 1
|
||||
sidebar_label: C/C++
|
||||
title: C/C++ Connector
|
||||
---
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
toc_max_heading_level: 4
|
||||
sidebar_position: 2
|
||||
sidebar_label: Java
|
||||
title: TDengine Java Connector
|
||||
description: TDengine Java 连接器基于标准 JDBC API 实现, 并提供原生连接与 REST连接两种连接器。
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
toc_max_heading_level: 4
|
||||
sidebar_position: 5
|
||||
sidebar_label: Rust
|
||||
title: TDengine Rust Connector
|
||||
---
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
---
|
||||
sidebar_position: 3
|
||||
sidebar_label: Python
|
||||
title: TDengine Python Connector
|
||||
description: "taospy 是 TDengine 的官方 Python 连接器。taospy 提供了丰富的 API, 使得 Python 应用可以很方便地使用 TDengine。tasopy 对 TDengine 的原生接口和 REST 接口都进行了封装, 分别对应 tasopy 的两个子模块:tasos 和 taosrest。除了对原生接口和 REST 接口的封装,taospy 还提供了符合 Python 数据访问规范(PEP 249)的编程接口。这使得 taospy 和很多第三方工具集成变得简单,比如 SQLAlchemy 和 pandas"
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
toc_max_heading_level: 4
|
||||
sidebar_position: 6
|
||||
sidebar_label: Node.js
|
||||
title: TDengine Node.js Connector
|
||||
---
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
toc_max_heading_level: 4
|
||||
sidebar_position: 7
|
||||
sidebar_label: C#
|
||||
title: C# Connector
|
||||
---
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
sidebar_position: 1
|
||||
sidebar_label: PHP(社区贡献)
|
||||
sidebar_label: PHP
|
||||
title: PHP Connector
|
||||
---
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ stream_options: {
|
|||
其中 subquery 是 select 普通查询语法的子集:
|
||||
|
||||
```sql
|
||||
subquery: SELECT [DISTINCT] select_list
|
||||
subquery: SELECT select_list
|
||||
from_clause
|
||||
[WHERE condition]
|
||||
[PARTITION BY tag_list]
|
||||
|
@ -37,7 +37,7 @@ window_clause: {
|
|||
|
||||
其中,SESSION 是会话窗口,tol_val 是时间间隔的最大范围。在 tol_val 时间间隔范围内的数据都属于同一个窗口,如果连续的两条数据的时间超过 tol_val,则自动开启下一个窗口。
|
||||
|
||||
窗口的定义与时序数据特色查询中的定义完全相同。
|
||||
窗口的定义与时序数据特色查询中的定义完全相同,详见 [TDengine 特色查询](../distinguished)
|
||||
|
||||
例如,如下语句创建流式计算,同时自动创建名为 avg_vol 的超级表,此流计算以一分钟为时间窗口、30 秒为前向增量统计这些电表的平均电压,并将来自 meters 表的数据的计算结果写入 avg_vol 表,不同 partition 的数据会分别创建子表并写入不同子表。
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ sidebar_label: SHOW 命令
|
|||
title: 使用 SHOW 命令查看系统元数据
|
||||
---
|
||||
|
||||
除了使用 `select` 语句查询 `INFORMATION_SCHEMA` 数据库中的表获得系统中的各种元数据、系统信息和状态之外,也可以用 `SHOW` 命令来实现同样的目的。
|
||||
SHOW 命令可以用来获取简要的系统信息。若想获取系统中详细的各种元数据、系统信息和状态,请使用 select 语句查询 INFORMATION_SCHEMA 数据库中的表。
|
||||
|
||||
## SHOW ACCOUNTS
|
||||
|
||||
|
|
|
@ -698,122 +698,123 @@ charset 的有效值是 UTF-8。
|
|||
| 45 | numOfVnodeFetchThreads | 否 | 是 |
|
||||
| 46 | numOfVnodeWriteThreads | 否 | 是 |
|
||||
| 47 | numOfVnodeSyncThreads | 否 | 是 |
|
||||
| 48 | numOfQnodeQueryThreads | 否 | 是 |
|
||||
| 49 | numOfQnodeFetchThreads | 否 | 是 |
|
||||
| 50 | numOfSnodeSharedThreads | 否 | 是 |
|
||||
| 51 | numOfSnodeUniqueThreads | 否 | 是 |
|
||||
| 52 | rpcQueueMemoryAllowed | 否 | 是 |
|
||||
| 53 | logDir | 是 | 是 |
|
||||
| 54 | minimalLogDirGB | 是 | 是 |
|
||||
| 55 | numOfLogLines | 是 | 是 |
|
||||
| 56 | asyncLog | 是 | 是 |
|
||||
| 57 | logKeepDays | 是 | 是 |
|
||||
| 58 | debugFlag | 是 | 是 |
|
||||
| 59 | tmrDebugFlag | 是 | 是 |
|
||||
| 60 | uDebugFlag | 是 | 是 |
|
||||
| 61 | rpcDebugFlag | 是 | 是 |
|
||||
| 62 | jniDebugFlag | 是 | 是 |
|
||||
| 63 | qDebugFlag | 是 | 是 |
|
||||
| 64 | cDebugFlag | 是 | 是 |
|
||||
| 65 | dDebugFlag | 是 | 是 |
|
||||
| 66 | vDebugFlag | 是 | 是 |
|
||||
| 67 | mDebugFlag | 是 | 是 |
|
||||
| 68 | wDebugFlag | 是 | 是 |
|
||||
| 69 | sDebugFlag | 是 | 是 |
|
||||
| 70 | tsdbDebugFlag | 是 | 是 |
|
||||
| 71 | tqDebugFlag | 否 | 是 |
|
||||
| 72 | fsDebugFlag | 是 | 是 |
|
||||
| 73 | udfDebugFlag | 否 | 是 |
|
||||
| 74 | smaDebugFlag | 否 | 是 |
|
||||
| 75 | idxDebugFlag | 否 | 是 |
|
||||
| 76 | tdbDebugFlag | 否 | 是 |
|
||||
| 77 | metaDebugFlag | 否 | 是 |
|
||||
| 78 | timezone | 是 | 是 |
|
||||
| 79 | locale | 是 | 是 |
|
||||
| 80 | charset | 是 | 是 |
|
||||
| 81 | udf | 是 | 是 |
|
||||
| 82 | enableCoreFile | 是 | 是 |
|
||||
| 83 | arbitrator | 是 | 否 |
|
||||
| 84 | numOfThreadsPerCore | 是 | 否 |
|
||||
| 85 | numOfMnodes | 是 | 否 |
|
||||
| 86 | vnodeBak | 是 | 否 |
|
||||
| 87 | balance | 是 | 否 |
|
||||
| 88 | balanceInterval | 是 | 否 |
|
||||
| 89 | offlineThreshold | 是 | 否 |
|
||||
| 90 | role | 是 | 否 |
|
||||
| 91 | dnodeNopLoop | 是 | 否 |
|
||||
| 92 | keepTimeOffset | 是 | 否 |
|
||||
| 93 | rpcTimer | 是 | 否 |
|
||||
| 94 | rpcMaxTime | 是 | 否 |
|
||||
| 95 | rpcForceTcp | 是 | 否 |
|
||||
| 96 | tcpConnTimeout | 是 | 否 |
|
||||
| 97 | syncCheckInterval | 是 | 否 |
|
||||
| 98 | maxTmrCtrl | 是 | 否 |
|
||||
| 99 | monitorReplica | 是 | 否 |
|
||||
| 100 | smlTagNullName | 是 | 否 |
|
||||
| 101 | keepColumnName | 是 | 否 |
|
||||
| 102 | ratioOfQueryCores | 是 | 否 |
|
||||
| 103 | maxStreamCompDelay | 是 | 否 |
|
||||
| 104 | maxFirstStreamCompDelay | 是 | 否 |
|
||||
| 105 | retryStreamCompDelay | 是 | 否 |
|
||||
| 106 | streamCompDelayRatio | 是 | 否 |
|
||||
| 107 | maxVgroupsPerDb | 是 | 否 |
|
||||
| 108 | maxTablesPerVnode | 是 | 否 |
|
||||
| 109 | minTablesPerVnode | 是 | 否 |
|
||||
| 110 | tableIncStepPerVnode | 是 | 否 |
|
||||
| 111 | cache | 是 | 否 |
|
||||
| 112 | blocks | 是 | 否 |
|
||||
| 113 | days | 是 | 否 |
|
||||
| 114 | keep | 是 | 否 |
|
||||
| 115 | minRows | 是 | 否 |
|
||||
| 116 | maxRows | 是 | 否 |
|
||||
| 117 | quorum | 是 | 否 |
|
||||
| 118 | comp | 是 | 否 |
|
||||
| 119 | walLevel | 是 | 否 |
|
||||
| 120 | fsync | 是 | 否 |
|
||||
| 121 | replica | 是 | 否 |
|
||||
| 122 | partitions | 是 | 否 |
|
||||
| 123 | quorum | 是 | 否 |
|
||||
| 124 | update | 是 | 否 |
|
||||
| 125 | cachelast | 是 | 否 |
|
||||
| 126 | maxSQLLength | 是 | 否 |
|
||||
| 127 | maxWildCardsLength | 是 | 否 |
|
||||
| 128 | maxRegexStringLen | 是 | 否 |
|
||||
| 129 | maxNumOfOrderedRes | 是 | 否 |
|
||||
| 130 | maxConnections | 是 | 否 |
|
||||
| 131 | mnodeEqualVnodeNum | 是 | 否 |
|
||||
| 132 | http | 是 | 否 |
|
||||
| 133 | httpEnableRecordSql | 是 | 否 |
|
||||
| 134 | httpMaxThreads | 是 | 否 |
|
||||
| 135 | restfulRowLimit | 是 | 否 |
|
||||
| 136 | httpDbNameMandatory | 是 | 否 |
|
||||
| 137 | httpKeepAlive | 是 | 否 |
|
||||
| 138 | enableRecordSql | 是 | 否 |
|
||||
| 139 | maxBinaryDisplayWidth | 是 | 否 |
|
||||
| 140 | stream | 是 | 否 |
|
||||
| 141 | retrieveBlockingModel | 是 | 否 |
|
||||
| 142 | tsdbMetaCompactRatio | 是 | 否 |
|
||||
| 143 | defaultJSONStrType | 是 | 否 |
|
||||
| 144 | walFlushSize | 是 | 否 |
|
||||
| 145 | keepTimeOffset | 是 | 否 |
|
||||
| 146 | flowctrl | 是 | 否 |
|
||||
| 147 | slaveQuery | 是 | 否 |
|
||||
| 148 | adjustMaster | 是 | 否 |
|
||||
| 149 | topicBinaryLen | 是 | 否 |
|
||||
| 150 | telegrafUseFieldNum | 是 | 否 |
|
||||
| 151 | deadLockKillQuery | 是 | 否 |
|
||||
| 152 | clientMerge | 是 | 否 |
|
||||
| 153 | sdbDebugFlag | 是 | 否 |
|
||||
| 154 | odbcDebugFlag | 是 | 否 |
|
||||
| 155 | httpDebugFlag | 是 | 否 |
|
||||
| 156 | monDebugFlag | 是 | 否 |
|
||||
| 157 | cqDebugFlag | 是 | 否 |
|
||||
| 158 | shortcutFlag | 是 | 否 |
|
||||
| 159 | probeSeconds | 是 | 否 |
|
||||
| 160 | probeKillSeconds | 是 | 否 |
|
||||
| 161 | probeInterval | 是 | 否 |
|
||||
| 162 | lossyColumns | 是 | 否 |
|
||||
| 163 | fPrecision | 是 | 否 |
|
||||
| 164 | dPrecision | 是 | 否 |
|
||||
| 165 | maxRange | 是 | 否 |
|
||||
| 166 | range | 是 | 否 |
|
||||
| 48 | numOfVnodeRsmaThreads | 否 | 是 |
|
||||
| 49 | numOfQnodeQueryThreads | 否 | 是 |
|
||||
| 50 | numOfQnodeFetchThreads | 否 | 是 |
|
||||
| 51 | numOfSnodeSharedThreads | 否 | 是 |
|
||||
| 52 | numOfSnodeUniqueThreads | 否 | 是 |
|
||||
| 53 | rpcQueueMemoryAllowed | 否 | 是 |
|
||||
| 54 | logDir | 是 | 是 |
|
||||
| 55 | minimalLogDirGB | 是 | 是 |
|
||||
| 56 | numOfLogLines | 是 | 是 |
|
||||
| 57 | asyncLog | 是 | 是 |
|
||||
| 58 | logKeepDays | 是 | 是 |
|
||||
| 59 | debugFlag | 是 | 是 |
|
||||
| 60 | tmrDebugFlag | 是 | 是 |
|
||||
| 61 | uDebugFlag | 是 | 是 |
|
||||
| 62 | rpcDebugFlag | 是 | 是 |
|
||||
| 63 | jniDebugFlag | 是 | 是 |
|
||||
| 64 | qDebugFlag | 是 | 是 |
|
||||
| 65 | cDebugFlag | 是 | 是 |
|
||||
| 66 | dDebugFlag | 是 | 是 |
|
||||
| 67 | vDebugFlag | 是 | 是 |
|
||||
| 68 | mDebugFlag | 是 | 是 |
|
||||
| 69 | wDebugFlag | 是 | 是 |
|
||||
| 70 | sDebugFlag | 是 | 是 |
|
||||
| 71 | tsdbDebugFlag | 是 | 是 |
|
||||
| 72 | tqDebugFlag | 否 | 是 |
|
||||
| 73 | fsDebugFlag | 是 | 是 |
|
||||
| 74 | udfDebugFlag | 否 | 是 |
|
||||
| 75 | smaDebugFlag | 否 | 是 |
|
||||
| 76 | idxDebugFlag | 否 | 是 |
|
||||
| 77 | tdbDebugFlag | 否 | 是 |
|
||||
| 78 | metaDebugFlag | 否 | 是 |
|
||||
| 79 | timezone | 是 | 是 |
|
||||
| 80 | locale | 是 | 是 |
|
||||
| 81 | charset | 是 | 是 |
|
||||
| 82 | udf | 是 | 是 |
|
||||
| 83 | enableCoreFile | 是 | 是 |
|
||||
| 84 | arbitrator | 是 | 否 |
|
||||
| 85 | numOfThreadsPerCore | 是 | 否 |
|
||||
| 86 | numOfMnodes | 是 | 否 |
|
||||
| 87 | vnodeBak | 是 | 否 |
|
||||
| 88 | balance | 是 | 否 |
|
||||
| 89 | balanceInterval | 是 | 否 |
|
||||
| 90 | offlineThreshold | 是 | 否 |
|
||||
| 91 | role | 是 | 否 |
|
||||
| 92 | dnodeNopLoop | 是 | 否 |
|
||||
| 93 | keepTimeOffset | 是 | 否 |
|
||||
| 94 | rpcTimer | 是 | 否 |
|
||||
| 95 | rpcMaxTime | 是 | 否 |
|
||||
| 96 | rpcForceTcp | 是 | 否 |
|
||||
| 97 | tcpConnTimeout | 是 | 否 |
|
||||
| 98 | syncCheckInterval | 是 | 否 |
|
||||
| 99 | maxTmrCtrl | 是 | 否 |
|
||||
| 100 | monitorReplica | 是 | 否 |
|
||||
| 101 | smlTagNullName | 是 | 否 |
|
||||
| 102 | keepColumnName | 是 | 否 |
|
||||
| 103 | ratioOfQueryCores | 是 | 否 |
|
||||
| 104 | maxStreamCompDelay | 是 | 否 |
|
||||
| 105 | maxFirstStreamCompDelay | 是 | 否 |
|
||||
| 106 | retryStreamCompDelay | 是 | 否 |
|
||||
| 107 | streamCompDelayRatio | 是 | 否 |
|
||||
| 108 | maxVgroupsPerDb | 是 | 否 |
|
||||
| 109 | maxTablesPerVnode | 是 | 否 |
|
||||
| 110 | minTablesPerVnode | 是 | 否 |
|
||||
| 111 | tableIncStepPerVnode | 是 | 否 |
|
||||
| 112 | cache | 是 | 否 |
|
||||
| 113 | blocks | 是 | 否 |
|
||||
| 114 | days | 是 | 否 |
|
||||
| 115 | keep | 是 | 否 |
|
||||
| 116 | minRows | 是 | 否 |
|
||||
| 117 | maxRows | 是 | 否 |
|
||||
| 118 | quorum | 是 | 否 |
|
||||
| 119 | comp | 是 | 否 |
|
||||
| 120 | walLevel | 是 | 否 |
|
||||
| 121 | fsync | 是 | 否 |
|
||||
| 122 | replica | 是 | 否 |
|
||||
| 123 | partitions | 是 | 否 |
|
||||
| 124 | quorum | 是 | 否 |
|
||||
| 125 | update | 是 | 否 |
|
||||
| 126 | cachelast | 是 | 否 |
|
||||
| 127 | maxSQLLength | 是 | 否 |
|
||||
| 128 | maxWildCardsLength | 是 | 否 |
|
||||
| 129 | maxRegexStringLen | 是 | 否 |
|
||||
| 130 | maxNumOfOrderedRes | 是 | 否 |
|
||||
| 131 | maxConnections | 是 | 否 |
|
||||
| 132 | mnodeEqualVnodeNum | 是 | 否 |
|
||||
| 133 | http | 是 | 否 |
|
||||
| 134 | httpEnableRecordSql | 是 | 否 |
|
||||
| 135 | httpMaxThreads | 是 | 否 |
|
||||
| 136 | restfulRowLimit | 是 | 否 |
|
||||
| 137 | httpDbNameMandatory | 是 | 否 |
|
||||
| 138 | httpKeepAlive | 是 | 否 |
|
||||
| 139 | enableRecordSql | 是 | 否 |
|
||||
| 140 | maxBinaryDisplayWidth | 是 | 否 |
|
||||
| 141 | stream | 是 | 否 |
|
||||
| 142 | retrieveBlockingModel | 是 | 否 |
|
||||
| 143 | tsdbMetaCompactRatio | 是 | 否 |
|
||||
| 144 | defaultJSONStrType | 是 | 否 |
|
||||
| 145 | walFlushSize | 是 | 否 |
|
||||
| 146 | keepTimeOffset | 是 | 否 |
|
||||
| 147 | flowctrl | 是 | 否 |
|
||||
| 148 | slaveQuery | 是 | 否 |
|
||||
| 149 | adjustMaster | 是 | 否 |
|
||||
| 150 | topicBinaryLen | 是 | 否 |
|
||||
| 151 | telegrafUseFieldNum | 是 | 否 |
|
||||
| 152 | deadLockKillQuery | 是 | 否 |
|
||||
| 153 | clientMerge | 是 | 否 |
|
||||
| 154 | sdbDebugFlag | 是 | 否 |
|
||||
| 155 | odbcDebugFlag | 是 | 否 |
|
||||
| 156 | httpDebugFlag | 是 | 否 |
|
||||
| 157 | monDebugFlag | 是 | 否 |
|
||||
| 158 | cqDebugFlag | 是 | 否 |
|
||||
| 159 | shortcutFlag | 是 | 否 |
|
||||
| 160 | probeSeconds | 是 | 否 |
|
||||
| 161 | probeKillSeconds | 是 | 否 |
|
||||
| 162 | probeInterval | 是 | 否 |
|
||||
| 163 | lossyColumns | 是 | 否 |
|
||||
| 164 | fPrecision | 是 | 否 |
|
||||
| 165 | dPrecision | 是 | 否 |
|
||||
| 166 | maxRange | 是 | 否 |
|
||||
| 167 | range | 是 | 否 |
|
||||
|
|
|
@ -9,7 +9,7 @@ import Release from "/components/ReleaseV3";
|
|||
|
||||
<Release type="tdengine" version="3.0.0.1" />
|
||||
|
||||
## 3.0.0.0
|
||||
<!-- ## 3.0.0.0
|
||||
|
||||
<Release type="tdengine" version="3.0.0.0" />
|
||||
<Release type="tdengine" version="3.0.0.0" /> -->
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// clang-format off
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -94,13 +95,8 @@ int32_t create_stream() {
|
|||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
/*const char* sql = "select min(k), max(k), sum(k) from tu1";*/
|
||||
/*const char* sql = "select min(k), max(k), sum(k) as sum_of_k from st1";*/
|
||||
/*const char* sql = "select sum(k) from tu1 interval(10m)";*/
|
||||
/*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/
|
||||
pRes = taos_query(pConn,
|
||||
"create stream stream1 trigger max_delay 10s watermark 10s into outstb as select _wstart start, "
|
||||
"count(k) from st1 partition by tbname interval(20s) ");
|
||||
"create stream stream1 trigger at_once watermark 10s into outstb as select _wstart start, avg(k) from st1 partition by tbname interval(10s)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create stream stream1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
|
|
|
@ -22,27 +22,27 @@ extern "C" {
|
|||
#ifndef TDENGINE_SYSTABLE_H
|
||||
#define TDENGINE_SYSTABLE_H
|
||||
|
||||
#define TSDB_INFORMATION_SCHEMA_DB "information_schema"
|
||||
#define TSDB_INS_TABLE_DNODES "ins_dnodes"
|
||||
#define TSDB_INS_TABLE_MNODES "ins_mnodes"
|
||||
#define TSDB_INS_TABLE_MODULES "ins_modules"
|
||||
#define TSDB_INS_TABLE_QNODES "ins_qnodes"
|
||||
#define TSDB_INS_TABLE_BNODES "ins_bnodes"
|
||||
#define TSDB_INS_TABLE_SNODES "ins_snodes"
|
||||
#define TSDB_INS_TABLE_CLUSTER "ins_cluster"
|
||||
#define TSDB_INS_TABLE_DATABASES "ins_databases"
|
||||
#define TSDB_INS_TABLE_FUNCTIONS "ins_functions"
|
||||
#define TSDB_INS_TABLE_INDEXES "ins_indexes"
|
||||
#define TSDB_INS_TABLE_STABLES "ins_stables"
|
||||
#define TSDB_INS_TABLE_TABLES "ins_tables"
|
||||
#define TSDB_INS_TABLE_TAGS "ins_tags"
|
||||
#define TSDB_INS_TABLE_TABLE_DISTRIBUTED "ins_table_distributed"
|
||||
#define TSDB_INS_TABLE_USERS "ins_users"
|
||||
#define TSDB_INS_TABLE_LICENCES "ins_grants"
|
||||
#define TSDB_INS_TABLE_VGROUPS "ins_vgroups"
|
||||
#define TSDB_INS_TABLE_VNODES "ins_vnodes"
|
||||
#define TSDB_INS_TABLE_CONFIGS "ins_configs"
|
||||
#define TSDB_INS_TABLE_DNODE_VARIABLES "ins_dnode_variables"
|
||||
#define TSDB_INFORMATION_SCHEMA_DB "information_schema"
|
||||
#define TSDB_INS_TABLE_DNODES "ins_dnodes"
|
||||
#define TSDB_INS_TABLE_MNODES "ins_mnodes"
|
||||
#define TSDB_INS_TABLE_MODULES "ins_modules"
|
||||
#define TSDB_INS_TABLE_QNODES "ins_qnodes"
|
||||
#define TSDB_INS_TABLE_BNODES "ins_bnodes"
|
||||
#define TSDB_INS_TABLE_SNODES "ins_snodes"
|
||||
#define TSDB_INS_TABLE_CLUSTER "ins_cluster"
|
||||
#define TSDB_INS_TABLE_DATABASES "ins_databases"
|
||||
#define TSDB_INS_TABLE_FUNCTIONS "ins_functions"
|
||||
#define TSDB_INS_TABLE_INDEXES "ins_indexes"
|
||||
#define TSDB_INS_TABLE_STABLES "ins_stables"
|
||||
#define TSDB_INS_TABLE_TABLES "ins_tables"
|
||||
#define TSDB_INS_TABLE_TAGS "ins_tags"
|
||||
#define TSDB_INS_TABLE_TABLE_DISTRIBUTED "ins_table_distributed"
|
||||
#define TSDB_INS_TABLE_USERS "ins_users"
|
||||
#define TSDB_INS_TABLE_LICENCES "ins_grants"
|
||||
#define TSDB_INS_TABLE_VGROUPS "ins_vgroups"
|
||||
#define TSDB_INS_TABLE_VNODES "ins_vnodes"
|
||||
#define TSDB_INS_TABLE_CONFIGS "ins_configs"
|
||||
#define TSDB_INS_TABLE_DNODE_VARIABLES "ins_dnode_variables"
|
||||
|
||||
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
|
||||
#define TSDB_PERFS_TABLE_SMAS "perf_smas"
|
||||
|
@ -60,16 +60,20 @@ typedef struct SSysDbTableSchema {
|
|||
const char* name;
|
||||
const int32_t type;
|
||||
const int32_t bytes;
|
||||
const bool sysInfo;
|
||||
} SSysDbTableSchema;
|
||||
|
||||
typedef struct SSysTableMeta {
|
||||
const char* name;
|
||||
const SSysDbTableSchema* schema;
|
||||
const int32_t colNum;
|
||||
const bool sysInfo;
|
||||
} SSysTableMeta;
|
||||
|
||||
void getInfosDbMeta(const SSysTableMeta** pInfosTableMeta, size_t* size);
|
||||
void getPerfDbMeta(const SSysTableMeta** pPerfsTableMeta, size_t* size);
|
||||
void getVisibleInfosTablesNum(bool sysInfo, size_t* size);
|
||||
bool invisibleColumn(bool sysInfo, int8_t tableType, int8_t flags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -44,6 +44,30 @@ enum {
|
|||
)
|
||||
// clang-format on
|
||||
|
||||
typedef struct {
|
||||
TSKEY ts;
|
||||
uint64_t groupId;
|
||||
} SWinKey;
|
||||
|
||||
static inline int SWinKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, int kLen2) {
|
||||
SWinKey* pWin1 = (SWinKey*)pKey1;
|
||||
SWinKey* pWin2 = (SWinKey*)pKey2;
|
||||
|
||||
if (pWin1->groupId > pWin2->groupId) {
|
||||
return 1;
|
||||
} else if (pWin1->groupId < pWin2->groupId) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pWin1->ts > pWin2->ts) {
|
||||
return 1;
|
||||
} else if (pWin1->ts < pWin2->ts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum {
|
||||
TMQ_MSG_TYPE__DUMMY = 0,
|
||||
TMQ_MSG_TYPE__POLL_RSP,
|
||||
|
@ -181,7 +205,7 @@ typedef struct SColumn {
|
|||
int16_t slotId;
|
||||
|
||||
char name[TSDB_COL_NAME_LEN];
|
||||
int8_t flag; // column type: normal column, tag, or user-input column (integer/float/string)
|
||||
int16_t colType; // column type: normal column, tag, or window column
|
||||
int16_t type;
|
||||
int32_t bytes;
|
||||
uint8_t precision;
|
||||
|
|
|
@ -66,6 +66,7 @@ extern int32_t tsNumOfVnodeStreamThreads;
|
|||
extern int32_t tsNumOfVnodeFetchThreads;
|
||||
extern int32_t tsNumOfVnodeWriteThreads;
|
||||
extern int32_t tsNumOfVnodeSyncThreads;
|
||||
extern int32_t tsNumOfVnodeRsmaThreads;
|
||||
extern int32_t tsNumOfQnodeQueryThreads;
|
||||
extern int32_t tsNumOfQnodeFetchThreads;
|
||||
extern int32_t tsNumOfSnodeSharedThreads;
|
||||
|
|
|
@ -292,10 +292,11 @@ int32_t tEncodeSSubmitRsp(SEncoder* pEncoder, const SSubmitRsp* pRsp);
|
|||
int32_t tDecodeSSubmitRsp(SDecoder* pDecoder, SSubmitRsp* pRsp);
|
||||
void tFreeSSubmitRsp(SSubmitRsp* pRsp);
|
||||
|
||||
#define COL_SMA_ON ((int8_t)0x1)
|
||||
#define COL_IDX_ON ((int8_t)0x2)
|
||||
#define COL_SET_NULL ((int8_t)0x10)
|
||||
#define COL_SET_VAL ((int8_t)0x20)
|
||||
#define COL_SMA_ON ((int8_t)0x1)
|
||||
#define COL_IDX_ON ((int8_t)0x2)
|
||||
#define COL_SET_NULL ((int8_t)0x10)
|
||||
#define COL_SET_VAL ((int8_t)0x20)
|
||||
#define COL_IS_SYSINFO ((int8_t)0x40)
|
||||
struct SSchema {
|
||||
int8_t type;
|
||||
int8_t flags;
|
||||
|
@ -557,6 +558,7 @@ typedef struct {
|
|||
uint32_t connId;
|
||||
int32_t dnodeNum;
|
||||
int8_t superUser;
|
||||
int8_t sysInfo;
|
||||
int8_t connType;
|
||||
SEpSet epSet;
|
||||
int32_t svrTimestamp;
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
#define TDENGINE_COMMAND_H
|
||||
|
||||
#include "cmdnodes.h"
|
||||
#include "tmsg.h"
|
||||
#include "plannodes.h"
|
||||
#include "tmsg.h"
|
||||
|
||||
typedef struct SExplainCtx SExplainCtx;
|
||||
|
||||
int32_t qExecCommand(SNode* pStmt, SRetrieveTableRsp** pRsp);
|
||||
int32_t qExecCommand(bool sysInfoUser, SNode *pStmt, SRetrieveTableRsp **pRsp);
|
||||
|
||||
int32_t qExecStaticExplain(SQueryPlan *pDag, SRetrieveTableRsp **pRsp);
|
||||
int32_t qExecExplainBegin(SQueryPlan *pDag, SExplainCtx **pCtx, int64_t startTs);
|
||||
|
|
|
@ -29,7 +29,7 @@ typedef void* DataSinkHandle;
|
|||
struct SRpcMsg;
|
||||
struct SSubplan;
|
||||
|
||||
typedef struct SReadHandle {
|
||||
typedef struct {
|
||||
void* tqReader;
|
||||
void* meta;
|
||||
void* config;
|
||||
|
@ -41,6 +41,7 @@ typedef struct SReadHandle {
|
|||
bool initTableReader;
|
||||
bool initTqReader;
|
||||
int32_t numOfVgroups;
|
||||
void* pStateBackend;
|
||||
} SReadHandle;
|
||||
|
||||
// in queue mode, data streams are seperated by msg
|
||||
|
@ -78,8 +79,8 @@ int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numO
|
|||
|
||||
/**
|
||||
* @brief Cleanup SSDataBlock for StreamScanInfo
|
||||
*
|
||||
* @param tinfo
|
||||
*
|
||||
* @param tinfo
|
||||
*/
|
||||
void tdCleanupStreamInputDataBlock(qTaskInfo_t tinfo);
|
||||
|
||||
|
@ -163,7 +164,7 @@ int32_t qGetQualifiedTableIdList(void* pTableList, const char* tagCond, int32_t
|
|||
|
||||
void qProcessRspMsg(void* parent, struct SRpcMsg* pMsg, struct SEpSet* pEpSet);
|
||||
|
||||
int32_t qGetExplainExecInfo(qTaskInfo_t tinfo, SArray* pExecInfoList/*,int32_t* resNum, SExplainExecInfo** pRes*/);
|
||||
int32_t qGetExplainExecInfo(qTaskInfo_t tinfo, SArray* pExecInfoList /*,int32_t* resNum, SExplainExecInfo** pRes*/);
|
||||
|
||||
int32_t qSerializeTaskStatus(qTaskInfo_t tinfo, char** pOutput, int32_t* len);
|
||||
|
||||
|
|
|
@ -317,6 +317,7 @@ typedef struct SSystemTableScanPhysiNode {
|
|||
SEpSet mgmtEpSet;
|
||||
bool showRewrite;
|
||||
int32_t accountId;
|
||||
bool sysInfo;
|
||||
} SSystemTableScanPhysiNode;
|
||||
|
||||
typedef struct STableScanPhysiNode {
|
||||
|
|
|
@ -57,7 +57,9 @@ typedef enum EColumnType {
|
|||
COLUMN_TYPE_COLUMN = 1,
|
||||
COLUMN_TYPE_TAG,
|
||||
COLUMN_TYPE_TBNAME,
|
||||
COLUMN_TYPE_WINDOW_PC,
|
||||
COLUMN_TYPE_WINDOW_START,
|
||||
COLUMN_TYPE_WINDOW_END,
|
||||
COLUMN_TYPE_WINDOW_DURATION,
|
||||
COLUMN_TYPE_GROUP_KEY
|
||||
} EColumnType;
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ typedef struct SParseContext {
|
|||
SStmtCallback* pStmtCb;
|
||||
const char* pUser;
|
||||
bool isSuperUser;
|
||||
bool enableSysInfo;
|
||||
bool async;
|
||||
int8_t schemalessType;
|
||||
const char* svrVer;
|
||||
|
|
|
@ -38,6 +38,7 @@ typedef struct SPlanContext {
|
|||
char* pMsg;
|
||||
int32_t msgLen;
|
||||
const char* pUser;
|
||||
bool sysInfo;
|
||||
} SPlanContext;
|
||||
|
||||
// Create the physical plan for the query, according to the AST.
|
||||
|
|
|
@ -263,6 +263,14 @@ typedef struct {
|
|||
SArray* checkpointVer;
|
||||
} SStreamRecoveringState;
|
||||
|
||||
// incremental state storage
|
||||
typedef struct {
|
||||
SStreamTask* pOwner;
|
||||
TDB* db;
|
||||
TTB* pStateDb;
|
||||
TXN txn;
|
||||
} SStreamState;
|
||||
|
||||
typedef struct SStreamTask {
|
||||
int64_t streamId;
|
||||
int32_t taskId;
|
||||
|
@ -312,6 +320,10 @@ typedef struct SStreamTask {
|
|||
|
||||
// msg handle
|
||||
SMsgCb* pMsgCb;
|
||||
|
||||
// state backend
|
||||
SStreamState* pState;
|
||||
|
||||
} SStreamTask;
|
||||
|
||||
int32_t tEncodeStreamEpInfo(SEncoder* pEncoder, const SStreamChildEpInfo* pInfo);
|
||||
|
@ -507,7 +519,7 @@ typedef struct SStreamMeta {
|
|||
char* path;
|
||||
TDB* db;
|
||||
TTB* pTaskDb;
|
||||
TTB* pStateDb;
|
||||
TTB* pCheckpointDb;
|
||||
SHashObj* pTasks;
|
||||
SHashObj* pRecoverStatus;
|
||||
void* ahandle;
|
||||
|
@ -528,6 +540,37 @@ int32_t streamMetaCommit(SStreamMeta* pMeta);
|
|||
int32_t streamMetaRollBack(SStreamMeta* pMeta);
|
||||
int32_t streamLoadTasks(SStreamMeta* pMeta);
|
||||
|
||||
SStreamState* streamStateOpen(char* path, SStreamTask* pTask);
|
||||
void streamStateClose(SStreamState* pState);
|
||||
int32_t streamStateBegin(SStreamState* pState);
|
||||
int32_t streamStateCommit(SStreamState* pState);
|
||||
int32_t streamStateAbort(SStreamState* pState);
|
||||
|
||||
typedef struct {
|
||||
TBC* pCur;
|
||||
} SStreamStateCur;
|
||||
|
||||
#if 1
|
||||
int32_t streamStatePut(SStreamState* pState, const SWinKey* key, const void* value, int32_t vLen);
|
||||
int32_t streamStateGet(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen);
|
||||
int32_t streamStateDel(SStreamState* pState, const SWinKey* key);
|
||||
void streamFreeVal(void* val);
|
||||
|
||||
SStreamStateCur* streamStateGetCur(SStreamState* pState, const SWinKey* key);
|
||||
SStreamStateCur* streamStateSeekKeyNext(SStreamState* pState, const SWinKey* key);
|
||||
SStreamStateCur* streamStateSeekKeyPrev(SStreamState* pState, const SWinKey* key);
|
||||
void streamStateFreeCur(SStreamStateCur* pCur);
|
||||
|
||||
int32_t streamStateGetKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen);
|
||||
|
||||
int32_t streamStateSeekFirst(SStreamState* pState, SStreamStateCur* pCur);
|
||||
int32_t streamStateSeekLast(SStreamState* pState, SStreamStateCur* pCur);
|
||||
|
||||
int32_t streamStateCurNext(SStreamState* pState, SStreamStateCur* pCur);
|
||||
int32_t streamStateCurPrev(SStreamState* pState, SStreamStateCur* pCur);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -40,10 +40,12 @@ if not exist %work_dir%\debug\ver-%2-x86 (
|
|||
)
|
||||
cd %work_dir%\debug\ver-%2-x64
|
||||
call vcvarsall.bat x64
|
||||
cmake ../../ -G "NMake Makefiles JOM" -DCMAKE_MAKE_PROGRAM=jom -DBUILD_TOOLS=true -DBUILD_HTTP=false -DVERNUMBER=%2 -DCPUTYPE=x64
|
||||
cmake ../../ -G "NMake Makefiles JOM" -DCMAKE_MAKE_PROGRAM=jom -DBUILD_TOOLS=true -DBUILD_HTTP=false -DBUILD_TEST=false -DVERNUMBER=%2 -DCPUTYPE=x64
|
||||
cmake --build .
|
||||
rd /s /Q C:\TDengine
|
||||
cmake --install .
|
||||
for /r c:\TDengine %%i in (*.dll) do signtool sign /f D:\\123.pfx /p taosdata %%i
|
||||
for /r c:\TDengine %%i in (*.exe) do signtool sign /f D:\\123.pfx /p taosdata %%i
|
||||
if not %errorlevel% == 0 ( call :RUNFAILED build x64 failed & exit /b 1)
|
||||
cd %package_dir%
|
||||
iscc /DMyAppInstallName="%packagServerName_x64%" /DMyAppVersion="%2" /DMyAppExcludeSource="" tools\tdengine.iss /O..\release
|
||||
|
@ -51,19 +53,7 @@ if not %errorlevel% == 0 ( call :RUNFAILED package %packagServerName_x64% faile
|
|||
iscc /DMyAppInstallName="%packagClientName_x64%" /DMyAppVersion="%2" /DMyAppExcludeSource="taosd.exe" tools\tdengine.iss /O..\release
|
||||
if not %errorlevel% == 0 ( call :RUNFAILED package %packagClientName_x64% failed & exit /b 1)
|
||||
|
||||
cd %work_dir%\debug\ver-%2-x86
|
||||
call vcvarsall.bat x86
|
||||
cmake ../../ -G "NMake Makefiles JOM" -DCMAKE_MAKE_PROGRAM=jom -DBUILD_TOOLS=true -DBUILD_HTTP=false -DVERNUMBER=%2 -DCPUTYPE=x86
|
||||
cmake --build .
|
||||
rd /s /Q C:\TDengine
|
||||
cmake --install .
|
||||
if not %errorlevel% == 0 ( call :RUNFAILED build x86 failed & exit /b 1)
|
||||
cd %package_dir%
|
||||
@REM iscc /DMyAppInstallName="%packagServerName_x86%" /DMyAppVersion="%2" /DMyAppExcludeSource="" tools\tdengine.iss /O..\release
|
||||
@REM if not %errorlevel% == 0 ( call :RUNFAILED package %packagServerName_x86% failed & exit /b 1)
|
||||
iscc /DMyAppInstallName="%packagClientName_x86%" /DMyAppVersion="%2" /DMyAppExcludeSource="taosd.exe" tools\tdengine.iss /O..\release
|
||||
if not %errorlevel% == 0 ( call :RUNFAILED package %packagClientName_x86% failed & exit /b 1)
|
||||
|
||||
for /r ..\release %%i in (*.exe) do signtool sign /f d:\\123.pfx /p taosdata %%i
|
||||
goto EXIT0
|
||||
|
||||
:USAGE
|
||||
|
|
|
@ -95,15 +95,15 @@ typedef struct {
|
|||
} SClientHbMgr;
|
||||
|
||||
typedef struct SQueryExecMetric {
|
||||
int64_t start; // start timestamp, us
|
||||
int64_t start; // start timestamp, us
|
||||
int64_t syntaxStart; // start to parse, us
|
||||
int64_t syntaxEnd; // end to parse, us
|
||||
int64_t ctgStart; // start to parse, us
|
||||
int64_t ctgEnd; // end to parse, us
|
||||
int64_t syntaxEnd; // end to parse, us
|
||||
int64_t ctgStart; // start to parse, us
|
||||
int64_t ctgEnd; // end to parse, us
|
||||
int64_t semanticEnd;
|
||||
int64_t execEnd;
|
||||
int64_t send; // start to send to server, us
|
||||
int64_t rsp; // receive response from server, us
|
||||
int64_t send; // start to send to server, us
|
||||
int64_t rsp; // receive response from server, us
|
||||
} SQueryExecMetric;
|
||||
|
||||
struct SAppInstInfo {
|
||||
|
@ -137,6 +137,7 @@ typedef struct STscObj {
|
|||
char db[TSDB_DB_FNAME_LEN];
|
||||
char sVer[TSDB_VERSION_LEN];
|
||||
char sDetailVer[128];
|
||||
int8_t sysInfo;
|
||||
int8_t connType;
|
||||
int32_t acctId;
|
||||
uint32_t connId;
|
||||
|
@ -257,7 +258,7 @@ SRequestObj* execQuery(uint64_t connId, const char* sql, int sqlLen, bool valida
|
|||
TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly);
|
||||
void taosAsyncQueryImpl(uint64_t connId, const char* sql, __taos_async_fn_t fp, void* param, bool validateOnly);
|
||||
|
||||
int32_t getVersion1BlockMetaSize(const char* p, int32_t numOfCols);
|
||||
int32_t getVersion1BlockMetaSize(const char* p, int32_t numOfCols);
|
||||
|
||||
static FORCE_INLINE SReqResultInfo* tmqGetCurResInfo(TAOS_RES* res) {
|
||||
SMqRspObj* msg = (SMqRspObj*)res;
|
||||
|
|
|
@ -404,7 +404,9 @@ void taos_init_imp(void) {
|
|||
schedulerInit();
|
||||
tscDebug("starting to initialize TAOS driver");
|
||||
|
||||
#ifndef WINDOWS
|
||||
taosSetCoreDump(true);
|
||||
#endif
|
||||
|
||||
initTaskQueue();
|
||||
fmFuncMgtInit();
|
||||
|
|
|
@ -215,6 +215,7 @@ int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtC
|
|||
.pUser = pTscObj->user,
|
||||
.schemalessType = pTscObj->schemalessType,
|
||||
.isSuperUser = (0 == strcmp(pTscObj->user, TSDB_DEFAULT_USER)),
|
||||
.enableSysInfo = pTscObj->sysInfo,
|
||||
.svrVer = pTscObj->sVer,
|
||||
.nodeOffline = (pTscObj->pAppInfo->onlineDnodes < pTscObj->pAppInfo->totalDnodes)};
|
||||
|
||||
|
@ -246,7 +247,7 @@ int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtC
|
|||
|
||||
int32_t execLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
|
||||
SRetrieveTableRsp* pRsp = NULL;
|
||||
int32_t code = qExecCommand(pQuery->pRoot, &pRsp);
|
||||
int32_t code = qExecCommand(pRequest->pTscObj->sysInfo, pQuery->pRoot, &pRsp);
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pRsp) {
|
||||
code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp, false, true);
|
||||
}
|
||||
|
@ -284,7 +285,7 @@ void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
|
|||
return;
|
||||
}
|
||||
|
||||
int32_t code = qExecCommand(pQuery->pRoot, &pRsp);
|
||||
int32_t code = qExecCommand(pRequest->pTscObj->sysInfo, pQuery->pRoot, &pRsp);
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pRsp) {
|
||||
code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp, false, true);
|
||||
}
|
||||
|
@ -419,7 +420,8 @@ int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArra
|
|||
.showRewrite = pQuery->showRewrite,
|
||||
.pMsg = pRequest->msgBuf,
|
||||
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
|
||||
.pUser = pRequest->pTscObj->user};
|
||||
.pUser = pRequest->pTscObj->user,
|
||||
.sysInfo = pRequest->pTscObj->sysInfo};
|
||||
|
||||
return qCreateQueryPlan(&cxt, pPlan, pNodeList);
|
||||
}
|
||||
|
@ -1009,7 +1011,8 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultM
|
|||
.showRewrite = pQuery->showRewrite,
|
||||
.pMsg = pRequest->msgBuf,
|
||||
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
|
||||
.pUser = pRequest->pTscObj->user};
|
||||
.pUser = pRequest->pTscObj->user,
|
||||
.sysInfo = pRequest->pTscObj->sysInfo};
|
||||
|
||||
SAppInstInfo* pAppInfo = getAppInfo(pRequest);
|
||||
SQueryPlan* pDag = NULL;
|
||||
|
@ -1590,10 +1593,11 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
|
|||
}
|
||||
|
||||
int32_t getVersion1BlockMetaSize(const char* p, int32_t numOfCols) {
|
||||
int32_t cols = *(int32_t*) (p + sizeof(int32_t) * 3);
|
||||
int32_t cols = *(int32_t*)(p + sizeof(int32_t) * 3);
|
||||
ASSERT(numOfCols == cols);
|
||||
|
||||
return sizeof(int32_t) + sizeof(int32_t) + sizeof(int32_t)*3 + sizeof(uint64_t) + numOfCols * (sizeof(int8_t) + sizeof(int32_t));
|
||||
return sizeof(int32_t) + sizeof(int32_t) + sizeof(int32_t) * 3 + sizeof(uint64_t) +
|
||||
numOfCols * (sizeof(int8_t) + sizeof(int32_t));
|
||||
}
|
||||
|
||||
static int32_t estimateJsonLen(SReqResultInfo* pResultInfo, int32_t numOfCols, int32_t numOfRows) {
|
||||
|
|
|
@ -759,6 +759,7 @@ int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt) {
|
|||
.pUser = pTscObj->user,
|
||||
.schemalessType = pTscObj->schemalessType,
|
||||
.isSuperUser = (0 == strcmp(pTscObj->user, TSDB_DEFAULT_USER)),
|
||||
.enableSysInfo = pTscObj->sysInfo,
|
||||
.async = true,
|
||||
.svrVer = pTscObj->sVer,
|
||||
.nodeOffline = (pTscObj->pAppInfo->onlineDnodes < pTscObj->pAppInfo->totalDnodes)};
|
||||
|
|
|
@ -96,6 +96,7 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
connectRsp.epSet.eps[i].fqdn, connectRsp.epSet.eps[i].port, pTscObj->id);
|
||||
}
|
||||
|
||||
pTscObj->sysInfo = connectRsp.sysInfo;
|
||||
pTscObj->connId = connectRsp.connId;
|
||||
pTscObj->acctId = connectRsp.acctId;
|
||||
tstrncpy(pTscObj->sVer, connectRsp.sVer, tListLen(pTscObj->sVer));
|
||||
|
|
|
@ -15,343 +15,345 @@
|
|||
|
||||
#include "systable.h"
|
||||
#include "taos.h"
|
||||
#include "taosdef.h"
|
||||
#include "tdef.h"
|
||||
#include "tgrant.h"
|
||||
#include "tmsg.h"
|
||||
#include "types.h"
|
||||
|
||||
#define SYSTABLE_SCH_TABLE_NAME_LEN ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
|
||||
#define SYSTABLE_SCH_DB_NAME_LEN ((TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
|
||||
#define SYSTABLE_SCH_COL_NAME_LEN ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
|
||||
|
||||
// clang-format off
|
||||
static const SSysDbTableSchema dnodesSchema[] = {
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "vnodes", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
||||
{.name = "support_vnodes", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
||||
{.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "note", .bytes = 256 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "vnodes", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
||||
{.name = "support_vnodes", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
||||
{.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true},
|
||||
{.name = "note", .bytes = 256 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema mnodesSchema[] = {
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "role", .bytes = 12 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "status", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "role", .bytes = 12 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "status", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema modulesSchema[] = {
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "endpoint", .bytes = 134 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "module", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "endpoint", .bytes = 134 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "module", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema qnodesSchema[] = {
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema snodesSchema[] = {
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema bnodesSchema[] = {
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema clusterSchema[] = {
|
||||
{.name = "id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "name", .bytes = TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "uptime", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||
{.name = "name", .bytes = TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "uptime", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema userDBSchema[] = {
|
||||
{.name = "name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "vgroups", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "ntables", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "replica", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "strict", .bytes = TSDB_DB_STRICT_STR_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "duration", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "keep", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "buffer", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "pagesize", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "pages", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "minrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "maxrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "comp", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "precision", .bytes = 2 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "retentions", .bytes = 60 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "single_stable", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL},
|
||||
{.name = "cachemodel", .bytes = TSDB_CACHE_MODEL_STR_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "cachesize", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "wal_level", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "wal_fsync_period", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "wal_retention_period", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "wal_retention_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "wal_roll_period", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "wal_segment_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
{.name = "vgroups", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "ntables", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false},
|
||||
{.name = "replica", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true},
|
||||
{.name = "strict", .bytes = TSDB_DB_STRICT_STR_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "duration", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "keep", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "buffer", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "pagesize", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "pages", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "minrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "maxrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "comp", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true},
|
||||
{.name = "precision", .bytes = 2 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "retentions", .bytes = 60 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "single_stable", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL, .sysInfo = true},
|
||||
{.name = "cachemodel", .bytes = TSDB_CACHE_MODEL_STR_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "cachesize", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "wal_level", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true},
|
||||
{.name = "wal_fsync_period", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "wal_retention_period", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "wal_retention_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||
{.name = "wal_roll_period", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "wal_segment_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema userFuncSchema[] = {
|
||||
{.name = "name", .bytes = TSDB_FUNC_NAME_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "comment", .bytes = PATH_MAX - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "aggregate", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "output_type", .bytes = TSDB_TYPE_STR_MAX_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "code_len", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "bufsize", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "name", .bytes = TSDB_FUNC_NAME_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "comment", .bytes = PATH_MAX - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "aggregate", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||
{.name = "output_type", .bytes = TSDB_TYPE_STR_MAX_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
{.name = "code_len", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||
{.name = "bufsize", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema userIdxSchema[] = {
|
||||
{.name = "index_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "table_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "index_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "table_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema userStbsSchema[] = {
|
||||
{.name = "stable_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "columns", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "tags", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "last_update", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "table_comment", .bytes = TSDB_TB_COMMENT_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "watermark", .bytes = 64 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "max_delay", .bytes = 64 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "rollup", .bytes = 128 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "stable_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
{.name = "columns", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||
{.name = "tags", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||
{.name = "last_update", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
{.name = "table_comment", .bytes = TSDB_TB_COMMENT_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "watermark", .bytes = 64 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "max_delay", .bytes = 64 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "rollup", .bytes = 128 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema streamSchema[] = {
|
||||
{.name = "stream_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "status", .bytes = 20 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "source_db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "target_db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "target_table", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "watermark", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "trigger", .bytes = 20 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "stream_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
{.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "status", .bytes = 20 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "source_db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "target_db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "target_table", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "watermark", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false},
|
||||
{.name = "trigger", .bytes = 20 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema userTblsSchema[] = {
|
||||
{.name = "table_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "columns", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "stable_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "uid", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "ttl", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "table_comment", .bytes = TSDB_TB_COMMENT_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "type", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "table_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
{.name = "columns", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||
{.name = "stable_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "uid", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false},
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "ttl", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||
{.name = "table_comment", .bytes = TSDB_TB_COMMENT_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "type", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema userTagsSchema[] = {
|
||||
{.name = "table_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "stable_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "tag_name", .bytes = TSDB_COL_NAME_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "tag_type", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "tag_value", .bytes = TSDB_MAX_TAGS_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "table_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "stable_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "tag_name", .bytes = TSDB_COL_NAME_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "tag_type", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "tag_value", .bytes = TSDB_MAX_TAGS_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema userTblDistSchema[] = {
|
||||
{.name = "db_name", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "table_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "distributed_histogram", .bytes = 500 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "min_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "max_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "avg_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "stddev_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "rows", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "blocks", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "storage_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "compression_ratio", .bytes = 8, .type = TSDB_DATA_TYPE_DOUBLE},
|
||||
{.name = "rows_in_mem", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "seek_header_time", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "db_name", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "table_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "distributed_histogram", .bytes = 500 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "min_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "max_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "avg_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "stddev_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "rows", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||
{.name = "blocks", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "storage_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||
{.name = "compression_ratio", .bytes = 8, .type = TSDB_DATA_TYPE_DOUBLE, .sysInfo = true},
|
||||
{.name = "rows_in_mem", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "seek_header_time", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema userUsersSchema[] = {
|
||||
{.name = "name", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "super", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "enable", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "sysinfo", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "name", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "super", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = false},
|
||||
{.name = "enable", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = false},
|
||||
{.name = "sysinfo", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = false},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
};
|
||||
|
||||
GRANTS_SCHEMA;
|
||||
|
||||
static const SSysDbTableSchema vgroupsSchema[] = {
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "tables", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "v1_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "v1_status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "v2_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "v2_status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "v3_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "v3_status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "status", .bytes = 12 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "nfiles", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "file_size", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "tsma", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "tables", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "v1_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "v1_status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "v2_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "v2_status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "v3_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "v3_status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "status", .bytes = 12 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "nfiles", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "file_size", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "tsma", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema smaSchema[] = {
|
||||
{.name = "sma_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "stable_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "sma_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
{.name = "stable_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema transSchema[] = {
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "stage", .bytes = TSDB_TRANS_STAGE_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "db1", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "db2", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "failed_times", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "last_exec_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "last_action_info",
|
||||
.bytes = (TSDB_TRANS_ERROR_LEN - 1) + VARSTR_HEADER_SIZE,
|
||||
.type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
{.name = "stage", .bytes = TSDB_TRANS_STAGE_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "db1", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "db2", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "failed_times", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||
{.name = "last_exec_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
{.name = "last_action_info", .bytes = (TSDB_TRANS_ERROR_LEN - 1) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema configSchema[] = {
|
||||
{.name = "name", .bytes = TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "value", .bytes = TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "name", .bytes = TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "value", .bytes = TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema variablesSchema[] = {
|
||||
{.name = "dnode_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "name", .bytes = TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "value", .bytes = TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "name", .bytes = TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "value", .bytes = TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysTableMeta infosMeta[] = {
|
||||
{TSDB_INS_TABLE_DNODES, dnodesSchema, tListLen(dnodesSchema)},
|
||||
{TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema)},
|
||||
{TSDB_INS_TABLE_MODULES, modulesSchema, tListLen(modulesSchema)},
|
||||
{TSDB_INS_TABLE_QNODES, qnodesSchema, tListLen(qnodesSchema)},
|
||||
{TSDB_INS_TABLE_DNODES, dnodesSchema, tListLen(dnodesSchema), true},
|
||||
{TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema), true},
|
||||
{TSDB_INS_TABLE_MODULES, modulesSchema, tListLen(modulesSchema), true},
|
||||
{TSDB_INS_TABLE_QNODES, qnodesSchema, tListLen(qnodesSchema), true},
|
||||
// {TSDB_INS_TABLE_SNODES, snodesSchema, tListLen(snodesSchema)},
|
||||
// {TSDB_INS_TABLE_BNODES, bnodesSchema, tListLen(bnodesSchema)},
|
||||
{TSDB_INS_TABLE_CLUSTER, clusterSchema, tListLen(clusterSchema)},
|
||||
{TSDB_INS_TABLE_DATABASES, userDBSchema, tListLen(userDBSchema)},
|
||||
{TSDB_INS_TABLE_FUNCTIONS, userFuncSchema, tListLen(userFuncSchema)},
|
||||
{TSDB_INS_TABLE_INDEXES, userIdxSchema, tListLen(userIdxSchema)},
|
||||
{TSDB_INS_TABLE_STABLES, userStbsSchema, tListLen(userStbsSchema)},
|
||||
{TSDB_INS_TABLE_TABLES, userTblsSchema, tListLen(userTblsSchema)},
|
||||
{TSDB_INS_TABLE_TAGS, userTagsSchema, tListLen(userTagsSchema)},
|
||||
{TSDB_INS_TABLE_CLUSTER, clusterSchema, tListLen(clusterSchema), true},
|
||||
{TSDB_INS_TABLE_DATABASES, userDBSchema, tListLen(userDBSchema), false},
|
||||
{TSDB_INS_TABLE_FUNCTIONS, userFuncSchema, tListLen(userFuncSchema), false},
|
||||
{TSDB_INS_TABLE_INDEXES, userIdxSchema, tListLen(userIdxSchema), false},
|
||||
{TSDB_INS_TABLE_STABLES, userStbsSchema, tListLen(userStbsSchema), false},
|
||||
{TSDB_INS_TABLE_TABLES, userTblsSchema, tListLen(userTblsSchema), false},
|
||||
{TSDB_INS_TABLE_TAGS, userTagsSchema, tListLen(userTagsSchema), false},
|
||||
// {TSDB_INS_TABLE_TABLE_DISTRIBUTED, userTblDistSchema, tListLen(userTblDistSchema)},
|
||||
{TSDB_INS_TABLE_USERS, userUsersSchema, tListLen(userUsersSchema)},
|
||||
{TSDB_INS_TABLE_LICENCES, grantsSchema, tListLen(grantsSchema)},
|
||||
{TSDB_INS_TABLE_VGROUPS, vgroupsSchema, tListLen(vgroupsSchema)},
|
||||
{TSDB_INS_TABLE_CONFIGS, configSchema, tListLen(configSchema)},
|
||||
{TSDB_INS_TABLE_DNODE_VARIABLES, variablesSchema, tListLen(variablesSchema)},
|
||||
{TSDB_INS_TABLE_USERS, userUsersSchema, tListLen(userUsersSchema), false},
|
||||
{TSDB_INS_TABLE_LICENCES, grantsSchema, tListLen(grantsSchema), true},
|
||||
{TSDB_INS_TABLE_VGROUPS, vgroupsSchema, tListLen(vgroupsSchema), true},
|
||||
{TSDB_INS_TABLE_CONFIGS, configSchema, tListLen(configSchema), true},
|
||||
{TSDB_INS_TABLE_DNODE_VARIABLES, variablesSchema, tListLen(variablesSchema), true},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema connectionsSchema[] = {
|
||||
{.name = "conn_id", .bytes = 4, .type = TSDB_DATA_TYPE_UINT},
|
||||
{.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "app", .bytes = TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_UINT},
|
||||
{.name = "end_point", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "login_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "last_access", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "conn_id", .bytes = 4, .type = TSDB_DATA_TYPE_UINT, .sysInfo = false},
|
||||
{.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "app", .bytes = TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_UINT, .sysInfo = false},
|
||||
{.name = "end_point", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "login_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
{.name = "last_access", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema topicSchema[] = {
|
||||
{.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
{.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
// TODO config
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema consumerSchema[] = {
|
||||
{.name = "consumer_id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "consumer_group", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "client_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "status", .bytes = 20 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "topics", .bytes = TSDB_TOPIC_FNAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
/*{.name = "end_point", .bytes = TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},*/
|
||||
{.name = "up_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "subscribe_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "rebalance_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "consumer_id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false},
|
||||
{.name = "consumer_group", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "client_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "status", .bytes = 20 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "topics", .bytes = TSDB_TOPIC_FNAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
/*{.name = "end_point", .bytes = TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},*/
|
||||
{.name = "up_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
{.name = "subscribe_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
{.name = "rebalance_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema subscriptionSchema[] = {
|
||||
{.name = "topic_name", .bytes = TSDB_TOPIC_FNAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "consumer_group", .bytes = TSDB_CGROUP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "consumer_id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "topic_name", .bytes = TSDB_TOPIC_FNAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "consumer_group", .bytes = TSDB_CGROUP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||
{.name = "consumer_id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema offsetSchema[] = {
|
||||
{.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "group_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "committed_offset", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "current_offset", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "skip_log_cnt", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "group_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||
{.name = "committed_offset", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false},
|
||||
{.name = "current_offset", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false},
|
||||
{.name = "skip_log_cnt", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema querySchema[] = {
|
||||
{.name = "kill_id", .bytes = TSDB_QUERY_ID_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "query_id", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT},
|
||||
{.name = "conn_id", .bytes = 4, .type = TSDB_DATA_TYPE_UINT},
|
||||
{.name = "app", .bytes = TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "end_point", .bytes = TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "exec_usec", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "stable_query", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL},
|
||||
{.name = "sub_num", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "sub_status", .bytes = TSDB_SHOW_SUBQUERY_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "kill_id", .bytes = TSDB_QUERY_ID_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "query_id", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT, .sysInfo = false},
|
||||
{.name = "conn_id", .bytes = 4, .type = TSDB_DATA_TYPE_UINT, .sysInfo = false},
|
||||
{.name = "app", .bytes = TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||
{.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "end_point", .bytes = TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
{.name = "exec_usec", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false},
|
||||
{.name = "stable_query", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL, .sysInfo = false},
|
||||
{.name = "sub_num", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||
{.name = "sub_status", .bytes = TSDB_SHOW_SUBQUERY_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema appSchema[] = {
|
||||
{.name = "app_id", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT},
|
||||
{.name = "ip", .bytes = TSDB_IPv4ADDR_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "name", .bytes = TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "start_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "insert_req", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT},
|
||||
{.name = "insert_row", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT},
|
||||
{.name = "insert_time", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT},
|
||||
{.name = "insert_bytes", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT},
|
||||
{.name = "fetch_bytes", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT},
|
||||
{.name = "query_time", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT},
|
||||
{.name = "slow_query", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT},
|
||||
{.name = "total_req", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT},
|
||||
{.name = "current_req", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT},
|
||||
{.name = "last_access", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "app_id", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT, .sysInfo = false},
|
||||
{.name = "ip", .bytes = TSDB_IPv4ADDR_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||
{.name = "name", .bytes = TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "start_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
{.name = "insert_req", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT, .sysInfo = false},
|
||||
{.name = "insert_row", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT, .sysInfo = false},
|
||||
{.name = "insert_time", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT, .sysInfo = false},
|
||||
{.name = "insert_bytes", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT, .sysInfo = false},
|
||||
{.name = "fetch_bytes", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT, .sysInfo = false},
|
||||
{.name = "query_time", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT, .sysInfo = false},
|
||||
{.name = "slow_query", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT, .sysInfo = false},
|
||||
{.name = "total_req", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT, .sysInfo = false},
|
||||
{.name = "current_req", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT, .sysInfo = false},
|
||||
{.name = "last_access", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
};
|
||||
|
||||
static const SSysTableMeta perfsMeta[] = {
|
||||
{TSDB_PERFS_TABLE_CONNECTIONS, connectionsSchema, tListLen(connectionsSchema)},
|
||||
{TSDB_PERFS_TABLE_QUERIES, querySchema, tListLen(querySchema)},
|
||||
{TSDB_PERFS_TABLE_TOPICS, topicSchema, tListLen(topicSchema)},
|
||||
{TSDB_PERFS_TABLE_CONSUMERS, consumerSchema, tListLen(consumerSchema)},
|
||||
{TSDB_PERFS_TABLE_SUBSCRIPTIONS, subscriptionSchema, tListLen(subscriptionSchema)},
|
||||
{TSDB_PERFS_TABLE_CONNECTIONS, connectionsSchema, tListLen(connectionsSchema), false},
|
||||
{TSDB_PERFS_TABLE_QUERIES, querySchema, tListLen(querySchema), false},
|
||||
{TSDB_PERFS_TABLE_TOPICS, topicSchema, tListLen(topicSchema), false},
|
||||
{TSDB_PERFS_TABLE_CONSUMERS, consumerSchema, tListLen(consumerSchema), false},
|
||||
{TSDB_PERFS_TABLE_SUBSCRIPTIONS, subscriptionSchema, tListLen(subscriptionSchema), false},
|
||||
// {TSDB_PERFS_TABLE_OFFSETS, offsetSchema, tListLen(offsetSchema)},
|
||||
{TSDB_PERFS_TABLE_TRANS, transSchema, tListLen(transSchema)},
|
||||
{TSDB_PERFS_TABLE_SMAS, smaSchema, tListLen(smaSchema)},
|
||||
{TSDB_PERFS_TABLE_STREAMS, streamSchema, tListLen(streamSchema)},
|
||||
{TSDB_PERFS_TABLE_APPS, appSchema, tListLen(appSchema)}};
|
||||
{TSDB_PERFS_TABLE_TRANS, transSchema, tListLen(transSchema), false},
|
||||
{TSDB_PERFS_TABLE_SMAS, smaSchema, tListLen(smaSchema), false},
|
||||
{TSDB_PERFS_TABLE_STREAMS, streamSchema, tListLen(streamSchema), false},
|
||||
{TSDB_PERFS_TABLE_APPS, appSchema, tListLen(appSchema), false}};
|
||||
// clang-format on
|
||||
|
||||
void getInfosDbMeta(const SSysTableMeta** pInfosTableMeta, size_t* size) {
|
||||
if (pInfosTableMeta) {
|
||||
|
@ -370,3 +372,26 @@ void getPerfDbMeta(const SSysTableMeta** pPerfsTableMeta, size_t* size) {
|
|||
*size = tListLen(perfsMeta);
|
||||
}
|
||||
}
|
||||
|
||||
void getVisibleInfosTablesNum(bool sysInfo, size_t* size) {
|
||||
if (sysInfo) {
|
||||
getInfosDbMeta(NULL, size);
|
||||
return;
|
||||
}
|
||||
*size = 0;
|
||||
const SSysTableMeta* pMeta = NULL;
|
||||
size_t totalNum = 0;
|
||||
getInfosDbMeta(&pMeta, &totalNum);
|
||||
for (size_t i = 0; i < totalNum; ++i) {
|
||||
if (!pMeta[i].sysInfo) {
|
||||
++(*size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool invisibleColumn(bool sysInfo, int8_t tableType, int8_t flags) {
|
||||
if (sysInfo || TSDB_SYSTEM_TABLE != tableType) {
|
||||
return false;
|
||||
}
|
||||
return 0 != (flags & COL_IS_SYSINFO);
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ int32_t tsNumOfVnodeStreamThreads = 2;
|
|||
int32_t tsNumOfVnodeFetchThreads = 4;
|
||||
int32_t tsNumOfVnodeWriteThreads = 2;
|
||||
int32_t tsNumOfVnodeSyncThreads = 2;
|
||||
int32_t tsNumOfVnodeRsmaThreads = 2;
|
||||
int32_t tsNumOfQnodeQueryThreads = 4;
|
||||
int32_t tsNumOfQnodeFetchThreads = 4;
|
||||
int32_t tsNumOfSnodeSharedThreads = 2;
|
||||
|
@ -76,7 +77,7 @@ bool tsMonitorComp = false;
|
|||
|
||||
// telem
|
||||
bool tsEnableTelem = true;
|
||||
int32_t tsTelemInterval = 86400;
|
||||
int32_t tsTelemInterval = 43200;
|
||||
char tsTelemServer[TSDB_FQDN_LEN] = "telemetry.taosdata.com";
|
||||
uint16_t tsTelemPort = 80;
|
||||
|
||||
|
@ -378,6 +379,10 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
tsNumOfVnodeSyncThreads = TMAX(tsNumOfVnodeSyncThreads, 16);
|
||||
if (cfgAddInt32(pCfg, "numOfVnodeSyncThreads", tsNumOfVnodeSyncThreads, 1, 1024, 0) != 0) return -1;
|
||||
|
||||
tsNumOfVnodeRsmaThreads = tsNumOfCores;
|
||||
tsNumOfVnodeRsmaThreads = TMAX(tsNumOfVnodeRsmaThreads, 4);
|
||||
if (cfgAddInt32(pCfg, "numOfVnodeRsmaThreads", tsNumOfVnodeRsmaThreads, 1, 1024, 0) != 0) return -1;
|
||||
|
||||
tsNumOfQnodeQueryThreads = tsNumOfCores * 2;
|
||||
tsNumOfQnodeQueryThreads = TMAX(tsNumOfQnodeQueryThreads, 4);
|
||||
if (cfgAddInt32(pCfg, "numOfQnodeQueryThreads", tsNumOfQnodeQueryThreads, 1, 1024, 0) != 0) return -1;
|
||||
|
@ -539,6 +544,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
tsNumOfVnodeFetchThreads = cfgGetItem(pCfg, "numOfVnodeFetchThreads")->i32;
|
||||
tsNumOfVnodeWriteThreads = cfgGetItem(pCfg, "numOfVnodeWriteThreads")->i32;
|
||||
tsNumOfVnodeSyncThreads = cfgGetItem(pCfg, "numOfVnodeSyncThreads")->i32;
|
||||
tsNumOfVnodeRsmaThreads = cfgGetItem(pCfg, "numOfVnodeRsmaThreads")->i32;
|
||||
tsNumOfQnodeQueryThreads = cfgGetItem(pCfg, "numOfQnodeQueryThreads")->i32;
|
||||
tsNumOfQnodeFetchThreads = cfgGetItem(pCfg, "numOfQnodeFetchThreads")->i32;
|
||||
tsNumOfSnodeSharedThreads = cfgGetItem(pCfg, "numOfSnodeSharedThreads")->i32;
|
||||
|
@ -783,6 +789,8 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
|
|||
tsNumOfVnodeWriteThreads = cfgGetItem(pCfg, "numOfVnodeWriteThreads")->i32;
|
||||
} else if (strcasecmp("numOfVnodeSyncThreads", name) == 0) {
|
||||
tsNumOfVnodeSyncThreads = cfgGetItem(pCfg, "numOfVnodeSyncThreads")->i32;
|
||||
} else if (strcasecmp("numOfVnodeRsmaThreads", name) == 0) {
|
||||
tsNumOfVnodeRsmaThreads = cfgGetItem(pCfg, "numOfVnodeRsmaThreads")->i32;
|
||||
} else if (strcasecmp("numOfQnodeQueryThreads", name) == 0) {
|
||||
tsNumOfQnodeQueryThreads = cfgGetItem(pCfg, "numOfQnodeQueryThreads")->i32;
|
||||
} else if (strcasecmp("numOfQnodeFetchThreads", name) == 0) {
|
||||
|
|
|
@ -3634,6 +3634,7 @@ int32_t tSerializeSConnectRsp(void *buf, int32_t bufLen, SConnectRsp *pRsp) {
|
|||
if (tEncodeU32(&encoder, pRsp->connId) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->dnodeNum) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pRsp->superUser) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pRsp->sysInfo) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pRsp->connType) < 0) return -1;
|
||||
if (tEncodeSEpSet(&encoder, &pRsp->epSet) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->svrTimestamp) < 0) return -1;
|
||||
|
@ -3656,6 +3657,7 @@ int32_t tDeserializeSConnectRsp(void *buf, int32_t bufLen, SConnectRsp *pRsp) {
|
|||
if (tDecodeU32(&decoder, &pRsp->connId) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pRsp->dnodeNum) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pRsp->superUser) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pRsp->sysInfo) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pRsp->connType) < 0) return -1;
|
||||
if (tDecodeSEpSet(&decoder, &pRsp->epSet) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pRsp->svrTimestamp) < 0) return -1;
|
||||
|
|
|
@ -24,7 +24,8 @@ extern "C" {
|
|||
|
||||
int32_t mndInitInfos(SMnode *pMnode);
|
||||
void mndCleanupInfos(SMnode *pMnode);
|
||||
int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp);
|
||||
int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, bool sysinfo,
|
||||
STableMetaRsp *pRsp);
|
||||
int32_t mndBuildInsTableCfg(SMnode *pMnode, const char *dbFName, const char *tbName, STableCfgRsp *pRsp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -1731,7 +1731,7 @@ static int32_t mndRetrieveDbs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
|
|||
SDbObj infoschemaDb = {0};
|
||||
setInformationSchemaDbCfg(&infoschemaDb);
|
||||
size_t numOfTables = 0;
|
||||
getInfosDbMeta(NULL, &numOfTables);
|
||||
getVisibleInfosTablesNum(sysinfo, &numOfTables);
|
||||
mndDumpDbInfoData(pMnode, pBlock, &infoschemaDb, pShow, numOfRows, numOfTables, true, 0, 1);
|
||||
|
||||
numOfRows += 1;
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "systable.h"
|
||||
#include "mndInt.h"
|
||||
#include "systable.h"
|
||||
|
||||
static int32_t mndInitInfosTableSchema(const SSysDbTableSchema *pSrc, int32_t colNum, SSchema **pDst) {
|
||||
SSchema *schema = taosMemoryCalloc(colNum, sizeof(SSchema));
|
||||
|
@ -29,6 +29,9 @@ static int32_t mndInitInfosTableSchema(const SSysDbTableSchema *pSrc, int32_t co
|
|||
schema[i].type = pSrc[i].type;
|
||||
schema[i].colId = i + 1;
|
||||
schema[i].bytes = pSrc[i].bytes;
|
||||
if (pSrc[i].sysInfo) {
|
||||
schema[i].flags |= COL_IS_SYSINFO;
|
||||
}
|
||||
}
|
||||
|
||||
*pDst = schema;
|
||||
|
@ -43,13 +46,14 @@ static int32_t mndInsInitMeta(SHashObj *hash) {
|
|||
meta.sversion = 1;
|
||||
meta.tversion = 1;
|
||||
|
||||
size_t size = 0;
|
||||
const SSysTableMeta* pInfosTableMeta = NULL;
|
||||
size_t size = 0;
|
||||
const SSysTableMeta *pInfosTableMeta = NULL;
|
||||
getInfosDbMeta(&pInfosTableMeta, &size);
|
||||
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
tstrncpy(meta.tbName, pInfosTableMeta[i].name, sizeof(meta.tbName));
|
||||
meta.numOfColumns = pInfosTableMeta[i].colNum;
|
||||
meta.sysInfo = pInfosTableMeta[i].sysInfo;
|
||||
|
||||
if (mndInitInfosTableSchema(pInfosTableMeta[i].schema, pInfosTableMeta[i].colNum, &meta.pSchemas)) {
|
||||
return -1;
|
||||
|
@ -64,14 +68,15 @@ static int32_t mndInsInitMeta(SHashObj *hash) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp) {
|
||||
int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, bool sysinfo,
|
||||
STableMetaRsp *pRsp) {
|
||||
if (NULL == pMnode->infosMeta) {
|
||||
terrno = TSDB_CODE_APP_NOT_READY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
STableMetaRsp *pMeta = taosHashGet(pMnode->infosMeta, tbName, strlen(tbName));
|
||||
if (NULL == pMeta) {
|
||||
if (NULL == pMeta || (!sysinfo && pMeta->sysInfo)) {
|
||||
mError("invalid information schema table name:%s", tbName);
|
||||
terrno = TSDB_CODE_MND_INVALID_SYS_TABLENAME;
|
||||
return -1;
|
||||
|
@ -121,7 +126,6 @@ int32_t mndBuildInsTableCfg(SMnode *pMnode, const char *dbFName, const char *tbN
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t mndInitInfos(SMnode *pMnode) {
|
||||
pMnode->infosMeta = taosHashInit(20, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), false, HASH_NO_LOCK);
|
||||
if (pMnode->infosMeta == NULL) {
|
||||
|
|
|
@ -270,6 +270,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
|
|||
SConnectRsp connectRsp = {0};
|
||||
connectRsp.acctId = pUser->acctId;
|
||||
connectRsp.superUser = pUser->superUser;
|
||||
connectRsp.sysInfo = pUser->sysInfo;
|
||||
connectRsp.clusterId = pMnode->clusterId;
|
||||
connectRsp.connId = pConn->id;
|
||||
connectRsp.connType = connReq.connType;
|
||||
|
|
|
@ -2218,6 +2218,10 @@ static int32_t mndProcessTableMetaReq(SRpcMsg *pReq) {
|
|||
STableInfoReq infoReq = {0};
|
||||
STableMetaRsp metaRsp = {0};
|
||||
|
||||
SUserObj *pUser = mndAcquireUser(pMnode, pReq->info.conn.user);
|
||||
if (pUser == NULL) return 0;
|
||||
bool sysinfo = pUser->sysInfo;
|
||||
|
||||
if (tDeserializeSTableInfoReq(pReq->pCont, pReq->contLen, &infoReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
goto _OVER;
|
||||
|
@ -2225,7 +2229,7 @@ static int32_t mndProcessTableMetaReq(SRpcMsg *pReq) {
|
|||
|
||||
if (0 == strcmp(infoReq.dbFName, TSDB_INFORMATION_SCHEMA_DB)) {
|
||||
mDebug("information_schema table:%s.%s, start to retrieve meta", infoReq.dbFName, infoReq.tbName);
|
||||
if (mndBuildInsTableSchema(pMnode, infoReq.dbFName, infoReq.tbName, &metaRsp) != 0) {
|
||||
if (mndBuildInsTableSchema(pMnode, infoReq.dbFName, infoReq.tbName, sysinfo, &metaRsp) != 0) {
|
||||
goto _OVER;
|
||||
}
|
||||
} else if (0 == strcmp(infoReq.dbFName, TSDB_PERFORMANCE_SCHEMA_DB)) {
|
||||
|
@ -2264,6 +2268,7 @@ _OVER:
|
|||
mError("stb:%s.%s, failed to retrieve meta since %s", infoReq.dbFName, infoReq.tbName, terrstr());
|
||||
}
|
||||
|
||||
mndReleaseUser(pMnode, pUser);
|
||||
tFreeSTableMetaRsp(&metaRsp);
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -131,7 +131,9 @@ static int32_t mndProcessTelemTimer(SRpcMsg* pReq) {
|
|||
char* pCont = mndBuildTelemetryReport(pMnode);
|
||||
if (pCont != NULL) {
|
||||
if (taosSendHttpReport(tsTelemServer, tsTelemPort, pCont, strlen(pCont), HTTP_FLAT) != 0) {
|
||||
mError("failed to send telemetry msg");
|
||||
mError("failed to send telemetry report");
|
||||
} else {
|
||||
mTrace("succeed to send telemetry report");
|
||||
}
|
||||
taosMemoryFree(pCont);
|
||||
}
|
||||
|
|
|
@ -1315,7 +1315,7 @@ static bool mndTransPerformRedoActionStage(SMnode *pMnode, STrans *pTrans) {
|
|||
if (pTrans->policy == TRN_POLICY_ROLLBACK) {
|
||||
if (pTrans->lastAction != 0) {
|
||||
STransAction *pAction = taosArrayGet(pTrans->redoActions, pTrans->lastAction);
|
||||
if (pAction->retryCode != 0 && pAction->retryCode != pAction->errCode) {
|
||||
if (pAction->retryCode != 0 && pAction->retryCode == pAction->errCode) {
|
||||
if (pTrans->failedTimes < 6) {
|
||||
mError("trans:%d, stage keep on redoAction since action:%d code:0x%x not 0x%x, failedTimes:%d", pTrans->id,
|
||||
pTrans->lastAction, pTrans->code, pAction->retryCode, pTrans->failedTimes);
|
||||
|
|
|
@ -5,7 +5,9 @@ target_link_libraries(
|
|||
PUBLIC sut
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME smaTest
|
||||
COMMAND smaTest
|
||||
)
|
||||
if(NOT ${TD_WINDOWS})
|
||||
add_test(
|
||||
NAME smaTest
|
||||
COMMAND smaTest
|
||||
)
|
||||
endif(NOT ${TD_WINDOWS})
|
||||
|
|
|
@ -5,7 +5,9 @@ target_link_libraries(
|
|||
PUBLIC sut
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME stbTest
|
||||
COMMAND stbTest
|
||||
)
|
||||
if(NOT ${TD_WINDOWS})
|
||||
add_test(
|
||||
NAME stbTest
|
||||
COMMAND stbTest
|
||||
)
|
||||
endif(NOT ${TD_WINDOWS})
|
|
@ -33,7 +33,6 @@ extern "C" {
|
|||
// clang-format on
|
||||
|
||||
#define RSMA_TASK_INFO_HASH_SLOT (8)
|
||||
#define RSMA_EXECUTOR_MAX (1)
|
||||
|
||||
typedef struct SSmaEnv SSmaEnv;
|
||||
typedef struct SSmaStat SSmaStat;
|
||||
|
@ -49,9 +48,12 @@ typedef struct SQTaskFWriter SQTaskFWriter;
|
|||
struct SSmaEnv {
|
||||
SRWLatch lock;
|
||||
int8_t type;
|
||||
int8_t flag; // 0x01 inClose
|
||||
SSmaStat *pStat;
|
||||
};
|
||||
|
||||
#define SMA_ENV_FLG_CLOSE ((int8_t)0x1)
|
||||
|
||||
typedef struct {
|
||||
int8_t inited;
|
||||
int32_t rsetId;
|
||||
|
@ -93,7 +95,6 @@ struct SRSmaStat {
|
|||
int64_t refId; // shared by fetch tasks
|
||||
volatile int64_t nBufItems; // number of items in queue buffer
|
||||
SRWLatch lock; // r/w lock for rsma fs(e.g. qtaskinfo)
|
||||
volatile int8_t nExecutor; // [1, max(half of query threads, 4)]
|
||||
int8_t triggerStat; // shared by fetch tasks
|
||||
int8_t commitStat; // 0 not in committing, 1 in committing
|
||||
SArray *aTaskFile; // qTaskFiles committed recently(for recovery/snapshot r/w)
|
||||
|
@ -107,6 +108,7 @@ struct SSmaStat {
|
|||
SRSmaStat rsmaStat; // rollup sma
|
||||
};
|
||||
T_REF_DECLARE()
|
||||
char data[];
|
||||
};
|
||||
|
||||
#define SMA_STAT_TSMA(s) (&(s)->tsmaStat)
|
||||
|
|
|
@ -189,7 +189,6 @@ SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchem
|
|||
int32_t smaInit();
|
||||
void smaCleanUp();
|
||||
int32_t smaOpen(SVnode* pVnode);
|
||||
int32_t smaPreClose(SSma* pSma);
|
||||
int32_t smaClose(SSma* pSma);
|
||||
int32_t smaBegin(SSma* pSma);
|
||||
int32_t smaSyncPreCommit(SSma* pSma);
|
||||
|
@ -199,7 +198,6 @@ int32_t smaAsyncPreCommit(SSma* pSma);
|
|||
int32_t smaAsyncCommit(SSma* pSma);
|
||||
int32_t smaAsyncPostCommit(SSma* pSma);
|
||||
int32_t smaDoRetention(SSma* pSma, int64_t now);
|
||||
int32_t smaProcessExec(SSma* pSma, void* pMsg);
|
||||
|
||||
int32_t tdProcessTSmaCreate(SSma* pSma, int64_t version, const char* msg);
|
||||
int32_t tdProcessTSmaInsert(SSma* pSma, int64_t indexUid, const char* msg);
|
||||
|
@ -323,7 +321,6 @@ struct SVnode {
|
|||
TdThreadMutex lock;
|
||||
bool blocked;
|
||||
bool restored;
|
||||
bool inClose;
|
||||
tsem_t syncSem;
|
||||
SQHandle* pQuery;
|
||||
};
|
||||
|
|
|
@ -23,11 +23,13 @@ extern SSmaMgmt smaMgmt;
|
|||
|
||||
// declaration of static functions
|
||||
|
||||
static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pSma);
|
||||
static SSmaEnv *tdNewSmaEnv(const SSma *pSma, int8_t smaType, const char *path);
|
||||
static int32_t tdInitSmaEnv(SSma *pSma, int8_t smaType, const char *path, SSmaEnv **pEnv);
|
||||
static void *tdFreeTSmaStat(STSmaStat *pStat);
|
||||
static void tdDestroyRSmaStat(void *pRSmaStat);
|
||||
static int32_t tdNewSmaEnv(SSma *pSma, int8_t smaType, SSmaEnv **ppEnv);
|
||||
static int32_t tdInitSmaEnv(SSma *pSma, int8_t smaType, SSmaEnv **ppEnv);
|
||||
static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pSma);
|
||||
static int32_t tdRsmaStartExecutor(const SSma *pSma);
|
||||
static int32_t tdRsmaStopExecutor(const SSma *pSma);
|
||||
static void *tdFreeTSmaStat(STSmaStat *pStat);
|
||||
static void tdDestroyRSmaStat(void *pRSmaStat);
|
||||
|
||||
/**
|
||||
* @brief rsma init
|
||||
|
@ -97,35 +99,42 @@ void smaCleanUp() {
|
|||
}
|
||||
}
|
||||
|
||||
static SSmaEnv *tdNewSmaEnv(const SSma *pSma, int8_t smaType, const char *path) {
|
||||
static int32_t tdNewSmaEnv(SSma *pSma, int8_t smaType, SSmaEnv **ppEnv) {
|
||||
SSmaEnv *pEnv = NULL;
|
||||
|
||||
pEnv = (SSmaEnv *)taosMemoryCalloc(1, sizeof(SSmaEnv));
|
||||
*ppEnv = pEnv;
|
||||
if (!pEnv) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
SMA_ENV_TYPE(pEnv) = smaType;
|
||||
|
||||
taosInitRWLatch(&(pEnv->lock));
|
||||
|
||||
(smaType == TSDB_SMA_TYPE_TIME_RANGE) ? atomic_store_ptr(&SMA_TSMA_ENV(pSma), *ppEnv)
|
||||
: atomic_store_ptr(&SMA_RSMA_ENV(pSma), *ppEnv);
|
||||
|
||||
if (tdInitSmaStat(&SMA_ENV_STAT(pEnv), smaType, pSma) != TSDB_CODE_SUCCESS) {
|
||||
tdFreeSmaEnv(pEnv);
|
||||
return NULL;
|
||||
*ppEnv = NULL;
|
||||
(smaType == TSDB_SMA_TYPE_TIME_RANGE) ? atomic_store_ptr(&SMA_TSMA_ENV(pSma), NULL)
|
||||
: atomic_store_ptr(&SMA_RSMA_ENV(pSma), NULL);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
return pEnv;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t tdInitSmaEnv(SSma *pSma, int8_t smaType, const char *path, SSmaEnv **pEnv) {
|
||||
if (!pEnv) {
|
||||
static int32_t tdInitSmaEnv(SSma *pSma, int8_t smaType, SSmaEnv **ppEnv) {
|
||||
if (!ppEnv) {
|
||||
terrno = TSDB_CODE_INVALID_PTR;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
if (!(*pEnv)) {
|
||||
if (!(*pEnv = tdNewSmaEnv(pSma, smaType, path))) {
|
||||
if (!(*ppEnv)) {
|
||||
if (tdNewSmaEnv(pSma, smaType, ppEnv) != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
}
|
||||
|
@ -199,7 +208,7 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS
|
|||
* tdInitSmaStat invoked in other multithread environment later.
|
||||
*/
|
||||
if (!(*pSmaStat)) {
|
||||
*pSmaStat = (SSmaStat *)taosMemoryCalloc(1, sizeof(SSmaStat));
|
||||
*pSmaStat = (SSmaStat *)taosMemoryCalloc(1, sizeof(SSmaStat) + sizeof(TdThread) * tsNumOfVnodeRsmaThreads);
|
||||
if (!(*pSmaStat)) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_FAILED;
|
||||
|
@ -231,6 +240,10 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS
|
|||
if (!RSMA_INFO_HASH(pRSmaStat)) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
if (tdRsmaStartExecutor(pSma) < 0) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
} else if (smaType == TSDB_SMA_TYPE_TIME_RANGE) {
|
||||
// TODO
|
||||
} else {
|
||||
|
@ -291,6 +304,9 @@ static void tdDestroyRSmaStat(void *pRSmaStat) {
|
|||
}
|
||||
}
|
||||
|
||||
// step 4:
|
||||
tdRsmaStopExecutor(pSma);
|
||||
|
||||
// step 5: free pStat
|
||||
taosMemoryFreeClear(pStat);
|
||||
}
|
||||
|
@ -381,17 +397,70 @@ int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType) {
|
|||
pEnv = (smaType == TSDB_SMA_TYPE_TIME_RANGE) ? atomic_load_ptr(&SMA_TSMA_ENV(pSma))
|
||||
: atomic_load_ptr(&SMA_RSMA_ENV(pSma));
|
||||
if (!pEnv) {
|
||||
char rname[TSDB_FILENAME_LEN] = {0};
|
||||
|
||||
if (tdInitSmaEnv(pSma, smaType, rname, &pEnv) < 0) {
|
||||
if (tdInitSmaEnv(pSma, smaType, &pEnv) < 0) {
|
||||
tdUnLockSma(pSma);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
(smaType == TSDB_SMA_TYPE_TIME_RANGE) ? atomic_store_ptr(&SMA_TSMA_ENV(pSma), pEnv)
|
||||
: atomic_store_ptr(&SMA_RSMA_ENV(pSma), pEnv);
|
||||
}
|
||||
tdUnLockSma(pSma);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
};
|
||||
|
||||
void *tdRSmaExecutorFunc(void *param) {
|
||||
setThreadName("vnode-rsma");
|
||||
|
||||
tdRSmaProcessExecImpl((SSma *)param, RSMA_EXEC_OVERFLOW);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int32_t tdRsmaStartExecutor(const SSma *pSma) {
|
||||
TdThreadAttr thAttr = {0};
|
||||
taosThreadAttrInit(&thAttr);
|
||||
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
|
||||
SSmaEnv *pEnv = SMA_RSMA_ENV(pSma);
|
||||
SSmaStat *pStat = SMA_ENV_STAT(pEnv);
|
||||
TdThread *pthread = (TdThread *)&pStat->data;
|
||||
|
||||
for (int32_t i = 0; i < tsNumOfVnodeRsmaThreads; ++i) {
|
||||
if (taosThreadCreate(&pthread[i], &thAttr, tdRSmaExecutorFunc, (void *)pSma) != 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
smaError("vgId:%d, failed to create pthread for rsma since %s", SMA_VID(pSma), terrstr());
|
||||
return -1;
|
||||
}
|
||||
smaDebug("vgId:%d, success to create pthread for rsma", SMA_VID(pSma));
|
||||
}
|
||||
|
||||
taosThreadAttrDestroy(&thAttr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t tdRsmaStopExecutor(const SSma *pSma) {
|
||||
if (pSma && VND_IS_RSMA(pSma->pVnode)) {
|
||||
SSmaEnv *pEnv = NULL;
|
||||
SSmaStat *pStat = NULL;
|
||||
SRSmaStat *pRSmaStat = NULL;
|
||||
TdThread *pthread = NULL;
|
||||
|
||||
if (!(pEnv = SMA_RSMA_ENV(pSma)) || !(pStat = SMA_ENV_STAT(pEnv))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
pEnv->flag |= SMA_ENV_FLG_CLOSE;
|
||||
pRSmaStat = (SRSmaStat *)pStat;
|
||||
pthread = (TdThread *)&pStat->data;
|
||||
|
||||
for (int32_t i = 0; i < tsNumOfVnodeRsmaThreads; ++i) {
|
||||
tsem_post(&(pRSmaStat->notEmpty));
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < tsNumOfVnodeRsmaThreads; ++i) {
|
||||
if (taosCheckPthreadValid(pthread[i])) {
|
||||
smaDebug("vgId:%d, start to join pthread for rsma:%" PRId64, SMA_VID(pSma), pthread[i]);
|
||||
taosThreadJoin(pthread[i], NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -146,20 +146,6 @@ int32_t smaClose(SSma *pSma) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t smaPreClose(SSma *pSma) {
|
||||
if (pSma && VND_IS_RSMA(pSma->pVnode)) {
|
||||
SSmaEnv *pEnv = NULL;
|
||||
SRSmaStat *pStat = NULL;
|
||||
if (!(pEnv = SMA_RSMA_ENV(pSma)) || !(pStat = (SRSmaStat *)SMA_ENV_STAT(pEnv))) {
|
||||
return 0;
|
||||
}
|
||||
for (int32_t i = 0; i < RSMA_EXECUTOR_MAX; ++i) {
|
||||
tsem_post(&(pStat->notEmpty));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief rsma env restore
|
||||
*
|
||||
|
|
|
@ -621,7 +621,7 @@ static int32_t tdFetchSubmitReqSuids(SSubmitReq *pMsg, STbUidStore *pStore) {
|
|||
*/
|
||||
int32_t smaDoRetention(SSma *pSma, int64_t now) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (VND_IS_RSMA(pSma->pVnode)) {
|
||||
if (!VND_IS_RSMA(pSma->pVnode)) {
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -734,10 +734,12 @@ static int32_t tdExecuteRSmaImplAsync(SSma *pSma, const void *pMsg, int32_t inpu
|
|||
|
||||
SRSmaStat *pRSmaStat = SMA_RSMA_STAT(pSma);
|
||||
|
||||
tsem_post(&(pRSmaStat->notEmpty));
|
||||
|
||||
int64_t nItems = atomic_fetch_add_64(&pRSmaStat->nBufItems, 1);
|
||||
|
||||
if (atomic_load_8(&pInfo->assigned) == 0) {
|
||||
tsem_post(&(pRSmaStat->notEmpty));
|
||||
}
|
||||
|
||||
// smoothing consume
|
||||
int32_t n = nItems / RSMA_QTASKEXEC_SMOOTH_SIZE;
|
||||
if (n > 1) {
|
||||
|
@ -911,39 +913,6 @@ static int32_t tdExecuteRSmaAsync(SSma *pSma, const void *pMsg, int32_t inputTyp
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t tdRSmaExecCheck(SSma *pSma) {
|
||||
SRSmaStat *pRSmaStat = SMA_RSMA_STAT(pSma);
|
||||
|
||||
if (atomic_load_8(&pRSmaStat->nExecutor) >= TMIN(RSMA_EXECUTOR_MAX, tsNumOfVnodeQueryThreads / 2)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SRSmaExecMsg fetchMsg;
|
||||
int32_t contLen = sizeof(SMsgHead);
|
||||
void *pBuf = rpcMallocCont(0 + contLen);
|
||||
|
||||
((SMsgHead *)pBuf)->vgId = SMA_VID(pSma);
|
||||
((SMsgHead *)pBuf)->contLen = sizeof(SMsgHead);
|
||||
|
||||
SRpcMsg rpcMsg = {
|
||||
.code = 0,
|
||||
.msgType = TDMT_VND_EXEC_RSMA,
|
||||
.pCont = pBuf,
|
||||
.contLen = contLen,
|
||||
};
|
||||
|
||||
if ((terrno = tmsgPutToQueue(&pSma->pVnode->msgCb, QUERY_QUEUE, &rpcMsg)) != 0) {
|
||||
smaError("vgId:%d, failed to put rsma exec msg into query-queue since %s", SMA_VID(pSma), terrstr());
|
||||
goto _err;
|
||||
}
|
||||
|
||||
smaDebug("vgId:%d, success to put rsma fetch msg into query-queue", SMA_VID(pSma));
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
_err:
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
int32_t tdProcessRSmaSubmit(SSma *pSma, void *pMsg, int32_t inputType) {
|
||||
SSmaEnv *pEnv = SMA_RSMA_ENV(pSma);
|
||||
if (!pEnv) {
|
||||
|
@ -974,10 +943,6 @@ int32_t tdProcessRSmaSubmit(SSma *pSma, void *pMsg, int32_t inputType) {
|
|||
goto _err;
|
||||
}
|
||||
}
|
||||
|
||||
if (tdRSmaExecCheck(pSma) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
}
|
||||
tdUidStoreDestory(&uidStore);
|
||||
|
@ -1563,7 +1528,9 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
|||
ASSERT(qItem->level == pItem->level);
|
||||
ASSERT(qItem->fetchLevel == pItem->fetchLevel);
|
||||
#endif
|
||||
tsem_post(&(pStat->notEmpty));
|
||||
if (atomic_load_8(&pRSmaInfo->assigned) == 0) {
|
||||
tsem_post(&(pStat->notEmpty));
|
||||
}
|
||||
smaInfo("vgId:%d, rsma fetch task planned for level:%" PRIi8 " suid:%" PRIi64, SMA_VID(pSma), pItem->level,
|
||||
pRSmaInfo->suid);
|
||||
} break;
|
||||
|
@ -1591,9 +1558,11 @@ _end:
|
|||
}
|
||||
|
||||
static void tdFreeRSmaSubmitItems(SArray *pItems) {
|
||||
ASSERT(taosArrayGetSize(pItems) > 0);
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pItems); ++i) {
|
||||
taosFreeQitem(*(void **)taosArrayGet(pItems, i));
|
||||
}
|
||||
taosArrayClear(pItems);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1703,6 +1672,7 @@ _err:
|
|||
* @param type
|
||||
* @return int32_t
|
||||
*/
|
||||
|
||||
int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
|
||||
SVnode *pVnode = pSma->pVnode;
|
||||
SSmaEnv *pEnv = SMA_RSMA_ENV(pSma);
|
||||
|
@ -1722,41 +1692,53 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
|
|||
goto _err;
|
||||
}
|
||||
|
||||
bool isBusy = false;
|
||||
while (true) {
|
||||
isBusy = false;
|
||||
// step 1: rsma exec - consume data in buffer queue for all suids
|
||||
if (type == RSMA_EXEC_OVERFLOW || type == RSMA_EXEC_COMMIT) {
|
||||
void *pIter = taosHashIterate(infoHash, NULL); // infoHash has r/w lock
|
||||
while (pIter) {
|
||||
void *pIter = NULL;
|
||||
while ((pIter = taosHashIterate(infoHash, pIter))) {
|
||||
SRSmaInfo *pInfo = *(SRSmaInfo **)pIter;
|
||||
int64_t itemSize = 0;
|
||||
if ((itemSize = taosQueueItemSize(pInfo->queue)) || RSMA_INFO_ITEM(pInfo, 0)->fetchLevel ||
|
||||
RSMA_INFO_ITEM(pInfo, 1)->fetchLevel) {
|
||||
smaDebug("vgId:%d, queueItemSize is %" PRIi64 " execType:%" PRIi8, SMA_VID(pSma), itemSize, type);
|
||||
if (atomic_val_compare_exchange_8(&pInfo->assigned, 0, 1) == 0) {
|
||||
taosReadAllQitems(pInfo->queue, pInfo->qall); // queue has mutex lock
|
||||
int32_t qallItemSize = taosQallItemSize(pInfo->qall);
|
||||
if (qallItemSize > 0) {
|
||||
tdRSmaBatchExec(pSma, pInfo, pInfo->qall, pSubmitArr, type);
|
||||
if (atomic_val_compare_exchange_8(&pInfo->assigned, 0, 1) == 0) {
|
||||
if ((taosQueueItemSize(pInfo->queue) > 0) || RSMA_INFO_ITEM(pInfo, 0)->fetchLevel ||
|
||||
RSMA_INFO_ITEM(pInfo, 1)->fetchLevel) {
|
||||
int32_t batchCnt = -1;
|
||||
int32_t batchMax = taosHashGetSize(infoHash) / tsNumOfVnodeRsmaThreads;
|
||||
bool occupied = (batchMax <= 1);
|
||||
if (batchMax > 1) {
|
||||
batchMax = 100 / batchMax;
|
||||
}
|
||||
while (occupied || (++batchCnt < batchMax)) { // greedy mode
|
||||
taosReadAllQitems(pInfo->queue, pInfo->qall); // queue has mutex lock
|
||||
int32_t qallItemSize = taosQallItemSize(pInfo->qall);
|
||||
if (qallItemSize > 0) {
|
||||
tdRSmaBatchExec(pSma, pInfo, pInfo->qall, pSubmitArr, type);
|
||||
smaDebug("vgId:%d, batchSize:%d, execType:%" PRIi8, SMA_VID(pSma), qallItemSize, type);
|
||||
}
|
||||
|
||||
if (type == RSMA_EXEC_OVERFLOW) {
|
||||
tdRSmaFetchAllResult(pSma, pInfo, pSubmitArr);
|
||||
}
|
||||
if (type == RSMA_EXEC_OVERFLOW) {
|
||||
tdRSmaFetchAllResult(pSma, pInfo, pSubmitArr);
|
||||
}
|
||||
|
||||
if (qallItemSize > 0) {
|
||||
// subtract the item size after the task finished, commit should wait for all items be consumed
|
||||
atomic_fetch_sub_64(&pRSmaStat->nBufItems, qallItemSize);
|
||||
isBusy = true;
|
||||
if (qallItemSize > 0) {
|
||||
atomic_fetch_sub_64(&pRSmaStat->nBufItems, qallItemSize);
|
||||
continue;
|
||||
} else if (RSMA_INFO_ITEM(pInfo, 0)->fetchLevel || RSMA_INFO_ITEM(pInfo, 1)->fetchLevel) {
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
ASSERT(1 == atomic_val_compare_exchange_8(&pInfo->assigned, 1, 0));
|
||||
}
|
||||
ASSERT(1 == atomic_val_compare_exchange_8(&pInfo->assigned, 1, 0));
|
||||
}
|
||||
pIter = taosHashIterate(infoHash, pIter);
|
||||
}
|
||||
if (type == RSMA_EXEC_COMMIT) {
|
||||
break;
|
||||
if (atomic_load_64(&pRSmaStat->nBufItems) <= 0) {
|
||||
break;
|
||||
} else {
|
||||
// commit should wait for all items be consumed
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
|
@ -1790,16 +1772,19 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
|
|||
}
|
||||
|
||||
if (atomic_load_64(&pRSmaStat->nBufItems) <= 0) {
|
||||
if (pVnode->inClose) {
|
||||
if (pEnv->flag & SMA_ENV_FLG_CLOSE) {
|
||||
break;
|
||||
}
|
||||
|
||||
tsem_wait(&pRSmaStat->notEmpty);
|
||||
if (pVnode->inClose && (atomic_load_64(&pRSmaStat->nBufItems) <= 0)) {
|
||||
smaInfo("vgId:%d, exec task end, inClose:%d, nBufItems:%" PRIi64, SMA_VID(pSma), pVnode->inClose,
|
||||
|
||||
if ((pEnv->flag & SMA_ENV_FLG_CLOSE) && (atomic_load_64(&pRSmaStat->nBufItems) <= 0)) {
|
||||
smaInfo("vgId:%d, exec task end, flag:%" PRIi8 ", nBufItems:%" PRIi64, SMA_VID(pSma), pEnv->flag,
|
||||
atomic_load_64(&pRSmaStat->nBufItems));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // end of while(true)
|
||||
|
||||
_end:
|
||||
|
@ -1809,39 +1794,3 @@ _err:
|
|||
taosArrayDestroy(pSubmitArr);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief exec rsma level 1data, fetch result of level 2/3 and submit
|
||||
*
|
||||
* @param pSma
|
||||
* @param pMsg
|
||||
* @return int32_t
|
||||
*/
|
||||
int32_t smaProcessExec(SSma *pSma, void *pMsg) {
|
||||
SRpcMsg *pRpcMsg = (SRpcMsg *)pMsg;
|
||||
SRSmaStat *pRSmaStat = SMA_RSMA_STAT(pSma);
|
||||
|
||||
if (!pRpcMsg || pRpcMsg->contLen < sizeof(SMsgHead)) {
|
||||
terrno = TSDB_CODE_RSMA_FETCH_MSG_MSSED_UP;
|
||||
goto _err;
|
||||
}
|
||||
smaDebug("vgId:%d, begin to process rsma exec msg by TID:%p", SMA_VID(pSma), (void *)taosGetSelfPthreadId());
|
||||
|
||||
int8_t nOld = atomic_fetch_add_8(&pRSmaStat->nExecutor, 1);
|
||||
|
||||
if (nOld < TMIN(RSMA_EXECUTOR_MAX, tsNumOfVnodeQueryThreads / 2)) {
|
||||
if (tdRSmaProcessExecImpl(pSma, RSMA_EXEC_OVERFLOW) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
} else {
|
||||
atomic_fetch_sub_8(&pRSmaStat->nExecutor, 1);
|
||||
}
|
||||
|
||||
smaDebug("vgId:%d, success to process rsma exec msg by TID:%p", SMA_VID(pSma), (void *)taosGetSelfPthreadId());
|
||||
return TSDB_CODE_SUCCESS;
|
||||
_err:
|
||||
atomic_fetch_sub_8(&pRSmaStat->nExecutor, 1);
|
||||
smaError("vgId:%d, failed to process rsma exec msg by TID:%p since %s", SMA_VID(pSma), (void *)taosGetSelfPthreadId(),
|
||||
terrstr());
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
|
|
@ -79,6 +79,10 @@ STQ* tqOpen(const char* path, SVnode* pVnode) {
|
|||
ASSERT(0);
|
||||
}
|
||||
|
||||
if (streamLoadTasks(pTq->pStreamMeta) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
return pTq;
|
||||
}
|
||||
|
||||
|
@ -648,17 +652,28 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask) {
|
|||
|
||||
// expand executor
|
||||
if (pTask->taskLevel == TASK_LEVEL__SOURCE) {
|
||||
pTask->pState = streamStateOpen(pTq->pStreamMeta->path, pTask);
|
||||
if (pTask->pState == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
SReadHandle handle = {
|
||||
.meta = pTq->pVnode->pMeta,
|
||||
.vnode = pTq->pVnode,
|
||||
.initTqReader = 1,
|
||||
.pStateBackend = pTask->pState,
|
||||
};
|
||||
pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &handle);
|
||||
ASSERT(pTask->exec.executor);
|
||||
} else if (pTask->taskLevel == TASK_LEVEL__AGG) {
|
||||
pTask->pState = streamStateOpen(pTq->pStreamMeta->path, pTask);
|
||||
if (pTask->pState == NULL) {
|
||||
return -1;
|
||||
}
|
||||
SReadHandle mgHandle = {
|
||||
.vnode = NULL,
|
||||
.numOfVgroups = (int32_t)taosArrayGetSize(pTask->childEpInfo),
|
||||
.pStateBackend = pTask->pState,
|
||||
};
|
||||
pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &mgHandle);
|
||||
ASSERT(pTask->exec.executor);
|
||||
|
|
|
@ -87,7 +87,6 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
|||
pVnode->msgCb = msgCb;
|
||||
taosThreadMutexInit(&pVnode->lock, NULL);
|
||||
pVnode->blocked = false;
|
||||
pVnode->inClose = false;
|
||||
|
||||
tsem_init(&pVnode->syncSem, 0, 0);
|
||||
tsem_init(&(pVnode->canCommit), 0, 1);
|
||||
|
@ -182,8 +181,6 @@ _err:
|
|||
void vnodePreClose(SVnode *pVnode) {
|
||||
if (pVnode) {
|
||||
syncLeaderTransfer(pVnode->sync);
|
||||
pVnode->inClose = true;
|
||||
smaPreClose(pVnode->pSma);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -301,8 +301,6 @@ int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
return qWorkerProcessQueryMsg(&handle, pVnode->pQuery, pMsg, 0);
|
||||
case TDMT_SCH_QUERY_CONTINUE:
|
||||
return qWorkerProcessCQueryMsg(&handle, pVnode->pQuery, pMsg, 0);
|
||||
case TDMT_VND_EXEC_RSMA:
|
||||
return smaProcessExec(pVnode->pSma, pMsg);
|
||||
default:
|
||||
vError("unknown msg type:%d in query queue", pMsg->msgType);
|
||||
return TSDB_CODE_VND_APP_ERROR;
|
||||
|
@ -384,14 +382,14 @@ static int32_t vnodeProcessTrimReq(SVnode *pVnode, int64_t version, void *pReq,
|
|||
int32_t code = 0;
|
||||
SVTrimDbReq trimReq = {0};
|
||||
|
||||
vInfo("vgId:%d, trim vnode request will be processed, time:%d", pVnode->config.vgId, trimReq.timestamp);
|
||||
|
||||
// decode
|
||||
if (tDeserializeSVTrimDbReq(pReq, len, &trimReq) != 0) {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
vInfo("vgId:%d, trim vnode request will be processed, time:%d", pVnode->config.vgId, trimReq.timestamp);
|
||||
|
||||
// process
|
||||
code = tsdbDoRetention(pVnode->pTsdb, trimReq.timestamp);
|
||||
if (code) goto _exit;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "catalog.h"
|
||||
#include "commandInt.h"
|
||||
#include "scheduler.h"
|
||||
#include "systable.h"
|
||||
#include "tdatablock.h"
|
||||
#include "tglobal.h"
|
||||
#include "tgrant.h"
|
||||
|
@ -75,46 +76,41 @@ static SSDataBlock* buildDescResultDataBlock() {
|
|||
return pBlock;
|
||||
}
|
||||
|
||||
static void setDescResultIntoDataBlock(SSDataBlock* pBlock, int32_t numOfRows, STableMeta* pMeta) {
|
||||
static void setDescResultIntoDataBlock(bool sysInfoUser, SSDataBlock* pBlock, int32_t numOfRows, STableMeta* pMeta) {
|
||||
blockDataEnsureCapacity(pBlock, numOfRows);
|
||||
pBlock->info.rows = numOfRows;
|
||||
pBlock->info.rows = 0;
|
||||
|
||||
// field
|
||||
SColumnInfoData* pCol1 = taosArrayGet(pBlock->pDataBlock, 0);
|
||||
char buf[DESCRIBE_RESULT_FIELD_LEN] = {0};
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
STR_TO_VARSTR(buf, pMeta->schema[i].name);
|
||||
colDataAppend(pCol1, i, buf, false);
|
||||
}
|
||||
|
||||
// Type
|
||||
SColumnInfoData* pCol2 = taosArrayGet(pBlock->pDataBlock, 1);
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
STR_TO_VARSTR(buf, tDataTypes[pMeta->schema[i].type].name);
|
||||
colDataAppend(pCol2, i, buf, false);
|
||||
}
|
||||
|
||||
// Length
|
||||
SColumnInfoData* pCol3 = taosArrayGet(pBlock->pDataBlock, 2);
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
int32_t bytes = getSchemaBytes(pMeta->schema + i);
|
||||
colDataAppend(pCol3, i, (const char*)&bytes, false);
|
||||
}
|
||||
|
||||
// Note
|
||||
SColumnInfoData* pCol4 = taosArrayGet(pBlock->pDataBlock, 3);
|
||||
char buf[DESCRIBE_RESULT_FIELD_LEN] = {0};
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
if (invisibleColumn(sysInfoUser, pMeta->tableType, pMeta->schema[i].flags)) {
|
||||
continue;
|
||||
}
|
||||
STR_TO_VARSTR(buf, pMeta->schema[i].name);
|
||||
colDataAppend(pCol1, pBlock->info.rows, buf, false);
|
||||
STR_TO_VARSTR(buf, tDataTypes[pMeta->schema[i].type].name);
|
||||
colDataAppend(pCol2, pBlock->info.rows, buf, false);
|
||||
int32_t bytes = getSchemaBytes(pMeta->schema + i);
|
||||
colDataAppend(pCol3, pBlock->info.rows, (const char*)&bytes, false);
|
||||
STR_TO_VARSTR(buf, i >= pMeta->tableInfo.numOfColumns ? "TAG" : "");
|
||||
colDataAppend(pCol4, i, buf, false);
|
||||
colDataAppend(pCol4, pBlock->info.rows, buf, false);
|
||||
++(pBlock->info.rows);
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t execDescribe(SNode* pStmt, SRetrieveTableRsp** pRsp) {
|
||||
static int32_t execDescribe(bool sysInfoUser, SNode* pStmt, SRetrieveTableRsp** pRsp) {
|
||||
SDescribeStmt* pDesc = (SDescribeStmt*)pStmt;
|
||||
int32_t numOfRows = TABLE_TOTAL_COL_NUM(pDesc->pMeta);
|
||||
|
||||
SSDataBlock* pBlock = buildDescResultDataBlock();
|
||||
setDescResultIntoDataBlock(pBlock, numOfRows, pDesc->pMeta);
|
||||
setDescResultIntoDataBlock(sysInfoUser, pBlock, numOfRows, pDesc->pMeta);
|
||||
|
||||
return buildRetrieveTableRsp(pBlock, DESCRIBE_RESULT_COLS, pRsp);
|
||||
}
|
||||
|
@ -665,10 +661,10 @@ static int32_t execSelectWithoutFrom(SSelectStmt* pSelect, SRetrieveTableRsp** p
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t qExecCommand(SNode* pStmt, SRetrieveTableRsp** pRsp) {
|
||||
int32_t qExecCommand(bool sysInfoUser, SNode* pStmt, SRetrieveTableRsp** pRsp) {
|
||||
switch (nodeType(pStmt)) {
|
||||
case QUERY_NODE_DESCRIBE_STMT:
|
||||
return execDescribe(pStmt, pRsp);
|
||||
return execDescribe(sysInfoUser, pStmt, pRsp);
|
||||
case QUERY_NODE_RESET_QUERY_CACHE_STMT:
|
||||
return execResetQueryCache();
|
||||
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
||||
|
|
|
@ -150,6 +150,7 @@ typedef struct {
|
|||
SQueryTableDataCond tableCond;
|
||||
int64_t recoverStartVer;
|
||||
int64_t recoverEndVer;
|
||||
SStreamState* pState;
|
||||
} SStreamTaskInfo;
|
||||
|
||||
typedef struct {
|
||||
|
@ -496,6 +497,7 @@ typedef struct SSysTableScanInfo {
|
|||
SReadHandle readHandle;
|
||||
int32_t accountId;
|
||||
const char* pUser;
|
||||
bool sysInfo;
|
||||
bool showRewrite;
|
||||
SNode* pCondition; // db_name filter condition, to discard data that are not in current database
|
||||
SMTbCursor* pCur; // cursor for iterate the local table meta store.
|
||||
|
|
|
@ -284,17 +284,17 @@ int32_t isQualifiedTable(STableKeyInfo* info, SNode* pTagCond, void* metaHandle,
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
typedef struct tagFilterAssist{
|
||||
SHashObj *colHash;
|
||||
typedef struct tagFilterAssist {
|
||||
SHashObj* colHash;
|
||||
int32_t index;
|
||||
SArray *cInfoList;
|
||||
}tagFilterAssist;
|
||||
SArray* cInfoList;
|
||||
} tagFilterAssist;
|
||||
|
||||
static EDealRes getColumn(SNode** pNode, void* pContext) {
|
||||
SColumnNode* pSColumnNode = NULL;
|
||||
if (QUERY_NODE_COLUMN == nodeType((*pNode))) {
|
||||
pSColumnNode = *(SColumnNode**)pNode;
|
||||
}else if(QUERY_NODE_FUNCTION == nodeType((*pNode))){
|
||||
} else if (QUERY_NODE_FUNCTION == nodeType((*pNode))) {
|
||||
SFunctionNode* pFuncNode = *(SFunctionNode**)(pNode);
|
||||
if (pFuncNode->funcType == FUNCTION_TYPE_TBNAME) {
|
||||
pSColumnNode = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
|
@ -307,24 +307,26 @@ static EDealRes getColumn(SNode** pNode, void* pContext) {
|
|||
pSColumnNode->node.resType.bytes = TSDB_TABLE_FNAME_LEN - 1 + VARSTR_HEADER_SIZE;
|
||||
nodesDestroyNode(*pNode);
|
||||
*pNode = (SNode*)pSColumnNode;
|
||||
}else{
|
||||
} else {
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
tagFilterAssist *pData = (tagFilterAssist *)pContext;
|
||||
void *data = taosHashGet(pData->colHash, &pSColumnNode->colId, sizeof(pSColumnNode->colId));
|
||||
if(!data){
|
||||
tagFilterAssist* pData = (tagFilterAssist*)pContext;
|
||||
void* data = taosHashGet(pData->colHash, &pSColumnNode->colId, sizeof(pSColumnNode->colId));
|
||||
if (!data) {
|
||||
taosHashPut(pData->colHash, &pSColumnNode->colId, sizeof(pSColumnNode->colId), pNode, sizeof((*pNode)));
|
||||
pSColumnNode->slotId = pData->index++;
|
||||
SColumnInfo cInfo = {.colId = pSColumnNode->colId, .type = pSColumnNode->node.resType.type, .bytes = pSColumnNode->node.resType.bytes};
|
||||
SColumnInfo cInfo = {.colId = pSColumnNode->colId,
|
||||
.type = pSColumnNode->node.resType.type,
|
||||
.bytes = pSColumnNode->node.resType.bytes};
|
||||
#if TAG_FILTER_DEBUG
|
||||
qDebug("tagfilter build column info, slotId:%d, colId:%d, type:%d", pSColumnNode->slotId, cInfo.colId, cInfo.type);
|
||||
#endif
|
||||
taosArrayPush(pData->cInfoList, &cInfo);
|
||||
}else{
|
||||
} else {
|
||||
SColumnNode* col = *(SColumnNode**)data;
|
||||
pSColumnNode->slotId = col->slotId;
|
||||
}
|
||||
|
@ -339,9 +341,9 @@ static int32_t createResultData(SDataType* pType, int32_t numOfRows, SScalarPara
|
|||
return terrno;
|
||||
}
|
||||
|
||||
pColumnData->info.type = pType->type;
|
||||
pColumnData->info.bytes = pType->bytes;
|
||||
pColumnData->info.scale = pType->scale;
|
||||
pColumnData->info.type = pType->type;
|
||||
pColumnData->info.bytes = pType->bytes;
|
||||
pColumnData->info.scale = pType->scale;
|
||||
pColumnData->info.precision = pType->precision;
|
||||
|
||||
int32_t code = colInfoDataEnsureCapacity(pColumnData, numOfRows);
|
||||
|
@ -356,27 +358,27 @@ static int32_t createResultData(SDataType* pType, int32_t numOfRows, SScalarPara
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray* uidList, SNode* pTagCond){
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SArray* pBlockList = NULL;
|
||||
static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray* uidList, SNode* pTagCond) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SArray* pBlockList = NULL;
|
||||
SSDataBlock* pResBlock = NULL;
|
||||
SHashObj * tags = NULL;
|
||||
SHashObj* tags = NULL;
|
||||
SScalarParam output = {0};
|
||||
|
||||
tagFilterAssist ctx = {0};
|
||||
ctx.colHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT), false, HASH_NO_LOCK);
|
||||
if(ctx.colHash == NULL){
|
||||
if (ctx.colHash == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
ctx.index = 0;
|
||||
ctx.cInfoList = taosArrayInit(4, sizeof(SColumnInfo));
|
||||
if(ctx.cInfoList == NULL){
|
||||
if (ctx.cInfoList == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
|
||||
nodesRewriteExprPostOrder(&pTagCond, getColumn, (void *)&ctx);
|
||||
nodesRewriteExprPostOrder(&pTagCond, getColumn, (void*)&ctx);
|
||||
|
||||
pResBlock = createDataBlock();
|
||||
if (pResBlock == NULL) {
|
||||
|
@ -390,7 +392,7 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray
|
|||
blockDataAppendColInfo(pResBlock, &colInfo);
|
||||
}
|
||||
|
||||
// int64_t stt = taosGetTimestampUs();
|
||||
// int64_t stt = taosGetTimestampUs();
|
||||
tags = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
code = metaGetTableTags(metaHandle, suid, uidList, tags);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -400,11 +402,11 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray
|
|||
}
|
||||
|
||||
int32_t rows = taosArrayGetSize(uidList);
|
||||
if(rows == 0){
|
||||
if (rows == 0) {
|
||||
goto end;
|
||||
}
|
||||
// int64_t stt1 = taosGetTimestampUs();
|
||||
// qDebug("generate tag meta rows:%d, cost:%ld us", rows, stt1-stt);
|
||||
// int64_t stt1 = taosGetTimestampUs();
|
||||
// qDebug("generate tag meta rows:%d, cost:%ld us", rows, stt1-stt);
|
||||
|
||||
code = blockDataEnsureCapacity(pResBlock, rows);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -412,46 +414,46 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray
|
|||
goto end;
|
||||
}
|
||||
|
||||
// int64_t st = taosGetTimestampUs();
|
||||
// int64_t st = taosGetTimestampUs();
|
||||
for (int32_t i = 0; i < rows; i++) {
|
||||
int64_t* uid = taosArrayGet(uidList, i);
|
||||
for(int32_t j = 0; j < taosArrayGetSize(pResBlock->pDataBlock); j++){
|
||||
for (int32_t j = 0; j < taosArrayGetSize(pResBlock->pDataBlock); j++) {
|
||||
SColumnInfoData* pColInfo = (SColumnInfoData*)taosArrayGet(pResBlock->pDataBlock, j);
|
||||
|
||||
if(pColInfo->info.colId == -1){ // tbname
|
||||
if (pColInfo->info.colId == -1) { // tbname
|
||||
char str[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
metaGetTableNameByUid(metaHandle, *uid, str);
|
||||
colDataAppend(pColInfo, i, str, false);
|
||||
#if TAG_FILTER_DEBUG
|
||||
qDebug("tagfilter uid:%ld, tbname:%s", *uid, str+2);
|
||||
qDebug("tagfilter uid:%ld, tbname:%s", *uid, str + 2);
|
||||
#endif
|
||||
}else{
|
||||
} else {
|
||||
void* tag = taosHashGet(tags, uid, sizeof(int64_t));
|
||||
ASSERT(tag);
|
||||
STagVal tagVal = {0};
|
||||
tagVal.cid = pColInfo->info.colId;
|
||||
const char* p = metaGetTableTagVal(tag, pColInfo->info.type, &tagVal);
|
||||
|
||||
if (p == NULL || (pColInfo->info.type == TSDB_DATA_TYPE_JSON && ((STag*)p)->nTag == 0)){
|
||||
if (p == NULL || (pColInfo->info.type == TSDB_DATA_TYPE_JSON && ((STag*)p)->nTag == 0)) {
|
||||
colDataAppend(pColInfo, i, p, true);
|
||||
} else if (pColInfo->info.type == TSDB_DATA_TYPE_JSON) {
|
||||
colDataAppend(pColInfo, i, p, false);
|
||||
} else if (IS_VAR_DATA_TYPE(pColInfo->info.type)) {
|
||||
char *tmp = taosMemoryCalloc(tagVal.nData + VARSTR_HEADER_SIZE + 1, 1);
|
||||
char* tmp = taosMemoryCalloc(tagVal.nData + VARSTR_HEADER_SIZE + 1, 1);
|
||||
varDataSetLen(tmp, tagVal.nData);
|
||||
memcpy(tmp + VARSTR_HEADER_SIZE, tagVal.pData, tagVal.nData);
|
||||
colDataAppend(pColInfo, i, tmp, false);
|
||||
#if TAG_FILTER_DEBUG
|
||||
qDebug("tagfilter varch:%s", tmp+2);
|
||||
qDebug("tagfilter varch:%s", tmp + 2);
|
||||
#endif
|
||||
taosMemoryFree(tmp);
|
||||
} else {
|
||||
colDataAppend(pColInfo, i, (const char*)&tagVal.i64, false);
|
||||
#if TAG_FILTER_DEBUG
|
||||
if(pColInfo->info.type == TSDB_DATA_TYPE_INT){
|
||||
if (pColInfo->info.type == TSDB_DATA_TYPE_INT) {
|
||||
qDebug("tagfilter int:%d", *(int*)(&tagVal.i64));
|
||||
}else if(pColInfo->info.type == TSDB_DATA_TYPE_DOUBLE){
|
||||
qDebug("tagfilter double:%f", *(double *)(&tagVal.i64));
|
||||
} else if (pColInfo->info.type == TSDB_DATA_TYPE_DOUBLE) {
|
||||
qDebug("tagfilter double:%f", *(double*)(&tagVal.i64));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -460,8 +462,8 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray
|
|||
}
|
||||
pResBlock->info.rows = rows;
|
||||
|
||||
// int64_t st1 = taosGetTimestampUs();
|
||||
// qDebug("generate tag block rows:%d, cost:%ld us", rows, st1-st);
|
||||
// int64_t st1 = taosGetTimestampUs();
|
||||
// qDebug("generate tag block rows:%d, cost:%ld us", rows, st1-st);
|
||||
|
||||
pBlockList = taosArrayInit(2, POINTER_BYTES);
|
||||
taosArrayPush(pBlockList, &pResBlock);
|
||||
|
@ -475,13 +477,13 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray
|
|||
}
|
||||
|
||||
code = scalarCalculate(pTagCond, pBlockList, &output);
|
||||
if(code != TSDB_CODE_SUCCESS){
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
qError("failed to calculate scalar, reason:%s", tstrerror(code));
|
||||
terrno = code;
|
||||
goto end;
|
||||
}
|
||||
// int64_t st2 = taosGetTimestampUs();
|
||||
// qDebug("calculate tag block rows:%d, cost:%ld us", rows, st2-st1);
|
||||
// int64_t st2 = taosGetTimestampUs();
|
||||
// qDebug("calculate tag block rows:%d, cost:%ld us", rows, st2-st1);
|
||||
|
||||
end:
|
||||
taosHashCleanup(tags);
|
||||
|
@ -493,43 +495,43 @@ end:
|
|||
}
|
||||
|
||||
static void releaseColInfoData(void* pCol) {
|
||||
if(pCol){
|
||||
SColumnInfoData* col = (SColumnInfoData*) pCol;
|
||||
if (pCol) {
|
||||
SColumnInfoData* col = (SColumnInfoData*)pCol;
|
||||
colDataDestroy(col);
|
||||
taosMemoryFree(col);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableListInfo* pTableListInfo){
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SArray *pBlockList = NULL;
|
||||
SSDataBlock *pResBlock = NULL;
|
||||
SHashObj *tags = NULL;
|
||||
SArray *uidList = NULL;
|
||||
void *keyBuf = NULL;
|
||||
SArray *groupData = NULL;
|
||||
int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableListInfo* pTableListInfo) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SArray* pBlockList = NULL;
|
||||
SSDataBlock* pResBlock = NULL;
|
||||
SHashObj* tags = NULL;
|
||||
SArray* uidList = NULL;
|
||||
void* keyBuf = NULL;
|
||||
SArray* groupData = NULL;
|
||||
|
||||
int32_t rows = taosArrayGetSize(pTableListInfo->pTableList);
|
||||
if(rows == 0){
|
||||
if (rows == 0) {
|
||||
return TDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
tagFilterAssist ctx = {0};
|
||||
ctx.colHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT), false, HASH_NO_LOCK);
|
||||
if(ctx.colHash == NULL){
|
||||
if (ctx.colHash == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
ctx.index = 0;
|
||||
ctx.cInfoList = taosArrayInit(4, sizeof(SColumnInfo));
|
||||
if(ctx.cInfoList == NULL){
|
||||
if (ctx.cInfoList == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
|
||||
SNode* pNode = NULL;
|
||||
SNode* pNode = NULL;
|
||||
FOREACH(pNode, group) {
|
||||
nodesRewriteExprPostOrder(&pNode, getColumn, (void *)&ctx);
|
||||
nodesRewriteExprPostOrder(&pNode, getColumn, (void*)&ctx);
|
||||
REPLACE_NODE(pNode);
|
||||
}
|
||||
|
||||
|
@ -551,61 +553,61 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis
|
|||
taosArrayPush(uidList, &pkeyInfo->uid);
|
||||
}
|
||||
|
||||
// int64_t stt = taosGetTimestampUs();
|
||||
// int64_t stt = taosGetTimestampUs();
|
||||
tags = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
code = metaGetTableTags(metaHandle, pTableListInfo->suid, uidList, tags);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
// int64_t stt1 = taosGetTimestampUs();
|
||||
// qDebug("generate tag meta rows:%d, cost:%ld us", rows, stt1-stt);
|
||||
// int64_t stt1 = taosGetTimestampUs();
|
||||
// qDebug("generate tag meta rows:%d, cost:%ld us", rows, stt1-stt);
|
||||
|
||||
code = blockDataEnsureCapacity(pResBlock, rows);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
// int64_t st = taosGetTimestampUs();
|
||||
// int64_t st = taosGetTimestampUs();
|
||||
for (int32_t i = 0; i < rows; i++) {
|
||||
int64_t* uid = taosArrayGet(uidList, i);
|
||||
for(int32_t j = 0; j < taosArrayGetSize(pResBlock->pDataBlock); j++){
|
||||
for (int32_t j = 0; j < taosArrayGetSize(pResBlock->pDataBlock); j++) {
|
||||
SColumnInfoData* pColInfo = (SColumnInfoData*)taosArrayGet(pResBlock->pDataBlock, j);
|
||||
|
||||
if(pColInfo->info.colId == -1){ // tbname
|
||||
if (pColInfo->info.colId == -1) { // tbname
|
||||
char str[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
metaGetTableNameByUid(metaHandle, *uid, str);
|
||||
colDataAppend(pColInfo, i, str, false);
|
||||
#if TAG_FILTER_DEBUG
|
||||
qDebug("tagfilter uid:%ld, tbname:%s", *uid, str+2);
|
||||
qDebug("tagfilter uid:%ld, tbname:%s", *uid, str + 2);
|
||||
#endif
|
||||
}else{
|
||||
} else {
|
||||
void* tag = taosHashGet(tags, uid, sizeof(int64_t));
|
||||
ASSERT(tag);
|
||||
STagVal tagVal = {0};
|
||||
tagVal.cid = pColInfo->info.colId;
|
||||
const char* p = metaGetTableTagVal(tag, pColInfo->info.type, &tagVal);
|
||||
|
||||
if (p == NULL || (pColInfo->info.type == TSDB_DATA_TYPE_JSON && ((STag*)p)->nTag == 0)){
|
||||
if (p == NULL || (pColInfo->info.type == TSDB_DATA_TYPE_JSON && ((STag*)p)->nTag == 0)) {
|
||||
colDataAppend(pColInfo, i, p, true);
|
||||
} else if (pColInfo->info.type == TSDB_DATA_TYPE_JSON) {
|
||||
colDataAppend(pColInfo, i, p, false);
|
||||
} else if (IS_VAR_DATA_TYPE(pColInfo->info.type)) {
|
||||
char *tmp = taosMemoryCalloc(tagVal.nData + VARSTR_HEADER_SIZE + 1, 1);
|
||||
char* tmp = taosMemoryCalloc(tagVal.nData + VARSTR_HEADER_SIZE + 1, 1);
|
||||
varDataSetLen(tmp, tagVal.nData);
|
||||
memcpy(tmp + VARSTR_HEADER_SIZE, tagVal.pData, tagVal.nData);
|
||||
colDataAppend(pColInfo, i, tmp, false);
|
||||
#if TAG_FILTER_DEBUG
|
||||
qDebug("tagfilter varch:%s", tmp+2);
|
||||
qDebug("tagfilter varch:%s", tmp + 2);
|
||||
#endif
|
||||
taosMemoryFree(tmp);
|
||||
} else {
|
||||
colDataAppend(pColInfo, i, (const char*)&tagVal.i64, false);
|
||||
#if TAG_FILTER_DEBUG
|
||||
if(pColInfo->info.type == TSDB_DATA_TYPE_INT){
|
||||
if (pColInfo->info.type == TSDB_DATA_TYPE_INT) {
|
||||
qDebug("tagfilter int:%d", *(int*)(&tagVal.i64));
|
||||
}else if(pColInfo->info.type == TSDB_DATA_TYPE_DOUBLE){
|
||||
qDebug("tagfilter double:%f", *(double *)(&tagVal.i64));
|
||||
} else if (pColInfo->info.type == TSDB_DATA_TYPE_DOUBLE) {
|
||||
qDebug("tagfilter double:%f", *(double*)(&tagVal.i64));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -614,8 +616,8 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis
|
|||
}
|
||||
pResBlock->info.rows = rows;
|
||||
|
||||
// int64_t st1 = taosGetTimestampUs();
|
||||
// qDebug("generate tag block rows:%d, cost:%ld us", rows, st1-st);
|
||||
// int64_t st1 = taosGetTimestampUs();
|
||||
// qDebug("generate tag block rows:%d, cost:%ld us", rows, st1-st);
|
||||
|
||||
pBlockList = taosArrayInit(2, POINTER_BYTES);
|
||||
taosArrayPush(pBlockList, &pResBlock);
|
||||
|
@ -629,7 +631,7 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis
|
|||
break;
|
||||
case QUERY_NODE_COLUMN:
|
||||
case QUERY_NODE_OPERATOR:
|
||||
case QUERY_NODE_FUNCTION:{
|
||||
case QUERY_NODE_FUNCTION: {
|
||||
SExprNode* expNode = (SExprNode*)pNode;
|
||||
code = createResultData(&expNode->resType, rows, &output);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -641,16 +643,16 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis
|
|||
code = TSDB_CODE_OPS_NOT_SUPPORT;
|
||||
goto end;
|
||||
}
|
||||
if(nodeType(pNode) == QUERY_NODE_COLUMN){
|
||||
SColumnNode* pSColumnNode = (SColumnNode*)pNode;
|
||||
if (nodeType(pNode) == QUERY_NODE_COLUMN) {
|
||||
SColumnNode* pSColumnNode = (SColumnNode*)pNode;
|
||||
SColumnInfoData* pColInfo = (SColumnInfoData*)taosArrayGet(pResBlock->pDataBlock, pSColumnNode->slotId);
|
||||
code = colDataAssign(output.columnData, pColInfo, rows, NULL);
|
||||
}else if(nodeType(pNode) == QUERY_NODE_VALUE){
|
||||
} else if (nodeType(pNode) == QUERY_NODE_VALUE) {
|
||||
continue;
|
||||
}else{
|
||||
} else {
|
||||
code = scalarCalculate(pNode, pBlockList, &output);
|
||||
}
|
||||
if(code != TSDB_CODE_SUCCESS){
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
releaseColInfoData(output.columnData);
|
||||
goto end;
|
||||
}
|
||||
|
@ -658,7 +660,7 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis
|
|||
}
|
||||
|
||||
int32_t keyLen = 0;
|
||||
SNode* node;
|
||||
SNode* node;
|
||||
FOREACH(node, group) {
|
||||
SExprNode* pExpr = (SExprNode*)node;
|
||||
keyLen += pExpr->resType.bytes;
|
||||
|
@ -672,12 +674,12 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis
|
|||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
for(int i = 0; i < rows; i++){
|
||||
for (int i = 0; i < rows; i++) {
|
||||
STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i);
|
||||
|
||||
char* isNull = (char*)keyBuf;
|
||||
char* pStart = (char*)keyBuf + sizeof(int8_t) * LIST_LENGTH(group);
|
||||
for(int j = 0; j < taosArrayGetSize(groupData); j++){
|
||||
for (int j = 0; j < taosArrayGetSize(groupData); j++) {
|
||||
SColumnInfoData* pValue = (SColumnInfoData*)taosArrayGetP(groupData, j);
|
||||
|
||||
if (colDataIsNull_s(pValue, i)) {
|
||||
|
@ -690,7 +692,7 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis
|
|||
code = TSDB_CODE_QRY_JSON_IN_GROUP_ERROR;
|
||||
goto end;
|
||||
}
|
||||
if(tTagIsJsonNull(data)){
|
||||
if (tTagIsJsonNull(data)) {
|
||||
isNull[j] = 1;
|
||||
continue;
|
||||
}
|
||||
|
@ -712,10 +714,10 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis
|
|||
taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), &info->groupId, sizeof(uint64_t));
|
||||
}
|
||||
|
||||
// int64_t st2 = taosGetTimestampUs();
|
||||
// qDebug("calculate tag block rows:%d, cost:%ld us", rows, st2-st1);
|
||||
// int64_t st2 = taosGetTimestampUs();
|
||||
// qDebug("calculate tag block rows:%d, cost:%ld us", rows, st2-st1);
|
||||
|
||||
end:
|
||||
end:
|
||||
taosMemoryFreeClear(keyBuf);
|
||||
taosHashCleanup(tags);
|
||||
taosHashCleanup(ctx.colHash);
|
||||
|
@ -745,7 +747,7 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode,
|
|||
SIndexMetaArg metaArg = {
|
||||
.metaEx = metaHandle, .idx = tsdbGetIdx(metaHandle), .ivtIdx = tsdbGetIvtIdx(metaHandle), .suid = tableUid};
|
||||
|
||||
// int64_t stt = taosGetTimestampUs();
|
||||
// int64_t stt = taosGetTimestampUs();
|
||||
SIdxFltStatus status = SFLT_NOT_INDEX;
|
||||
code = doFilterTag(pTagIndexCond, &metaArg, res, &status);
|
||||
if (code != 0 || status == SFLT_NOT_INDEX) {
|
||||
|
@ -753,13 +755,13 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode,
|
|||
code = TDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
// int64_t stt1 = taosGetTimestampUs();
|
||||
// qDebug("generate table list, cost:%ld us", stt1-stt);
|
||||
}else if(!pTagCond){
|
||||
// int64_t stt1 = taosGetTimestampUs();
|
||||
// qDebug("generate table list, cost:%ld us", stt1-stt);
|
||||
} else if (!pTagCond) {
|
||||
vnodeGetCtbIdList(pVnode, pScanNode->suid, res);
|
||||
}
|
||||
} else { // Create one table group.
|
||||
if(metaIsTableExist(metaHandle, tableUid)){
|
||||
if (metaIsTableExist(metaHandle, tableUid)) {
|
||||
taosArrayPush(res, &tableUid);
|
||||
}
|
||||
}
|
||||
|
@ -767,7 +769,7 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode,
|
|||
if (pTagCond) {
|
||||
terrno = TDB_CODE_SUCCESS;
|
||||
SColumnInfoData* pColInfoData = getColInfoResult(metaHandle, pListInfo->suid, res, pTagCond);
|
||||
if(terrno != TDB_CODE_SUCCESS){
|
||||
if (terrno != TDB_CODE_SUCCESS) {
|
||||
colDataDestroy(pColInfoData);
|
||||
taosMemoryFreeClear(pColInfoData);
|
||||
taosArrayDestroy(res);
|
||||
|
@ -829,7 +831,7 @@ size_t getTableTagsBufLen(const SNodeList* pGroups) {
|
|||
int32_t getGroupIdFromTagsVal(void* pMeta, uint64_t uid, SNodeList* pGroupNode, char* keyBuf, uint64_t* pGroupId) {
|
||||
SMetaReader mr = {0};
|
||||
metaReaderInit(&mr, pMeta, 0);
|
||||
if(metaGetTableEntryByUid(&mr, uid) != 0){ // table not exist
|
||||
if (metaGetTableEntryByUid(&mr, uid) != 0) { // table not exist
|
||||
metaReaderClear(&mr);
|
||||
return TSDB_CODE_PAR_TABLE_NOT_EXIST;
|
||||
}
|
||||
|
@ -987,7 +989,7 @@ static SResSchema createResSchema(int32_t type, int32_t bytes, int32_t slotId, i
|
|||
return s;
|
||||
}
|
||||
|
||||
static SColumn* createColumn(int32_t blockId, int32_t slotId, int32_t colId, SDataType* pType) {
|
||||
static SColumn* createColumn(int32_t blockId, int32_t slotId, int32_t colId, SDataType* pType, EColumnType colType) {
|
||||
SColumn* pCol = taosMemoryCalloc(1, sizeof(SColumn));
|
||||
if (pCol == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -1001,7 +1003,7 @@ static SColumn* createColumn(int32_t blockId, int32_t slotId, int32_t colId, SDa
|
|||
pCol->scale = pType->scale;
|
||||
pCol->precision = pType->precision;
|
||||
pCol->dataBlockId = blockId;
|
||||
|
||||
pCol->colType = colType;
|
||||
return pCol;
|
||||
}
|
||||
|
||||
|
@ -1045,7 +1047,8 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t*
|
|||
SDataType* pType = &pColNode->node.resType;
|
||||
pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale,
|
||||
pType->precision, pColNode->colName);
|
||||
pExp->base.pParam[0].pCol = createColumn(pColNode->dataBlockId, pColNode->slotId, pColNode->colId, pType);
|
||||
pExp->base.pParam[0].pCol =
|
||||
createColumn(pColNode->dataBlockId, pColNode->slotId, pColNode->colId, pType, pColNode->colType);
|
||||
pExp->base.pParam[0].type = FUNC_PARAM_TYPE_COLUMN;
|
||||
} else if (type == QUERY_NODE_VALUE) {
|
||||
pExp->pExpr->nodeType = QUERY_NODE_VALUE;
|
||||
|
@ -1097,7 +1100,8 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t*
|
|||
SColumnNode* pcn = (SColumnNode*)p1;
|
||||
|
||||
pExp->base.pParam[j].type = FUNC_PARAM_TYPE_COLUMN;
|
||||
pExp->base.pParam[j].pCol = createColumn(pcn->dataBlockId, pcn->slotId, pcn->colId, &pcn->node.resType);
|
||||
pExp->base.pParam[j].pCol =
|
||||
createColumn(pcn->dataBlockId, pcn->slotId, pcn->colId, &pcn->node.resType, pcn->colType);
|
||||
} else if (p1->type == QUERY_NODE_VALUE) {
|
||||
SValueNode* pvn = (SValueNode*)p1;
|
||||
pExp->base.pParam[j].type = FUNC_PARAM_TYPE_VALUE;
|
||||
|
|
|
@ -148,20 +148,6 @@ static int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock,
|
|||
static void initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size);
|
||||
static void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId);
|
||||
|
||||
// setup the output buffer for each operator
|
||||
static bool hasNull(SColumn* pColumn, SColumnDataAgg* pStatis) {
|
||||
if (TSDB_COL_IS_TAG(pColumn->flag) || TSDB_COL_IS_UD_COL(pColumn->flag) ||
|
||||
pColumn->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pStatis != NULL && pStatis->numOfNull == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static bool chkResultRowFromKey(STaskRuntimeEnv* pRuntimeEnv, SResultRowInfo* pResultRowInfo, char* pData,
|
||||
int16_t bytes, bool masterscan, uint64_t uid) {
|
||||
|
@ -392,7 +378,7 @@ static void functionCtxSave(SqlFunctionCtx* pCtx, SFunctionCtxStatus* pStatus) {
|
|||
|
||||
static void functionCtxRestore(SqlFunctionCtx* pCtx, SFunctionCtxStatus* pStatus) {
|
||||
pCtx->input.colDataAggIsSet = pStatus->hasAgg;
|
||||
pCtx->input.numOfRows = pStatus->numOfRows;
|
||||
pCtx->input.numOfRows = pStatus->numOfRows;
|
||||
pCtx->input.startRowIndex = pStatus->startOffset;
|
||||
}
|
||||
|
||||
|
@ -3715,7 +3701,7 @@ static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t
|
|||
const char* id, SInterval* pInterval, int32_t fillType, int32_t order) {
|
||||
SFillColInfo* pColInfo = createFillColInfo(pExpr, numOfCols, pNotFillExpr, numOfNotFillCols, pValNode);
|
||||
|
||||
int64_t startKey = (order == TSDB_ORDER_ASC) ? win.skey : win.ekey;
|
||||
int64_t startKey = (order == TSDB_ORDER_ASC) ? win.skey : win.ekey;
|
||||
STimeWindow w = getAlignQueryTimeWindow(pInterval, pInterval->precision, startKey);
|
||||
w = getFirstQualifiedTimeWindow(startKey, &w, pInterval, order);
|
||||
|
||||
|
@ -3988,15 +3974,15 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle,
|
|||
|
||||
bool assignUid = groupbyTbname(group);
|
||||
|
||||
size_t numOfTables = taosArrayGetSize(pTableListInfo->pTableList);
|
||||
size_t numOfTables = taosArrayGetSize(pTableListInfo->pTableList);
|
||||
|
||||
if(assignUid){
|
||||
if (assignUid) {
|
||||
for (int32_t i = 0; i < numOfTables; i++) {
|
||||
STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i);
|
||||
info->groupId = info->uid;
|
||||
taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), &info->groupId, sizeof(uint64_t));
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
int32_t code = getColInfoResultForGroupby(pHandle->meta, group, pTableListInfo);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
|
@ -4615,6 +4601,10 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead
|
|||
goto _complete;
|
||||
}
|
||||
|
||||
if (pHandle && pHandle->pStateBackend) {
|
||||
(*pTaskInfo)->streamInfo.pState = pHandle->pStateBackend;
|
||||
}
|
||||
|
||||
(*pTaskInfo)->sql = sql;
|
||||
sql = NULL;
|
||||
(*pTaskInfo)->pSubplan = pPlan;
|
||||
|
|
|
@ -36,8 +36,8 @@
|
|||
#define SWITCH_ORDER(n) (((n) = ((n) == TSDB_ORDER_ASC) ? TSDB_ORDER_DESC : TSDB_ORDER_ASC))
|
||||
|
||||
static int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo, int32_t capacity);
|
||||
static int32_t buildDbTableInfoBlock(const SSDataBlock* p, const SSysTableMeta* pSysDbTableMeta, size_t size,
|
||||
const char* dbName);
|
||||
static int32_t buildDbTableInfoBlock(bool sysInfo, const SSDataBlock* p, const SSysTableMeta* pSysDbTableMeta,
|
||||
size_t size, const char* dbName);
|
||||
|
||||
static bool processBlockWithProbability(const SSampleExecInfo* pInfo);
|
||||
|
||||
|
@ -1281,6 +1281,42 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
|
|||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
SStreamScanInfo* pInfo = pOperator->info;
|
||||
|
||||
#if 0
|
||||
SStreamState* pState = pTaskInfo->streamInfo.pState;
|
||||
if (pState) {
|
||||
printf(">>>>>>>> stream write backend\n");
|
||||
SWinKey key = {
|
||||
.ts = 1,
|
||||
.groupId = 2,
|
||||
};
|
||||
char tmp[100] = "abcdefg1";
|
||||
if (streamStatePut(pState, &key, &tmp, strlen(tmp) + 1) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
key.ts = 2;
|
||||
char tmp2[100] = "abcdefg2";
|
||||
if (streamStatePut(pState, &key, &tmp2, strlen(tmp2) + 1) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
key.groupId = 5;
|
||||
key.ts = 1;
|
||||
char tmp3[100] = "abcdefg3";
|
||||
if (streamStatePut(pState, &key, &tmp3, strlen(tmp3) + 1) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
char* val2 = NULL;
|
||||
int32_t sz;
|
||||
if (streamStateGet(pState, &key, (void**)&val2, &sz) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
printf("stream read %s %d\n", val2, sz);
|
||||
streamFreeVal(val2);
|
||||
}
|
||||
#endif
|
||||
|
||||
qDebug("stream scan called");
|
||||
if (pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__LOG) {
|
||||
while (1) {
|
||||
|
@ -2392,10 +2428,10 @@ int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo, int32_t capacity) {
|
|||
const SSysTableMeta* pSysDbTableMeta = NULL;
|
||||
|
||||
getInfosDbMeta(&pSysDbTableMeta, &size);
|
||||
p->info.rows = buildDbTableInfoBlock(p, pSysDbTableMeta, size, TSDB_INFORMATION_SCHEMA_DB);
|
||||
p->info.rows = buildDbTableInfoBlock(pInfo->sysInfo, p, pSysDbTableMeta, size, TSDB_INFORMATION_SCHEMA_DB);
|
||||
|
||||
getPerfDbMeta(&pSysDbTableMeta, &size);
|
||||
p->info.rows = buildDbTableInfoBlock(p, pSysDbTableMeta, size, TSDB_PERFORMANCE_SCHEMA_DB);
|
||||
p->info.rows = buildDbTableInfoBlock(pInfo->sysInfo, p, pSysDbTableMeta, size, TSDB_PERFORMANCE_SCHEMA_DB);
|
||||
|
||||
pInfo->pRes->info.rows = p->info.rows;
|
||||
relocateColumnData(pInfo->pRes, pInfo->scanCols, p->pDataBlock, false);
|
||||
|
@ -2404,13 +2440,16 @@ int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo, int32_t capacity) {
|
|||
return pInfo->pRes->info.rows;
|
||||
}
|
||||
|
||||
int32_t buildDbTableInfoBlock(const SSDataBlock* p, const SSysTableMeta* pSysDbTableMeta, size_t size,
|
||||
int32_t buildDbTableInfoBlock(bool sysInfo, const SSDataBlock* p, const SSysTableMeta* pSysDbTableMeta, size_t size,
|
||||
const char* dbName) {
|
||||
char n[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
int32_t numOfRows = p->info.rows;
|
||||
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
const SSysTableMeta* pm = &pSysDbTableMeta[i];
|
||||
if (!sysInfo && pm->sysInfo) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SColumnInfoData* pColInfoData = taosArrayGet(p->pDataBlock, 0);
|
||||
|
||||
|
@ -2464,6 +2503,7 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan
|
|||
|
||||
pInfo->accountId = pScanPhyNode->accountId;
|
||||
pInfo->pUser = taosMemoryStrDup((void*)pUser);
|
||||
pInfo->sysInfo = pScanPhyNode->sysInfo;
|
||||
pInfo->showRewrite = pScanPhyNode->showRewrite;
|
||||
pInfo->pRes = pResBlock;
|
||||
pInfo->pCondition = pScanNode->node.pConditions;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#define GET_DEST_SLOT_ID(_p) ((_p)->pExpr->base.resSchema.slotId)
|
||||
|
||||
static void doSetVal(SColumnInfoData* pDstColInfoData, int32_t rowIndex, const SGroupKeys* pKey);
|
||||
static bool fillIfWindowPseudoColumn(SFillInfo* pFillInfo, SFillColInfo* pCol, SColumnInfoData* pDstColInfoData, int32_t rowIndex);
|
||||
|
||||
static void setNullRow(SSDataBlock* pBlock, SFillInfo* pFillInfo, int32_t rowIndex) {
|
||||
for(int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
||||
|
@ -43,9 +44,8 @@ static void setNullRow(SSDataBlock* pBlock, SFillInfo* pFillInfo, int32_t rowInd
|
|||
int32_t dstSlotId = GET_DEST_SLOT_ID(pCol);
|
||||
SColumnInfoData* pDstColInfo = taosArrayGet(pBlock->pDataBlock, dstSlotId);
|
||||
if (pCol->notFillCol) {
|
||||
if (pDstColInfo->info.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
colDataAppend(pDstColInfo, rowIndex, (const char*)&pFillInfo->currentKey, false);
|
||||
} else {
|
||||
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfo, rowIndex);
|
||||
if (!filled) {
|
||||
SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev.pRowVal : pFillInfo->next.pRowVal;
|
||||
SGroupKeys* pKey = taosArrayGet(p, i);
|
||||
doSetVal(pDstColInfo, rowIndex, pKey);
|
||||
|
@ -76,6 +76,35 @@ static void doSetUserSpecifiedValue(SColumnInfoData* pDst, SVariant* pVar, int32
|
|||
}
|
||||
}
|
||||
|
||||
//fill windows pseudo column, _wstart, _wend, _wduration and return true, otherwise return false
|
||||
static bool fillIfWindowPseudoColumn(SFillInfo* pFillInfo, SFillColInfo* pCol, SColumnInfoData* pDstColInfoData, int32_t rowIndex) {
|
||||
if (!pCol->notFillCol) {
|
||||
return false;
|
||||
}
|
||||
if (pCol->pExpr->pExpr->nodeType == QUERY_NODE_COLUMN) {
|
||||
if (pCol->pExpr->base.numOfParams != 1) {
|
||||
return false;
|
||||
}
|
||||
if (pCol->pExpr->base.pParam[0].pCol->colType == COLUMN_TYPE_WINDOW_START) {
|
||||
colDataAppend(pDstColInfoData, rowIndex, (const char*)&pFillInfo->currentKey, false);
|
||||
return true;
|
||||
} else if (pCol->pExpr->base.pParam[0].pCol->colType == COLUMN_TYPE_WINDOW_END) {
|
||||
//TODO: include endpoint
|
||||
SInterval* pInterval = &pFillInfo->interval;
|
||||
int32_t step = (pFillInfo->order == TSDB_ORDER_ASC) ? 1 : -1;
|
||||
int64_t windowEnd =
|
||||
taosTimeAdd(pFillInfo->currentKey, pInterval->sliding * step, pInterval->slidingUnit, pInterval->precision);
|
||||
colDataAppend(pDstColInfoData, rowIndex, (const char*)&windowEnd, false);
|
||||
return true;
|
||||
} else if (pCol->pExpr->base.pParam[0].pCol->colType == COLUMN_TYPE_WINDOW_DURATION) {
|
||||
//TODO: include endpoint
|
||||
colDataAppend(pDstColInfoData, rowIndex, (const char*)&pFillInfo->interval.sliding, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock* pSrcBlock, int64_t ts,
|
||||
bool outOfBound) {
|
||||
SPoint point1, point2, point;
|
||||
|
@ -92,10 +121,8 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock*
|
|||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||
|
||||
SColumnInfoData* pDstColInfoData = taosArrayGet(pBlock->pDataBlock, GET_DEST_SLOT_ID(pCol));
|
||||
|
||||
if (pDstColInfoData->info.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
colDataAppend(pDstColInfoData, index, (const char*)&pFillInfo->currentKey, false);
|
||||
} else {
|
||||
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfoData, index);
|
||||
if (!filled) {
|
||||
SGroupKeys* pKey = taosArrayGet(p, i);
|
||||
doSetVal(pDstColInfoData, index, pKey);
|
||||
}
|
||||
|
@ -106,10 +133,8 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock*
|
|||
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||
SColumnInfoData* pDstColInfoData = taosArrayGet(pBlock->pDataBlock, GET_DEST_SLOT_ID(pCol));
|
||||
|
||||
if (pDstColInfoData->info.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
colDataAppend(pDstColInfoData, index, (const char*)&pFillInfo->currentKey, false);
|
||||
} else {
|
||||
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfoData, index);
|
||||
if (!filled) {
|
||||
SGroupKeys* pKey = taosArrayGet(p, i);
|
||||
doSetVal(pDstColInfoData, index, pKey);
|
||||
}
|
||||
|
@ -127,9 +152,8 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock*
|
|||
int16_t type = pDstCol->info.type;
|
||||
|
||||
if (pCol->notFillCol) {
|
||||
if (type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
colDataAppend(pDstCol, index, (const char*)&pFillInfo->currentKey, false);
|
||||
} else {
|
||||
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstCol, index);
|
||||
if (!filled) {
|
||||
SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev.pRowVal : pFillInfo->next.pRowVal;
|
||||
SGroupKeys* pKey = taosArrayGet(p, i);
|
||||
doSetVal(pDstCol, index, pKey);
|
||||
|
@ -170,9 +194,8 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock*
|
|||
SColumnInfoData* pDst = taosArrayGet(pBlock->pDataBlock, slotId);
|
||||
|
||||
if (pCol->notFillCol) {
|
||||
if (pDst->info.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
colDataAppend(pDst, index, (const char*)&pFillInfo->currentKey, false);
|
||||
} else {
|
||||
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDst, index);
|
||||
if (!filled) {
|
||||
SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev.pRowVal : pFillInfo->next.pRowVal;
|
||||
SGroupKeys* pKey = taosArrayGet(p, i);
|
||||
doSetVal(pDst, index, pKey);
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "executorimpl.h"
|
||||
#include "function.h"
|
||||
#include "functionMgt.h"
|
||||
#include "tcommon.h"
|
||||
#include "tcompare.h"
|
||||
#include "tdatablock.h"
|
||||
#include "tfill.h"
|
||||
|
@ -27,11 +28,6 @@ typedef enum SResultTsInterpType {
|
|||
|
||||
#define IS_FINAL_OP(op) ((op)->isFinal)
|
||||
|
||||
typedef struct SWinRes {
|
||||
TSKEY ts;
|
||||
uint64_t groupId;
|
||||
} SWinRes;
|
||||
|
||||
typedef struct SPullWindowInfo {
|
||||
STimeWindow window;
|
||||
uint64_t groupId;
|
||||
|
@ -641,7 +637,8 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num
|
|||
setResultRowInterpo(pResult, RESULT_ROW_END_INTERP);
|
||||
setNotInterpoWindowKey(pSup->pCtx, numOfExprs, RESULT_ROW_START_INTERP);
|
||||
|
||||
doApplyFunctions(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, 0, pBlock->info.rows, numOfExprs);
|
||||
doApplyFunctions(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, 0, pBlock->info.rows,
|
||||
numOfExprs);
|
||||
|
||||
if (isResultRowInterpolated(pResult, RESULT_ROW_END_INTERP)) {
|
||||
closeResultRow(pr);
|
||||
|
@ -812,7 +809,7 @@ static int32_t savePullWindow(SPullWindowInfo* pPullInfo, SArray* pPullWins) {
|
|||
int32_t compareResKey(void* pKey, void* data, int32_t index) {
|
||||
SArray* res = (SArray*)data;
|
||||
SResKeyPos* pos = taosArrayGetP(res, index);
|
||||
SWinRes* pData = (SWinRes*)pKey;
|
||||
SWinKey* pData = (SWinKey*)pKey;
|
||||
if (pData->ts == *(int64_t*)pos->key) {
|
||||
if (pData->groupId > pos->groupId) {
|
||||
return 1;
|
||||
|
@ -828,7 +825,7 @@ int32_t compareResKey(void* pKey, void* data, int32_t index) {
|
|||
|
||||
static int32_t saveResult(int64_t ts, int32_t pageId, int32_t offset, uint64_t groupId, SArray* pUpdated) {
|
||||
int32_t size = taosArrayGetSize(pUpdated);
|
||||
SWinRes data = {.ts = ts, .groupId = groupId};
|
||||
SWinKey data = {.ts = ts, .groupId = groupId};
|
||||
int32_t index = binarySearchCom(pUpdated, size, &data, TSDB_ORDER_DESC, compareResKey);
|
||||
if (index == -1) {
|
||||
index = 0;
|
||||
|
@ -861,8 +858,8 @@ static int32_t saveWinResult(int64_t ts, int32_t pageId, int32_t offset, uint64_
|
|||
newPos->groupId = groupId;
|
||||
newPos->pos = (SResultRowPosition){.pageId = pageId, .offset = offset};
|
||||
*(int64_t*)newPos->key = ts;
|
||||
SWinRes key = {.ts = ts, .groupId = groupId};
|
||||
if (taosHashPut(pUpdatedMap, &key, sizeof(SWinRes), &newPos, sizeof(void*)) != TSDB_CODE_SUCCESS) {
|
||||
SWinKey key = {.ts = ts, .groupId = groupId};
|
||||
if (taosHashPut(pUpdatedMap, &key, sizeof(SWinKey), &newPos, sizeof(void*)) != TSDB_CODE_SUCCESS) {
|
||||
taosMemoryFree(newPos);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -879,20 +876,20 @@ static int32_t saveResultRow(SResultRow* result, uint64_t groupId, SArray* pUpda
|
|||
static void removeResults(SArray* pWins, SHashObj* pUpdatedMap) {
|
||||
int32_t size = taosArrayGetSize(pWins);
|
||||
for (int32_t i = 0; i < size; i++) {
|
||||
SWinRes* pW = taosArrayGet(pWins, i);
|
||||
taosHashRemove(pUpdatedMap, pW, sizeof(SWinRes));
|
||||
SWinKey* pW = taosArrayGet(pWins, i);
|
||||
taosHashRemove(pUpdatedMap, pW, sizeof(SWinKey));
|
||||
}
|
||||
}
|
||||
|
||||
int64_t getWinReskey(void* data, int32_t index) {
|
||||
SArray* res = (SArray*)data;
|
||||
SWinRes* pos = taosArrayGet(res, index);
|
||||
SWinKey* pos = taosArrayGet(res, index);
|
||||
return pos->ts;
|
||||
}
|
||||
|
||||
int32_t compareWinRes(void* pKey, void* data, int32_t index) {
|
||||
SArray* res = (SArray*)data;
|
||||
SWinRes* pos = taosArrayGetP(res, index);
|
||||
SWinKey* pos = taosArrayGetP(res, index);
|
||||
SResKeyPos* pData = (SResKeyPos*)pKey;
|
||||
if (*(int64_t*)pData->key == pos->ts) {
|
||||
if (pData->groupId > pos->groupId) {
|
||||
|
@ -985,8 +982,8 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
|
|||
if ((!pInfo->ignoreExpiredData || !isCloseWindow(&win, &pInfo->twAggSup)) &&
|
||||
inSlidingWindow(&pInfo->interval, &win, &pBlock->info)) {
|
||||
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &win, true);
|
||||
doApplyFunctions(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows,
|
||||
pBlock->info.rows, numOfOutput);
|
||||
doApplyFunctions(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, pBlock->info.rows,
|
||||
numOfOutput);
|
||||
}
|
||||
|
||||
doCloseWindow(pResultRowInfo, pInfo, pResult);
|
||||
|
@ -1025,8 +1022,8 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
|
|||
doWindowBorderInterpolation(pInfo, pBlock, pResult, &nextWin, startPos, forwardRows, pSup);
|
||||
|
||||
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &nextWin, true);
|
||||
doApplyFunctions(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows,
|
||||
pBlock->info.rows, numOfOutput);
|
||||
doApplyFunctions(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, pBlock->info.rows,
|
||||
numOfOutput);
|
||||
doCloseWindow(pResultRowInfo, pInfo, pResult);
|
||||
}
|
||||
|
||||
|
@ -1214,8 +1211,8 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI
|
|||
}
|
||||
|
||||
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pRowSup->win, false);
|
||||
doApplyFunctions(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, pRowSup->startRowIndex,
|
||||
pRowSup->numOfRows, pBlock->info.rows, numOfOutput);
|
||||
doApplyFunctions(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, pRowSup->startRowIndex, pRowSup->numOfRows,
|
||||
pBlock->info.rows, numOfOutput);
|
||||
}
|
||||
|
||||
static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator) {
|
||||
|
@ -1418,7 +1415,7 @@ void doDeleteSpecifyIntervalWindow(SAggSupporter* pAggSup, SSDataBlock* pBlock,
|
|||
STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, tsStarts[i], pInterval, TSDB_ORDER_ASC);
|
||||
doDeleteIntervalWindow(pAggSup, win.skey, groupIds[i]);
|
||||
if (pUpWins) {
|
||||
SWinRes winRes = {.ts = win.skey, .groupId = groupIds[i]};
|
||||
SWinKey winRes = {.ts = win.skey, .groupId = groupIds[i]};
|
||||
taosArrayPush(pUpWins, &winRes);
|
||||
}
|
||||
}
|
||||
|
@ -1445,7 +1442,7 @@ static void doClearWindows(SAggSupporter* pAggSup, SExprSupp* pSup1, SInterval*
|
|||
uint64_t winGpId = pGpDatas ? pGpDatas[startPos] : pBlock->info.groupId;
|
||||
bool res = doClearWindow(pAggSup, pSup1, (char*)&win.skey, sizeof(TSKEY), winGpId, numOfOutput);
|
||||
if (pUpWins && res) {
|
||||
SWinRes winRes = {.ts = win.skey, .groupId = winGpId};
|
||||
SWinKey winRes = {.ts = win.skey, .groupId = winGpId};
|
||||
taosArrayPush(pUpWins, &winRes);
|
||||
}
|
||||
getNextTimeWindow(pInterval, pInterval->precision, TSDB_ORDER_ASC, &win);
|
||||
|
@ -1484,11 +1481,11 @@ static int32_t closeIntervalWindow(SHashObj* pHashMap, STimeWindowAggSupp* pSup,
|
|||
STimeWindow win;
|
||||
win.skey = ts;
|
||||
win.ekey = taosTimeAdd(win.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
|
||||
SWinRes winRe = {
|
||||
SWinKey winRe = {
|
||||
.ts = win.skey,
|
||||
.groupId = groupId,
|
||||
};
|
||||
void* chIds = taosHashGet(pPullDataMap, &winRe, sizeof(SWinRes));
|
||||
void* chIds = taosHashGet(pPullDataMap, &winRe, sizeof(SWinKey));
|
||||
if (isCloseWindow(&win, pSup)) {
|
||||
if (chIds && pPullDataMap) {
|
||||
SArray* chAy = *(SArray**)chIds;
|
||||
|
@ -1555,7 +1552,7 @@ static void doBuildDeleteResult(SArray* pWins, int32_t* index, SSDataBlock* pBlo
|
|||
SColumnInfoData* pTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
||||
SColumnInfoData* pGroupCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
||||
for (int32_t i = *index; i < size; i++) {
|
||||
SWinRes* pWin = taosArrayGet(pWins, i);
|
||||
SWinKey* pWin = taosArrayGet(pWins, i);
|
||||
colDataAppend(pTsCol, pBlock->info.rows, (const char*)&pWin->ts, false);
|
||||
colDataAppend(pGroupCol, pBlock->info.rows, (const char*)&pWin->groupId, false);
|
||||
pBlock->info.rows++;
|
||||
|
@ -1595,6 +1592,9 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
|||
SArray* pUpdated = taosArrayInit(4, POINTER_BYTES); // SResKeyPos
|
||||
_hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
|
||||
SHashObj* pUpdatedMap = taosHashInit(1024, hashFn, false, HASH_NO_LOCK);
|
||||
|
||||
SStreamState* pState = pTaskInfo->streamInfo.pState;
|
||||
|
||||
while (1) {
|
||||
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
|
||||
if (pBlock == NULL) {
|
||||
|
@ -1639,6 +1639,35 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
|||
hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, MAIN_SCAN, pUpdatedMap);
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (pState) {
|
||||
printf(">>>>>>>> stream read backend\n");
|
||||
SWinKey key = {
|
||||
.ts = 1,
|
||||
.groupId = 2,
|
||||
};
|
||||
char* val = NULL;
|
||||
int32_t sz;
|
||||
if (streamStateGet(pState, &key, (void**)&val, &sz) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
printf("stream read %s %d\n", val, sz);
|
||||
streamFreeVal(val);
|
||||
|
||||
SStreamStateCur* pCur = streamStateGetCur(pState, &key);
|
||||
ASSERT(pCur);
|
||||
while (streamStateCurNext(pState, pCur) == 0) {
|
||||
SWinKey key1;
|
||||
const void* val1;
|
||||
if (streamStateGetKVByCur(pCur, &key1, &val1, &sz) < 0) {
|
||||
break;
|
||||
}
|
||||
printf("stream iter key groupId:%d ts:%d, value %s %d\n", key1.groupId, key1.ts, val1, sz);
|
||||
}
|
||||
streamStateFreeCur(pCur);
|
||||
}
|
||||
#endif
|
||||
|
||||
pOperator->status = OP_RES_TO_RETURN;
|
||||
closeIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, &pInfo->interval, NULL, pUpdatedMap,
|
||||
pInfo->pRecycledPages, pInfo->aggSup.pResultBuf);
|
||||
|
@ -1857,7 +1886,7 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
|||
}
|
||||
}
|
||||
pInfo->pRecycledPages = taosArrayInit(4, sizeof(int32_t));
|
||||
pInfo->pDelWins = taosArrayInit(4, sizeof(SWinRes));
|
||||
pInfo->pDelWins = taosArrayInit(4, sizeof(SWinKey));
|
||||
pInfo->delIndex = 0;
|
||||
pInfo->pDelRes = createSpecialDataBlock(STREAM_DELETE_RESULT);
|
||||
initResultRowInfo(&pInfo->binfo.resultRowInfo);
|
||||
|
@ -1918,8 +1947,8 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSessionAggOperator
|
|||
if (gid != pRowSup->groupId || pInfo->winSup.prevTs == INT64_MIN) {
|
||||
doKeepNewWindowStartInfo(pRowSup, tsList, j, gid);
|
||||
doKeepTuple(pRowSup, tsList[j], gid);
|
||||
} else if ((tsList[j] - pRowSup->prevTs >= 0) && tsList[j] - pRowSup->prevTs <= gap ||
|
||||
(pRowSup->prevTs - tsList[j] >= 0) && (pRowSup->prevTs - tsList[j] <= gap)) {
|
||||
} else if (((tsList[j] - pRowSup->prevTs >= 0) && (tsList[j] - pRowSup->prevTs <= gap)) ||
|
||||
((pRowSup->prevTs - tsList[j] >= 0) && (pRowSup->prevTs - tsList[j] <= gap))) {
|
||||
// The gap is less than the threshold, so it belongs to current session window that has been opened already.
|
||||
doKeepTuple(pRowSup, tsList[j], gid);
|
||||
if (j == 0 && pRowSup->startRowIndex != 0) {
|
||||
|
@ -1958,8 +1987,8 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSessionAggOperator
|
|||
}
|
||||
|
||||
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pRowSup->win, false);
|
||||
doApplyFunctions(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, pRowSup->startRowIndex,
|
||||
pRowSup->numOfRows, pBlock->info.rows, numOfOutput);
|
||||
doApplyFunctions(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, pRowSup->startRowIndex, pRowSup->numOfRows,
|
||||
pBlock->info.rows, numOfOutput);
|
||||
}
|
||||
|
||||
static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) {
|
||||
|
@ -2811,7 +2840,7 @@ static void rebuildIntervalWindow(SStreamFinalIntervalOperatorInfo* pInfo, SExpr
|
|||
return;
|
||||
}
|
||||
for (int32_t i = 0; i < size; i++) {
|
||||
SWinRes* pWinRes = taosArrayGet(pWinArray, i);
|
||||
SWinKey* pWinRes = taosArrayGet(pWinArray, i);
|
||||
SResultRow* pCurResult = NULL;
|
||||
STimeWindow ParentWin = {.skey = pWinRes->ts, .ekey = pWinRes->ts + 1};
|
||||
setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, &ParentWin, true, &pCurResult, pWinRes->groupId, pSup->pCtx,
|
||||
|
@ -2854,12 +2883,12 @@ int32_t getNexWindowPos(SInterval* pInterval, SDataBlockInfo* pBlockInfo, TSKEY*
|
|||
return getNextQualifiedWindow(pInterval, pNextWin, pBlockInfo, tsCols, prevEndPos, TSDB_ORDER_ASC);
|
||||
}
|
||||
|
||||
void addPullWindow(SHashObj* pMap, SWinRes* pWinRes, int32_t size) {
|
||||
void addPullWindow(SHashObj* pMap, SWinKey* pWinRes, int32_t size) {
|
||||
SArray* childIds = taosArrayInit(8, sizeof(int32_t));
|
||||
for (int32_t i = 0; i < size; i++) {
|
||||
taosArrayPush(childIds, &i);
|
||||
}
|
||||
taosHashPut(pMap, pWinRes, sizeof(SWinRes), &childIds, sizeof(void*));
|
||||
taosHashPut(pMap, pWinRes, sizeof(SWinKey), &childIds, sizeof(void*));
|
||||
}
|
||||
|
||||
static int32_t getChildIndex(SSDataBlock* pBlock) { return pBlock->info.childId; }
|
||||
|
@ -2906,11 +2935,11 @@ static void doHashInterval(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBloc
|
|||
}
|
||||
if (IS_FINAL_OP(pInfo) && isClosed && pInfo->pChildren) {
|
||||
bool ignore = true;
|
||||
SWinRes winRes = {
|
||||
SWinKey winRes = {
|
||||
.ts = nextWin.skey,
|
||||
.groupId = tableGroupId,
|
||||
};
|
||||
void* chIds = taosHashGet(pInfo->pPullDataMap, &winRes, sizeof(SWinRes));
|
||||
void* chIds = taosHashGet(pInfo->pPullDataMap, &winRes, sizeof(SWinKey));
|
||||
if (isDeletedWindow(&nextWin, tableGroupId, &pInfo->aggSup) && !chIds) {
|
||||
SPullWindowInfo pull = {.window = nextWin, .groupId = tableGroupId};
|
||||
// add pull data request
|
||||
|
@ -3038,8 +3067,8 @@ void processPullOver(SSDataBlock* pBlock, SHashObj* pMap) {
|
|||
uint64_t* groupIdData = (uint64_t*)pGroupCol->pData;
|
||||
int32_t chId = getChildIndex(pBlock);
|
||||
for (int32_t i = 0; i < pBlock->info.rows; i++) {
|
||||
SWinRes winRes = {.ts = tsData[i], .groupId = groupIdData[i]};
|
||||
void* chIds = taosHashGet(pMap, &winRes, sizeof(SWinRes));
|
||||
SWinKey winRes = {.ts = tsData[i], .groupId = groupIdData[i]};
|
||||
void* chIds = taosHashGet(pMap, &winRes, sizeof(SWinKey));
|
||||
if (chIds) {
|
||||
SArray* chArray = *(SArray**)chIds;
|
||||
int32_t index = taosArraySearchIdx(chArray, &chId, compareInt32Val, TD_EQ);
|
||||
|
@ -3048,7 +3077,7 @@ void processPullOver(SSDataBlock* pBlock, SHashObj* pMap) {
|
|||
taosArrayRemove(chArray, index);
|
||||
if (taosArrayGetSize(chArray) == 0) {
|
||||
// pull data is over
|
||||
taosHashRemove(pMap, &winRes, sizeof(SWinRes));
|
||||
taosHashRemove(pMap, &winRes, sizeof(SWinKey));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3128,11 +3157,11 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
|||
maxTs = TMAX(maxTs, pBlock->info.window.ekey);
|
||||
maxTs = TMAX(maxTs, pBlock->info.watermark);
|
||||
|
||||
if (pBlock->info.type == STREAM_NORMAL || pBlock->info.type == STREAM_PULL_DATA ||
|
||||
pBlock->info.type == STREAM_INVALID) {
|
||||
ASSERT(pBlock->info.type != STREAM_INVERT);
|
||||
if (pBlock->info.type == STREAM_NORMAL || pBlock->info.type == STREAM_PULL_DATA) {
|
||||
pInfo->binfo.pRes->info.type = pBlock->info.type;
|
||||
} else if (pBlock->info.type == STREAM_CLEAR) {
|
||||
SArray* pUpWins = taosArrayInit(8, sizeof(SWinRes));
|
||||
SArray* pUpWins = taosArrayInit(8, sizeof(SWinKey));
|
||||
doClearWindows(&pInfo->aggSup, pSup, &pInfo->interval, pOperator->exprSupp.numOfExprs, pBlock, pUpWins);
|
||||
if (IS_FINAL_OP(pInfo)) {
|
||||
int32_t childIndex = getChildIndex(pBlock);
|
||||
|
@ -3170,7 +3199,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
|||
getAllIntervalWindow(pInfo->aggSup.pResultRowHashTable, pUpdatedMap);
|
||||
continue;
|
||||
} else if (pBlock->info.type == STREAM_RETRIEVE && !IS_FINAL_OP(pInfo)) {
|
||||
SArray* pUpWins = taosArrayInit(8, sizeof(SWinRes));
|
||||
SArray* pUpWins = taosArrayInit(8, sizeof(SWinKey));
|
||||
doClearWindows(&pInfo->aggSup, pSup, &pInfo->interval, pOperator->exprSupp.numOfExprs, pBlock, pUpWins);
|
||||
removeResults(pUpWins, pUpdatedMap);
|
||||
taosArrayDestroy(pUpWins);
|
||||
|
@ -3385,7 +3414,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
|
|||
pInfo->ignoreExpiredData = pIntervalPhyNode->window.igExpired;
|
||||
pInfo->pDelRes = createSpecialDataBlock(STREAM_DELETE_RESULT);
|
||||
pInfo->delIndex = 0;
|
||||
pInfo->pDelWins = taosArrayInit(4, sizeof(SWinRes));
|
||||
pInfo->pDelWins = taosArrayInit(4, sizeof(SWinKey));
|
||||
pInfo->pRecycledPages = taosArrayInit(4, sizeof(int32_t));
|
||||
|
||||
pOperator->operatorType = pPhyNode->type;
|
||||
|
@ -3720,8 +3749,8 @@ int32_t updateSessionWindowInfo(SResultWindowInfo* pWinInfo, TSKEY* pStartTs, TS
|
|||
}
|
||||
if (pWinInfo->win.skey > pStartTs[i]) {
|
||||
if (pStDeleted && pWinInfo->isOutput) {
|
||||
SWinRes res = {.ts = pWinInfo->win.skey, .groupId = groupId};
|
||||
taosHashPut(pStDeleted, &pWinInfo->pos, sizeof(SResultRowPosition), &res, sizeof(SWinRes));
|
||||
SWinKey res = {.ts = pWinInfo->win.skey, .groupId = groupId};
|
||||
taosHashPut(pStDeleted, &pWinInfo->pos, sizeof(SResultRowPosition), &res, sizeof(SWinKey));
|
||||
pWinInfo->isOutput = false;
|
||||
}
|
||||
pWinInfo->win.skey = pStartTs[i];
|
||||
|
@ -3839,8 +3868,8 @@ void compactTimeWindow(SStreamSessionAggOperatorInfo* pInfo, int32_t startIndex,
|
|||
compactFunctions(pSup->pCtx, pInfo->pDummyCtx, numOfOutput, pTaskInfo);
|
||||
taosHashRemove(pStUpdated, &pWinInfo->pos, sizeof(SResultRowPosition));
|
||||
if (pWinInfo->isOutput) {
|
||||
SWinRes res = {.ts = pWinInfo->win.skey, .groupId = groupId};
|
||||
taosHashPut(pStDeleted, &pWinInfo->pos, sizeof(SResultRowPosition), &res, sizeof(SWinRes));
|
||||
SWinKey res = {.ts = pWinInfo->win.skey, .groupId = groupId};
|
||||
taosHashPut(pStDeleted, &pWinInfo->pos, sizeof(SResultRowPosition), &res, sizeof(SWinKey));
|
||||
pWinInfo->isOutput = false;
|
||||
}
|
||||
taosArrayRemove(pInfo->streamAggSup.pCurWins, i);
|
||||
|
@ -3902,8 +3931,8 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData
|
|||
}
|
||||
pCurWin->isClosed = false;
|
||||
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE && pStUpdated) {
|
||||
SWinRes value = {.ts = pCurWin->win.skey, .groupId = groupId};
|
||||
code = taosHashPut(pStUpdated, &pCurWin->pos, sizeof(SResultRowPosition), &value, sizeof(SWinRes));
|
||||
SWinKey value = {.ts = pCurWin->win.skey, .groupId = groupId};
|
||||
code = taosHashPut(pStUpdated, &pCurWin->pos, sizeof(SResultRowPosition), &value, sizeof(SWinKey));
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
}
|
||||
|
@ -3955,8 +3984,7 @@ static void doClearSessionWindows(SStreamAggSupporter* pAggSup, SExprSupp* pSup,
|
|||
int32_t step = 0;
|
||||
for (int32_t i = 0; i < pBlock->info.rows; i += step) {
|
||||
int32_t winIndex = 0;
|
||||
SResultWindowInfo* pCurWin =
|
||||
getCurSessionWindow(pAggSup, tsCols[i], INT64_MIN, gpCols[i], gap, &winIndex);
|
||||
SResultWindowInfo* pCurWin = getCurSessionWindow(pAggSup, tsCols[i], INT64_MIN, gpCols[i], gap, &winIndex);
|
||||
if (!pCurWin || pCurWin->pos.pageId == -1) {
|
||||
// window has been closed.
|
||||
step = 1;
|
||||
|
@ -3981,9 +4009,9 @@ static int32_t copyUpdateResult(SHashObj* pStUpdated, SArray* pUpdated) {
|
|||
if (pos == NULL) {
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
}
|
||||
pos->groupId = ((SWinRes*)pData)->groupId;
|
||||
pos->groupId = ((SWinKey*)pData)->groupId;
|
||||
pos->pos = *(SResultRowPosition*)key;
|
||||
*(int64_t*)pos->key = ((SWinRes*)pData)->ts;
|
||||
*(int64_t*)pos->key = ((SWinKey*)pData)->ts;
|
||||
taosArrayPush(pUpdated, &pos);
|
||||
}
|
||||
taosArraySort(pUpdated, resultrowComparAsc);
|
||||
|
@ -3999,7 +4027,7 @@ void doBuildDeleteDataBlock(SHashObj* pStDeleted, SSDataBlock* pBlock, void** It
|
|||
blockDataEnsureCapacity(pBlock, size);
|
||||
size_t keyLen = 0;
|
||||
while (((*Ite) = taosHashIterate(pStDeleted, *Ite)) != NULL) {
|
||||
SWinRes* res = *Ite;
|
||||
SWinKey* res = *Ite;
|
||||
SColumnInfoData* pTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
||||
colDataAppend(pTsCol, pBlock->info.rows, (const char*)&res->ts, false);
|
||||
SColumnInfoData* pGpCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
||||
|
@ -4130,8 +4158,8 @@ static void copyDeleteWindowInfo(SArray* pResWins, SHashObj* pStDeleted) {
|
|||
int32_t size = taosArrayGetSize(pResWins);
|
||||
for (int32_t i = 0; i < size; i++) {
|
||||
SResultWindowInfo* pWinInfo = taosArrayGet(pResWins, i);
|
||||
SWinRes res = {.ts = pWinInfo->win.skey, .groupId = pWinInfo->groupId};
|
||||
taosHashPut(pStDeleted, &pWinInfo->pos, sizeof(SResultRowPosition), &res, sizeof(SWinRes));
|
||||
SWinKey res = {.ts = pWinInfo->win.skey, .groupId = pWinInfo->groupId};
|
||||
taosHashPut(pStDeleted, &pWinInfo->pos, sizeof(SResultRowPosition), &res, sizeof(SWinKey));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4169,14 +4197,14 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
|
|||
|
||||
if (pBlock->info.type == STREAM_CLEAR) {
|
||||
SArray* pWins = taosArrayInit(16, sizeof(SResultWindowInfo));
|
||||
doClearSessionWindows(&pInfo->streamAggSup, &pOperator->exprSupp, pBlock, START_TS_COLUMN_INDEX, pOperator->exprSupp.numOfExprs, 0,
|
||||
pWins);
|
||||
doClearSessionWindows(&pInfo->streamAggSup, &pOperator->exprSupp, pBlock, START_TS_COLUMN_INDEX,
|
||||
pOperator->exprSupp.numOfExprs, 0, pWins);
|
||||
if (IS_FINAL_OP(pInfo)) {
|
||||
int32_t childIndex = getChildIndex(pBlock);
|
||||
SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, childIndex);
|
||||
SStreamSessionAggOperatorInfo* pChildInfo = pChildOp->info;
|
||||
doClearSessionWindows(&pChildInfo->streamAggSup, &pChildOp->exprSupp, pBlock, START_TS_COLUMN_INDEX, pChildOp->exprSupp.numOfExprs,
|
||||
0, NULL);
|
||||
doClearSessionWindows(&pChildInfo->streamAggSup, &pChildOp->exprSupp, pBlock, START_TS_COLUMN_INDEX,
|
||||
pChildOp->exprSupp.numOfExprs, 0, NULL);
|
||||
rebuildTimeWindow(pInfo, pWins, pBlock->info.groupId, pOperator->exprSupp.numOfExprs, pOperator);
|
||||
}
|
||||
taosArrayDestroy(pWins);
|
||||
|
@ -4578,7 +4606,8 @@ SStateWindowInfo* getStateWindow(SStreamAggSupporter* pAggSup, TSKEY ts, uint64_
|
|||
}
|
||||
|
||||
int32_t updateStateWindowInfo(SArray* pWinInfos, int32_t winIndex, TSKEY* pTs, uint64_t groupId,
|
||||
SColumnInfoData* pKeyCol, int32_t rows, int32_t start, bool* allEqual, SHashObj* pSeDeleted) {
|
||||
SColumnInfoData* pKeyCol, int32_t rows, int32_t start, bool* allEqual,
|
||||
SHashObj* pSeDeleted) {
|
||||
*allEqual = true;
|
||||
SStateWindowInfo* pWinInfo = taosArrayGet(pWinInfos, winIndex);
|
||||
for (int32_t i = start; i < rows; ++i) {
|
||||
|
@ -4599,9 +4628,8 @@ int32_t updateStateWindowInfo(SArray* pWinInfos, int32_t winIndex, TSKEY* pTs, u
|
|||
}
|
||||
if (pWinInfo->winInfo.win.skey > pTs[i]) {
|
||||
if (pSeDeleted && pWinInfo->winInfo.isOutput) {
|
||||
SWinRes res = {.ts = pWinInfo->winInfo.win.skey, .groupId = groupId};
|
||||
taosHashPut(pSeDeleted, &pWinInfo->winInfo.pos, sizeof(SResultRowPosition), &res,
|
||||
sizeof(SWinRes));
|
||||
SWinKey res = {.ts = pWinInfo->winInfo.win.skey, .groupId = groupId};
|
||||
taosHashPut(pSeDeleted, &pWinInfo->winInfo.pos, sizeof(SResultRowPosition), &res, sizeof(SWinKey));
|
||||
pWinInfo->winInfo.isOutput = false;
|
||||
}
|
||||
pWinInfo->winInfo.win.skey = pTs[i];
|
||||
|
@ -4614,14 +4642,14 @@ int32_t updateStateWindowInfo(SArray* pWinInfos, int32_t winIndex, TSKEY* pTs, u
|
|||
return rows - start;
|
||||
}
|
||||
|
||||
static void doClearStateWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock,
|
||||
SHashObj* pSeUpdated, SHashObj* pSeDeleted) {
|
||||
static void doClearStateWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, SHashObj* pSeUpdated,
|
||||
SHashObj* pSeDeleted) {
|
||||
SColumnInfoData* pTsColInfo = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
||||
SColumnInfoData* pGroupColInfo = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
||||
TSKEY* tsCol = (TSKEY*)pTsColInfo->pData;
|
||||
bool allEqual = false;
|
||||
int32_t step = 1;
|
||||
uint64_t* gpCol = (uint64_t*) pGroupColInfo->pData;
|
||||
uint64_t* gpCol = (uint64_t*)pGroupColInfo->pData;
|
||||
for (int32_t i = 0; i < pBlock->info.rows; i += step) {
|
||||
int32_t winIndex = 0;
|
||||
SStateWindowInfo* pCurWin = getStateWindowByTs(pAggSup, tsCol[i], gpCol[i], &winIndex);
|
||||
|
@ -4665,13 +4693,12 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
|
|||
char* pKeyData = colDataGetData(pKeyColInfo, i);
|
||||
int32_t winIndex = 0;
|
||||
bool allEqual = true;
|
||||
SStateWindowInfo* pCurWin =
|
||||
getStateWindow(pAggSup, tsCols[i], groupId, pKeyData, &pInfo->stateCol, &winIndex);
|
||||
winRows = updateStateWindowInfo(pAggSup->pCurWins, winIndex, tsCols, groupId, pKeyColInfo,
|
||||
pSDataBlock->info.rows, i, &allEqual, pStDeleted);
|
||||
SStateWindowInfo* pCurWin = getStateWindow(pAggSup, tsCols[i], groupId, pKeyData, &pInfo->stateCol, &winIndex);
|
||||
winRows = updateStateWindowInfo(pAggSup->pCurWins, winIndex, tsCols, groupId, pKeyColInfo, pSDataBlock->info.rows,
|
||||
i, &allEqual, pStDeleted);
|
||||
if (!allEqual) {
|
||||
appendOneRow(pAggSup->pScanBlock, &pCurWin->winInfo.win.skey, &pCurWin->winInfo.win.ekey,
|
||||
GROUPID_COLUMN_INDEX, &groupId);
|
||||
appendOneRow(pAggSup->pScanBlock, &pCurWin->winInfo.win.skey, &pCurWin->winInfo.win.ekey, GROUPID_COLUMN_INDEX,
|
||||
&groupId);
|
||||
taosHashRemove(pSeUpdated, &pCurWin->winInfo.pos, sizeof(SResultRowPosition));
|
||||
deleteWindow(pAggSup->pCurWins, winIndex, destroyStateWinInfo);
|
||||
continue;
|
||||
|
@ -4682,8 +4709,8 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
|
|||
}
|
||||
pCurWin->winInfo.isClosed = false;
|
||||
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) {
|
||||
SWinRes value = {.ts = pCurWin->winInfo.win.skey, .groupId = groupId};
|
||||
code = taosHashPut(pSeUpdated, &pCurWin->winInfo.pos, sizeof(SResultRowPosition), &value, sizeof(SWinRes));
|
||||
SWinKey value = {.ts = pCurWin->winInfo.win.skey, .groupId = groupId};
|
||||
code = taosHashPut(pSeUpdated, &pCurWin->winInfo.pos, sizeof(SResultRowPosition), &value, sizeof(SWinKey));
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
}
|
||||
|
|
|
@ -255,6 +255,13 @@ static int32_t sifInitOperParams(SIFParam **params, SOperatorNode *node, SIFCtx
|
|||
if (node->opType == OP_TYPE_JSON_GET_VALUE) {
|
||||
return code;
|
||||
}
|
||||
if ((node->pLeft != NULL && nodeType(node->pLeft) == QUERY_NODE_COLUMN) &&
|
||||
(node->pRight != NULL && nodeType(node->pRight) == QUERY_NODE_VALUE)) {
|
||||
SColumnNode *cn = (SColumnNode *)(node->pLeft);
|
||||
if (cn->node.resType.type == TSDB_DATA_TYPE_JSON) {
|
||||
SIF_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||
}
|
||||
}
|
||||
SIFParam *paramList = taosMemoryCalloc(nParam, sizeof(SIFParam));
|
||||
|
||||
if (NULL == paramList) {
|
||||
|
|
|
@ -545,6 +545,7 @@ static int32_t physiSysTableScanCopy(const SSystemTableScanPhysiNode* pSrc, SSys
|
|||
COPY_OBJECT_FIELD(mgmtEpSet, sizeof(SEpSet));
|
||||
COPY_SCALAR_FIELD(showRewrite);
|
||||
COPY_SCALAR_FIELD(accountId);
|
||||
COPY_SCALAR_FIELD(sysInfo);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -1654,6 +1654,7 @@ static int32_t jsonToPhysiTableScanNode(const SJson* pJson, void* pObj) {
|
|||
static const char* jkSysTableScanPhysiPlanMnodeEpSet = "MnodeEpSet";
|
||||
static const char* jkSysTableScanPhysiPlanShowRewrite = "ShowRewrite";
|
||||
static const char* jkSysTableScanPhysiPlanAccountId = "AccountId";
|
||||
static const char* jkSysTableScanPhysiPlanSysInfo = "SysInfo";
|
||||
|
||||
static int32_t physiSysTableScanNodeToJson(const void* pObj, SJson* pJson) {
|
||||
const SSystemTableScanPhysiNode* pNode = (const SSystemTableScanPhysiNode*)pObj;
|
||||
|
@ -1668,6 +1669,9 @@ static int32_t physiSysTableScanNodeToJson(const void* pObj, SJson* pJson) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkSysTableScanPhysiPlanAccountId, pNode->accountId);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddBoolToObject(pJson, jkSysTableScanPhysiPlanSysInfo, pNode->sysInfo);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -1684,7 +1688,9 @@ static int32_t jsonToPhysiSysTableScanNode(const SJson* pJson, void* pObj) {
|
|||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
tjsonGetNumberValue(pJson, jkSysTableScanPhysiPlanAccountId, pNode->accountId, code);
|
||||
;
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetBoolValue(pJson, jkSysTableScanPhysiPlanSysInfo, &pNode->sysInfo);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
|
|
@ -108,6 +108,21 @@ static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt) {
|
|||
return authDelete(pCxt, (SDeleteStmt*)pStmt);
|
||||
case QUERY_NODE_INSERT_STMT:
|
||||
return authInsert(pCxt, (SInsertStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_DNODES_STMT:
|
||||
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||
case QUERY_NODE_SHOW_MODULES_STMT:
|
||||
case QUERY_NODE_SHOW_QNODES_STMT:
|
||||
case QUERY_NODE_SHOW_SNODES_STMT:
|
||||
case QUERY_NODE_SHOW_BNODES_STMT:
|
||||
case QUERY_NODE_SHOW_CLUSTER_STMT:
|
||||
case QUERY_NODE_SHOW_LICENCES_STMT:
|
||||
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
||||
case QUERY_NODE_SHOW_VARIABLES_STMT:
|
||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT:
|
||||
case QUERY_NODE_SHOW_VNODES_STMT:
|
||||
case QUERY_NODE_SHOW_SCORES_STMT:
|
||||
return !pCxt->pParseCxt->enableSysInfo ? TSDB_CODE_PAR_PERMISSION_DENIED : TSDB_CODE_SUCCESS;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -784,6 +784,9 @@ static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* p
|
|||
int32_t nums = pMeta->tableInfo.numOfColumns +
|
||||
(igTags ? 0 : ((TSDB_SUPER_TABLE == pMeta->tableType) ? pMeta->tableInfo.numOfTags : 0));
|
||||
for (int32_t i = 0; i < nums; ++i) {
|
||||
if (invisibleColumn(pCxt->pParseCxt->enableSysInfo, pMeta->tableType, pMeta->schema[i].flags)) {
|
||||
continue;
|
||||
}
|
||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
if (NULL == pCol) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY);
|
||||
|
@ -826,7 +829,8 @@ static int32_t findAndSetColumn(STranslateContext* pCxt, SColumnNode** pColRef,
|
|||
}
|
||||
int32_t nums = pMeta->tableInfo.numOfTags + pMeta->tableInfo.numOfColumns;
|
||||
for (int32_t i = 0; i < nums; ++i) {
|
||||
if (0 == strcmp(pCol->colName, pMeta->schema[i].name)) {
|
||||
if (0 == strcmp(pCol->colName, pMeta->schema[i].name) &&
|
||||
!invisibleColumn(pCxt->pParseCxt->enableSysInfo, pMeta->tableType, pMeta->schema[i].flags)) {
|
||||
setColumnInfoBySchema((SRealTableNode*)pTable, pMeta->schema + i, (i - pMeta->tableInfo.numOfColumns), pCol);
|
||||
*pFound = true;
|
||||
break;
|
||||
|
@ -2192,14 +2196,14 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
|
|||
code = setTableCacheLastMode(pCxt, &name, pRealTable);
|
||||
}
|
||||
}
|
||||
pRealTable->table.precision = pRealTable->pMeta->tableInfo.precision;
|
||||
pRealTable->table.singleTable = isSingleTable(pRealTable);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pRealTable->table.precision = pRealTable->pMeta->tableInfo.precision;
|
||||
pRealTable->table.singleTable = isSingleTable(pRealTable);
|
||||
if (TSDB_SUPER_TABLE == pRealTable->pMeta->tableType) {
|
||||
pCxt->stableQuery = true;
|
||||
}
|
||||
code = addNamespace(pCxt, pRealTable);
|
||||
}
|
||||
if (TSDB_SUPER_TABLE == pRealTable->pMeta->tableType) {
|
||||
pCxt->stableQuery = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_TEMP_TABLE: {
|
||||
|
@ -2594,8 +2598,7 @@ static int32_t getQueryTimeRange(STranslateContext* pCxt, SNode* pWhere, STimeWi
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t checkFill(STranslateContext* pCxt, SFillNode* pFill, SValueNode* pInterval,
|
||||
bool isInterpFill) {
|
||||
static int32_t checkFill(STranslateContext* pCxt, SFillNode* pFill, SValueNode* pInterval, bool isInterpFill) {
|
||||
if (FILL_MODE_NONE == pFill->mode) {
|
||||
if (isInterpFill) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, "Unsupported fill type");
|
||||
|
|
|
@ -207,6 +207,7 @@ class ParserTestBaseImpl {
|
|||
pCxt->db = caseEnv_.db_.c_str();
|
||||
pCxt->pUser = caseEnv_.user_.c_str();
|
||||
pCxt->isSuperUser = caseEnv_.user_ == "root";
|
||||
pCxt->enableSysInfo = true;
|
||||
pCxt->pSql = stmtEnv_.sql_.c_str();
|
||||
pCxt->sqlLen = stmtEnv_.sql_.length();
|
||||
pCxt->pMsg = stmtEnv_.msgBuf_.data();
|
||||
|
|
|
@ -44,12 +44,15 @@ static void setColumnInfo(SFunctionNode* pFunc, SColumnNode* pCol) {
|
|||
pCol->colType = COLUMN_TYPE_TBNAME;
|
||||
break;
|
||||
case FUNCTION_TYPE_WSTART:
|
||||
pCol->colId = PRIMARYKEY_TIMESTAMP_COL_ID;
|
||||
pCol->colType = COLUMN_TYPE_WINDOW_START;
|
||||
break;
|
||||
case FUNCTION_TYPE_WEND:
|
||||
pCol->colId = PRIMARYKEY_TIMESTAMP_COL_ID;
|
||||
pCol->colType = COLUMN_TYPE_WINDOW_PC;
|
||||
pCol->colType = COLUMN_TYPE_WINDOW_END;
|
||||
break;
|
||||
case FUNCTION_TYPE_WDURATION:
|
||||
pCol->colType = COLUMN_TYPE_WINDOW_PC;
|
||||
pCol->colType = COLUMN_TYPE_WINDOW_DURATION;
|
||||
break;
|
||||
case FUNCTION_TYPE_GROUP_KEY:
|
||||
pCol->colType = COLUMN_TYPE_GROUP_KEY;
|
||||
|
@ -784,7 +787,10 @@ static int32_t createWindowLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
|
|||
static EDealRes needFillValueImpl(SNode* pNode, void* pContext) {
|
||||
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
||||
SColumnNode* pCol = (SColumnNode*)pNode;
|
||||
if (COLUMN_TYPE_WINDOW_PC != pCol->colType && COLUMN_TYPE_GROUP_KEY != pCol->colType) {
|
||||
if (COLUMN_TYPE_WINDOW_START != pCol->colType &&
|
||||
COLUMN_TYPE_WINDOW_END != pCol->colType &&
|
||||
COLUMN_TYPE_WINDOW_DURATION != pCol->colType &&
|
||||
COLUMN_TYPE_GROUP_KEY != pCol->colType) {
|
||||
*(bool*)pContext = true;
|
||||
return DEAL_RES_END;
|
||||
}
|
||||
|
|
|
@ -576,6 +576,7 @@ static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan*
|
|||
|
||||
pScan->showRewrite = pScanLogicNode->showRewrite;
|
||||
pScan->accountId = pCxt->pPlanCxt->acctId;
|
||||
pScan->sysInfo = pCxt->pPlanCxt->sysInfo;
|
||||
if (0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_TABLES) ||
|
||||
0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_TABLE_DISTRIBUTED) ||
|
||||
0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_TAGS)) {
|
||||
|
|
|
@ -343,6 +343,7 @@ class PlannerTestBaseImpl {
|
|||
cxt.pMsg = stmtEnv_.msgBuf_.data();
|
||||
cxt.msgLen = stmtEnv_.msgBuf_.max_size();
|
||||
cxt.svrVer = "3.0.0.0";
|
||||
cxt.enableSysInfo = true;
|
||||
if (prepare) {
|
||||
SStmtCallback stmtCb = {0};
|
||||
cxt.pStmtCb = &stmtCb;
|
||||
|
|
|
@ -358,7 +358,7 @@ int32_t streamDispatchAllBlocks(SStreamTask* pTask, const SStreamDataBlock* pDat
|
|||
FAIL_SHUFFLE_DISPATCH:
|
||||
if (pReqs) {
|
||||
for (int32_t i = 0; i < vgSz; i++) {
|
||||
taosArrayDestroy(pReqs[i].data);
|
||||
taosArrayDestroyP(pReqs[i].data, taosMemoryFree);
|
||||
taosArrayDestroy(pReqs[i].dataLen);
|
||||
}
|
||||
taosMemoryFree(pReqs);
|
||||
|
|
|
@ -140,7 +140,6 @@ int32_t streamPipelineExec(SStreamTask* pTask, int32_t batchNum, bool dispatch)
|
|||
return 0;
|
||||
}
|
||||
|
||||
// TODO: handle version
|
||||
int32_t streamExecForAll(SStreamTask* pTask) {
|
||||
while (1) {
|
||||
int32_t batchCnt = 1;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
|
||||
#include "executor.h"
|
||||
#include "tstream.h"
|
||||
#include "streamInc.h"
|
||||
#include "ttimer.h"
|
||||
|
||||
SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandFunc) {
|
||||
|
@ -23,17 +23,23 @@ SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandF
|
|||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
pMeta->path = strdup(path);
|
||||
int32_t len = strlen(path) + 20;
|
||||
char* streamPath = taosMemoryCalloc(1, len);
|
||||
sprintf(streamPath, "%s/%s", path, "stream");
|
||||
pMeta->path = strdup(streamPath);
|
||||
if (tdbOpen(pMeta->path, 16 * 1024, 1, &pMeta->db) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
sprintf(streamPath, "%s/%s", pMeta->path, "checkpoints");
|
||||
mkdir(streamPath, 0755);
|
||||
taosMemoryFree(streamPath);
|
||||
|
||||
if (tdbTbOpen("task.db", sizeof(int32_t), -1, NULL, pMeta->db, &pMeta->pTaskDb) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
// open state storage backend
|
||||
if (tdbTbOpen("state.db", sizeof(int32_t), -1, NULL, pMeta->db, &pMeta->pStateDb) < 0) {
|
||||
if (tdbTbOpen("checkpoint.db", sizeof(int32_t), -1, NULL, pMeta->db, &pMeta->pCheckpointDb) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
@ -49,16 +55,13 @@ SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandF
|
|||
pMeta->ahandle = ahandle;
|
||||
pMeta->expandFunc = expandFunc;
|
||||
|
||||
if (streamLoadTasks(pMeta) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
return pMeta;
|
||||
|
||||
_err:
|
||||
if (pMeta->path) taosMemoryFree(pMeta->path);
|
||||
if (pMeta->pTasks) taosHashCleanup(pMeta->pTasks);
|
||||
if (pMeta->pStateDb) tdbTbClose(pMeta->pStateDb);
|
||||
if (pMeta->pTaskDb) tdbTbClose(pMeta->pTaskDb);
|
||||
if (pMeta->pCheckpointDb) tdbTbClose(pMeta->pCheckpointDb);
|
||||
if (pMeta->db) tdbClose(pMeta->db);
|
||||
taosMemoryFree(pMeta);
|
||||
return NULL;
|
||||
|
@ -67,7 +70,7 @@ _err:
|
|||
void streamMetaClose(SStreamMeta* pMeta) {
|
||||
tdbCommit(pMeta->db, &pMeta->txn);
|
||||
tdbTbClose(pMeta->pTaskDb);
|
||||
tdbTbClose(pMeta->pStateDb);
|
||||
tdbTbClose(pMeta->pCheckpointDb);
|
||||
tdbClose(pMeta->db);
|
||||
|
||||
void* pIter = NULL;
|
||||
|
|
|
@ -176,6 +176,7 @@ int32_t tDecodeSStreamTaskRecoverRsp(SDecoder* pDecoder, SStreamRecoverDownstrea
|
|||
}
|
||||
|
||||
int32_t streamSaveStateInfo(SStreamMeta* pMeta, SStreamTask* pTask) {
|
||||
#if 0
|
||||
void* buf = NULL;
|
||||
|
||||
ASSERT(pTask->taskLevel == TASK_LEVEL__SINK);
|
||||
|
@ -224,10 +225,12 @@ int32_t streamSaveStateInfo(SStreamMeta* pMeta, SStreamTask* pTask) {
|
|||
FAIL:
|
||||
if (buf) taosMemoryFree(buf);
|
||||
return -1;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t streamLoadStateInfo(SStreamMeta* pMeta, SStreamTask* pTask) {
|
||||
#if 0
|
||||
void* pVal = NULL;
|
||||
int32_t vLen = 0;
|
||||
if (tdbTbGet(pMeta->pStateDb, &pTask->taskId, sizeof(void*), &pVal, &vLen) < 0) {
|
||||
|
@ -241,7 +244,7 @@ int32_t streamLoadStateInfo(SStreamMeta* pMeta, SStreamTask* pTask) {
|
|||
|
||||
pTask->nextCheckId = aggCheckpoint.checkpointId + 1;
|
||||
pTask->checkpointInfo = aggCheckpoint.checkpointVer;
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,205 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "executor.h"
|
||||
#include "streamInc.h"
|
||||
#include "tcommon.h"
|
||||
#include "ttimer.h"
|
||||
|
||||
SStreamState* streamStateOpen(char* path, SStreamTask* pTask) {
|
||||
SStreamState* pState = taosMemoryCalloc(1, sizeof(SStreamState));
|
||||
if (pState == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
char statePath[300];
|
||||
sprintf(statePath, "%s/%d", path, pTask->taskId);
|
||||
if (tdbOpen(statePath, 4096, 256, &pState->db) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
// open state storage backend
|
||||
if (tdbTbOpen("state.db", sizeof(SWinKey), -1, SWinKeyCmpr, pState->db, &pState->pStateDb) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
if (streamStateBegin(pState) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
pState->pOwner = pTask;
|
||||
|
||||
return pState;
|
||||
|
||||
_err:
|
||||
if (pState->pStateDb) tdbTbClose(pState->pStateDb);
|
||||
if (pState->db) tdbClose(pState->db);
|
||||
taosMemoryFree(pState);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void streamStateClose(SStreamState* pState) {
|
||||
tdbCommit(pState->db, &pState->txn);
|
||||
tdbTbClose(pState->pStateDb);
|
||||
tdbClose(pState->db);
|
||||
|
||||
taosMemoryFree(pState);
|
||||
}
|
||||
|
||||
int32_t streamStateBegin(SStreamState* pState) {
|
||||
if (tdbTxnOpen(&pState->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) <
|
||||
0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tdbBegin(pState->db, &pState->txn) < 0) {
|
||||
tdbTxnClose(&pState->txn);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t streamStateCommit(SStreamState* pState) {
|
||||
if (tdbCommit(pState->db, &pState->txn) < 0) {
|
||||
return -1;
|
||||
}
|
||||
memset(&pState->txn, 0, sizeof(TXN));
|
||||
if (tdbTxnOpen(&pState->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) <
|
||||
0) {
|
||||
return -1;
|
||||
}
|
||||
if (tdbBegin(pState->db, &pState->txn) < 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t streamStateAbort(SStreamState* pState) {
|
||||
if (tdbAbort(pState->db, &pState->txn) < 0) {
|
||||
return -1;
|
||||
}
|
||||
memset(&pState->txn, 0, sizeof(TXN));
|
||||
if (tdbTxnOpen(&pState->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) <
|
||||
0) {
|
||||
return -1;
|
||||
}
|
||||
if (tdbBegin(pState->db, &pState->txn) < 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t streamStatePut(SStreamState* pState, const SWinKey* key, const void* value, int32_t vLen) {
|
||||
return tdbTbUpsert(pState->pStateDb, key, sizeof(SWinKey), value, vLen, &pState->txn);
|
||||
}
|
||||
int32_t streamStateGet(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen) {
|
||||
return tdbTbGet(pState->pStateDb, key, sizeof(SWinKey), pVal, pVLen);
|
||||
}
|
||||
|
||||
int32_t streamStateDel(SStreamState* pState, const SWinKey* key) {
|
||||
return tdbTbDelete(pState->pStateDb, key, sizeof(SWinKey), &pState->txn);
|
||||
}
|
||||
|
||||
SStreamStateCur* streamStateGetCur(SStreamState* pState, const SWinKey* key) {
|
||||
SStreamStateCur* pCur = taosMemoryCalloc(1, sizeof(SStreamStateCur));
|
||||
if (pCur == NULL) return NULL;
|
||||
tdbTbcOpen(pState->pStateDb, &pCur->pCur, NULL);
|
||||
|
||||
int32_t c;
|
||||
tdbTbcMoveTo(pCur->pCur, key, sizeof(SWinKey), &c);
|
||||
if (c != 0) {
|
||||
taosMemoryFree(pCur);
|
||||
return NULL;
|
||||
}
|
||||
return pCur;
|
||||
}
|
||||
|
||||
int32_t streamStateGetKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen) {
|
||||
const SWinKey* pKTmp = NULL;
|
||||
int32_t kLen;
|
||||
if (tdbTbcGet(pCur->pCur, (const void**)&pKTmp, &kLen, pVal, pVLen) < 0) {
|
||||
return -1;
|
||||
}
|
||||
*pKey = *pKTmp;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t streamStateSeekFirst(SStreamState* pState, SStreamStateCur* pCur) {
|
||||
//
|
||||
return tdbTbcMoveToFirst(pCur->pCur);
|
||||
}
|
||||
|
||||
int32_t streamStateSeekLast(SStreamState* pState, SStreamStateCur* pCur) {
|
||||
//
|
||||
return tdbTbcMoveToLast(pCur->pCur);
|
||||
}
|
||||
|
||||
SStreamStateCur* streamStateSeekKeyNext(SStreamState* pState, const SWinKey* key) {
|
||||
SStreamStateCur* pCur = taosMemoryCalloc(1, sizeof(SStreamStateCur));
|
||||
if (pCur == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t c;
|
||||
if (tdbTbcMoveTo(pCur->pCur, key, sizeof(SWinKey), &c) < 0) {
|
||||
taosMemoryFree(pCur);
|
||||
return NULL;
|
||||
}
|
||||
if (c > 0) return pCur;
|
||||
|
||||
if (tdbTbcMoveToNext(pCur->pCur) < 0) {
|
||||
taosMemoryFree(pCur);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pCur;
|
||||
}
|
||||
|
||||
SStreamStateCur* streamStateSeekKeyPrev(SStreamState* pState, const SWinKey* key) {
|
||||
SStreamStateCur* pCur = taosMemoryCalloc(1, sizeof(SStreamStateCur));
|
||||
if (pCur == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t c;
|
||||
if (tdbTbcMoveTo(pCur->pCur, key, sizeof(SWinKey), &c) < 0) {
|
||||
taosMemoryFree(pCur);
|
||||
return NULL;
|
||||
}
|
||||
if (c < 0) return pCur;
|
||||
|
||||
if (tdbTbcMoveToPrev(pCur->pCur) < 0) {
|
||||
taosMemoryFree(pCur);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pCur;
|
||||
}
|
||||
|
||||
int32_t streamStateCurNext(SStreamState* pState, SStreamStateCur* pCur) {
|
||||
//
|
||||
return tdbTbcMoveToNext(pCur->pCur);
|
||||
}
|
||||
|
||||
int32_t streamStateCurPrev(SStreamState* pState, SStreamStateCur* pCur) {
|
||||
//
|
||||
return tdbTbcMoveToPrev(pCur->pCur);
|
||||
}
|
||||
void streamStateFreeCur(SStreamStateCur* pCur) {
|
||||
tdbTbcClose(pCur->pCur);
|
||||
taosMemoryFree(pCur);
|
||||
}
|
||||
|
||||
void streamFreeVal(void* val) { tdbFree(val); }
|
|
@ -165,5 +165,8 @@ void tFreeSStreamTask(SStreamTask* pTask) {
|
|||
if (pTask->outputType == TASK_OUTPUT__SHUFFLE_DISPATCH) {
|
||||
taosArrayDestroy(pTask->shuffleDispatcher.dbInfo.pVgroupInfos);
|
||||
}
|
||||
|
||||
if (pTask->pState) streamStateClose(pTask->pState);
|
||||
|
||||
taosMemoryFree(pTask);
|
||||
}
|
||||
|
|
|
@ -1401,7 +1401,7 @@ static int tdbBtreeDecodeCell(SPage *pPage, const SCell *pCell, SCellDecoder *pD
|
|||
pDecoder->pgno = 0;
|
||||
TDB_CELLDECODER_SET_FREE_NIL(pDecoder);
|
||||
|
||||
tdbDebug("tdb btc decoder set nil: %p/0x%x ", pDecoder, pDecoder->freeKV);
|
||||
// tdbTrace("tdb btc decoder set nil: %p/0x%x ", pDecoder, pDecoder->freeKV);
|
||||
|
||||
// 1. Decode header part
|
||||
if (!leaf) {
|
||||
|
|
|
@ -145,7 +145,7 @@ static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, TXN *pTxn)
|
|||
// 1. Search the hash table
|
||||
pPage = pCache->pgHash[tdbPCachePageHash(pPgid) % pCache->nHash];
|
||||
while (pPage) {
|
||||
if (memcmp(pPage->pgid.fileid, pPgid->fileid, TDB_FILE_ID_LEN) == 0 && pPage->pgid.pgno == pPgid->pgno) break;
|
||||
if (pPage->pgid.pgno == pPgid->pgno && memcmp(pPage->pgid.fileid, pPgid->fileid, TDB_FILE_ID_LEN) == 0) break;
|
||||
pPage = pPage->pHashNext;
|
||||
}
|
||||
|
||||
|
@ -243,7 +243,7 @@ static void tdbPCachePinPage(SPCache *pCache, SPage *pPage) {
|
|||
pCache->nRecyclable--;
|
||||
|
||||
// printf("pin page %d pgno %d pPage %p\n", pPage->id, TDB_PAGE_PGNO(pPage), pPage);
|
||||
tdbTrace("pin page %d", pPage->id);
|
||||
tdbDebug("pin page %d", pPage->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,30 +264,33 @@ static void tdbPCacheUnpinPage(SPCache *pCache, SPage *pPage) {
|
|||
pCache->nRecyclable++;
|
||||
|
||||
// printf("unpin page %d pgno %d pPage %p\n", pPage->id, TDB_PAGE_PGNO(pPage), pPage);
|
||||
tdbTrace("unpin page %d", pPage->id);
|
||||
tdbDebug("unpin page %d", pPage->id);
|
||||
}
|
||||
|
||||
static void tdbPCacheRemovePageFromHash(SPCache *pCache, SPage *pPage) {
|
||||
SPage **ppPage;
|
||||
uint32_t h;
|
||||
|
||||
h = tdbPCachePageHash(&(pPage->pgid));
|
||||
for (ppPage = &(pCache->pgHash[h % pCache->nHash]); (*ppPage) && *ppPage != pPage; ppPage = &((*ppPage)->pHashNext))
|
||||
;
|
||||
uint32_t h = tdbPCachePageHash(&(pPage->pgid)) % pCache->nHash;
|
||||
|
||||
SPage **ppPage = &(pCache->pgHash[h]);
|
||||
if (*ppPage == pPage) {
|
||||
pCache->pgHash[h] = pPage->pHashNext;
|
||||
} else {
|
||||
for (; (*ppPage) && (*ppPage)->pHashNext != pPage; ppPage = &((*ppPage)->pHashNext))
|
||||
;
|
||||
if (*ppPage) {
|
||||
(*ppPage)->pHashNext = pPage->pHashNext;
|
||||
}
|
||||
}
|
||||
if (*ppPage) {
|
||||
*ppPage = pPage->pHashNext;
|
||||
pCache->nPage--;
|
||||
pPage->pHashNext = NULL;
|
||||
--pCache->nPage;
|
||||
// printf("rmv page %d to hash, pgno %d, pPage %p\n", pPage->id, TDB_PAGE_PGNO(pPage), pPage);
|
||||
}
|
||||
|
||||
tdbTrace("remove page %d to hash", pPage->id);
|
||||
tdbDebug("remove page %p/%d from hash", pPage, pPage->id);
|
||||
}
|
||||
|
||||
static void tdbPCacheAddPageToHash(SPCache *pCache, SPage *pPage) {
|
||||
int h;
|
||||
|
||||
h = tdbPCachePageHash(&(pPage->pgid)) % pCache->nHash;
|
||||
uint32_t h = tdbPCachePageHash(&(pPage->pgid)) % pCache->nHash;
|
||||
|
||||
pPage->pHashNext = pCache->pgHash[h];
|
||||
pCache->pgHash[h] = pPage;
|
||||
|
@ -295,7 +298,7 @@ static void tdbPCacheAddPageToHash(SPCache *pCache, SPage *pPage) {
|
|||
pCache->nPage++;
|
||||
|
||||
// printf("add page %d to hash, pgno %d, pPage %p\n", pPage->id, TDB_PAGE_PGNO(pPage), pPage);
|
||||
tdbTrace("add page %d to hash", pPage->id);
|
||||
tdbDebug("add page %p/%d to hash", pPage, pPage->id);
|
||||
}
|
||||
|
||||
static int tdbPCacheOpenImpl(SPCache *pCache) {
|
||||
|
|
|
@ -74,6 +74,7 @@ int tdbPageCreate(int pageSize, SPage **ppPage, void *(*xMalloc)(void *, size_t)
|
|||
int tdbPageDestroy(SPage *pPage, void (*xFree)(void *arg, void *ptr), void *arg) {
|
||||
u8 *ptr;
|
||||
|
||||
tdbDebug("page/destroy: %p %p", pPage, xFree);
|
||||
ASSERT(xFree);
|
||||
|
||||
for (int iOvfl = 0; iOvfl < pPage->nOverflow; iOvfl++) {
|
||||
|
@ -87,6 +88,7 @@ int tdbPageDestroy(SPage *pPage, void (*xFree)(void *arg, void *ptr), void *arg)
|
|||
}
|
||||
|
||||
void tdbPageZero(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell *, int, TXN *, SBTree *pBt)) {
|
||||
tdbDebug("page/zero: %p %" PRIu8 " %p", pPage, szAmHdr, xCellSize);
|
||||
pPage->pPageHdr = pPage->pData + szAmHdr;
|
||||
TDB_PAGE_NCELLS_SET(pPage, 0);
|
||||
TDB_PAGE_CCELLS_SET(pPage, pPage->pageSize - sizeof(SPageFtr));
|
||||
|
@ -103,6 +105,7 @@ void tdbPageZero(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell
|
|||
}
|
||||
|
||||
void tdbPageInit(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell *, int, TXN *, SBTree *pBt)) {
|
||||
tdbDebug("page/init: %p %" PRIu8 " %p", pPage, szAmHdr, xCellSize);
|
||||
pPage->pPageHdr = pPage->pData + szAmHdr;
|
||||
pPage->pCellIdx = pPage->pPageHdr + TDB_PAGE_HDR_SIZE(pPage);
|
||||
pPage->pFreeStart = pPage->pCellIdx + TDB_PAGE_OFFSET_SIZE(pPage) * TDB_PAGE_NCELLS(pPage);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
|
||||
#define HTTP_RECV_BUF_SIZE 1024
|
||||
|
||||
typedef struct SHttpClient {
|
||||
uv_connect_t conn;
|
||||
uv_tcp_t tcp;
|
||||
|
@ -143,9 +144,9 @@ static void clientAllocBuffCb(uv_handle_t *handle, size_t suggested_size, uv_buf
|
|||
static void clientRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t *buf) {
|
||||
SHttpClient* cli = handle->data;
|
||||
if (nread < 0) {
|
||||
uError("http-report read error:%s", uv_err_name(nread));
|
||||
uError("http-report recv error:%s", uv_err_name(nread));
|
||||
} else {
|
||||
uTrace("http-report succ to read %d bytes, just ignore it", nread);
|
||||
uTrace("http-report succ to recv %d bytes, just ignore it", nread);
|
||||
}
|
||||
uv_close((uv_handle_t*)&cli->tcp, clientCloseCb);
|
||||
}
|
||||
|
|
|
@ -276,14 +276,16 @@ void uvOnRecvCb(uv_stream_t* cli, ssize_t nread, const uv_buf_t* buf) {
|
|||
while (transReadComplete(pBuf)) {
|
||||
tTrace("%s conn %p alread read complete packet", transLabel(pTransInst), conn);
|
||||
if (true == pBuf->invalid || false == uvHandleReq(conn)) {
|
||||
tError("%s conn %p read invalid packet", transLabel(pTransInst), conn);
|
||||
tError("%s conn %p read invalid packet, received from %s, local info:%s", transLabel(pTransInst), conn,
|
||||
conn->dst, conn->src);
|
||||
destroyConn(conn, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
tError("%s conn %p read invalid packet, exceed limit", transLabel(pTransInst), conn);
|
||||
tError("%s conn %p read invalid packet, exceed limit, received from %s, local info:", transLabel(pTransInst),
|
||||
conn, conn->dst, conn->src);
|
||||
destroyConn(conn, true);
|
||||
return;
|
||||
}
|
||||
|
@ -649,7 +651,7 @@ void uvOnAcceptCb(uv_stream_t* stream, int status) {
|
|||
|
||||
pObj->workerIdx = (pObj->workerIdx + 1) % pObj->numOfThreads;
|
||||
|
||||
tTrace("new conntion accepted by main server, dispatch to %dth worker-thread", pObj->workerIdx);
|
||||
tTrace("new connection accepted by main server, dispatch to %dth worker-thread", pObj->workerIdx);
|
||||
|
||||
uv_write2(wr, (uv_stream_t*)&(pObj->pipe[pObj->workerIdx][0]), &buf, 1, (uv_stream_t*)cli, uvOnPipeWriteCb);
|
||||
} else {
|
||||
|
|
|
@ -121,7 +121,7 @@ static FORCE_INLINE int64_t walScanLogGetLastVer(SWal* pWal) {
|
|||
if (found == NULL) {
|
||||
// file corrupted, no complete log
|
||||
// TODO delete and search in previous files
|
||||
ASSERT(0);
|
||||
/*ASSERT(0);*/
|
||||
terrno = TSDB_CODE_WAL_FILE_CORRUPTED;
|
||||
return -1;
|
||||
}
|
||||
|
@ -221,7 +221,6 @@ int walCheckAndRepairMeta(SWal* pWal) {
|
|||
|
||||
int code = walSaveMeta(pWal);
|
||||
if (code < 0) {
|
||||
taosArrayDestroy(actualLog);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -203,10 +203,11 @@ int32_t taosRenameFile(const char *oldName, const char *newName) {
|
|||
}
|
||||
|
||||
int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime) {
|
||||
struct stat fileStat;
|
||||
#ifdef WINDOWS
|
||||
int32_t code = _stat(path, &fileStat);
|
||||
struct _stati64 fileStat;
|
||||
int32_t code = _stati64(path, &fileStat);
|
||||
#else
|
||||
struct stat fileStat;
|
||||
int32_t code = stat(path, &fileStat);
|
||||
#endif
|
||||
if (code < 0) {
|
||||
|
|
|
@ -851,13 +851,12 @@ char *taosGetCmdlineByPID(int pid) {
|
|||
}
|
||||
|
||||
void taosSetCoreDump(bool enable) {
|
||||
if (!enable) return;
|
||||
#ifdef WINDOWS
|
||||
// SetUnhandledExceptionFilter(exceptionHandler);
|
||||
// SetUnhandledExceptionFilter(&FlCrashDump);
|
||||
SetUnhandledExceptionFilter(exceptionHandler);
|
||||
SetUnhandledExceptionFilter(&FlCrashDump);
|
||||
#elif defined(_TD_DARWIN_64)
|
||||
#else
|
||||
if (!enable) return;
|
||||
|
||||
// 1. set ulimit -c unlimited
|
||||
struct rlimit rlim;
|
||||
struct rlimit rlim_new;
|
||||
|
|
|
@ -4,7 +4,7 @@ system sh/exec.sh -n dnode1 -s start
|
|||
sql connect
|
||||
|
||||
print =============== conflict stb
|
||||
sql create database db vgroups 1;
|
||||
sql create database db vgroups 4;
|
||||
sql use db;
|
||||
sql create table stb (ts timestamp, i int) tags (j int);
|
||||
sql_error create table stb using stb tags (1);
|
||||
|
@ -16,6 +16,9 @@ sql_error create table ctb (ts timestamp, i int) tags (j int);
|
|||
sql create table ntb (ts timestamp, i int);
|
||||
sql_error create table ntb (ts timestamp, i int) tags (j int);
|
||||
|
||||
sql drop table ntb
|
||||
sql create table ntb (ts timestamp, i int) tags (j int);
|
||||
|
||||
sql drop database db
|
||||
|
||||
print =============== create database d1
|
||||
|
|
|
@ -51,13 +51,13 @@ sql select * from information_schema.ins_tables where db_name = 'db'
|
|||
print =============== check show
|
||||
sql select * from information_schema.ins_users
|
||||
sql_error show cluster
|
||||
sql select * from information_schema.ins_dnodes
|
||||
sql select * from information_schema.ins_mnodes
|
||||
sql_error select * from information_schema.ins_dnodes
|
||||
sql_error select * from information_schema.ins_mnodes
|
||||
sql_error show snodes
|
||||
sql select * from information_schema.ins_qnodes
|
||||
sql_error select * from information_schema.ins_qnodes
|
||||
sql_error show bnodes
|
||||
sql_error show grants
|
||||
sql_error show dnode 1 variables;
|
||||
sql show variables;
|
||||
sql_error show variables;
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
Loading…
Reference in New Issue