Merge remote-tracking branch 'origin/feature/tq' into fix/TD-19204
This commit is contained in:
commit
95f3041c14
|
@ -2,7 +2,7 @@
|
|||
# taosadapter
|
||||
ExternalProject_Add(taosadapter
|
||||
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
|
||||
GIT_TAG 05fb2ff
|
||||
GIT_TAG be729ab
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
{{#include docs/examples/csharp/connect/Program.cs}}
|
||||
```
|
||||
|
||||
:::info
|
||||
C# connector supports only native connection for now.
|
||||
|
||||
:::
|
||||
```csharp title="WebSocket Connection"
|
||||
{{#include docs/examples/csharp/wsConnect/Program.cs}}
|
||||
```
|
||||
|
|
|
@ -116,7 +116,7 @@ The parameters are described as follows:
|
|||
- **protocol**: Specify which connection method to use. For example, `taos+ws://localhost:6041` uses Websocket to establish connections.
|
||||
- **username/password**: Username and password used to create connections.
|
||||
- **host/port**: Specifies the server and port to establish a connection. If you do not specify a hostname or port, native connections default to `localhost:6030` and Websocket connections default to `localhost:6041`.
|
||||
- **database**: Specify the default database to connect to.
|
||||
- **database**: Specify the default database to connect to. It's optional.
|
||||
- **params**:Optional parameters.
|
||||
|
||||
A sample DSN description string is as follows:
|
||||
|
|
|
@ -17,7 +17,7 @@ import CSAsyncQuery from "../../07-develop/04-query-data/_cs_async.mdx"
|
|||
|
||||
`TDengine.Connector` is a C# language connector provided by TDengine that allows C# developers to develop C# applications that access TDengine cluster data.
|
||||
|
||||
The `TDengine.Connector` connector supports connect to TDengine instances via the TDengine client driver (taosc), providing data writing, querying, subscription, schemaless writing, bind interface, etc. The `TDengine.Connector` currently does not provide a REST connection interface. Developers can write their RESTful application by referring to the [REST API](/reference/rest-api/) documentation.
|
||||
The `TDengine.Connector` connector supports connect to TDengine instances via the TDengine client driver (taosc), providing data writing, querying, subscription, schemaless writing, bind interface, etc.The `TDengine.Connector` also supports WebSocket and developers can build connection through DSN, which supports data writing, querying, and parameter binding, etc.
|
||||
|
||||
This article describes how to install `TDengine.Connector` in a Linux or Windows environment and connect to TDengine clusters via `TDengine.Connector` to perform basic operations such as data writing and querying.
|
||||
|
||||
|
@ -35,6 +35,10 @@ Please refer to [version support list](/reference/connector#version-support)
|
|||
|
||||
## Supported features
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
|
||||
<TabItem value="native" label="Native Connection">
|
||||
|
||||
1. Connection Management
|
||||
2. General Query
|
||||
3. Continuous Query
|
||||
|
@ -42,6 +46,18 @@ Please refer to [version support list](/reference/connector#version-support)
|
|||
5. Subscription
|
||||
6. Schemaless
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="rest" label="WebSocket Connection">
|
||||
|
||||
1. Connection Management
|
||||
2. General Query
|
||||
3. Continuous Query
|
||||
4. Parameter Binding
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Installation Steps
|
||||
|
||||
### Pre-installation preparation
|
||||
|
@ -74,11 +90,17 @@ cp -r src/ myProject
|
|||
cd myProject
|
||||
dotnet add exmaple.csproj reference src/TDengine.csproj
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Establish a Connection
|
||||
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
|
||||
<TabItem value="native" label="Native Connection">
|
||||
|
||||
``` csharp
|
||||
using TDengineDriver;
|
||||
|
||||
|
@ -112,14 +134,62 @@ namespace TDengineExample
|
|||
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="rest" label="WebSocket Connection">
|
||||
|
||||
The structure of the DSN description string is as follows:
|
||||
|
||||
```text
|
||||
[<protocol>]://[[<username>:<password>@]<host>:<port>][/<database>][?<p1>=<v1>[&<p2>=<v2>]]
|
||||
|------------|---|-----------|-----------|------|------|------------|-----------------------|
|
||||
| protocol | | username | password | host | port | database | params |
|
||||
```
|
||||
|
||||
The parameters are described as follows:
|
||||
|
||||
* **protocol**: Specify which connection method to use (support http/ws). For example, `ws://localhost:6041` uses Websocket to establish connections.
|
||||
* **username/password**: Username and password used to create connections.
|
||||
* **host/port**: Specifies the server and port to establish a connection. Websocket connections default to `localhost:6041`.
|
||||
* **database**: Specify the default database to connect to. It's optional.
|
||||
* **params**:Optional parameters.
|
||||
|
||||
A sample DSN description string is as follows:
|
||||
|
||||
```text
|
||||
ws://localhost:6041/test
|
||||
```
|
||||
|
||||
``` csharp
|
||||
{{#include docs/examples/csharp/wsConnect/Program.cs}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Usage examples
|
||||
|
||||
### Write data
|
||||
|
||||
#### SQL Write
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
|
||||
<TabItem value="native" label="Native Connection">
|
||||
|
||||
<CSInsert />
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="rest" label="WebSocket Connection">
|
||||
|
||||
```csharp
|
||||
{{#include docs/examples/csharp/wsInsert/Program.cs}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
#### InfluxDB line protocol write
|
||||
|
||||
<CSInfluxLine />
|
||||
|
@ -132,12 +202,48 @@ namespace TDengineExample
|
|||
|
||||
<CSOpenTSDBJson />
|
||||
|
||||
#### Parameter Binding
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
|
||||
<TabItem value="native" label="Native Connection">
|
||||
|
||||
``` csharp
|
||||
{{#include docs/examples/csharp/stmtInsert/Program.cs}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="rest" label="WebSocket Connection">
|
||||
|
||||
```csharp
|
||||
{{#include docs/examples/csharp/wsStmt/Program.cs}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Query data
|
||||
|
||||
#### Synchronous Query
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
|
||||
<TabItem value="native" label="Native Connection">
|
||||
|
||||
<CSQuery />
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="rest" label="WebSocket Connection">
|
||||
|
||||
```csharp
|
||||
{{#include docs/examples/csharp/wsQuery/Program.cs}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
#### Asynchronous query
|
||||
|
||||
<CSAsyncQuery />
|
||||
|
@ -145,18 +251,21 @@ namespace TDengineExample
|
|||
### More sample programs
|
||||
|
||||
|Sample program |Sample program description |
|
||||
|--------------------------------------------------------------------------------------------------------------------|------------ --------------------------------|
|
||||
|--------------------------------------------------------------------------------------------------------------------|--------------------------------------------|
|
||||
| [CURD](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/Query/Query.cs) | Table creation, data insertion, and query examples with TDengine.Connector |
|
||||
| [JSON Tag](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/JSONTag) | Writing and querying JSON tag data with TDengine Connector |
|
||||
| [stmt](https://github.com/taosdata/taos-connector-dotnet/tree/3.0/examples/Stmt) | Parameter binding with TDengine Connector |
|
||||
| [schemaless](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/schemaless) | Schemaless writes with TDengine Connector |
|
||||
| [async query](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/AsyncQuery/QueryAsync.cs) | Asynchronous queries with TDengine Connector |
|
||||
| [TMQ](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/TMQ/TMQ.cs) | Data subscription with TDengine Connector |
|
||||
| [Subscription](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/TMQ/TMQ.cs) | Subscription example with TDengine Connector |
|
||||
| [Basic WebSocket Usage](https://github.com/taosdata/taos-connector-dotnet/blob/5a4a7cd0dbcda114447cdc6d0c6dedd8e84a52da/examples/WS/WebSocketSample.cs) | WebSocket basic data in and out with TDengine connector |
|
||||
| [WebSocket Parameter Binding](https://github.com/taosdata/taos-connector-dotnet/blob/5a4a7cd0dbcda114447cdc6d0c6dedd8e84a52da/examples/WS/WebSocketSTMT.cs) | WebSocket parameter binding example |
|
||||
|
||||
## Important update records
|
||||
|
||||
| TDengine.Connector | Description |
|
||||
|--------------------|--------------------------------|
|
||||
| 3.0.1 | Support WebSocket and Cloud,With function query, insert, and parameter binding|
|
||||
| 3.0.0 | Supports TDengine 3.0.0.0. TDengine 2.x is not supported. Added `TDengine.Impl.GetData()` interface to deserialize query results. |
|
||||
| 1.0.7 | Fixed TDengine.Query() memory leak. |
|
||||
| 1.0.6 | Fix schemaless bug in 1.0.4 and 1.0.5. |
|
||||
|
|
|
@ -164,7 +164,7 @@ The parameters described in this document by the effect that they have on the sy
|
|||
| Attribute | Description |
|
||||
| -------- | -------------------- |
|
||||
| Applicable | Client only |
|
||||
| 含义 | SMA index optimization policy |
|
||||
| Meaning | SMA index optimization policy |
|
||||
| Unit | None |
|
||||
| Default Value | 0 |
|
||||
| Notes |
|
||||
|
@ -325,7 +325,7 @@ The charset that takes effect is UTF-8.
|
|||
| Applicable | Server Only |
|
||||
| Meaning | Maximum number of vnodes per dnode |
|
||||
| Value Range | 0-4096 |
|
||||
| Default Value | 256 |
|
||||
| Default Value | 2x the CPU cores |
|
||||
|
||||
## Time Parameters
|
||||
|
||||
|
@ -697,152 +697,154 @@ To prevent system resource from being exhausted by multiple concurrent streams,
|
|||
| 15 | telemetryPort | No | Yes |
|
||||
| 16 | queryPolicy | No | Yes |
|
||||
| 17 | querySmaOptimize | No | Yes |
|
||||
| 18 | queryBufferSize | Yes | Yes |
|
||||
| 19 | maxNumOfDistinctRes | Yes | Yes |
|
||||
| 20 | minSlidingTime | Yes | Yes |
|
||||
| 21 | minIntervalTime | Yes | Yes |
|
||||
| 22 | countAlwaysReturnValue | Yes | Yes |
|
||||
| 23 | dataDir | Yes | Yes |
|
||||
| 24 | minimalDataDirGB | Yes | Yes |
|
||||
| 25 | supportVnodes | No | Yes |
|
||||
| 26 | tempDir | Yes | Yes |
|
||||
| 27 | minimalTmpDirGB | Yes | Yes |
|
||||
| 28 | compressMsgSize | Yes | Yes |
|
||||
| 29 | compressColData | Yes | Yes |
|
||||
| 30 | smlChildTableName | Yes | Yes |
|
||||
| 31 | smlTagName | Yes | Yes |
|
||||
| 32 | smlDataFormat | No | Yes |
|
||||
| 33 | statusInterval | Yes | Yes |
|
||||
| 34 | shellActivityTimer | Yes | Yes |
|
||||
| 35 | transPullupInterval | No | Yes |
|
||||
| 36 | mqRebalanceInterval | No | Yes |
|
||||
| 37 | ttlUnit | No | Yes |
|
||||
| 38 | ttlPushInterval | No | Yes |
|
||||
| 39 | numOfTaskQueueThreads | No | Yes |
|
||||
| 40 | numOfRpcThreads | No | Yes |
|
||||
| 41 | numOfCommitThreads | Yes | Yes |
|
||||
| 42 | numOfMnodeReadThreads | No | Yes |
|
||||
| 43 | numOfVnodeQueryThreads | No | Yes |
|
||||
| 44 | numOfVnodeStreamThreads | No | Yes |
|
||||
| 45 | numOfVnodeFetchThreads | No | Yes |
|
||||
| 46 | numOfVnodeWriteThreads | No | Yes |
|
||||
| 47 | numOfVnodeSyncThreads | No | Yes |
|
||||
| 48 | numOfQnodeQueryThreads | No | Yes |
|
||||
| 49 | numOfQnodeFetchThreads | No | Yes |
|
||||
| 50 | numOfSnodeSharedThreads | No | Yes |
|
||||
| 51 | numOfSnodeUniqueThreads | No | Yes |
|
||||
| 52 | rpcQueueMemoryAllowed | No | Yes |
|
||||
| 53 | logDir | Yes | Yes |
|
||||
| 54 | minimalLogDirGB | Yes | Yes |
|
||||
| 55 | numOfLogLines | Yes | Yes |
|
||||
| 56 | asyncLog | Yes | Yes |
|
||||
| 57 | logKeepDays | Yes | Yes |
|
||||
| 58 | debugFlag | Yes | Yes |
|
||||
| 59 | tmrDebugFlag | Yes | Yes |
|
||||
| 60 | uDebugFlag | Yes | Yes |
|
||||
| 61 | rpcDebugFlag | Yes | Yes |
|
||||
| 62 | jniDebugFlag | Yes | Yes |
|
||||
| 63 | qDebugFlag | Yes | Yes |
|
||||
| 64 | cDebugFlag | Yes | Yes |
|
||||
| 65 | dDebugFlag | Yes | Yes |
|
||||
| 66 | vDebugFlag | Yes | Yes |
|
||||
| 67 | mDebugFlag | Yes | Yes |
|
||||
| 68 | wDebugFlag | Yes | Yes |
|
||||
| 69 | sDebugFlag | Yes | Yes |
|
||||
| 70 | tsdbDebugFlag | Yes | Yes |
|
||||
| 71 | tqDebugFlag | No | Yes |
|
||||
| 72 | fsDebugFlag | Yes | Yes |
|
||||
| 73 | udfDebugFlag | No | Yes |
|
||||
| 74 | smaDebugFlag | No | Yes |
|
||||
| 75 | idxDebugFlag | No | Yes |
|
||||
| 76 | tdbDebugFlag | No | Yes |
|
||||
| 77 | metaDebugFlag | No | Yes |
|
||||
| 78 | timezone | Yes | Yes |
|
||||
| 79 | locale | Yes | Yes |
|
||||
| 80 | charset | Yes | Yes |
|
||||
| 81 | udf | Yes | Yes |
|
||||
| 82 | enableCoreFile | Yes | Yes |
|
||||
| 83 | arbitrator | Yes | No |
|
||||
| 84 | numOfThreadsPerCore | Yes | No |
|
||||
| 85 | numOfMnodes | Yes | No |
|
||||
| 86 | vnodeBak | Yes | No |
|
||||
| 87 | balance | Yes | No |
|
||||
| 88 | balanceInterval | Yes | No |
|
||||
| 89 | offlineThreshold | Yes | No |
|
||||
| 90 | role | Yes | No |
|
||||
| 91 | dnodeNopLoop | Yes | No |
|
||||
| 92 | keepTimeOffset | Yes | No |
|
||||
| 93 | rpcTimer | Yes | No |
|
||||
| 94 | rpcMaxTime | Yes | No |
|
||||
| 95 | rpcForceTcp | Yes | No |
|
||||
| 96 | tcpConnTimeout | Yes | No |
|
||||
| 97 | syncCheckInterval | Yes | No |
|
||||
| 98 | maxTmrCtrl | Yes | No |
|
||||
| 99 | monitorReplica | Yes | No |
|
||||
| 100 | smlTagNullName | Yes | No |
|
||||
| 101 | keepColumnName | Yes | No |
|
||||
| 102 | ratioOfQueryCores | Yes | No |
|
||||
| 103 | maxStreamCompDelay | Yes | No |
|
||||
| 104 | maxFirstStreamCompDelay | Yes | No |
|
||||
| 105 | retryStreamCompDelay | Yes | No |
|
||||
| 106 | streamCompDelayRatio | Yes | No |
|
||||
| 107 | maxVgroupsPerDb | Yes | No |
|
||||
| 108 | maxTablesPerVnode | Yes | No |
|
||||
| 109 | minTablesPerVnode | Yes | No |
|
||||
| 110 | tableIncStepPerVnode | Yes | No |
|
||||
| 111 | cache | Yes | No |
|
||||
| 112 | blocks | Yes | No |
|
||||
| 113 | days | Yes | No |
|
||||
| 114 | keep | Yes | No |
|
||||
| 115 | minRows | Yes | No |
|
||||
| 116 | maxRows | Yes | No |
|
||||
| 117 | quorum | Yes | No |
|
||||
| 118 | comp | Yes | No |
|
||||
| 119 | walLevel | Yes | No |
|
||||
| 120 | fsync | Yes | No |
|
||||
| 121 | replica | Yes | No |
|
||||
| 122 | partitions | Yes | No |
|
||||
| 123 | quorum | Yes | No |
|
||||
| 124 | update | Yes | No |
|
||||
| 125 | cachelast | Yes | No |
|
||||
| 126 | maxSQLLength | Yes | No |
|
||||
| 127 | maxWildCardsLength | Yes | No |
|
||||
| 128 | maxRegexStringLen | Yes | No |
|
||||
| 129 | maxNumOfOrderedRes | Yes | No |
|
||||
| 130 | maxConnections | Yes | No |
|
||||
| 131 | mnodeEqualVnodeNum | Yes | No |
|
||||
| 132 | http | Yes | No |
|
||||
| 133 | httpEnableRecordSql | Yes | No |
|
||||
| 134 | httpMaxThreads | Yes | No |
|
||||
| 135 | restfulRowLimit | Yes | No |
|
||||
| 136 | httpDbNameMandatory | Yes | No |
|
||||
| 137 | httpKeepAlive | Yes | No |
|
||||
| 138 | enableRecordSql | Yes | No |
|
||||
| 139 | maxBinaryDisplayWidth | Yes | No |
|
||||
| 140 | stream | Yes | No |
|
||||
| 141 | retrieveBlockingModel | Yes | No |
|
||||
| 142 | tsdbMetaCompactRatio | Yes | No |
|
||||
| 143 | defaultJSONStrType | Yes | No |
|
||||
| 144 | walFlushSize | Yes | No |
|
||||
| 145 | keepTimeOffset | Yes | No |
|
||||
| 146 | flowctrl | Yes | No |
|
||||
| 147 | slaveQuery | Yes | No |
|
||||
| 148 | adjustMaster | Yes | No |
|
||||
| 149 | topicBinaryLen | Yes | No |
|
||||
| 150 | telegrafUseFieldNum | Yes | No |
|
||||
| 151 | deadLockKillQuery | Yes | No |
|
||||
| 152 | clientMerge | Yes | No |
|
||||
| 153 | sdbDebugFlag | Yes | No |
|
||||
| 154 | odbcDebugFlag | Yes | No |
|
||||
| 155 | httpDebugFlag | Yes | No |
|
||||
| 156 | monDebugFlag | Yes | No |
|
||||
| 157 | cqDebugFlag | Yes | No |
|
||||
| 158 | shortcutFlag | Yes | No |
|
||||
| 159 | probeSeconds | Yes | No |
|
||||
| 160 | probeKillSeconds | Yes | No |
|
||||
| 161 | probeInterval | Yes | No |
|
||||
| 162 | lossyColumns | Yes | No |
|
||||
| 163 | fPrecision | Yes | No |
|
||||
| 164 | dPrecision | Yes | No |
|
||||
| 165 | maxRange | Yes | No |
|
||||
| 166 | range | Yes | No |
|
||||
| 18 | queryRsmaTolerance | No | Yes |
|
||||
| 19 | queryBufferSize | Yes | Yes |
|
||||
| 20 | maxNumOfDistinctRes | Yes | Yes |
|
||||
| 21 | minSlidingTime | Yes | Yes |
|
||||
| 22 | minIntervalTime | Yes | Yes |
|
||||
| 23 | countAlwaysReturnValue | Yes | Yes |
|
||||
| 24 | dataDir | Yes | Yes |
|
||||
| 25 | minimalDataDirGB | Yes | Yes |
|
||||
| 26 | supportVnodes | No | Yes |
|
||||
| 27 | tempDir | Yes | Yes |
|
||||
| 28 | minimalTmpDirGB | Yes | Yes |
|
||||
| 29 | compressMsgSize | Yes | Yes |
|
||||
| 30 | compressColData | Yes | Yes |
|
||||
| 31 | smlChildTableName | Yes | Yes |
|
||||
| 32 | smlTagName | Yes | Yes |
|
||||
| 33 | smlDataFormat | No | Yes |
|
||||
| 34 | statusInterval | Yes | Yes |
|
||||
| 35 | shellActivityTimer | Yes | Yes |
|
||||
| 36 | transPullupInterval | No | Yes |
|
||||
| 37 | mqRebalanceInterval | No | Yes |
|
||||
| 38 | ttlUnit | No | Yes |
|
||||
| 39 | ttlPushInterval | No | Yes |
|
||||
| 40 | numOfTaskQueueThreads | No | Yes |
|
||||
| 41 | numOfRpcThreads | No | Yes |
|
||||
| 42 | numOfCommitThreads | Yes | Yes |
|
||||
| 43 | numOfMnodeReadThreads | No | Yes |
|
||||
| 44 | numOfVnodeQueryThreads | No | Yes |
|
||||
| 45 | numOfVnodeStreamThreads | No | Yes |
|
||||
| 46 | numOfVnodeFetchThreads | No | Yes |
|
||||
| 47 | numOfVnodeWriteThreads | No | Yes |
|
||||
| 48 | numOfVnodeSyncThreads | No | Yes |
|
||||
| 49 | numOfVnodeRsmaThreads | No | Yes |
|
||||
| 50 | numOfQnodeQueryThreads | No | Yes |
|
||||
| 51 | numOfQnodeFetchThreads | No | Yes |
|
||||
| 52 | numOfSnodeSharedThreads | No | Yes |
|
||||
| 53 | numOfSnodeUniqueThreads | No | Yes |
|
||||
| 54 | rpcQueueMemoryAllowed | No | Yes |
|
||||
| 55 | logDir | Yes | Yes |
|
||||
| 56 | minimalLogDirGB | Yes | Yes |
|
||||
| 57 | numOfLogLines | Yes | Yes |
|
||||
| 58 | asyncLog | Yes | Yes |
|
||||
| 59 | logKeepDays | Yes | Yes |
|
||||
| 60 | debugFlag | Yes | Yes |
|
||||
| 61 | tmrDebugFlag | Yes | Yes |
|
||||
| 62 | uDebugFlag | Yes | Yes |
|
||||
| 63 | rpcDebugFlag | Yes | Yes |
|
||||
| 64 | jniDebugFlag | Yes | Yes |
|
||||
| 65 | qDebugFlag | Yes | Yes |
|
||||
| 66 | cDebugFlag | Yes | Yes |
|
||||
| 67 | dDebugFlag | Yes | Yes |
|
||||
| 68 | vDebugFlag | Yes | Yes |
|
||||
| 69 | mDebugFlag | Yes | Yes |
|
||||
| 70 | wDebugFlag | Yes | Yes |
|
||||
| 71 | sDebugFlag | Yes | Yes |
|
||||
| 72 | tsdbDebugFlag | Yes | Yes |
|
||||
| 73 | tqDebugFlag | No | Yes |
|
||||
| 74 | fsDebugFlag | Yes | Yes |
|
||||
| 75 | udfDebugFlag | No | Yes |
|
||||
| 76 | smaDebugFlag | No | Yes |
|
||||
| 77 | idxDebugFlag | No | Yes |
|
||||
| 78 | tdbDebugFlag | No | Yes |
|
||||
| 79 | metaDebugFlag | No | Yes |
|
||||
| 80 | timezone | Yes | Yes |
|
||||
| 81 | locale | Yes | Yes |
|
||||
| 82 | charset | Yes | Yes |
|
||||
| 83 | udf | Yes | Yes |
|
||||
| 84 | enableCoreFile | Yes | Yes |
|
||||
| 85 | arbitrator | Yes | No |
|
||||
| 86 | numOfThreadsPerCore | Yes | No |
|
||||
| 87 | numOfMnodes | Yes | No |
|
||||
| 88 | vnodeBak | Yes | No |
|
||||
| 89 | balance | Yes | No |
|
||||
| 90 | balanceInterval | Yes | No |
|
||||
| 91 | offlineThreshold | Yes | No |
|
||||
| 92 | role | Yes | No |
|
||||
| 93 | dnodeNopLoop | Yes | No |
|
||||
| 94 | keepTimeOffset | Yes | No |
|
||||
| 95 | rpcTimer | Yes | No |
|
||||
| 96 | rpcMaxTime | Yes | No |
|
||||
| 97 | rpcForceTcp | Yes | No |
|
||||
| 98 | tcpConnTimeout | Yes | No |
|
||||
| 99 | syncCheckInterval | Yes | No |
|
||||
| 100 | maxTmrCtrl | Yes | No |
|
||||
| 101 | monitorReplica | Yes | No |
|
||||
| 102 | smlTagNullName | Yes | No |
|
||||
| 103 | keepColumnName | Yes | No |
|
||||
| 104 | ratioOfQueryCores | Yes | No |
|
||||
| 105 | maxStreamCompDelay | Yes | No |
|
||||
| 106 | maxFirstStreamCompDelay | Yes | No |
|
||||
| 107 | retryStreamCompDelay | Yes | No |
|
||||
| 108 | streamCompDelayRatio | Yes | No |
|
||||
| 109 | maxVgroupsPerDb | Yes | No |
|
||||
| 110 | maxTablesPerVnode | Yes | No |
|
||||
| 111 | minTablesPerVnode | Yes | No |
|
||||
| 112 | tableIncStepPerVnode | Yes | No |
|
||||
| 113 | cache | Yes | No |
|
||||
| 114 | blocks | Yes | No |
|
||||
| 115 | days | Yes | No |
|
||||
| 116 | keep | Yes | No |
|
||||
| 117 | minRows | Yes | No |
|
||||
| 118 | maxRows | Yes | No |
|
||||
| 119 | quorum | Yes | No |
|
||||
| 120 | comp | Yes | No |
|
||||
| 121 | walLevel | Yes | No |
|
||||
| 122 | fsync | Yes | No |
|
||||
| 123 | replica | Yes | No |
|
||||
| 124 | partitions | Yes | No |
|
||||
| 125 | quorum | Yes | No |
|
||||
| 126 | update | Yes | No |
|
||||
| 127 | cachelast | Yes | No |
|
||||
| 128 | maxSQLLength | Yes | No |
|
||||
| 129 | maxWildCardsLength | Yes | No |
|
||||
| 130 | maxRegexStringLen | Yes | No |
|
||||
| 131 | maxNumOfOrderedRes | Yes | No |
|
||||
| 132 | maxConnections | Yes | No |
|
||||
| 133 | mnodeEqualVnodeNum | Yes | No |
|
||||
| 134 | http | Yes | No |
|
||||
| 135 | httpEnableRecordSql | Yes | No |
|
||||
| 136 | httpMaxThreads | Yes | No |
|
||||
| 137 | restfulRowLimit | Yes | No |
|
||||
| 138 | httpDbNameMandatory | Yes | No |
|
||||
| 139 | httpKeepAlive | Yes | No |
|
||||
| 140 | enableRecordSql | Yes | No |
|
||||
| 141 | maxBinaryDisplayWidth | Yes | No |
|
||||
| 142 | stream | Yes | No |
|
||||
| 143 | retrieveBlockingModel | Yes | No |
|
||||
| 144 | tsdbMetaCompactRatio | Yes | No |
|
||||
| 145 | defaultJSONStrType | Yes | No |
|
||||
| 146 | walFlushSize | Yes | No |
|
||||
| 147 | keepTimeOffset | Yes | No |
|
||||
| 148 | flowctrl | Yes | No |
|
||||
| 149 | slaveQuery | Yes | No |
|
||||
| 150 | adjustMaster | Yes | No |
|
||||
| 151 | topicBinaryLen | Yes | No |
|
||||
| 152 | telegrafUseFieldNum | Yes | No |
|
||||
| 153 | deadLockKillQuery | Yes | No |
|
||||
| 154 | clientMerge | Yes | No |
|
||||
| 155 | sdbDebugFlag | Yes | No |
|
||||
| 156 | odbcDebugFlag | Yes | No |
|
||||
| 157 | httpDebugFlag | Yes | No |
|
||||
| 158 | monDebugFlag | Yes | No |
|
||||
| 159 | cqDebugFlag | Yes | No |
|
||||
| 160 | shortcutFlag | Yes | No |
|
||||
| 161 | probeSeconds | Yes | No |
|
||||
| 162 | probeKillSeconds | Yes | No |
|
||||
| 163 | probeInterval | Yes | No |
|
||||
| 164 | lossyColumns | Yes | No |
|
||||
| 165 | fPrecision | Yes | No |
|
||||
| 166 | dPrecision | Yes | No |
|
||||
| 167 | maxRange | Yes | No |
|
||||
| 168 | range | Yes | No |
|
||||
|
|
|
@ -116,7 +116,7 @@ DSN 描述字符串基本结构如下:
|
|||
- **protocol**: 显示指定以何种方式建立连接,例如:`taos+ws://localhost:6041` 指定以 Websocket 方式建立连接。
|
||||
- **username/password**: 用于创建连接的用户名及密码。
|
||||
- **host/port**: 指定创建连接的服务器及端口,当不指定服务器地址及端口时(`taos://`),原生连接默认为 `localhost:6030`,Websocket 连接默认为 `localhost:6041` 。
|
||||
- **database**: 指定默认连接的数据库名。
|
||||
- **database**: 指定默认连接的数据库名,可选参数。
|
||||
- **params**:其他可选参数。
|
||||
|
||||
一个完整的 DSN 描述字符串示例如下:
|
||||
|
|
|
@ -154,7 +154,7 @@ namespace TDengineExample
|
|||
|
||||
* **host/port**: 指定创建连接的服务器及端口,WebSocket 连接默认为 `localhost:6041` 。
|
||||
|
||||
* **database**: 指定默认连接的数据库名。
|
||||
* **database**: 指定默认连接的数据库名,可选参数。
|
||||
|
||||
* **params**:其他可选参数。
|
||||
|
||||
|
|
|
@ -325,7 +325,7 @@ charset 的有效值是 UTF-8。
|
|||
| 适用范围 | 仅服务端适用 |
|
||||
| 含义 | dnode 支持的最大 vnode 数目 |
|
||||
| 取值范围 | 0-4096 |
|
||||
| 缺省值 | 256 |
|
||||
| 缺省值 | CPU 核数的 2 倍 |
|
||||
|
||||
## 时间相关
|
||||
|
||||
|
@ -668,153 +668,154 @@ charset 的有效值是 UTF-8。
|
|||
| 15 | telemetryPort | 否 | 是 |
|
||||
| 16 | queryPolicy | 否 | 是 |
|
||||
| 17 | querySmaOptimize | 否 | 是 |
|
||||
| 18 | queryBufferSize | 是 | 是 |
|
||||
| 19 | maxNumOfDistinctRes | 是 | 是 |
|
||||
| 20 | minSlidingTime | 是 | 是 |
|
||||
| 21 | minIntervalTime | 是 | 是 |
|
||||
| 22 | countAlwaysReturnValue | 是 | 是 |
|
||||
| 23 | dataDir | 是 | 是 |
|
||||
| 24 | minimalDataDirGB | 是 | 是 |
|
||||
| 25 | supportVnodes | 否 | 是 |
|
||||
| 26 | tempDir | 是 | 是 |
|
||||
| 27 | minimalTmpDirGB | 是 | 是 |
|
||||
| 28 | compressMsgSize | 是 | 是 |
|
||||
| 29 | compressColData | 是 | 是 |
|
||||
| 30 | smlChildTableName | 是 | 是 |
|
||||
| 31 | smlTagName | 是 | 是 |
|
||||
| 32 | smlDataFormat | 否 | 是 |
|
||||
| 33 | statusInterval | 是 | 是 |
|
||||
| 34 | shellActivityTimer | 是 | 是 |
|
||||
| 35 | transPullupInterval | 否 | 是 |
|
||||
| 36 | mqRebalanceInterval | 否 | 是 |
|
||||
| 37 | ttlUnit | 否 | 是 |
|
||||
| 38 | ttlPushInterval | 否 | 是 |
|
||||
| 39 | numOfTaskQueueThreads | 否 | 是 |
|
||||
| 40 | numOfRpcThreads | 否 | 是 |
|
||||
| 41 | numOfCommitThreads | 是 | 是 |
|
||||
| 42 | numOfMnodeReadThreads | 否 | 是 |
|
||||
| 43 | numOfVnodeQueryThreads | 否 | 是 |
|
||||
| 44 | numOfVnodeStreamThreads | 否 | 是 |
|
||||
| 45 | numOfVnodeFetchThreads | 否 | 是 |
|
||||
| 46 | numOfVnodeWriteThreads | 否 | 是 |
|
||||
| 47 | numOfVnodeSyncThreads | 否 | 是 |
|
||||
| 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 | 是 | 否 |
|
||||
| 18 | queryRsmaTolerance | 否 | 是 |
|
||||
| 19 | queryBufferSize | 是 | 是 |
|
||||
| 20 | maxNumOfDistinctRes | 是 | 是 |
|
||||
| 21 | minSlidingTime | 是 | 是 |
|
||||
| 22 | minIntervalTime | 是 | 是 |
|
||||
| 23 | countAlwaysReturnValue | 是 | 是 |
|
||||
| 24 | dataDir | 是 | 是 |
|
||||
| 25 | minimalDataDirGB | 是 | 是 |
|
||||
| 26 | supportVnodes | 否 | 是 |
|
||||
| 27 | tempDir | 是 | 是 |
|
||||
| 28 | minimalTmpDirGB | 是 | 是 |
|
||||
| 29 | compressMsgSize | 是 | 是 |
|
||||
| 30 | compressColData | 是 | 是 |
|
||||
| 31 | smlChildTableName | 是 | 是 |
|
||||
| 32 | smlTagName | 是 | 是 |
|
||||
| 33 | smlDataFormat | 否 | 是 |
|
||||
| 34 | statusInterval | 是 | 是 |
|
||||
| 35 | shellActivityTimer | 是 | 是 |
|
||||
| 36 | transPullupInterval | 否 | 是 |
|
||||
| 37 | mqRebalanceInterval | 否 | 是 |
|
||||
| 38 | ttlUnit | 否 | 是 |
|
||||
| 39 | ttlPushInterval | 否 | 是 |
|
||||
| 40 | numOfTaskQueueThreads | 否 | 是 |
|
||||
| 41 | numOfRpcThreads | 否 | 是 |
|
||||
| 42 | numOfCommitThreads | 是 | 是 |
|
||||
| 43 | numOfMnodeReadThreads | 否 | 是 |
|
||||
| 44 | numOfVnodeQueryThreads | 否 | 是 |
|
||||
| 45 | numOfVnodeStreamThreads | 否 | 是 |
|
||||
| 46 | numOfVnodeFetchThreads | 否 | 是 |
|
||||
| 47 | numOfVnodeWriteThreads | 否 | 是 |
|
||||
| 48 | numOfVnodeSyncThreads | 否 | 是 |
|
||||
| 49 | numOfVnodeRsmaThreads | 否 | 是 |
|
||||
| 50 | numOfQnodeQueryThreads | 否 | 是 |
|
||||
| 51 | numOfQnodeFetchThreads | 否 | 是 |
|
||||
| 52 | numOfSnodeSharedThreads | 否 | 是 |
|
||||
| 53 | numOfSnodeUniqueThreads | 否 | 是 |
|
||||
| 54 | rpcQueueMemoryAllowed | 否 | 是 |
|
||||
| 55 | logDir | 是 | 是 |
|
||||
| 56 | minimalLogDirGB | 是 | 是 |
|
||||
| 57 | numOfLogLines | 是 | 是 |
|
||||
| 58 | asyncLog | 是 | 是 |
|
||||
| 59 | logKeepDays | 是 | 是 |
|
||||
| 60 | debugFlag | 是 | 是 |
|
||||
| 61 | tmrDebugFlag | 是 | 是 |
|
||||
| 62 | uDebugFlag | 是 | 是 |
|
||||
| 63 | rpcDebugFlag | 是 | 是 |
|
||||
| 64 | jniDebugFlag | 是 | 是 |
|
||||
| 65 | qDebugFlag | 是 | 是 |
|
||||
| 66 | cDebugFlag | 是 | 是 |
|
||||
| 67 | dDebugFlag | 是 | 是 |
|
||||
| 68 | vDebugFlag | 是 | 是 |
|
||||
| 69 | mDebugFlag | 是 | 是 |
|
||||
| 70 | wDebugFlag | 是 | 是 |
|
||||
| 71 | sDebugFlag | 是 | 是 |
|
||||
| 72 | tsdbDebugFlag | 是 | 是 |
|
||||
| 73 | tqDebugFlag | 否 | 是 |
|
||||
| 74 | fsDebugFlag | 是 | 是 |
|
||||
| 75 | udfDebugFlag | 否 | 是 |
|
||||
| 76 | smaDebugFlag | 否 | 是 |
|
||||
| 77 | idxDebugFlag | 否 | 是 |
|
||||
| 78 | tdbDebugFlag | 否 | 是 |
|
||||
| 79 | metaDebugFlag | 否 | 是 |
|
||||
| 80 | timezone | 是 | 是 |
|
||||
| 81 | locale | 是 | 是 |
|
||||
| 82 | charset | 是 | 是 |
|
||||
| 83 | udf | 是 | 是 |
|
||||
| 84 | enableCoreFile | 是 | 是 |
|
||||
| 85 | arbitrator | 是 | 否 |
|
||||
| 86 | numOfThreadsPerCore | 是 | 否 |
|
||||
| 87 | numOfMnodes | 是 | 否 |
|
||||
| 88 | vnodeBak | 是 | 否 |
|
||||
| 89 | balance | 是 | 否 |
|
||||
| 90 | balanceInterval | 是 | 否 |
|
||||
| 91 | offlineThreshold | 是 | 否 |
|
||||
| 92 | role | 是 | 否 |
|
||||
| 93 | dnodeNopLoop | 是 | 否 |
|
||||
| 94 | keepTimeOffset | 是 | 否 |
|
||||
| 95 | rpcTimer | 是 | 否 |
|
||||
| 96 | rpcMaxTime | 是 | 否 |
|
||||
| 97 | rpcForceTcp | 是 | 否 |
|
||||
| 98 | tcpConnTimeout | 是 | 否 |
|
||||
| 99 | syncCheckInterval | 是 | 否 |
|
||||
| 100 | maxTmrCtrl | 是 | 否 |
|
||||
| 101 | monitorReplica | 是 | 否 |
|
||||
| 102 | smlTagNullName | 是 | 否 |
|
||||
| 103 | keepColumnName | 是 | 否 |
|
||||
| 104 | ratioOfQueryCores | 是 | 否 |
|
||||
| 105 | maxStreamCompDelay | 是 | 否 |
|
||||
| 106 | maxFirstStreamCompDelay | 是 | 否 |
|
||||
| 107 | retryStreamCompDelay | 是 | 否 |
|
||||
| 108 | streamCompDelayRatio | 是 | 否 |
|
||||
| 109 | maxVgroupsPerDb | 是 | 否 |
|
||||
| 110 | maxTablesPerVnode | 是 | 否 |
|
||||
| 111 | minTablesPerVnode | 是 | 否 |
|
||||
| 112 | tableIncStepPerVnode | 是 | 否 |
|
||||
| 113 | cache | 是 | 否 |
|
||||
| 114 | blocks | 是 | 否 |
|
||||
| 115 | days | 是 | 否 |
|
||||
| 116 | keep | 是 | 否 |
|
||||
| 117 | minRows | 是 | 否 |
|
||||
| 118 | maxRows | 是 | 否 |
|
||||
| 119 | quorum | 是 | 否 |
|
||||
| 120 | comp | 是 | 否 |
|
||||
| 121 | walLevel | 是 | 否 |
|
||||
| 122 | fsync | 是 | 否 |
|
||||
| 123 | replica | 是 | 否 |
|
||||
| 124 | partitions | 是 | 否 |
|
||||
| 125 | quorum | 是 | 否 |
|
||||
| 126 | update | 是 | 否 |
|
||||
| 127 | cachelast | 是 | 否 |
|
||||
| 128 | maxSQLLength | 是 | 否 |
|
||||
| 129 | maxWildCardsLength | 是 | 否 |
|
||||
| 130 | maxRegexStringLen | 是 | 否 |
|
||||
| 131 | maxNumOfOrderedRes | 是 | 否 |
|
||||
| 132 | maxConnections | 是 | 否 |
|
||||
| 133 | mnodeEqualVnodeNum | 是 | 否 |
|
||||
| 134 | http | 是 | 否 |
|
||||
| 135 | httpEnableRecordSql | 是 | 否 |
|
||||
| 136 | httpMaxThreads | 是 | 否 |
|
||||
| 137 | restfulRowLimit | 是 | 否 |
|
||||
| 138 | httpDbNameMandatory | 是 | 否 |
|
||||
| 139 | httpKeepAlive | 是 | 否 |
|
||||
| 140 | enableRecordSql | 是 | 否 |
|
||||
| 141 | maxBinaryDisplayWidth | 是 | 否 |
|
||||
| 142 | stream | 是 | 否 |
|
||||
| 143 | retrieveBlockingModel | 是 | 否 |
|
||||
| 144 | tsdbMetaCompactRatio | 是 | 否 |
|
||||
| 145 | defaultJSONStrType | 是 | 否 |
|
||||
| 146 | walFlushSize | 是 | 否 |
|
||||
| 147 | keepTimeOffset | 是 | 否 |
|
||||
| 148 | flowctrl | 是 | 否 |
|
||||
| 149 | slaveQuery | 是 | 否 |
|
||||
| 150 | adjustMaster | 是 | 否 |
|
||||
| 151 | topicBinaryLen | 是 | 否 |
|
||||
| 152 | telegrafUseFieldNum | 是 | 否 |
|
||||
| 153 | deadLockKillQuery | 是 | 否 |
|
||||
| 154 | clientMerge | 是 | 否 |
|
||||
| 155 | sdbDebugFlag | 是 | 否 |
|
||||
| 156 | odbcDebugFlag | 是 | 否 |
|
||||
| 157 | httpDebugFlag | 是 | 否 |
|
||||
| 158 | monDebugFlag | 是 | 否 |
|
||||
| 159 | cqDebugFlag | 是 | 否 |
|
||||
| 160 | shortcutFlag | 是 | 否 |
|
||||
| 161 | probeSeconds | 是 | 否 |
|
||||
| 162 | probeKillSeconds | 是 | 否 |
|
||||
| 163 | probeInterval | 是 | 否 |
|
||||
| 164 | lossyColumns | 是 | 否 |
|
||||
| 165 | fPrecision | 是 | 否 |
|
||||
| 166 | dPrecision | 是 | 否 |
|
||||
| 167 | maxRange | 是 | 否 |
|
||||
| 168 | range | 是 | 否 |
|
||||
|
|
|
@ -94,6 +94,7 @@ extern int64_t tsQueryBufferSizeBytes; // maximum allowed usage buffer size in
|
|||
// query client
|
||||
extern int32_t tsQueryPolicy;
|
||||
extern int32_t tsQuerySmaOptimize;
|
||||
extern int32_t tsQueryRsmaTolerance;
|
||||
extern bool tsQueryPlannerTrace;
|
||||
extern int32_t tsQueryNodeChunkSize;
|
||||
extern bool tsQueryUseNodeAllocator;
|
||||
|
|
|
@ -234,96 +234,100 @@
|
|||
#define TK_CURRENT_USER 216
|
||||
#define TK_COUNT 217
|
||||
#define TK_LAST_ROW 218
|
||||
#define TK_BETWEEN 219
|
||||
#define TK_IS 220
|
||||
#define TK_NK_LT 221
|
||||
#define TK_NK_GT 222
|
||||
#define TK_NK_LE 223
|
||||
#define TK_NK_GE 224
|
||||
#define TK_NK_NE 225
|
||||
#define TK_MATCH 226
|
||||
#define TK_NMATCH 227
|
||||
#define TK_CONTAINS 228
|
||||
#define TK_IN 229
|
||||
#define TK_JOIN 230
|
||||
#define TK_INNER 231
|
||||
#define TK_SELECT 232
|
||||
#define TK_DISTINCT 233
|
||||
#define TK_WHERE 234
|
||||
#define TK_PARTITION 235
|
||||
#define TK_BY 236
|
||||
#define TK_SESSION 237
|
||||
#define TK_STATE_WINDOW 238
|
||||
#define TK_SLIDING 239
|
||||
#define TK_FILL 240
|
||||
#define TK_VALUE 241
|
||||
#define TK_NONE 242
|
||||
#define TK_PREV 243
|
||||
#define TK_LINEAR 244
|
||||
#define TK_NEXT 245
|
||||
#define TK_HAVING 246
|
||||
#define TK_RANGE 247
|
||||
#define TK_EVERY 248
|
||||
#define TK_ORDER 249
|
||||
#define TK_SLIMIT 250
|
||||
#define TK_SOFFSET 251
|
||||
#define TK_LIMIT 252
|
||||
#define TK_OFFSET 253
|
||||
#define TK_ASC 254
|
||||
#define TK_NULLS 255
|
||||
#define TK_ABORT 256
|
||||
#define TK_AFTER 257
|
||||
#define TK_ATTACH 258
|
||||
#define TK_BEFORE 259
|
||||
#define TK_BEGIN 260
|
||||
#define TK_BITAND 261
|
||||
#define TK_BITNOT 262
|
||||
#define TK_BITOR 263
|
||||
#define TK_BLOCKS 264
|
||||
#define TK_CHANGE 265
|
||||
#define TK_COMMA 266
|
||||
#define TK_COMPACT 267
|
||||
#define TK_CONCAT 268
|
||||
#define TK_CONFLICT 269
|
||||
#define TK_COPY 270
|
||||
#define TK_DEFERRED 271
|
||||
#define TK_DELIMITERS 272
|
||||
#define TK_DETACH 273
|
||||
#define TK_DIVIDE 274
|
||||
#define TK_DOT 275
|
||||
#define TK_EACH 276
|
||||
#define TK_END 277
|
||||
#define TK_FAIL 278
|
||||
#define TK_FILE 279
|
||||
#define TK_FOR 280
|
||||
#define TK_GLOB 281
|
||||
#define TK_ID 282
|
||||
#define TK_IMMEDIATE 283
|
||||
#define TK_IMPORT 284
|
||||
#define TK_INITIALLY 285
|
||||
#define TK_INSTEAD 286
|
||||
#define TK_ISNULL 287
|
||||
#define TK_KEY 288
|
||||
#define TK_NK_BITNOT 289
|
||||
#define TK_NK_SEMI 290
|
||||
#define TK_NOTNULL 291
|
||||
#define TK_OF 292
|
||||
#define TK_PLUS 293
|
||||
#define TK_PRIVILEGE 294
|
||||
#define TK_RAISE 295
|
||||
#define TK_REPLACE 296
|
||||
#define TK_RESTRICT 297
|
||||
#define TK_ROW 298
|
||||
#define TK_SEMI 299
|
||||
#define TK_STAR 300
|
||||
#define TK_STATEMENT 301
|
||||
#define TK_STRING 302
|
||||
#define TK_TIMES 303
|
||||
#define TK_UPDATE 304
|
||||
#define TK_VALUES 305
|
||||
#define TK_VARIABLE 306
|
||||
#define TK_VIEW 307
|
||||
#define TK_WAL 308
|
||||
#define TK_CASE 219
|
||||
#define TK_END 220
|
||||
#define TK_WHEN 221
|
||||
#define TK_THEN 222
|
||||
#define TK_ELSE 223
|
||||
#define TK_BETWEEN 224
|
||||
#define TK_IS 225
|
||||
#define TK_NK_LT 226
|
||||
#define TK_NK_GT 227
|
||||
#define TK_NK_LE 228
|
||||
#define TK_NK_GE 229
|
||||
#define TK_NK_NE 230
|
||||
#define TK_MATCH 231
|
||||
#define TK_NMATCH 232
|
||||
#define TK_CONTAINS 233
|
||||
#define TK_IN 234
|
||||
#define TK_JOIN 235
|
||||
#define TK_INNER 236
|
||||
#define TK_SELECT 237
|
||||
#define TK_DISTINCT 238
|
||||
#define TK_WHERE 239
|
||||
#define TK_PARTITION 240
|
||||
#define TK_BY 241
|
||||
#define TK_SESSION 242
|
||||
#define TK_STATE_WINDOW 243
|
||||
#define TK_SLIDING 244
|
||||
#define TK_FILL 245
|
||||
#define TK_VALUE 246
|
||||
#define TK_NONE 247
|
||||
#define TK_PREV 248
|
||||
#define TK_LINEAR 249
|
||||
#define TK_NEXT 250
|
||||
#define TK_HAVING 251
|
||||
#define TK_RANGE 252
|
||||
#define TK_EVERY 253
|
||||
#define TK_ORDER 254
|
||||
#define TK_SLIMIT 255
|
||||
#define TK_SOFFSET 256
|
||||
#define TK_LIMIT 257
|
||||
#define TK_OFFSET 258
|
||||
#define TK_ASC 259
|
||||
#define TK_NULLS 260
|
||||
#define TK_ABORT 261
|
||||
#define TK_AFTER 262
|
||||
#define TK_ATTACH 263
|
||||
#define TK_BEFORE 264
|
||||
#define TK_BEGIN 265
|
||||
#define TK_BITAND 266
|
||||
#define TK_BITNOT 267
|
||||
#define TK_BITOR 268
|
||||
#define TK_BLOCKS 269
|
||||
#define TK_CHANGE 270
|
||||
#define TK_COMMA 271
|
||||
#define TK_COMPACT 272
|
||||
#define TK_CONCAT 273
|
||||
#define TK_CONFLICT 274
|
||||
#define TK_COPY 275
|
||||
#define TK_DEFERRED 276
|
||||
#define TK_DELIMITERS 277
|
||||
#define TK_DETACH 278
|
||||
#define TK_DIVIDE 279
|
||||
#define TK_DOT 280
|
||||
#define TK_EACH 281
|
||||
#define TK_FAIL 282
|
||||
#define TK_FILE 283
|
||||
#define TK_FOR 284
|
||||
#define TK_GLOB 285
|
||||
#define TK_ID 286
|
||||
#define TK_IMMEDIATE 287
|
||||
#define TK_IMPORT 288
|
||||
#define TK_INITIALLY 289
|
||||
#define TK_INSTEAD 290
|
||||
#define TK_ISNULL 291
|
||||
#define TK_KEY 292
|
||||
#define TK_NK_BITNOT 293
|
||||
#define TK_NK_SEMI 294
|
||||
#define TK_NOTNULL 295
|
||||
#define TK_OF 296
|
||||
#define TK_PLUS 297
|
||||
#define TK_PRIVILEGE 298
|
||||
#define TK_RAISE 299
|
||||
#define TK_REPLACE 300
|
||||
#define TK_RESTRICT 301
|
||||
#define TK_ROW 302
|
||||
#define TK_SEMI 303
|
||||
#define TK_STAR 304
|
||||
#define TK_STATEMENT 305
|
||||
#define TK_STRING 306
|
||||
#define TK_TIMES 307
|
||||
#define TK_UPDATE 308
|
||||
#define TK_VALUES 309
|
||||
#define TK_VARIABLE 310
|
||||
#define TK_VIEW 311
|
||||
#define TK_WAL 312
|
||||
|
||||
#define TK_NK_SPACE 300
|
||||
#define TK_NK_COMMENT 301
|
||||
|
|
|
@ -78,7 +78,6 @@ enum {
|
|||
MAIN_SCAN = 0x0u,
|
||||
REVERSE_SCAN = 0x1u, // todo remove it
|
||||
REPEAT_SCAN = 0x2u, // repeat scan belongs to the master scan
|
||||
MERGE_STAGE = 0x20u,
|
||||
};
|
||||
|
||||
typedef struct SPoint1 {
|
||||
|
@ -156,11 +155,6 @@ typedef struct SqlFunctionCtx {
|
|||
char udfName[TSDB_FUNC_NAME_LEN];
|
||||
} SqlFunctionCtx;
|
||||
|
||||
enum {
|
||||
TEXPR_BINARYEXPR_NODE = 0x1,
|
||||
TEXPR_UNARYEXPR_NODE = 0x2,
|
||||
};
|
||||
|
||||
typedef struct tExprNode {
|
||||
int32_t nodeType;
|
||||
union {
|
||||
|
@ -182,8 +176,9 @@ struct SScalarParam {
|
|||
SColumnInfoData *columnData;
|
||||
SHashObj *pHashFilter;
|
||||
int32_t hashValueType;
|
||||
void *param; // other parameter, such as meta handle from vnode, to extract table name/tag value
|
||||
void *param; // other parameter, such as meta handle from vnode, to extract table name/tag value
|
||||
int32_t numOfRows;
|
||||
int32_t numOfQualified; // number of qualified elements in the final results
|
||||
};
|
||||
|
||||
void cleanupResultRowEntry(struct SResultRowEntryInfo *pCell);
|
||||
|
@ -201,8 +196,6 @@ int32_t taosGetLinearInterpolationVal(SPoint *point, int32_t outputType, SPoint
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// udf api
|
||||
struct SUdfInfo;
|
||||
|
||||
/**
|
||||
* create udfd proxy, called once in process that call doSetupUdf/callUdfxxx/doTeardownUdf
|
||||
* @return error code
|
||||
|
@ -226,6 +219,7 @@ int32_t udfStartUdfd(int32_t startDnodeId);
|
|||
* @return
|
||||
*/
|
||||
int32_t udfStopUdfd();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -103,6 +103,8 @@ typedef enum ENodeType {
|
|||
QUERY_NODE_STREAM_OPTIONS,
|
||||
QUERY_NODE_LEFT_VALUE,
|
||||
QUERY_NODE_COLUMN_REF,
|
||||
QUERY_NODE_WHEN_THEN,
|
||||
QUERY_NODE_CASE_WHEN,
|
||||
|
||||
// Statement nodes are used in parser and planner module.
|
||||
QUERY_NODE_SET_OPERATOR = 100,
|
||||
|
|
|
@ -165,7 +165,8 @@ typedef struct SVnodeModifyLogicNode {
|
|||
|
||||
typedef struct SExchangeLogicNode {
|
||||
SLogicNode node;
|
||||
int32_t srcGroupId;
|
||||
int32_t srcStartGroupId;
|
||||
int32_t srcEndGroupId;
|
||||
} SExchangeLogicNode;
|
||||
|
||||
typedef struct SMergeLogicNode {
|
||||
|
@ -399,7 +400,10 @@ typedef struct SDownstreamSourceNode {
|
|||
|
||||
typedef struct SExchangePhysiNode {
|
||||
SPhysiNode node;
|
||||
int32_t srcGroupId; // group id of datasource suplans
|
||||
// for set operators, there will be multiple execution groups under one exchange, and the ids of these execution
|
||||
// groups are consecutive
|
||||
int32_t srcStartGroupId;
|
||||
int32_t srcEndGroupId;
|
||||
bool singleChannel;
|
||||
SNodeList* pSrcEndPoints; // element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
|
||||
} SExchangePhysiNode;
|
||||
|
|
|
@ -241,6 +241,19 @@ typedef struct SFillNode {
|
|||
STimeWindow timeRange;
|
||||
} SFillNode;
|
||||
|
||||
typedef struct SWhenThenNode {
|
||||
SExprNode node; // QUERY_NODE_WHEN_THEN
|
||||
SNode* pWhen;
|
||||
SNode* pThen;
|
||||
} SWhenThenNode;
|
||||
|
||||
typedef struct SCaseWhenNode {
|
||||
SExprNode node; // QUERY_NODE_CASE_WHEN
|
||||
SNode* pCase;
|
||||
SNode* pElse;
|
||||
SNodeList* pWhenThenList;
|
||||
} SCaseWhenNode;
|
||||
|
||||
typedef struct SSelectStmt {
|
||||
ENodeType type; // QUERY_NODE_SELECT_STMT
|
||||
bool isDistinct;
|
||||
|
|
|
@ -31,13 +31,17 @@ enum {
|
|||
FLT_OPTION_NEED_UNIQE = 4,
|
||||
};
|
||||
|
||||
#define FILTER_RESULT_ALL_QUALIFIED 0x1
|
||||
#define FILTER_RESULT_NONE_QUALIFIED 0x2
|
||||
#define FILTER_RESULT_PARTIAL_QUALIFIED 0x3
|
||||
|
||||
typedef struct SFilterColumnParam {
|
||||
int32_t numOfCols;
|
||||
SArray *pDataBlock;
|
||||
} SFilterColumnParam;
|
||||
|
||||
extern int32_t filterInitFromNode(SNode *pNode, SFilterInfo **pinfo, uint32_t options);
|
||||
extern bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, int8_t **p, SColumnDataAgg *statis, int16_t numOfCols);
|
||||
extern bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData** p, SColumnDataAgg *statis, int16_t numOfCols, int32_t* pFilterResStatus);
|
||||
extern int32_t filterSetDataFromSlotId(SFilterInfo *info, void *param);
|
||||
extern int32_t filterSetDataFromColId(SFilterInfo *info, void *param);
|
||||
extern int32_t filterGetTimeRange(SNode *pNode, STimeWindow *win, bool *isStrict);
|
||||
|
|
|
@ -552,7 +552,6 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_PAR_VALUE_TOO_LONG TAOS_DEF_ERROR_CODE(0, 0x2653)
|
||||
#define TSDB_CODE_PAR_INVALID_DELETE_WHERE TAOS_DEF_ERROR_CODE(0, 0x2655)
|
||||
#define TSDB_CODE_PAR_INVALID_REDISTRIBUTE_VG TAOS_DEF_ERROR_CODE(0, 0x2656)
|
||||
|
||||
#define TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x2657)
|
||||
#define TSDB_CODE_PAR_INVALID_WINDOW_PC TAOS_DEF_ERROR_CODE(0, 0x2658)
|
||||
#define TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x2659)
|
||||
|
@ -565,6 +564,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_PAR_INVALID_SELECTED_EXPR TAOS_DEF_ERROR_CODE(0, 0x2661)
|
||||
#define TSDB_CODE_PAR_GET_META_ERROR TAOS_DEF_ERROR_CODE(0, 0x2662)
|
||||
#define TSDB_CODE_PAR_NOT_UNIQUE_TABLE_ALIAS TAOS_DEF_ERROR_CODE(0, 0x2663)
|
||||
#define TSDB_CODE_PAR_NOT_SUPPORT_JOIN TAOS_DEF_ERROR_CODE(0, 0x2664)
|
||||
#define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF)
|
||||
|
||||
//planner
|
||||
|
|
|
@ -225,7 +225,8 @@ typedef enum ELogicConditionType {
|
|||
#define TSDB_APP_NAME_LEN TSDB_UNI_LEN
|
||||
#define TSDB_TB_COMMENT_LEN 1025
|
||||
|
||||
#define TSDB_QUERY_ID_LEN 26
|
||||
#define TSDB_QUERY_ID_LEN 26
|
||||
#define TSDB_TRANS_OPER_LEN 16
|
||||
|
||||
/**
|
||||
* In some scenarios uint16_t (0~65535) is used to store the row len.
|
||||
|
|
|
@ -695,6 +695,8 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
|
|||
};
|
||||
|
||||
int32_t code = schedulerExecJob(&req, &pRequest->body.queryJob);
|
||||
|
||||
destroyQueryExecRes(&pRequest->body.resInfo.execRes);
|
||||
memcpy(&pRequest->body.resInfo.execRes, &res, sizeof(res));
|
||||
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
|
|
@ -227,6 +227,7 @@ static const SSysDbTableSchema transSchema[] = {
|
|||
{.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 = "oper", .bytes = TSDB_TRANS_OPER_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "stable", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "failed_times", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||
|
|
|
@ -58,7 +58,7 @@ int32_t tsNumOfMnodeFetchThreads = 1;
|
|||
int32_t tsNumOfMnodeReadThreads = 1;
|
||||
int32_t tsNumOfVnodeQueryThreads = 4;
|
||||
int32_t tsNumOfVnodeStreamThreads = 2;
|
||||
int32_t tsNumOfVnodeFetchThreads = 4;
|
||||
int32_t tsNumOfVnodeFetchThreads = 1;
|
||||
int32_t tsNumOfVnodeWriteThreads = 2;
|
||||
int32_t tsNumOfVnodeSyncThreads = 2;
|
||||
int32_t tsNumOfVnodeRsmaThreads = 2;
|
||||
|
@ -91,6 +91,7 @@ bool tsSmlDataFormat =
|
|||
// query
|
||||
int32_t tsQueryPolicy = 1;
|
||||
int32_t tsQuerySmaOptimize = 0;
|
||||
int32_t tsQueryRsmaTolerance = 1000; // the tolerance time (ms) to judge from which level to query rsma data.
|
||||
bool tsQueryPlannerTrace = false;
|
||||
int32_t tsQueryNodeChunkSize = 32 * 1024;
|
||||
bool tsQueryUseNodeAllocator = true;
|
||||
|
@ -164,8 +165,8 @@ int32_t tsMqRebalanceInterval = 2;
|
|||
int32_t tsTtlUnit = 86400;
|
||||
int32_t tsTtlPushInterval = 86400;
|
||||
int32_t tsGrantHBInterval = 60;
|
||||
int32_t tsUptimeInterval = 300; // seconds
|
||||
char tsUdfdResFuncs[1024] = ""; // udfd resident funcs that teardown when udfd exits
|
||||
int32_t tsUptimeInterval = 300; // seconds
|
||||
char tsUdfdResFuncs[1024] = ""; // udfd resident funcs that teardown when udfd exits
|
||||
|
||||
#ifndef _STORAGE
|
||||
int32_t taosSetTfsCfg(SConfig *pCfg) {
|
||||
|
@ -370,9 +371,8 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
tsNumOfVnodeStreamThreads = TMAX(tsNumOfVnodeStreamThreads, 4);
|
||||
if (cfgAddInt32(pCfg, "numOfVnodeStreamThreads", tsNumOfVnodeStreamThreads, 4, 1024, 0) != 0) return -1;
|
||||
|
||||
tsNumOfVnodeFetchThreads = tsNumOfCores / 4;
|
||||
tsNumOfVnodeFetchThreads = TMAX(tsNumOfVnodeFetchThreads, 4);
|
||||
if (cfgAddInt32(pCfg, "numOfVnodeFetchThreads", tsNumOfVnodeFetchThreads, 4, 1024, 0) != 0) return -1;
|
||||
tsNumOfVnodeFetchThreads = 1;
|
||||
if (cfgAddInt32(pCfg, "numOfVnodeFetchThreads", tsNumOfVnodeFetchThreads, 1, 1024, 0) != 0) return -1;
|
||||
|
||||
tsNumOfVnodeWriteThreads = tsNumOfCores;
|
||||
tsNumOfVnodeWriteThreads = TMAX(tsNumOfVnodeWriteThreads, 1);
|
||||
|
@ -424,6 +424,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
if (cfgAddInt32(pCfg, "ttlUnit", tsTtlUnit, 1, 86400 * 365, 1) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "ttlPushInterval", tsTtlPushInterval, 1, 100000, 1) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "uptimeInterval", tsUptimeInterval, 1, 100000, 1) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "queryRsmaTolerance", tsQueryRsmaTolerance, 0, 900000, 0) != 0) return -1;
|
||||
|
||||
if (cfgAddBool(pCfg, "udf", tsStartUdfd, 0) != 0) return -1;
|
||||
if (cfgAddString(pCfg, "udfdResFuncs", tsUdfdResFuncs, 0) != 0) return -1;
|
||||
|
@ -723,6 +724,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
tsTtlUnit = cfgGetItem(pCfg, "ttlUnit")->i32;
|
||||
tsTtlPushInterval = cfgGetItem(pCfg, "ttlPushInterval")->i32;
|
||||
tsUptimeInterval = cfgGetItem(pCfg, "uptimeInterval")->i32;
|
||||
tsQueryRsmaTolerance = cfgGetItem(pCfg, "queryRsmaTolerance")->i32;
|
||||
|
||||
tsStartUdfd = cfgGetItem(pCfg, "udf")->bval;
|
||||
tstrncpy(tsUdfdResFuncs, cfgGetItem(pCfg, "udfdResFuncs")->str, sizeof(tsUdfdResFuncs));
|
||||
|
@ -989,6 +991,8 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
|
|||
tsQueryNodeChunkSize = cfgGetItem(pCfg, "queryNodeChunkSize")->i32;
|
||||
} else if (strcasecmp("queryUseNodeAllocator", name) == 0) {
|
||||
tsQueryUseNodeAllocator = cfgGetItem(pCfg, "queryUseNodeAllocator")->bval;
|
||||
} else if (strcasecmp("queryRsmaTolerance", name) == 0) {
|
||||
tsQueryRsmaTolerance = cfgGetItem(pCfg, "queryRsmaTolerance")->i32;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@ typedef struct {
|
|||
TdThread thread;
|
||||
SVnodeMgmt *pMgmt;
|
||||
SWrapperCfg *pCfgs;
|
||||
SVnodeObj **ppVnodes;
|
||||
} SVnodeThread;
|
||||
|
||||
// vmInt.c
|
||||
|
|
|
@ -218,14 +218,14 @@ static void vmCloseVnodes(SVnodeMgmt *pMgmt) {
|
|||
dInfo("start to close all vnodes");
|
||||
|
||||
int32_t numOfVnodes = 0;
|
||||
SVnodeObj **pVnodes = vmGetVnodeListFromHash(pMgmt, &numOfVnodes);
|
||||
SVnodeObj **ppVnodes = vmGetVnodeListFromHash(pMgmt, &numOfVnodes);
|
||||
|
||||
for (int32_t i = 0; i < numOfVnodes; ++i) {
|
||||
vmCloseVnode(pMgmt, pVnodes[i]);
|
||||
vmCloseVnode(pMgmt, ppVnodes[i]);
|
||||
}
|
||||
|
||||
if (pVnodes != NULL) {
|
||||
taosMemoryFree(pVnodes);
|
||||
if (ppVnodes != NULL) {
|
||||
taosMemoryFree(ppVnodes);
|
||||
}
|
||||
|
||||
if (pMgmt->hash != NULL) {
|
||||
|
@ -331,22 +331,92 @@ static int32_t vmRequire(const SMgmtInputOpt *pInput, bool *required) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t vmStart(SVnodeMgmt *pMgmt) {
|
||||
int32_t numOfVnodes = 0;
|
||||
SVnodeObj **pVnodes = vmGetVnodeListFromHash(pMgmt, &numOfVnodes);
|
||||
static void *vmRestoreVnodeInThread(void *param) {
|
||||
SVnodeThread *pThread = param;
|
||||
SVnodeMgmt *pMgmt = pThread->pMgmt;
|
||||
|
||||
for (int32_t i = 0; i < numOfVnodes; ++i) {
|
||||
SVnodeObj *pVnode = pVnodes[i];
|
||||
vnodeStart(pVnode->pImpl);
|
||||
dInfo("thread:%d, start to restore %d vnodes", pThread->threadIndex, pThread->vnodeNum);
|
||||
setThreadName("restore-vnodes");
|
||||
|
||||
for (int32_t v = 0; v < pThread->vnodeNum; ++v) {
|
||||
SVnodeObj *pVnode = pThread->ppVnodes[v];
|
||||
|
||||
char stepDesc[TSDB_STEP_DESC_LEN] = {0};
|
||||
snprintf(stepDesc, TSDB_STEP_DESC_LEN, "vgId:%d, start to restore, %d of %d have been restored", pVnode->vgId,
|
||||
pMgmt->state.openVnodes, pMgmt->state.totalVnodes);
|
||||
tmsgReportStartup("vnode-restore", stepDesc);
|
||||
|
||||
int32_t code = vnodeStart(pVnode->pImpl);
|
||||
if (code != 0) {
|
||||
dError("vgId:%d, failed to restore vnode by thread:%d", pVnode->vgId, pThread->threadIndex);
|
||||
pThread->failed++;
|
||||
} else {
|
||||
dDebug("vgId:%d, is restored by thread:%d", pVnode->vgId, pThread->threadIndex);
|
||||
pThread->opened++;
|
||||
atomic_add_fetch_32(&pMgmt->state.openVnodes, 1);
|
||||
}
|
||||
}
|
||||
|
||||
dInfo("thread:%d, numOfVnodes:%d, restored:%d failed:%d", pThread->threadIndex, pThread->vnodeNum, pThread->opened,
|
||||
pThread->failed);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int32_t vmStartVnodes(SVnodeMgmt *pMgmt) {
|
||||
int32_t numOfVnodes = 0;
|
||||
SVnodeObj **ppVnodes = vmGetVnodeListFromHash(pMgmt, &numOfVnodes);
|
||||
|
||||
int32_t threadNum = tsNumOfCores / 2;
|
||||
if (threadNum < 1) threadNum = 1;
|
||||
int32_t vnodesPerThread = numOfVnodes / threadNum + 1;
|
||||
|
||||
SVnodeThread *threads = taosMemoryCalloc(threadNum, sizeof(SVnodeThread));
|
||||
for (int32_t t = 0; t < threadNum; ++t) {
|
||||
threads[t].threadIndex = t;
|
||||
threads[t].pMgmt = pMgmt;
|
||||
threads[t].ppVnodes = taosMemoryCalloc(vnodesPerThread, sizeof(SVnode *));
|
||||
}
|
||||
|
||||
for (int32_t v = 0; v < numOfVnodes; ++v) {
|
||||
int32_t t = v % threadNum;
|
||||
SVnodeThread *pThread = &threads[t];
|
||||
pThread->ppVnodes[pThread->vnodeNum++] = ppVnodes[v];
|
||||
}
|
||||
|
||||
pMgmt->state.openVnodes = 0;
|
||||
dInfo("restore %d vnodes with %d threads", numOfVnodes, threadNum);
|
||||
|
||||
for (int32_t t = 0; t < threadNum; ++t) {
|
||||
SVnodeThread *pThread = &threads[t];
|
||||
if (pThread->vnodeNum == 0) continue;
|
||||
|
||||
TdThreadAttr thAttr;
|
||||
taosThreadAttrInit(&thAttr);
|
||||
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
if (taosThreadCreate(&pThread->thread, &thAttr, vmRestoreVnodeInThread, pThread) != 0) {
|
||||
dError("thread:%d, failed to create thread to restore vnode since %s", pThread->threadIndex, strerror(errno));
|
||||
}
|
||||
|
||||
taosThreadAttrDestroy(&thAttr);
|
||||
}
|
||||
|
||||
for (int32_t t = 0; t < threadNum; ++t) {
|
||||
SVnodeThread *pThread = &threads[t];
|
||||
if (pThread->vnodeNum > 0 && taosCheckPthreadValid(pThread->thread)) {
|
||||
taosThreadJoin(pThread->thread, NULL);
|
||||
taosThreadClear(&pThread->thread);
|
||||
}
|
||||
taosMemoryFree(pThread->ppVnodes);
|
||||
}
|
||||
taosMemoryFree(threads);
|
||||
|
||||
for (int32_t i = 0; i < numOfVnodes; ++i) {
|
||||
SVnodeObj *pVnode = pVnodes[i];
|
||||
SVnodeObj *pVnode = ppVnodes[i];
|
||||
vmReleaseVnode(pMgmt, pVnode);
|
||||
}
|
||||
|
||||
if (pVnodes != NULL) {
|
||||
taosMemoryFree(pVnodes);
|
||||
if (ppVnodes != NULL) {
|
||||
taosMemoryFree(ppVnodes);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -360,7 +430,7 @@ SMgmtFunc vmGetMgmtFunc() {
|
|||
SMgmtFunc mgmtFunc = {0};
|
||||
mgmtFunc.openFp = vmInit;
|
||||
mgmtFunc.closeFp = (NodeCloseFp)vmCleanup;
|
||||
mgmtFunc.startFp = (NodeStartFp)vmStart;
|
||||
mgmtFunc.startFp = (NodeStartFp)vmStartVnodes;
|
||||
mgmtFunc.stopFp = (NodeStopFp)vmStop;
|
||||
mgmtFunc.requiredFp = vmRequire;
|
||||
mgmtFunc.getHandlesFp = vmGetMsgHandles;
|
||||
|
|
|
@ -171,6 +171,7 @@ typedef struct {
|
|||
int32_t stopFunc;
|
||||
int32_t paramLen;
|
||||
void* param;
|
||||
char opername[TSDB_TRANS_OPER_LEN];
|
||||
SArray* pRpcArray;
|
||||
} STrans;
|
||||
|
||||
|
|
|
@ -61,7 +61,8 @@ void mndCleanupTrans(SMnode *pMnode);
|
|||
STrans *mndAcquireTrans(SMnode *pMnode, int32_t transId);
|
||||
void mndReleaseTrans(SMnode *pMnode, STrans *pTrans);
|
||||
|
||||
STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict, const SRpcMsg *pReq);
|
||||
STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict, const SRpcMsg *pReq,
|
||||
const char *opername);
|
||||
void mndTransDrop(STrans *pTrans);
|
||||
int32_t mndTransAppendRedolog(STrans *pTrans, SSdbRaw *pRaw);
|
||||
int32_t mndTransAppendUndolog(STrans *pTrans, SSdbRaw *pRaw);
|
||||
|
|
|
@ -81,7 +81,7 @@ static int32_t mndCreateDefaultAcct(SMnode *pMnode) {
|
|||
|
||||
mDebug("acct:%s, will be created when deploying, raw:%p", acctObj.acct, pRaw);
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, "create-acct");
|
||||
if (pTrans == NULL) {
|
||||
mError("acct:%s, failed to create since %s", acctObj.acct, terrstr());
|
||||
return -1;
|
||||
|
|
|
@ -246,7 +246,7 @@ static int32_t mndCreateBnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode,
|
|||
bnodeObj.createdTime = taosGetTimestampMs();
|
||||
bnodeObj.updateTime = bnodeObj.createdTime;
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "create-bnode");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
|
||||
mDebug("trans:%d, used to create bnode:%d", pTrans->id, pCreate->dnodeId);
|
||||
|
@ -354,7 +354,7 @@ static int32_t mndSetDropBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SBn
|
|||
static int32_t mndDropBnode(SMnode *pMnode, SRpcMsg *pReq, SBnodeObj *pObj) {
|
||||
int32_t code = -1;
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq, "drop-bnode");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
|
||||
mDebug("trans:%d, used to drop bnode:%d", pTrans->id, pObj->id);
|
||||
|
|
|
@ -235,7 +235,7 @@ static int32_t mndCreateDefaultCluster(SMnode *pMnode) {
|
|||
|
||||
mDebug("cluster:%" PRId64 ", will be created when deploying, raw:%p", clusterObj.id, pRaw);
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, "create-cluster");
|
||||
if (pTrans == NULL) {
|
||||
mError("cluster:%" PRId64 ", failed to create since %s", clusterObj.id, terrstr());
|
||||
return -1;
|
||||
|
@ -316,7 +316,7 @@ static int32_t mndProcessUptimeTimer(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
mTrace("update cluster uptime to %" PRId64, clusterObj.upTime);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "update-uptime");
|
||||
if (pTrans == NULL) return -1;
|
||||
|
||||
SSdbRaw *pCommitRaw = mndClusterActionEncode(&clusterObj);
|
||||
|
|
|
@ -109,7 +109,7 @@ static int32_t mndProcessConsumerLostMsg(SRpcMsg *pMsg) {
|
|||
|
||||
mndReleaseConsumer(pMnode, pConsumer);
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pMsg);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pMsg, "lost-csm");
|
||||
if (pTrans == NULL) goto FAIL;
|
||||
if (mndSetConsumerCommitLogs(pMnode, pTrans, pConsumerNew) != 0) goto FAIL;
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto FAIL;
|
||||
|
@ -142,7 +142,7 @@ static int32_t mndProcessConsumerRecoverMsg(SRpcMsg *pMsg) {
|
|||
|
||||
mndReleaseConsumer(pMnode, pConsumer);
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pMsg);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pMsg, "recover-csm");
|
||||
if (pTrans == NULL) goto FAIL;
|
||||
if (mndSetConsumerCommitLogs(pMnode, pTrans, pConsumerNew) != 0) goto FAIL;
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto FAIL;
|
||||
|
@ -465,7 +465,7 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
|
|||
|
||||
int32_t newTopicNum = taosArrayGetSize(newSub);
|
||||
// check topic existance
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pMsg);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pMsg, "subscribe");
|
||||
if (pTrans == NULL) goto SUBSCRIBE_OVER;
|
||||
|
||||
for (int32_t i = 0; i < newTopicNum; i++) {
|
||||
|
|
|
@ -541,7 +541,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
|
|||
}
|
||||
|
||||
int32_t code = -1;
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq, "create-db");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
// mndTransSetSerial(pTrans);
|
||||
mDebug("trans:%d, used to create db:%s", pTrans->id, pCreate->db);
|
||||
|
@ -773,7 +773,7 @@ static int32_t mndSetAlterDbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *
|
|||
}
|
||||
|
||||
static int32_t mndAlterDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pOld, SDbObj *pNew) {
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq, "alter-db");
|
||||
if (pTrans == NULL) return -1;
|
||||
mDebug("trans:%d, used to alter db:%s", pTrans->id, pOld->name);
|
||||
|
||||
|
@ -1027,7 +1027,7 @@ static int32_t mndBuildDropDbRsp(SDbObj *pDb, int32_t *pRspLen, void **ppRsp, bo
|
|||
|
||||
static int32_t mndDropDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb) {
|
||||
int32_t code = -1;
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq, "drop-db");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
|
||||
mDebug("trans:%d, used to drop db:%s", pTrans->id, pDb->name);
|
||||
|
|
|
@ -104,7 +104,7 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) {
|
|||
memcpy(&dnodeObj.fqdn, tsLocalFqdn, TSDB_FQDN_LEN);
|
||||
snprintf(dnodeObj.ep, TSDB_EP_LEN, "%s:%u", dnodeObj.fqdn, dnodeObj.port);
|
||||
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL);
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL, "create-dnode");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
mDebug("trans:%d, used to create dnode:%s on first deploy", pTrans->id, dnodeObj.ep);
|
||||
|
||||
|
@ -488,7 +488,7 @@ static int32_t mndCreateDnode(SMnode *pMnode, SRpcMsg *pReq, SCreateDnodeReq *pC
|
|||
memcpy(dnodeObj.fqdn, pCreate->fqdn, TSDB_FQDN_LEN);
|
||||
snprintf(dnodeObj.ep, TSDB_EP_LEN, "%s:%u", dnodeObj.fqdn, dnodeObj.port);
|
||||
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_GLOBAL, pReq);
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_GLOBAL, pReq, "create-dnode");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
mDebug("trans:%d, used to create dnode:%s", pTrans->id, dnodeObj.ep);
|
||||
|
||||
|
@ -667,7 +667,7 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM
|
|||
SSdbRaw *pRaw = NULL;
|
||||
STrans *pTrans = NULL;
|
||||
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq);
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "drop-dnode");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
mndTransSetSerial(pTrans);
|
||||
mInfo("trans:%d, used to drop dnode:%d", pTrans->id, pDnode->id);
|
||||
|
|
|
@ -219,7 +219,7 @@ static int32_t mndCreateFunc(SMnode *pMnode, SRpcMsg *pReq, SCreateFuncReq *pCre
|
|||
}
|
||||
memcpy(func.pCode, pCreate->pCode, func.codeSize);
|
||||
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq);
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "create-func");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
|
||||
mDebug("trans:%d, used to create func:%s", pTrans->id, pCreate->name);
|
||||
|
@ -249,7 +249,7 @@ _OVER:
|
|||
|
||||
static int32_t mndDropFunc(SMnode *pMnode, SRpcMsg *pReq, SFuncObj *pFunc) {
|
||||
int32_t code = -1;
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "drop-func");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
|
||||
mDebug("trans:%d, used to drop user:%s", pTrans->id, pFunc->name);
|
||||
|
|
|
@ -91,7 +91,7 @@ static int32_t mndCreateDefaultMnode(SMnode *pMnode) {
|
|||
|
||||
mInfo("mnode:%d, will be created when deploying, raw:%p", mnodeObj.id, pRaw);
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL, "create-mnode");
|
||||
if (pTrans == NULL) {
|
||||
mError("mnode:%d, failed to create since %s", mnodeObj.id, terrstr());
|
||||
return -1;
|
||||
|
@ -362,7 +362,7 @@ static int32_t mndCreateMnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode,
|
|||
mnodeObj.createdTime = taosGetTimestampMs();
|
||||
mnodeObj.updateTime = mnodeObj.createdTime;
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "create-mnode");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
mndTransSetSerial(pTrans);
|
||||
mInfo("trans:%d, used to create mnode:%d", pTrans->id, pCreate->dnodeId);
|
||||
|
@ -571,7 +571,7 @@ static int32_t mndDropMnode(SMnode *pMnode, SRpcMsg *pReq, SMnodeObj *pObj) {
|
|||
int32_t code = -1;
|
||||
STrans *pTrans = NULL;
|
||||
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq);
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "drop-mnode");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
mndTransSetSerial(pTrans);
|
||||
mInfo("trans:%d, used to drop mnode:%d", pTrans->id, pObj->id);
|
||||
|
|
|
@ -181,7 +181,7 @@ static int32_t mndProcessCommitOffsetReq(SRpcMsg *pMsg) {
|
|||
|
||||
tDecodeSMqCMCommitOffsetReq(&decoder, &commitOffsetReq);
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pMsg);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pMsg, "commit-offset");
|
||||
|
||||
for (int32_t i = 0; i < commitOffsetReq.num; i++) {
|
||||
SMqOffset *pOffset = &commitOffsetReq.offsets[i];
|
||||
|
|
|
@ -248,7 +248,7 @@ static int32_t mndCreateQnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode,
|
|||
qnodeObj.createdTime = taosGetTimestampMs();
|
||||
qnodeObj.updateTime = qnodeObj.createdTime;
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "create-qnode");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
|
||||
mDebug("trans:%d, used to create qnode:%d", pTrans->id, pCreate->dnodeId);
|
||||
|
@ -364,7 +364,7 @@ int32_t mndSetDropQnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SQnodeObj *pO
|
|||
static int32_t mndDropQnode(SMnode *pMnode, SRpcMsg *pReq, SQnodeObj *pObj) {
|
||||
int32_t code = -1;
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq, "drop-qnode");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
|
||||
mDebug("trans:%d, used to drop qnode:%d", pTrans->id, pObj->id);
|
||||
|
|
|
@ -587,7 +587,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
|||
nodesDestroyNode((SNode *)pPlan);
|
||||
|
||||
int32_t code = -1;
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq, "create-sma");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
mndTransSetDbName(pTrans, pDb->name, NULL);
|
||||
mndTransSetSerial(pTrans);
|
||||
|
@ -799,7 +799,7 @@ static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *p
|
|||
pStb = mndAcquireStb(pMnode, pSma->stb);
|
||||
if (pStb == NULL) goto _OVER;
|
||||
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq);
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq, "drop-sma");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
|
||||
mDebug("trans:%d, used to drop sma:%s", pTrans->id, pSma->name);
|
||||
|
|
|
@ -253,7 +253,7 @@ static int32_t mndCreateSnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode,
|
|||
snodeObj.createdTime = taosGetTimestampMs();
|
||||
snodeObj.updateTime = snodeObj.createdTime;
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "create-snode");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
|
||||
mDebug("trans:%d, used to create snode:%d", pTrans->id, pCreate->dnodeId);
|
||||
|
@ -375,7 +375,7 @@ int32_t mndSetDropSnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SSnodeObj *pO
|
|||
static int32_t mndDropSnode(SMnode *pMnode, SRpcMsg *pReq, SSnodeObj *pObj) {
|
||||
int32_t code = -1;
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq, "drop-snode");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
|
||||
mDebug("trans:%d, used to drop snode:%d", pTrans->id, pObj->id);
|
||||
|
|
|
@ -800,7 +800,7 @@ static int32_t mndCreateStb(SMnode *pMnode, SRpcMsg *pReq, SMCreateStbReq *pCrea
|
|||
SStbObj stbObj = {0};
|
||||
int32_t code = -1;
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq, "create-stb");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
|
||||
mDebug("trans:%d, used to create stb:%s", pTrans->id, pCreate->name);
|
||||
|
@ -1843,7 +1843,7 @@ _OVER:
|
|||
static int32_t mndAlterStbImp(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pStb, bool needRsp,
|
||||
void *alterOriData, int32_t alterOriDataLen) {
|
||||
int32_t code = -1;
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq, "alter-stb");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
|
||||
mDebug("trans:%d, used to alter stb:%s", pTrans->id, pStb->name);
|
||||
|
@ -2042,7 +2042,7 @@ static int32_t mndSetDropStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *
|
|||
|
||||
static int32_t mndDropStb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pStb) {
|
||||
int32_t code = -1;
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq, "drop-stb");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
|
||||
mDebug("trans:%d, used to drop stb:%s", pTrans->id, pStb->name);
|
||||
|
|
|
@ -666,7 +666,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq, "create-stream");
|
||||
if (pTrans == NULL) {
|
||||
mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr());
|
||||
goto _OVER;
|
||||
|
@ -759,7 +759,7 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq, "drop-stream");
|
||||
if (pTrans == NULL) {
|
||||
mError("stream:%s, failed to drop since %s", dropReq.name, terrstr());
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
|
|
|
@ -441,7 +441,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
|
|||
}
|
||||
|
||||
static int32_t mndPersistRebResult(SMnode *pMnode, SRpcMsg *pMsg, const SMqRebOutputObj *pOutput) {
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pMsg);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pMsg, "persist-reb");
|
||||
mndTransSetDbName(pTrans, pOutput->pSub->dbName, NULL);
|
||||
if (pTrans == NULL) return -1;
|
||||
|
||||
|
@ -674,7 +674,7 @@ static int32_t mndProcessDropCgroupReq(SRpcMsg *pReq) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "drop-cgroup");
|
||||
if (pTrans == NULL) {
|
||||
mError("cgroup: %s on topic:%s, failed to drop since %s", dropReq.cgroup, dropReq.topic, terrstr());
|
||||
mndReleaseSubscribe(pMnode, pSub);
|
||||
|
|
|
@ -440,7 +440,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
|
|||
/*topicObj.withTbName = 1;*/
|
||||
/*topicObj.withSchema = 1;*/
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "create-topic");
|
||||
if (pTrans == NULL) {
|
||||
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
||||
taosMemoryFreeClear(topicObj.ast);
|
||||
|
@ -663,7 +663,7 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq, "drop-topic");
|
||||
mndTransSetDbName(pTrans, pTopic->db, NULL);
|
||||
if (pTrans == NULL) {
|
||||
mError("topic:%s, failed to drop since %s", pTopic->name, terrstr());
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#define TRANS_VER_NUMBER 1
|
||||
#define TRANS_ARRAY_SIZE 8
|
||||
#define TRANS_RESERVE_SIZE 64
|
||||
#define TRANS_RESERVE_SIZE 48
|
||||
|
||||
static SSdbRaw *mndTransActionEncode(STrans *pTrans);
|
||||
static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw);
|
||||
|
@ -223,6 +223,7 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
|
|||
SDB_SET_BINARY(pRaw, dataPos, pTrans->param, pTrans->paramLen, _OVER)
|
||||
}
|
||||
|
||||
SDB_SET_BINARY(pRaw, dataPos, pTrans->opername, TSDB_TRANS_OPER_LEN, _OVER)
|
||||
SDB_SET_RESERVE(pRaw, dataPos, TRANS_RESERVE_SIZE, _OVER)
|
||||
SDB_SET_DATALEN(pRaw, dataPos, _OVER)
|
||||
|
||||
|
@ -305,6 +306,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
|||
if (pTrans->commitActions == NULL) goto _OVER;
|
||||
|
||||
for (int32_t i = 0; i < redoActionNum; ++i) {
|
||||
memset(&action, 0, sizeof(action));
|
||||
SDB_GET_INT32(pRaw, dataPos, &action.id, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &action.errCode, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, _OVER)
|
||||
|
@ -340,6 +342,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
|||
}
|
||||
|
||||
for (int32_t i = 0; i < undoActionNum; ++i) {
|
||||
memset(&action, 0, sizeof(action));
|
||||
SDB_GET_INT32(pRaw, dataPos, &action.id, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &action.errCode, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, _OVER)
|
||||
|
@ -375,6 +378,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
|||
}
|
||||
|
||||
for (int32_t i = 0; i < commitActionNum; ++i) {
|
||||
memset(&action, 0, sizeof(action));
|
||||
SDB_GET_INT32(pRaw, dataPos, &action.id, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &action.errCode, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, _OVER)
|
||||
|
@ -417,6 +421,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
|||
SDB_GET_BINARY(pRaw, dataPos, pTrans->param, pTrans->paramLen, _OVER);
|
||||
}
|
||||
|
||||
SDB_GET_BINARY(pRaw, dataPos, pTrans->opername, TSDB_TRANS_OPER_LEN, _OVER);
|
||||
SDB_GET_RESERVE(pRaw, dataPos, TRANS_RESERVE_SIZE, _OVER)
|
||||
|
||||
terrno = 0;
|
||||
|
@ -455,6 +460,20 @@ static const char *mndTransStr(ETrnStage stage) {
|
|||
}
|
||||
}
|
||||
|
||||
static void mndSetTransLastAction(STrans *pTrans, STransAction *pAction) {
|
||||
if (pAction != NULL) {
|
||||
pTrans->lastAction = pAction->id;
|
||||
pTrans->lastMsgType = pAction->msgType;
|
||||
pTrans->lastEpset = pAction->epSet;
|
||||
pTrans->lastErrorNo = pAction->errCode;
|
||||
} else {
|
||||
pTrans->lastAction = 0;
|
||||
pTrans->lastMsgType = 0;
|
||||
memset(&pTrans->lastEpset, 0, sizeof(pTrans->lastEpset));
|
||||
pTrans->lastErrorNo = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void mndTransTestStartFunc(SMnode *pMnode, void *param, int32_t paramLen) {
|
||||
mInfo("test trans start, param:%s, len:%d", (char *)param, paramLen);
|
||||
}
|
||||
|
@ -582,7 +601,8 @@ void mndReleaseTrans(SMnode *pMnode, STrans *pTrans) {
|
|||
sdbRelease(pSdb, pTrans);
|
||||
}
|
||||
|
||||
STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict, const SRpcMsg *pReq) {
|
||||
STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict, const SRpcMsg *pReq,
|
||||
const char *opername) {
|
||||
STrans *pTrans = taosMemoryCalloc(1, sizeof(STrans));
|
||||
if (pTrans == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -590,6 +610,10 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (opername != NULL) {
|
||||
tstrncpy(pTrans->opername, opername, TSDB_TRANS_OPER_LEN);
|
||||
}
|
||||
|
||||
pTrans->id = sdbGetMaxId(pMnode->pSdb, SDB_TRANS);
|
||||
pTrans->stage = TRN_STAGE_PREPARE;
|
||||
pTrans->policy = policy;
|
||||
|
@ -1037,18 +1061,12 @@ static int32_t mndTransWriteSingleLog(SMnode *pMnode, STrans *pTrans, STransActi
|
|||
mInfo("trans:%d, %s:%d write to sdb, type:%s status:%s", pTrans->id, mndTransStr(pAction->stage), pAction->id,
|
||||
sdbTableName(pAction->pRaw->type), sdbStatusName(pAction->pRaw->status));
|
||||
|
||||
pTrans->lastAction = pAction->id;
|
||||
pTrans->lastMsgType = pAction->msgType;
|
||||
pTrans->lastEpset = pAction->epSet;
|
||||
pTrans->lastErrorNo = 0;
|
||||
mndSetTransLastAction(pTrans, pAction);
|
||||
} else {
|
||||
pAction->errCode = (terrno != 0) ? terrno : code;
|
||||
mError("trans:%d, %s:%d failed to write sdb since %s, type:%s status:%s", pTrans->id, mndTransStr(pAction->stage),
|
||||
pAction->id, terrstr(), sdbTableName(pAction->pRaw->type), sdbStatusName(pAction->pRaw->status));
|
||||
pTrans->lastAction = pAction->id;
|
||||
pTrans->lastMsgType = pAction->msgType;
|
||||
pTrans->lastEpset = pAction->epSet;
|
||||
pTrans->lastErrorNo = pAction->errCode;
|
||||
mndSetTransLastAction(pTrans, pAction);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -1082,15 +1100,10 @@ static int32_t mndTransSendSingleMsg(SMnode *pMnode, STrans *pTrans, STransActio
|
|||
if (code == 0) {
|
||||
pAction->msgSent = 1;
|
||||
pAction->msgReceived = 0;
|
||||
pAction->errCode = 0;
|
||||
pAction->errCode = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
mInfo("trans:%d, %s:%d is sent, %s", pTrans->id, mndTransStr(pAction->stage), pAction->id, detail);
|
||||
|
||||
pTrans->lastAction = pAction->id;
|
||||
pTrans->lastMsgType = pAction->msgType;
|
||||
pTrans->lastEpset = pAction->epSet;
|
||||
if (pTrans->lastErrorNo == 0) {
|
||||
pTrans->lastErrorNo = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
}
|
||||
mndSetTransLastAction(pTrans, pAction);
|
||||
} else {
|
||||
pAction->msgSent = 0;
|
||||
pAction->msgReceived = 0;
|
||||
|
@ -1098,10 +1111,7 @@ static int32_t mndTransSendSingleMsg(SMnode *pMnode, STrans *pTrans, STransActio
|
|||
mError("trans:%d, %s:%d not send since %s, %s", pTrans->id, mndTransStr(pAction->stage), pAction->id, terrstr(),
|
||||
detail);
|
||||
|
||||
pTrans->lastAction = pAction->id;
|
||||
pTrans->lastMsgType = pAction->msgType;
|
||||
pTrans->lastEpset = pAction->epSet;
|
||||
pTrans->lastErrorNo = pAction->errCode;
|
||||
mndSetTransLastAction(pTrans, pAction);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -1112,10 +1122,7 @@ static int32_t mndTransExecNullMsg(SMnode *pMnode, STrans *pTrans, STransAction
|
|||
pAction->errCode = 0;
|
||||
mInfo("trans:%d, %s:%d confirm action executed", pTrans->id, mndTransStr(pAction->stage), pAction->id);
|
||||
|
||||
pTrans->lastAction = pAction->id;
|
||||
pTrans->lastMsgType = pAction->msgType;
|
||||
pTrans->lastEpset = pAction->epSet;
|
||||
pTrans->lastErrorNo = 0;
|
||||
mndSetTransLastAction(pTrans, pAction);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1161,25 +1168,19 @@ static int32_t mndTransExecuteActions(SMnode *pMnode, STrans *pTrans, SArray *pA
|
|||
errCode = pAction->errCode;
|
||||
pErrAction = pAction;
|
||||
}
|
||||
} else {
|
||||
pErrAction = pAction;
|
||||
}
|
||||
}
|
||||
|
||||
mndSetTransLastAction(pTrans, pErrAction);
|
||||
|
||||
if (numOfExecuted == numOfActions) {
|
||||
if (errCode == 0) {
|
||||
pTrans->lastAction = 0;
|
||||
pTrans->lastMsgType = 0;
|
||||
memset(&pTrans->lastEpset, 0, sizeof(pTrans->lastEpset));
|
||||
pTrans->lastErrorNo = 0;
|
||||
mInfo("trans:%d, all %d actions execute successfully", pTrans->id, numOfActions);
|
||||
return 0;
|
||||
} else {
|
||||
mError("trans:%d, all %d actions executed, code:0x%x", pTrans->id, numOfActions, errCode & 0XFFFF);
|
||||
if (pErrAction != NULL) {
|
||||
pTrans->lastAction = pErrAction->id;
|
||||
pTrans->lastMsgType = pErrAction->msgType;
|
||||
pTrans->lastEpset = pErrAction->epSet;
|
||||
pTrans->lastErrorNo = pErrAction->errCode;
|
||||
}
|
||||
mndTransResetActions(pMnode, pTrans, pArray);
|
||||
terrno = errCode;
|
||||
return errCode;
|
||||
|
@ -1220,6 +1221,8 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans)
|
|||
if (numOfActions == 0) return code;
|
||||
if (pTrans->redoActionPos >= numOfActions) return code;
|
||||
|
||||
mInfo("trans:%d, execute %d actions serial", pTrans->id, numOfActions);
|
||||
|
||||
for (int32_t action = pTrans->redoActionPos; action < numOfActions; ++action) {
|
||||
STransAction *pAction = taosArrayGet(pTrans->redoActions, pTrans->redoActionPos);
|
||||
|
||||
|
@ -1248,16 +1251,8 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans)
|
|||
|
||||
if (code == 0) {
|
||||
pTrans->failedTimes = 0;
|
||||
pTrans->lastAction = action;
|
||||
pTrans->lastMsgType = 0;
|
||||
pTrans->lastErrorNo = 0;
|
||||
memset(&pTrans->lastEpset, 0, sizeof(pTrans->lastEpset));
|
||||
} else {
|
||||
pTrans->lastAction = action;
|
||||
pTrans->lastMsgType = pAction->msgType;
|
||||
pTrans->lastErrorNo = code;
|
||||
pTrans->lastEpset = pAction->epSet;
|
||||
}
|
||||
mndSetTransLastAction(pTrans, pAction);
|
||||
|
||||
if (mndCannotExecuteTransAction(pMnode)) break;
|
||||
|
||||
|
@ -1599,6 +1594,11 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
|||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)stage, false);
|
||||
|
||||
char opername[TSDB_TRANS_OPER_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(opername, pTrans->opername, pShow->pMeta->pSchemas[cols].bytes);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)opername, false);
|
||||
|
||||
char dbname[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(dbname, mndGetDbStr(pTrans->dbname), pShow->pMeta->pSchemas[cols].bytes);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
|
|
@ -81,7 +81,7 @@ static int32_t mndCreateDefaultUser(SMnode *pMnode, char *acct, char *user, char
|
|||
|
||||
mDebug("user:%s, will be created when deploying, raw:%p", userObj.user, pRaw);
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, "create-user");
|
||||
if (pTrans == NULL) {
|
||||
mError("user:%s, failed to create since %s", userObj.user, terrstr());
|
||||
return -1;
|
||||
|
@ -299,7 +299,7 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, SCreateUserReq *pCreate
|
|||
userObj.sysInfo = pCreate->sysInfo;
|
||||
userObj.enable = pCreate->enable;
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "create-user");
|
||||
if (pTrans == NULL) {
|
||||
mError("user:%s, failed to create since %s", pCreate->user, terrstr());
|
||||
return -1;
|
||||
|
@ -383,7 +383,7 @@ _OVER:
|
|||
}
|
||||
|
||||
static int32_t mndAlterUser(SMnode *pMnode, SUserObj *pOld, SUserObj *pNew, SRpcMsg *pReq) {
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "alter-user");
|
||||
if (pTrans == NULL) {
|
||||
mError("user:%s, failed to alter since %s", pOld->user, terrstr());
|
||||
return -1;
|
||||
|
@ -598,7 +598,7 @@ _OVER:
|
|||
}
|
||||
|
||||
static int32_t mndDropUser(SMnode *pMnode, SRpcMsg *pReq, SUserObj *pUser) {
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "drop-user");
|
||||
if (pTrans == NULL) {
|
||||
mError("user:%s, failed to drop since %s", pUser->user, terrstr());
|
||||
return -1;
|
||||
|
|
|
@ -1223,7 +1223,7 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb,
|
|||
SSdbRaw *pRaw = NULL;
|
||||
STrans *pTrans = NULL;
|
||||
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq);
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "red-vgroup");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
mndTransSetSerial(pTrans);
|
||||
mDebug("trans:%d, used to redistribute vgroup, vgId:%d", pTrans->id, pVgroup->vgId);
|
||||
|
@ -1606,7 +1606,7 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
|
|||
STrans *pTrans = NULL;
|
||||
SArray *pArray = mndBuildDnodesArray(pMnode, 0);
|
||||
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq);
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "split-vgroup");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
mndTransSetSerial(pTrans);
|
||||
mDebug("trans:%d, used to split vgroup, vgId:%d", pTrans->id, pVgroup->vgId);
|
||||
|
@ -1774,7 +1774,7 @@ static int32_t mndBalanceVgroup(SMnode *pMnode, SRpcMsg *pReq, SArray *pArray) {
|
|||
pBalancedVgroups = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
|
||||
if (pBalancedVgroups == NULL) goto _OVER;
|
||||
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq);
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "balance-vgroup");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
mndTransSetSerial(pTrans);
|
||||
mDebug("trans:%d, used to balance vgroup", pTrans->id);
|
||||
|
|
|
@ -115,7 +115,7 @@ class MndTestTrans2 : public ::testing::Test {
|
|||
userObj.superUser = 1;
|
||||
|
||||
SRpcMsg rpcMsg = {0};
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, conflict, &rpcMsg);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, conflict, &rpcMsg, "");
|
||||
SSdbRaw *pRedoRaw = mndUserActionEncode(&userObj);
|
||||
mndTransAppendRedolog(pTrans, pRedoRaw);
|
||||
sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY);
|
||||
|
@ -148,7 +148,7 @@ class MndTestTrans2 : public ::testing::Test {
|
|||
userObj.superUser = 1;
|
||||
|
||||
SRpcMsg rpcMsg = {0};
|
||||
STrans *pTrans = mndTransCreate(pMnode, policy, conflict, &rpcMsg);
|
||||
STrans *pTrans = mndTransCreate(pMnode, policy, conflict, &rpcMsg, "");
|
||||
SSdbRaw *pRedoRaw = mndUserActionEncode(&userObj);
|
||||
mndTransAppendRedolog(pTrans, pRedoRaw);
|
||||
sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY);
|
||||
|
@ -220,7 +220,7 @@ class MndTestTrans2 : public ::testing::Test {
|
|||
userObj.superUser = 1;
|
||||
|
||||
SRpcMsg rpcMsg = {0};
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, &rpcMsg);
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, &rpcMsg, "");
|
||||
SSdbRaw *pRedoRaw = mndUserActionEncode(&userObj);
|
||||
mndTransAppendRedolog(pTrans, pRedoRaw);
|
||||
sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY);
|
||||
|
|
|
@ -295,12 +295,17 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief step 3: consume the SubmitReq in buffer
|
||||
* @brief step 3: commit should wait for all SubmitReq in buffer be consumed
|
||||
* 1) This is high cost task and should not put in asyncPreCommit originally.
|
||||
* 2) But, if put in asyncCommit, would trigger taskInfo cloning frequently.
|
||||
*/
|
||||
if (tdRSmaProcessExecImpl(pSma, RSMA_EXEC_COMMIT) < 0) {
|
||||
return TSDB_CODE_FAILED;
|
||||
nLoops = 0;
|
||||
while (atomic_load_64(&pRSmaStat->nBufItems) > 0) {
|
||||
++nLoops;
|
||||
if (nLoops > 1000) {
|
||||
sched_yield();
|
||||
nLoops = 0;
|
||||
}
|
||||
}
|
||||
|
||||
smaInfo("vgId:%d, rsma commit, wait for all items to be consumed, TID:%p", SMA_VID(pSma),
|
||||
|
|
|
@ -278,7 +278,6 @@ static void tdDestroyRSmaStat(void *pRSmaStat) {
|
|||
smaDebug("vgId:%d, destroy rsma stat %p", SMA_VID(pSma), pRSmaStat);
|
||||
// step 1: set rsma trigger stat cancelled
|
||||
atomic_store_8(RSMA_TRIGGER_STAT(pStat), TASK_TRIGGER_STAT_CANCELLED);
|
||||
tsem_destroy(&(pStat->notEmpty));
|
||||
|
||||
// step 2: destroy the rsma info and associated fetch tasks
|
||||
taosHashCleanup(RSMA_INFO_HASH(pStat));
|
||||
|
@ -306,6 +305,7 @@ static void tdDestroyRSmaStat(void *pRSmaStat) {
|
|||
tdRSmaFSClose(RSMA_FS(pStat));
|
||||
|
||||
// step 6: free pStat
|
||||
tsem_destroy(&(pStat->notEmpty));
|
||||
taosMemoryFreeClear(pStat);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,6 +150,8 @@ static int32_t tdFetchQTaskInfoFiles(SSma *pSma, int64_t version, SArray **outpu
|
|||
regex_t regex;
|
||||
int code = 0;
|
||||
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
|
||||
tdGetVndDirName(TD_VID(pVnode), tfsGetPrimaryPath(pVnode->pTfs), VNODE_RSMA_DIR, true, dir);
|
||||
|
||||
if (!taosCheckExistFile(dir)) {
|
||||
|
|
|
@ -1906,7 +1906,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
|
|||
|
||||
while (true) {
|
||||
// step 1: rsma exec - consume data in buffer queue for all suids
|
||||
if (type == RSMA_EXEC_OVERFLOW || type == RSMA_EXEC_COMMIT) {
|
||||
if (type == RSMA_EXEC_OVERFLOW) {
|
||||
void *pIter = NULL;
|
||||
while ((pIter = taosHashIterate(infoHash, pIter))) {
|
||||
SRSmaInfo *pInfo = *(SRSmaInfo **)pIter;
|
||||
|
@ -1962,42 +1962,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
|
|||
atomic_val_compare_exchange_8(&pInfo->assigned, 1, 0);
|
||||
}
|
||||
}
|
||||
if (type == RSMA_EXEC_COMMIT) {
|
||||
if (atomic_load_64(&pRSmaStat->nBufItems) <= 0) {
|
||||
break;
|
||||
} else {
|
||||
// commit should wait for all items be consumed
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
else if (type == RSMA_EXEC_COMMIT) {
|
||||
while (pIter) {
|
||||
SRSmaInfo *pInfo = *(SRSmaInfo **)pIter;
|
||||
if (taosQueueItemSize(pInfo->iQueue)) {
|
||||
if (atomic_val_compare_exchange_8(&pInfo->assigned, 0, 1) == 0) {
|
||||
taosReadAllQitems(pInfo->iQueue, pInfo->iQall); // queue has mutex lock
|
||||
int32_t qallItemSize = taosQallItemSize(pInfo->iQall);
|
||||
if (qallItemSize > 0) {
|
||||
atomic_fetch_sub_64(&pRSmaStat->nBufItems, qallItemSize);
|
||||
nIdle = 0;
|
||||
|
||||
// batch exec
|
||||
tdRSmaBatchExec(pSma, pInfo, pInfo->qall, pSubmitArr, type);
|
||||
}
|
||||
|
||||
// tdRSmaFetchAllResult(pSma, pInfo, pSubmitArr);
|
||||
atomic_val_compare_exchange_8(&pInfo->assigned, 1, 0);
|
||||
}
|
||||
}
|
||||
ASSERT(taosQueueItemSize(pInfo->iQueue) == 0);
|
||||
pIter = taosHashIterate(infoHash, pIter);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -479,6 +479,9 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
tqInitDataRsp(&dataRsp, pReq, pHandle->execHandle.subType);
|
||||
tqScanData(pTq, pHandle, &dataRsp, &fetchOffsetNew);
|
||||
|
||||
#if 1
|
||||
|
||||
#endif
|
||||
if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) {
|
||||
code = -1;
|
||||
}
|
||||
|
|
|
@ -25,17 +25,17 @@ int32_t tEncodeSTqHandle(SEncoder* pEncoder, const STqHandle* pHandle) {
|
|||
if (tEncodeI8(pEncoder, pHandle->execHandle.subType) < 0) return -1;
|
||||
if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||
if (tEncodeCStr(pEncoder, pHandle->execHandle.execCol.qmsg) < 0) return -1;
|
||||
} else if(pHandle->execHandle.subType == TOPIC_SUB_TYPE__DB){
|
||||
} else if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__DB) {
|
||||
int32_t size = taosHashGetSize(pHandle->execHandle.execDb.pFilterOutTbUid);
|
||||
if (tEncodeI32(pEncoder, size) < 0) return -1;
|
||||
void *pIter = NULL;
|
||||
void* pIter = NULL;
|
||||
pIter = taosHashIterate(pHandle->execHandle.execDb.pFilterOutTbUid, pIter);
|
||||
while(pIter){
|
||||
int64_t *tbUid = (int64_t *)taosHashGetKey(pIter, NULL);
|
||||
while (pIter) {
|
||||
int64_t* tbUid = (int64_t*)taosHashGetKey(pIter, NULL);
|
||||
if (tEncodeI64(pEncoder, *tbUid) < 0) return -1;
|
||||
pIter = taosHashIterate(pHandle->execHandle.execDb.pFilterOutTbUid, pIter);
|
||||
}
|
||||
} else if(pHandle->execHandle.subType == TOPIC_SUB_TYPE__TABLE){
|
||||
} else if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__TABLE) {
|
||||
if (tEncodeI64(pEncoder, pHandle->execHandle.execTb.suid) < 0) return -1;
|
||||
}
|
||||
tEndEncode(pEncoder);
|
||||
|
@ -52,17 +52,17 @@ int32_t tDecodeSTqHandle(SDecoder* pDecoder, STqHandle* pHandle) {
|
|||
if (tDecodeI8(pDecoder, &pHandle->execHandle.subType) < 0) return -1;
|
||||
if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||
if (tDecodeCStrAlloc(pDecoder, &pHandle->execHandle.execCol.qmsg) < 0) return -1;
|
||||
}else if(pHandle->execHandle.subType == TOPIC_SUB_TYPE__DB){
|
||||
} else if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__DB) {
|
||||
pHandle->execHandle.execDb.pFilterOutTbUid =
|
||||
taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
int32_t size = 0;
|
||||
if (tDecodeI32(pDecoder, &size) < 0) return -1;
|
||||
for(int32_t i = 0; i < size; i++){
|
||||
for (int32_t i = 0; i < size; i++) {
|
||||
int64_t tbUid = 0;
|
||||
if (tDecodeI64(pDecoder, &tbUid) < 0) return -1;
|
||||
taosHashPut(pHandle->execHandle.execDb.pFilterOutTbUid, &tbUid, sizeof(int64_t), NULL, 0);
|
||||
}
|
||||
} else if(pHandle->execHandle.subType == TOPIC_SUB_TYPE__TABLE){
|
||||
} else if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__TABLE) {
|
||||
if (tDecodeI64(pDecoder, &pHandle->execHandle.execTb.suid) < 0) return -1;
|
||||
}
|
||||
tEndDecode(pDecoder);
|
||||
|
@ -117,7 +117,7 @@ int32_t tqMetaSaveCheckInfo(STQ* pTq, const char* key, const void* value, int32_
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (tdbTbUpsert(pTq->pExecStore, key, strlen(key), value, vLen, &txn) < 0) {
|
||||
if (tdbTbUpsert(pTq->pCheckStore, key, strlen(key), value, vLen, &txn) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -284,7 +284,6 @@ int32_t tqMetaRestoreHandle(STQ* pTq) {
|
|||
};
|
||||
|
||||
if (handle.execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||
|
||||
handle.execHandle.task = qCreateQueueExecTaskInfo(
|
||||
handle.execHandle.execCol.qmsg, &reader, &handle.execHandle.numOfCols, &handle.execHandle.pSchemaWrapper);
|
||||
ASSERT(handle.execHandle.task);
|
||||
|
@ -297,9 +296,9 @@ int32_t tqMetaRestoreHandle(STQ* pTq) {
|
|||
handle.pWalReader = walOpenReader(pTq->pVnode->pWal, NULL);
|
||||
handle.execHandle.pExecReader = tqOpenReader(pTq->pVnode);
|
||||
|
||||
buildSnapContext(reader.meta, reader.version, 0, handle.execHandle.subType, handle.fetchMeta, (SSnapContext **)(&reader.sContext));
|
||||
handle.execHandle.task =
|
||||
qCreateQueueExecTaskInfo(NULL, &reader, NULL, NULL);
|
||||
buildSnapContext(reader.meta, reader.version, 0, handle.execHandle.subType, handle.fetchMeta,
|
||||
(SSnapContext**)(&reader.sContext));
|
||||
handle.execHandle.task = qCreateQueueExecTaskInfo(NULL, &reader, NULL, NULL);
|
||||
} else if (handle.execHandle.subType == TOPIC_SUB_TYPE__TABLE) {
|
||||
handle.pWalReader = walOpenReader(pTq->pVnode->pWal, NULL);
|
||||
|
||||
|
@ -314,9 +313,9 @@ int32_t tqMetaRestoreHandle(STQ* pTq) {
|
|||
tqReaderSetTbUidList(handle.execHandle.pExecReader, tbUidList);
|
||||
taosArrayDestroy(tbUidList);
|
||||
|
||||
buildSnapContext(reader.meta, reader.version, handle.execHandle.execTb.suid, handle.execHandle.subType, handle.fetchMeta, (SSnapContext **)(&reader.sContext));
|
||||
handle.execHandle.task =
|
||||
qCreateQueueExecTaskInfo(NULL, &reader, NULL, NULL);
|
||||
buildSnapContext(reader.meta, reader.version, handle.execHandle.execTb.suid, handle.execHandle.subType,
|
||||
handle.fetchMeta, (SSnapContext**)(&reader.sContext));
|
||||
handle.execHandle.task = qCreateQueueExecTaskInfo(NULL, &reader, NULL, NULL);
|
||||
}
|
||||
tqDebug("tq restore %s consumer %" PRId64 " vgId:%d", handle.subKey, handle.consumerId, TD_VID(pTq->pVnode));
|
||||
taosHashPut(pTq->pHandle, pKey, kLen, &handle, sizeof(STqHandle));
|
||||
|
|
|
@ -193,6 +193,8 @@ static int64_t getCurrentKeyInLastBlock(SLastBlockReader* pLastBlockReader
|
|||
static bool hasDataInLastBlock(SLastBlockReader* pLastBlockReader);
|
||||
static int32_t doBuildDataBlock(STsdbReader* pReader);
|
||||
static TSDBKEY getCurrentKeyInBuf(STableBlockScanInfo* pScanInfo, STsdbReader* pReader);
|
||||
static bool hasDataInFileBlock(const SBlockData* pBlockData, const SFileBlockDumpInfo* pDumpInfo);
|
||||
static bool hasDataInLastBlock(SLastBlockReader* pLastBlockReader);
|
||||
|
||||
static bool outOfTimeWindow(int64_t ts, STimeWindow* pWindow) { return (ts > pWindow->ekey) || (ts < pWindow->skey); }
|
||||
|
||||
|
@ -893,7 +895,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
|
|||
if (pData->cid < pColData->info.colId) {
|
||||
colIndex += 1;
|
||||
} else if (pData->cid == pColData->info.colId) {
|
||||
if (pData->flag == HAS_NONE || pData->flag == HAS_NULL) {
|
||||
if (pData->flag == HAS_NONE || pData->flag == HAS_NULL || pData->flag == (HAS_NULL|HAS_NONE)) {
|
||||
colDataAppendNNULL(pColData, 0, remain);
|
||||
} else {
|
||||
if (IS_NUMERIC_TYPE(pColData->info.type) && asc) {
|
||||
|
@ -1537,7 +1539,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
|
|||
minKey = k.ts;
|
||||
}
|
||||
|
||||
if (minKey > key && pBlockData->nRow > 0) {
|
||||
if (minKey > key && hasDataInFileBlock(pBlockData, pDumpInfo)) {
|
||||
minKey = key;
|
||||
}
|
||||
} else {
|
||||
|
@ -1550,7 +1552,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
|
|||
minKey = k.ts;
|
||||
}
|
||||
|
||||
if (minKey < key && pBlockData->nRow > 0) {
|
||||
if (minKey < key && hasDataInFileBlock(pBlockData, pDumpInfo)) {
|
||||
minKey = key;
|
||||
}
|
||||
}
|
||||
|
@ -1688,7 +1690,7 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader
|
|||
STableBlockScanInfo* pBlockScanInfo, SBlockData* pBlockData) {
|
||||
SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
|
||||
|
||||
if (pBlockData->nRow > 0) {
|
||||
if (hasDataInFileBlock(pBlockData, pDumpInfo)) {
|
||||
// no last block available, only data block exists
|
||||
if (!hasDataInLastBlock(pLastBlockReader)) {
|
||||
return mergeRowsInFileBlocks(pBlockData, pBlockScanInfo, key, pReader);
|
||||
|
@ -1753,7 +1755,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
|
|||
tsLast = getCurrentKeyInLastBlock(pLastBlockReader);
|
||||
}
|
||||
|
||||
int64_t key = pBlockData->aTSKEY[pDumpInfo->rowIndex];
|
||||
int64_t key = hasDataInFileBlock(pBlockData, pDumpInfo)? pBlockData->aTSKEY[pDumpInfo->rowIndex]:INT64_MIN;
|
||||
|
||||
TSDBKEY k = TSDBROW_KEY(pRow);
|
||||
TSDBKEY ik = TSDBROW_KEY(piRow);
|
||||
|
@ -1769,7 +1771,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
|
|||
minKey = ik.ts;
|
||||
}
|
||||
|
||||
if (minKey > key && pBlockData->nRow > 0) {
|
||||
if (minKey > key && hasDataInFileBlock(pBlockData, pDumpInfo)) {
|
||||
minKey = key;
|
||||
}
|
||||
|
||||
|
@ -1786,7 +1788,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
|
|||
minKey = ik.ts;
|
||||
}
|
||||
|
||||
if (minKey < key && pBlockData->nRow > 0) {
|
||||
if (minKey < key && hasDataInFileBlock(pBlockData, pDumpInfo)) {
|
||||
minKey = key;
|
||||
}
|
||||
|
||||
|
@ -2021,6 +2023,13 @@ static int64_t getCurrentKeyInLastBlock(SLastBlockReader* pLastBlockReader) {
|
|||
}
|
||||
|
||||
static bool hasDataInLastBlock(SLastBlockReader* pLastBlockReader) { return pLastBlockReader->mergeTree.pIter != NULL; }
|
||||
bool hasDataInFileBlock(const SBlockData* pBlockData, const SFileBlockDumpInfo* pDumpInfo) {
|
||||
if (pBlockData->nRow > 0) {
|
||||
ASSERT(pBlockData->nRow == pDumpInfo->totalRows);
|
||||
}
|
||||
|
||||
return pBlockData->nRow > 0 && (!pDumpInfo->allDumped);
|
||||
}
|
||||
|
||||
int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBlockScanInfo, int64_t key,
|
||||
STsdbReader* pReader) {
|
||||
|
@ -2052,7 +2061,7 @@ static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanI
|
|||
SBlockData* pBlockData, SLastBlockReader* pLastBlockReader) {
|
||||
SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
|
||||
|
||||
int64_t key = (pBlockData->nRow > 0) ? pBlockData->aTSKEY[pDumpInfo->rowIndex] : INT64_MIN;
|
||||
int64_t key = (pBlockData->nRow > 0 && (!pDumpInfo->allDumped)) ? pBlockData->aTSKEY[pDumpInfo->rowIndex] : INT64_MIN;
|
||||
if (pBlockScanInfo->iter.hasVal && pBlockScanInfo->iiter.hasVal) {
|
||||
return doMergeMultiLevelRows(pReader, pBlockScanInfo, pBlockData, pLastBlockReader);
|
||||
} else {
|
||||
|
@ -2664,8 +2673,11 @@ static STsdb* getTsdbByRetentions(SVnode* pVnode, TSKEY winSKey, SRetention* ret
|
|||
int8_t* pLevel) {
|
||||
if (VND_IS_RSMA(pVnode)) {
|
||||
int8_t level = 0;
|
||||
int64_t now = taosGetTimestamp(pVnode->config.tsdbCfg.precision);
|
||||
int64_t offset = TSDB_TICK_PER_SECOND(pVnode->config.tsdbCfg.precision);
|
||||
int8_t precision = pVnode->config.tsdbCfg.precision;
|
||||
int64_t now = taosGetTimestamp(precision);
|
||||
int64_t offset = tsQueryRsmaTolerance * ((precision == TSDB_TIME_PRECISION_MILLI) ? 1
|
||||
: (precision == TSDB_TIME_PRECISION_MICRO) ? 1000
|
||||
: 1000000);
|
||||
|
||||
for (int8_t i = 0; i < TSDB_RETENTION_MAX; ++i) {
|
||||
SRetention* pRetention = retentions + level;
|
||||
|
@ -3290,9 +3302,31 @@ void* tsdbGetIvtIdx(SMeta* pMeta) {
|
|||
|
||||
uint64_t getReaderMaxVersion(STsdbReader* pReader) { return pReader->verRange.maxVer; }
|
||||
|
||||
|
||||
static int32_t doOpenReaderImpl(STsdbReader* pReader) {
|
||||
SDataBlockIter* pBlockIter = &pReader->status.blockIter;
|
||||
|
||||
initFilesetIterator(&pReader->status.fileIter, pReader->pReadSnap->fs.aDFileSet, pReader);
|
||||
resetDataBlockIterator(&pReader->status.blockIter, pReader->order);
|
||||
|
||||
// no data in files, let's try buffer in memory
|
||||
if (pReader->status.fileIter.numOfFiles == 0) {
|
||||
pReader->status.loadFromFile = false;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
} else {
|
||||
return initForFirstBlockInFile(pReader, pBlockIter);
|
||||
}
|
||||
}
|
||||
|
||||
// ====================================== EXPOSED APIs ======================================
|
||||
int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTableList, STsdbReader** ppReader,
|
||||
const char* idstr) {
|
||||
STimeWindow window = pCond->twindows;
|
||||
if (pCond->type == TIMEWINDOW_RANGE_EXTERNAL) {
|
||||
pCond->twindows.skey += 1;
|
||||
pCond->twindows.ekey -= 1;
|
||||
}
|
||||
|
||||
int32_t code = tsdbReaderCreate(pVnode, pCond, ppReader, 4096, idstr);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _err;
|
||||
|
@ -3300,21 +3334,20 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
|
|||
|
||||
// check for query time window
|
||||
STsdbReader* pReader = *ppReader;
|
||||
if (isEmptyQueryTimeWindow(&pReader->window)) {
|
||||
if (isEmptyQueryTimeWindow(&pReader->window) && pCond->type == TIMEWINDOW_RANGE_CONTAINED) {
|
||||
tsdbDebug("%p query window not overlaps with the data set, no result returned, %s", pReader, pReader->idStr);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if (pCond->type == TIMEWINDOW_RANGE_EXTERNAL) {
|
||||
// update the SQueryTableDataCond to create inner reader
|
||||
STimeWindow w = pCond->twindows;
|
||||
int32_t order = pCond->order;
|
||||
int32_t order = pCond->order;
|
||||
if (order == TSDB_ORDER_ASC) {
|
||||
pCond->twindows.ekey = pCond->twindows.skey;
|
||||
pCond->twindows.ekey = window.skey;
|
||||
pCond->twindows.skey = INT64_MIN;
|
||||
pCond->order = TSDB_ORDER_DESC;
|
||||
} else {
|
||||
pCond->twindows.skey = pCond->twindows.ekey;
|
||||
pCond->twindows.skey = window.ekey;
|
||||
pCond->twindows.ekey = INT64_MAX;
|
||||
pCond->order = TSDB_ORDER_ASC;
|
||||
}
|
||||
|
@ -3326,12 +3359,14 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
|
|||
}
|
||||
|
||||
if (order == TSDB_ORDER_ASC) {
|
||||
pCond->twindows.skey = w.ekey;
|
||||
pCond->twindows.skey = window.ekey;
|
||||
pCond->twindows.ekey = INT64_MAX;
|
||||
} else {
|
||||
pCond->twindows.skey = INT64_MIN;
|
||||
pCond->twindows.ekey = w.ekey;
|
||||
pCond->twindows.ekey = window.ekey;
|
||||
}
|
||||
pCond->order = order;
|
||||
|
||||
code = tsdbReaderCreate(pVnode, pCond, &pReader->innerReader[1], 1, idstr);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _err;
|
||||
|
@ -3340,20 +3375,22 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
|
|||
|
||||
// NOTE: the endVersion in pCond is the data version not schema version, so pCond->endVersion is not correct here.
|
||||
if (pCond->suid != 0) {
|
||||
pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pReader->suid, /*pCond->endVersion*/ -1);
|
||||
pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pReader->suid, -1);
|
||||
if (pReader->pSchema == NULL) {
|
||||
tsdbError("failed to get table schema, suid:%"PRIu64", ver:%"PRId64" , %s", pReader->suid, -1, pReader->idStr);
|
||||
}
|
||||
} else if (taosArrayGetSize(pTableList) > 0) {
|
||||
STableKeyInfo* pKey = taosArrayGet(pTableList, 0);
|
||||
pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pKey->uid, /*pCond->endVersion*/ -1);
|
||||
pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pKey->uid, -1);
|
||||
if (pReader->pSchema == NULL) {
|
||||
tsdbError("failed to get table schema, uid:%"PRIu64", ver:%"PRId64" , %s", pKey->uid, -1, pReader->idStr);
|
||||
}
|
||||
}
|
||||
|
||||
STsdbReader* p = pReader->innerReader[0] != NULL? pReader->innerReader[0]:pReader;
|
||||
|
||||
int32_t numOfTables = taosArrayGetSize(pTableList);
|
||||
pReader->status.pTableMap = createDataBlockScanInfo(pReader, pTableList->pData, numOfTables);
|
||||
pReader->status.pTableMap = createDataBlockScanInfo(p, pTableList->pData, numOfTables);
|
||||
if (pReader->status.pTableMap == NULL) {
|
||||
tsdbReaderClose(pReader);
|
||||
*ppReader = NULL;
|
||||
|
@ -3368,40 +3405,36 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
|
|||
}
|
||||
|
||||
if (pReader->type == TIMEWINDOW_RANGE_CONTAINED) {
|
||||
SDataBlockIter* pBlockIter = &pReader->status.blockIter;
|
||||
|
||||
initFilesetIterator(&pReader->status.fileIter, pReader->pReadSnap->fs.aDFileSet, pReader);
|
||||
resetDataBlockIterator(&pReader->status.blockIter, pReader->order);
|
||||
|
||||
// no data in files, let's try buffer in memory
|
||||
if (pReader->status.fileIter.numOfFiles == 0) {
|
||||
pReader->status.loadFromFile = false;
|
||||
} else {
|
||||
code = initForFirstBlockInFile(pReader, pBlockIter);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
code = doOpenReaderImpl(pReader);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
} else {
|
||||
STsdbReader* pPrevReader = pReader->innerReader[0];
|
||||
SDataBlockIter* pBlockIter = &pPrevReader->status.blockIter;
|
||||
STsdbReader* pPrevReader = pReader->innerReader[0];
|
||||
STsdbReader* pNextReader = pReader->innerReader[1];
|
||||
|
||||
code = tsdbTakeReadSnap(pPrevReader->pTsdb, &pPrevReader->pReadSnap, pReader->idStr);
|
||||
// we need only one row
|
||||
pPrevReader->capacity = 1;
|
||||
pPrevReader->status.pTableMap = pReader->status.pTableMap;
|
||||
pPrevReader->pReadSnap = pReader->pReadSnap;
|
||||
|
||||
pNextReader->capacity = 1;
|
||||
pNextReader->status.pTableMap = pReader->status.pTableMap;
|
||||
pNextReader->pReadSnap = pReader->pReadSnap;
|
||||
|
||||
code = doOpenReaderImpl(pPrevReader);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _err;
|
||||
return code;
|
||||
}
|
||||
|
||||
initFilesetIterator(&pPrevReader->status.fileIter, pPrevReader->pReadSnap->fs.aDFileSet, pPrevReader);
|
||||
resetDataBlockIterator(&pPrevReader->status.blockIter, pPrevReader->order);
|
||||
code = doOpenReaderImpl(pNextReader);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
||||
// no data in files, let's try buffer in memory
|
||||
if (pPrevReader->status.fileIter.numOfFiles == 0) {
|
||||
pPrevReader->status.loadFromFile = false;
|
||||
} else {
|
||||
code = initForFirstBlockInFile(pPrevReader, pBlockIter);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
code = doOpenReaderImpl(pReader);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3418,6 +3451,19 @@ void tsdbReaderClose(STsdbReader* pReader) {
|
|||
return;
|
||||
}
|
||||
|
||||
{
|
||||
if (pReader->innerReader[0] != NULL) {
|
||||
pReader->innerReader[0]->status.pTableMap = NULL;
|
||||
pReader->innerReader[0]->pReadSnap = NULL;
|
||||
|
||||
pReader->innerReader[1]->status.pTableMap = NULL;
|
||||
pReader->innerReader[1]->pReadSnap = NULL;
|
||||
|
||||
tsdbReaderClose(pReader->innerReader[0]);
|
||||
tsdbReaderClose(pReader->innerReader[1]);
|
||||
}
|
||||
}
|
||||
|
||||
SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo;
|
||||
|
||||
taosMemoryFreeClear(pSupInfo->plist);
|
||||
|
@ -3508,32 +3554,32 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (pReader->innerReader[0] != NULL) {
|
||||
if (pReader->innerReader[0] != NULL && pReader->step == 0) {
|
||||
bool ret = doTsdbNextDataBlock(pReader->innerReader[0]);
|
||||
resetDataBlockScanInfo(pReader->innerReader[0]->status.pTableMap, pReader->innerReader[0]->window.ekey);
|
||||
pReader->step = EXTERNAL_ROWS_PREV;
|
||||
|
||||
if (ret) {
|
||||
pReader->step = EXTERNAL_ROWS_PREV;
|
||||
return ret;
|
||||
}
|
||||
|
||||
tsdbReaderClose(pReader->innerReader[0]);
|
||||
pReader->innerReader[0] = NULL;
|
||||
}
|
||||
|
||||
pReader->step = EXTERNAL_ROWS_MAIN;
|
||||
if (pReader->step == EXTERNAL_ROWS_PREV) {
|
||||
pReader->step = EXTERNAL_ROWS_MAIN;
|
||||
}
|
||||
|
||||
bool ret = doTsdbNextDataBlock(pReader);
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (pReader->innerReader[1] != NULL) {
|
||||
if (pReader->innerReader[1] != NULL && pReader->step == EXTERNAL_ROWS_MAIN) {
|
||||
resetDataBlockScanInfo(pReader->innerReader[1]->status.pTableMap, pReader->window.ekey);
|
||||
bool ret1 = doTsdbNextDataBlock(pReader->innerReader[1]);
|
||||
pReader->step = EXTERNAL_ROWS_NEXT;
|
||||
if (ret1) {
|
||||
pReader->step = EXTERNAL_ROWS_NEXT;
|
||||
return ret1;
|
||||
}
|
||||
|
||||
tsdbReaderClose(pReader->innerReader[1]);
|
||||
pReader->innerReader[1] = NULL;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -764,9 +764,9 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
|||
}
|
||||
case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE: {
|
||||
SExchangePhysiNode *pExchNode = (SExchangePhysiNode *)pNode;
|
||||
SExplainGroup *group = taosHashGet(ctx->groupHash, &pExchNode->srcGroupId, sizeof(pExchNode->srcGroupId));
|
||||
SExplainGroup *group = taosHashGet(ctx->groupHash, &pExchNode->srcStartGroupId, sizeof(pExchNode->srcStartGroupId));
|
||||
if (NULL == group) {
|
||||
qError("exchange src group %d not in groupHash", pExchNode->srcGroupId);
|
||||
qError("exchange src group %d not in groupHash", pExchNode->srcStartGroupId);
|
||||
QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||
}
|
||||
|
||||
|
@ -801,7 +801,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
|||
}
|
||||
}
|
||||
|
||||
QRY_ERR_RET(qExplainAppendGroupResRows(ctx, pExchNode->srcGroupId, level + 1));
|
||||
QRY_ERR_RET(qExplainAppendGroupResRows(ctx, pExchNode->srcStartGroupId, level + 1));
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_PHYSICAL_PLAN_SORT: {
|
||||
|
|
|
@ -49,6 +49,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
|
|||
|
||||
SStreamScanInfo* pInfo = pOperator->info;
|
||||
|
||||
#if 0
|
||||
// TODO: if a block was set but not consumed,
|
||||
// prevent setting a different type of block
|
||||
pInfo->validBlockIndex = 0;
|
||||
|
@ -57,6 +58,10 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
|
|||
} else {
|
||||
taosArrayClear(pInfo->pBlockLists);
|
||||
}
|
||||
#endif
|
||||
|
||||
ASSERT(pInfo->validBlockIndex == 0);
|
||||
ASSERT(taosArrayGetSize(pInfo->pBlockLists) == 0);
|
||||
|
||||
if (type == STREAM_INPUT__MERGED_SUBMIT) {
|
||||
// ASSERT(numOfBlocks > 1);
|
||||
|
@ -79,7 +84,9 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
|
|||
} else if (type == STREAM_INPUT__DATA_BLOCK) {
|
||||
for (int32_t i = 0; i < numOfBlocks; ++i) {
|
||||
SSDataBlock* pDataBlock = &((SSDataBlock*)input)[i];
|
||||
taosArrayPush(pInfo->pBlockLists, &pDataBlock);
|
||||
|
||||
#if 0
|
||||
// TODO optimize
|
||||
SSDataBlock* p = createOneDataBlock(pDataBlock, false);
|
||||
p->info = pDataBlock->info;
|
||||
|
@ -87,6 +94,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
|
|||
taosArrayClear(p->pDataBlock);
|
||||
taosArrayAddAll(p->pDataBlock, pDataBlock->pDataBlock);
|
||||
taosArrayPush(pInfo->pBlockLists, &p);
|
||||
#endif
|
||||
}
|
||||
pInfo->blockType = STREAM_INPUT__DATA_BLOCK;
|
||||
} else {
|
||||
|
@ -100,6 +108,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
|
|||
static FORCE_INLINE void streamInputBlockDataDestory(void* pBlock) { blockDataDestroy((SSDataBlock*)pBlock); }
|
||||
|
||||
void tdCleanupStreamInputDataBlock(qTaskInfo_t tinfo) {
|
||||
#if 0
|
||||
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
||||
if (!pTaskInfo || !pTaskInfo->pRoot || pTaskInfo->pRoot->numOfDownstream <= 0) {
|
||||
return;
|
||||
|
@ -116,6 +125,7 @@ void tdCleanupStreamInputDataBlock(qTaskInfo_t tinfo) {
|
|||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numOfBlocks, int32_t type) {
|
||||
|
|
|
@ -81,11 +81,6 @@ static UNUSED_FUNC void* u_realloc(void* p, size_t __size) {
|
|||
|
||||
int32_t getMaximumIdleDurationSec() { return tsShellActivityTimer * 2; }
|
||||
|
||||
static int32_t getExprFunctionId(SExprInfo* pExprInfo) {
|
||||
assert(pExprInfo != NULL && pExprInfo->pExpr != NULL && pExprInfo->pExpr->nodeType == TEXPR_UNARYEXPR_NODE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExpr, SSDataBlock* pBlock);
|
||||
|
||||
static void releaseQueryBuf(size_t numOfTables);
|
||||
|
@ -1115,7 +1110,7 @@ void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numO
|
|||
}
|
||||
}
|
||||
|
||||
static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowRes, bool keep);
|
||||
static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, bool keep, int32_t status);
|
||||
|
||||
void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, const SArray* pColMatchInfo) {
|
||||
if (pFilterNode == NULL || pBlock->info.rows == 0) {
|
||||
|
@ -1126,18 +1121,17 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, const SArray* pColM
|
|||
|
||||
// todo move to the initialization function
|
||||
int32_t code = filterInitFromNode((SNode*)pFilterNode, &filter, 0);
|
||||
|
||||
size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock);
|
||||
SFilterColumnParam param1 = {.numOfCols = numOfCols, .pDataBlock = pBlock->pDataBlock};
|
||||
SFilterColumnParam param1 = {.numOfCols = taosArrayGetSize(pBlock->pDataBlock), .pDataBlock = pBlock->pDataBlock};
|
||||
code = filterSetDataFromSlotId(filter, ¶m1);
|
||||
|
||||
int8_t* rowRes = NULL;
|
||||
SColumnInfoData* p = NULL;
|
||||
int32_t status = 0;
|
||||
|
||||
// todo the keep seems never to be True??
|
||||
bool keep = filterExecute(filter, pBlock, &rowRes, NULL, param1.numOfCols);
|
||||
bool keep = filterExecute(filter, pBlock, &p, NULL, param1.numOfCols, &status);
|
||||
filterFreeInfo(filter);
|
||||
|
||||
extractQualifiedTupleByFilterResult(pBlock, rowRes, keep);
|
||||
extractQualifiedTupleByFilterResult(pBlock, p, keep, status);
|
||||
|
||||
if (pColMatchInfo != NULL) {
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pColMatchInfo); ++i) {
|
||||
|
@ -1152,16 +1146,22 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, const SArray* pColM
|
|||
}
|
||||
}
|
||||
|
||||
taosMemoryFree(rowRes);
|
||||
colDataDestroy(p);
|
||||
taosMemoryFree(p);
|
||||
}
|
||||
|
||||
void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowRes, bool keep) {
|
||||
void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, bool keep, int32_t status) {
|
||||
if (keep) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (rowRes != NULL) {
|
||||
int32_t totalRows = pBlock->info.rows;
|
||||
int32_t totalRows = pBlock->info.rows;
|
||||
|
||||
if (status == FILTER_RESULT_ALL_QUALIFIED) {
|
||||
// here nothing needs to be done
|
||||
} else if (status == FILTER_RESULT_NONE_QUALIFIED) {
|
||||
pBlock->info.rows = 0;
|
||||
} else {
|
||||
SSDataBlock* px = createOneDataBlock(pBlock, true);
|
||||
|
||||
size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock);
|
||||
|
@ -1177,7 +1177,7 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowR
|
|||
|
||||
int32_t numOfRows = 0;
|
||||
for (int32_t j = 0; j < totalRows; ++j) {
|
||||
if (rowRes[j] == 0) {
|
||||
if (((int8_t*)p->pData)[j] == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1189,6 +1189,7 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowR
|
|||
numOfRows += 1;
|
||||
}
|
||||
|
||||
// todo this value can be assigned directly
|
||||
if (pBlock->info.rows == totalRows) {
|
||||
pBlock->info.rows = numOfRows;
|
||||
} else {
|
||||
|
@ -1197,13 +1198,10 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowR
|
|||
}
|
||||
|
||||
blockDataDestroy(px); // fix memory leak
|
||||
} else {
|
||||
// do nothing
|
||||
pBlock->info.rows = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId) {
|
||||
void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId) {
|
||||
// for simple group by query without interval, all the tables belong to one group result.
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
SAggOperatorInfo* pAggInfo = pOperator->info;
|
||||
|
@ -4246,10 +4244,10 @@ int32_t buildDataBlockFromGroupRes(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock
|
|||
|
||||
pCtx[j].resultInfo = getResultEntryInfo(pRow, j, rowEntryOffset);
|
||||
if (pCtx[j].fpSet.finalize) {
|
||||
int32_t code = pCtx[j].fpSet.finalize(&pCtx[j], pBlock);
|
||||
if (TAOS_FAILED(code)) {
|
||||
qError("%s build result data block error, code %s", GET_TASKID(pTaskInfo), tstrerror(code));
|
||||
T_LONG_JMP(pTaskInfo->env, code);
|
||||
int32_t code1 = pCtx[j].fpSet.finalize(&pCtx[j], pBlock);
|
||||
if (TAOS_FAILED(code1)) {
|
||||
qError("%s build result data block error, code %s", GET_TASKID(pTaskInfo), tstrerror(code1));
|
||||
T_LONG_JMP(pTaskInfo->env, code1);
|
||||
}
|
||||
} else if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_select_value") == 0) {
|
||||
// do nothing, todo refactor
|
||||
|
|
|
@ -920,6 +920,19 @@ _error:
|
|||
}
|
||||
|
||||
static void doClearBufferedBlocks(SStreamScanInfo* pInfo) {
|
||||
#if 0
|
||||
if (pInfo->blockType == STREAM_INPUT__DATA_BLOCK) {
|
||||
size_t total = taosArrayGetSize(pInfo->pBlockLists);
|
||||
for (int32_t i = 0; i < total; i++) {
|
||||
SSDataBlock* p = taosArrayGetP(pInfo->pBlockLists, i);
|
||||
taosArrayDestroy(p->pDataBlock);
|
||||
taosMemoryFree(p);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
taosArrayClear(pInfo->pBlockLists);
|
||||
pInfo->validBlockIndex = 0;
|
||||
#if 0
|
||||
size_t total = taosArrayGetSize(pInfo->pBlockLists);
|
||||
|
||||
pInfo->validBlockIndex = 0;
|
||||
|
@ -928,6 +941,7 @@ static void doClearBufferedBlocks(SStreamScanInfo* pInfo) {
|
|||
blockDataDestroy(p);
|
||||
}
|
||||
taosArrayClear(pInfo->pBlockLists);
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool isSessionWindow(SStreamScanInfo* pInfo) {
|
||||
|
@ -1580,9 +1594,10 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
|
|||
|
||||
size_t total = taosArrayGetSize(pInfo->pBlockLists);
|
||||
// TODO: refactor
|
||||
FETCH_NEXT_BLOCK:
|
||||
if (pInfo->blockType == STREAM_INPUT__DATA_BLOCK) {
|
||||
if (pInfo->validBlockIndex >= total) {
|
||||
/*doClearBufferedBlocks(pInfo);*/
|
||||
doClearBufferedBlocks(pInfo);
|
||||
/*pOperator->status = OP_EXEC_DONE;*/
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1606,27 +1621,40 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
|
|||
} break;
|
||||
case STREAM_DELETE_DATA: {
|
||||
printDataBlock(pBlock, "stream scan delete recv");
|
||||
SSDataBlock* pDelBlock = NULL;
|
||||
if (pInfo->tqReader) {
|
||||
SSDataBlock* pDelBlock = createSpecialDataBlock(STREAM_DELETE_DATA);
|
||||
pDelBlock = createSpecialDataBlock(STREAM_DELETE_DATA);
|
||||
filterDelBlockByUid(pDelBlock, pBlock, pInfo);
|
||||
pBlock = pDelBlock;
|
||||
} else {
|
||||
pDelBlock = pBlock;
|
||||
}
|
||||
printDataBlock(pBlock, "stream scan delete recv filtered");
|
||||
if (!isIntervalWindow(pInfo) && !isSessionWindow(pInfo) && !isStateWindow(pInfo)) {
|
||||
generateDeleteResultBlock(pInfo, pBlock, pInfo->pDeleteDataRes);
|
||||
generateDeleteResultBlock(pInfo, pDelBlock, pInfo->pDeleteDataRes);
|
||||
pInfo->pDeleteDataRes->info.type = STREAM_DELETE_RESULT;
|
||||
printDataBlock(pBlock, "stream scan delete result");
|
||||
return pInfo->pDeleteDataRes;
|
||||
printDataBlock(pDelBlock, "stream scan delete result");
|
||||
if (pInfo->pDeleteDataRes->info.rows > 0) {
|
||||
return pInfo->pDeleteDataRes;
|
||||
} else {
|
||||
goto FETCH_NEXT_BLOCK;
|
||||
}
|
||||
} else {
|
||||
pInfo->blockType = STREAM_INPUT__DATA_SUBMIT;
|
||||
pInfo->updateResIndex = 0;
|
||||
generateScanRange(pInfo, pBlock, pInfo->pUpdateRes);
|
||||
generateScanRange(pInfo, pDelBlock, pInfo->pUpdateRes);
|
||||
prepareRangeScan(pInfo, pInfo->pUpdateRes, &pInfo->updateResIndex);
|
||||
copyDataBlock(pInfo->pDeleteDataRes, pInfo->pUpdateRes);
|
||||
pInfo->pDeleteDataRes->info.type = STREAM_DELETE_DATA;
|
||||
pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER_RANGE;
|
||||
printDataBlock(pBlock, "stream scan delete data");
|
||||
return pInfo->pDeleteDataRes;
|
||||
printDataBlock(pDelBlock, "stream scan delete data");
|
||||
if (pInfo->tqReader) {
|
||||
blockDataDestroy(pDelBlock);
|
||||
}
|
||||
if (pInfo->pDeleteDataRes->info.rows > 0) {
|
||||
return pInfo->pDeleteDataRes;
|
||||
} else {
|
||||
goto FETCH_NEXT_BLOCK;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
|
@ -1688,10 +1716,12 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
|
|||
|
||||
int32_t totBlockNum = taosArrayGetSize(pInfo->pBlockLists);
|
||||
|
||||
NEXT_SUBMIT_BLK:
|
||||
while (1) {
|
||||
if (pInfo->tqReader->pMsg == NULL) {
|
||||
if (pInfo->validBlockIndex >= totBlockNum) {
|
||||
updateInfoDestoryColseWinSBF(pInfo->pUpdateInfo);
|
||||
doClearBufferedBlocks(pInfo);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1763,7 +1793,12 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
|
|||
}
|
||||
|
||||
qDebug("scan rows: %d", pBlockInfo->rows);
|
||||
return (pBlockInfo->rows == 0) ? NULL : pInfo->pRes;
|
||||
if (pBlockInfo->rows > 0) {
|
||||
return pInfo->pRes;
|
||||
} else {
|
||||
goto NEXT_SUBMIT_BLK;
|
||||
}
|
||||
/*return (pBlockInfo->rows == 0) ? NULL : pInfo->pRes;*/
|
||||
} else {
|
||||
ASSERT(0);
|
||||
return NULL;
|
||||
|
|
|
@ -2075,7 +2075,7 @@ static void doKeepLinearInfo(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlo
|
|||
}
|
||||
}
|
||||
|
||||
pSliceInfo->fillLastPoint = isLastRow ? true : false;
|
||||
pSliceInfo->fillLastPoint = isLastRow;
|
||||
}
|
||||
|
||||
static void genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp* pExprSup, SSDataBlock* pResBlock) {
|
||||
|
@ -2294,15 +2294,6 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
|
|||
SSDataBlock* pResBlock = pSliceInfo->pRes;
|
||||
SExprSupp* pSup = &pOperator->exprSupp;
|
||||
|
||||
// if (pOperator->status == OP_RES_TO_RETURN) {
|
||||
// // doBuildResultDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pIntervalInfo->pRes);
|
||||
// if (pResBlock->info.rows == 0 || !hasRemainResults(&pSliceInfo->groupResInfo)) {
|
||||
// doSetOperatorCompleted(pOperator);
|
||||
// }
|
||||
//
|
||||
// return pResBlock;
|
||||
// }
|
||||
|
||||
int32_t order = TSDB_ORDER_ASC;
|
||||
SInterval* pInterval = &pSliceInfo->interval;
|
||||
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
||||
|
@ -2432,6 +2423,9 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// store ts value as start, and calculate interp value when processing next block
|
||||
doKeepLinearInfo(pSliceInfo, pBlock, i, true);
|
||||
}
|
||||
} else { // non-linear interpolation
|
||||
if (i < pBlock->info.rows - 1) {
|
||||
|
@ -2510,6 +2504,9 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else { // it is the last row of current block
|
||||
// store ts value as start, and calculate interp value when processing next block
|
||||
doKeepLinearInfo(pSliceInfo, pBlock, i, true);
|
||||
}
|
||||
} else { // non-linear interpolation
|
||||
pSliceInfo->current =
|
||||
|
@ -2615,6 +2612,10 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode
|
|||
pInfo->interval.interval = pInterpPhyNode->interval;
|
||||
pInfo->current = pInfo->win.skey;
|
||||
|
||||
STableScanInfo* pScanInfo = (STableScanInfo*)downstream->info;
|
||||
pScanInfo->cond.twindows = pInfo->win;
|
||||
pScanInfo->cond.type = TIMEWINDOW_RANGE_EXTERNAL;
|
||||
|
||||
pOperator->name = "TimeSliceOperator";
|
||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC;
|
||||
pOperator->blocking = false;
|
||||
|
@ -5657,7 +5658,6 @@ static void doStreamIntervalAggImpl2(SOperatorInfo* pOperatorInfo, SSDataBlock*
|
|||
TSKEY* tsCols = NULL;
|
||||
SResultRow* pResult = NULL;
|
||||
int32_t forwardRows = 0;
|
||||
int32_t aa = 4;
|
||||
|
||||
ASSERT(pSDataBlock->pDataBlock != NULL);
|
||||
SColumnInfoData* pColDataInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex);
|
||||
|
|
|
@ -26,11 +26,6 @@ typedef struct SFuncMgtService {
|
|||
SHashObj* pFuncNameHashTable;
|
||||
} SFuncMgtService;
|
||||
|
||||
typedef struct SUdfInfo {
|
||||
SDataType outputDt;
|
||||
int8_t funcType;
|
||||
} SUdfInfo;
|
||||
|
||||
static SFuncMgtService gFunMgtService;
|
||||
static TdThreadOnce functionHashTableInit = PTHREAD_ONCE_INIT;
|
||||
static int32_t initFunctionCode = 0;
|
||||
|
|
|
@ -324,6 +324,21 @@ static int32_t fillNodeCopy(const SFillNode* pSrc, SFillNode* pDst) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t whenThenNodeCopy(const SWhenThenNode* pSrc, SWhenThenNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, exprNodeCopy);
|
||||
CLONE_NODE_FIELD(pWhen);
|
||||
CLONE_NODE_FIELD(pThen);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t caseWhenNodeCopy(const SCaseWhenNode* pSrc, SCaseWhenNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, exprNodeCopy);
|
||||
CLONE_NODE_FIELD(pCase);
|
||||
CLONE_NODE_FIELD(pElse);
|
||||
CLONE_NODE_LIST_FIELD(pWhenThenList);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t logicNodeCopy(const SLogicNode* pSrc, SLogicNode* pDst) {
|
||||
CLONE_NODE_LIST_FIELD(pTargets);
|
||||
CLONE_NODE_FIELD(pConditions);
|
||||
|
@ -414,7 +429,8 @@ static int32_t logicVnodeModifCopy(const SVnodeModifyLogicNode* pSrc, SVnodeModi
|
|||
|
||||
static int32_t logicExchangeCopy(const SExchangeLogicNode* pSrc, SExchangeLogicNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||
COPY_SCALAR_FIELD(srcGroupId);
|
||||
COPY_SCALAR_FIELD(srcStartGroupId);
|
||||
COPY_SCALAR_FIELD(srcEndGroupId);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -711,6 +727,12 @@ SNode* nodesCloneNode(const SNode* pNode) {
|
|||
case QUERY_NODE_LEFT_VALUE:
|
||||
code = TSDB_CODE_SUCCESS;
|
||||
break;
|
||||
case QUERY_NODE_WHEN_THEN:
|
||||
code = whenThenNodeCopy((const SWhenThenNode*)pNode, (SWhenThenNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_CASE_WHEN:
|
||||
code = caseWhenNodeCopy((const SCaseWhenNode*)pNode, (SCaseWhenNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_SELECT_STMT:
|
||||
code = selectStmtCopy((const SSelectStmt*)pNode, (SSelectStmt*)pDst);
|
||||
break;
|
||||
|
|
|
@ -81,6 +81,10 @@ const char* nodesNodeName(ENodeType type) {
|
|||
return "IndexOptions";
|
||||
case QUERY_NODE_LEFT_VALUE:
|
||||
return "LeftValue";
|
||||
case QUERY_NODE_WHEN_THEN:
|
||||
return "WhenThen";
|
||||
case QUERY_NODE_CASE_WHEN:
|
||||
return "CaseWhen";
|
||||
case QUERY_NODE_SET_OPERATOR:
|
||||
return "SetOperator";
|
||||
case QUERY_NODE_SELECT_STMT:
|
||||
|
@ -722,14 +726,18 @@ static int32_t jsonToLogicVnodeModifyNode(const SJson* pJson, void* pObj) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static const char* jkExchangeLogicPlanSrcGroupId = "SrcGroupId";
|
||||
static const char* jkExchangeLogicPlanSrcStartGroupId = "SrcStartGroupId";
|
||||
static const char* jkExchangeLogicPlanSrcEndGroupId = "SrcEndGroupId";
|
||||
|
||||
static int32_t logicExchangeNodeToJson(const void* pObj, SJson* pJson) {
|
||||
const SExchangeLogicNode* pNode = (const SExchangeLogicNode*)pObj;
|
||||
|
||||
int32_t code = logicPlanNodeToJson(pObj, pJson);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkExchangeLogicPlanSrcGroupId, pNode->srcGroupId);
|
||||
code = tjsonAddIntegerToObject(pJson, jkExchangeLogicPlanSrcStartGroupId, pNode->srcStartGroupId);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkExchangeLogicPlanSrcEndGroupId, pNode->srcEndGroupId);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -740,7 +748,10 @@ static int32_t jsonToLogicExchangeNode(const SJson* pJson, void* pObj) {
|
|||
|
||||
int32_t code = jsonToLogicPlanNode(pJson, pObj);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetIntValue(pJson, jkExchangeLogicPlanSrcGroupId, &pNode->srcGroupId);
|
||||
code = tjsonGetIntValue(pJson, jkExchangeLogicPlanSrcStartGroupId, &pNode->srcStartGroupId);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetIntValue(pJson, jkExchangeLogicPlanSrcEndGroupId, &pNode->srcEndGroupId);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -1833,7 +1844,8 @@ static int32_t jsonToPhysiAggNode(const SJson* pJson, void* pObj) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static const char* jkExchangePhysiPlanSrcGroupId = "SrcGroupId";
|
||||
static const char* jkExchangePhysiPlanSrcStartGroupId = "SrcStartGroupId";
|
||||
static const char* jkExchangePhysiPlanSrcEndGroupId = "SrcEndGroupId";
|
||||
static const char* jkExchangePhysiPlanSrcEndPoints = "SrcEndPoints";
|
||||
|
||||
static int32_t physiExchangeNodeToJson(const void* pObj, SJson* pJson) {
|
||||
|
@ -1841,7 +1853,10 @@ static int32_t physiExchangeNodeToJson(const void* pObj, SJson* pJson) {
|
|||
|
||||
int32_t code = physicPlanNodeToJson(pObj, pJson);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkExchangePhysiPlanSrcGroupId, pNode->srcGroupId);
|
||||
code = tjsonAddIntegerToObject(pJson, jkExchangePhysiPlanSrcStartGroupId, pNode->srcStartGroupId);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkExchangePhysiPlanSrcEndGroupId, pNode->srcEndGroupId);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodeListToJson(pJson, jkExchangePhysiPlanSrcEndPoints, pNode->pSrcEndPoints);
|
||||
|
@ -1855,7 +1870,10 @@ static int32_t jsonToPhysiExchangeNode(const SJson* pJson, void* pObj) {
|
|||
|
||||
int32_t code = jsonToPhysicPlanNode(pJson, pObj);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetIntValue(pJson, jkExchangePhysiPlanSrcGroupId, &pNode->srcGroupId);
|
||||
code = tjsonGetIntValue(pJson, jkExchangePhysiPlanSrcStartGroupId, &pNode->srcStartGroupId);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetIntValue(pJson, jkExchangePhysiPlanSrcEndGroupId, &pNode->srcEndGroupId);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeList(pJson, jkExchangePhysiPlanSrcEndPoints, &pNode->pSrcEndPoints);
|
||||
|
@ -3917,6 +3935,75 @@ static int32_t jsonToDatabaseOptions(const SJson* pJson, void* pObj) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static const char* jkWhenThenWhen = "When";
|
||||
static const char* jkWhenThenThen = "Then";
|
||||
|
||||
static int32_t whenThenNodeToJson(const void* pObj, SJson* pJson) {
|
||||
const SWhenThenNode* pNode = (const SWhenThenNode*)pObj;
|
||||
|
||||
int32_t code = exprNodeToJson(pObj, pJson);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkWhenThenWhen, nodeToJson, pNode->pWhen);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkWhenThenThen, nodeToJson, pNode->pThen);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t jsonToWhenThenNode(const SJson* pJson, void* pObj) {
|
||||
SWhenThenNode* pNode = (SWhenThenNode*)pObj;
|
||||
|
||||
int32_t code = jsonToExprNode(pJson, pObj);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeObject(pJson, jkWhenThenWhen, &pNode->pWhen);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeObject(pJson, jkWhenThenThen, &pNode->pThen);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static const char* jkCaseWhenCase = "Case";
|
||||
static const char* jkCaseWhenWhenThenList = "WhenThenList";
|
||||
static const char* jkCaseWhenElse = "Else";
|
||||
|
||||
static int32_t caseWhenNodeToJson(const void* pObj, SJson* pJson) {
|
||||
const SCaseWhenNode* pNode = (const SCaseWhenNode*)pObj;
|
||||
|
||||
int32_t code = exprNodeToJson(pObj, pJson);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkCaseWhenCase, nodeToJson, pNode->pCase);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodeListToJson(pJson, jkCaseWhenWhenThenList, pNode->pWhenThenList);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkCaseWhenElse, nodeToJson, pNode->pElse);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t jsonToCaseWhenNode(const SJson* pJson, void* pObj) {
|
||||
SCaseWhenNode* pNode = (SCaseWhenNode*)pObj;
|
||||
|
||||
int32_t code = jsonToExprNode(pJson, pObj);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeObject(pJson, jkCaseWhenCase, &pNode->pCase);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeList(pJson, jkCaseWhenWhenThenList, &pNode->pWhenThenList);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeObject(pJson, jkCaseWhenElse, &pNode->pElse);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static const char* jkDataBlockDescDataBlockId = "DataBlockId";
|
||||
static const char* jkDataBlockDescSlots = "Slots";
|
||||
static const char* jkDataBlockTotalRowSize = "TotalRowSize";
|
||||
|
@ -4399,6 +4486,10 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
|||
return databaseOptionsToJson(pObj, pJson);
|
||||
case QUERY_NODE_LEFT_VALUE:
|
||||
return TSDB_CODE_SUCCESS; // SLeftValueNode has no fields to serialize.
|
||||
case QUERY_NODE_WHEN_THEN:
|
||||
return whenThenNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_CASE_WHEN:
|
||||
return caseWhenNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_SET_OPERATOR:
|
||||
return setOperatorToJson(pObj, pJson);
|
||||
case QUERY_NODE_SELECT_STMT:
|
||||
|
@ -4562,6 +4653,10 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
|||
return jsonToDatabaseOptions(pJson, pObj);
|
||||
case QUERY_NODE_LEFT_VALUE:
|
||||
return TSDB_CODE_SUCCESS; // SLeftValueNode has no fields to deserialize.
|
||||
case QUERY_NODE_WHEN_THEN:
|
||||
return jsonToWhenThenNode(pJson, pObj);
|
||||
case QUERY_NODE_CASE_WHEN:
|
||||
return jsonToCaseWhenNode(pJson, pObj);
|
||||
case QUERY_NODE_SET_OPERATOR:
|
||||
return jsonToSetOperator(pJson, pObj);
|
||||
case QUERY_NODE_SELECT_STMT:
|
||||
|
|
|
@ -140,6 +140,19 @@ static bool functionNodeEqual(const SFunctionNode* a, const SFunctionNode* b) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool whenThenNodeEqual(const SWhenThenNode* a, const SWhenThenNode* b) {
|
||||
COMPARE_NODE_FIELD(pWhen);
|
||||
COMPARE_NODE_FIELD(pThen);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool caseWhenNodeEqual(const SCaseWhenNode* a, const SCaseWhenNode* b) {
|
||||
COMPARE_NODE_FIELD(pCase);
|
||||
COMPARE_NODE_FIELD(pElse);
|
||||
COMPARE_NODE_LIST_FIELD(pWhenThenList);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool nodesEqualNode(const SNode* a, const SNode* b) {
|
||||
if (a == b) {
|
||||
return true;
|
||||
|
@ -164,13 +177,17 @@ bool nodesEqualNode(const SNode* a, const SNode* b) {
|
|||
return logicConditionNodeEqual((const SLogicConditionNode*)a, (const SLogicConditionNode*)b);
|
||||
case QUERY_NODE_FUNCTION:
|
||||
return functionNodeEqual((const SFunctionNode*)a, (const SFunctionNode*)b);
|
||||
case QUERY_NODE_WHEN_THEN:
|
||||
return whenThenNodeEqual((const SWhenThenNode*)a, (const SWhenThenNode*)b);
|
||||
case QUERY_NODE_CASE_WHEN:
|
||||
return caseWhenNodeEqual((const SCaseWhenNode*)a, (const SCaseWhenNode*)b);
|
||||
case QUERY_NODE_REAL_TABLE:
|
||||
case QUERY_NODE_TEMP_TABLE:
|
||||
case QUERY_NODE_JOIN_TABLE:
|
||||
case QUERY_NODE_GROUPING_SET:
|
||||
case QUERY_NODE_ORDER_BY_EXPR:
|
||||
case QUERY_NODE_LIMIT:
|
||||
return false; // todo
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1733,6 +1733,92 @@ static int32_t msgToDownstreamSourceNode(STlvDecoder* pDecoder, void* pObj) {
|
|||
return code;
|
||||
}
|
||||
|
||||
enum { WHEN_THEN_CODE_EXPR_BASE = 1, WHEN_THEN_CODE_WHEN, WHEN_THEN_CODE_THEN };
|
||||
|
||||
static int32_t whenThenNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
||||
const SWhenThenNode* pNode = (const SWhenThenNode*)pObj;
|
||||
|
||||
int32_t code = tlvEncodeObj(pEncoder, WHEN_THEN_CODE_EXPR_BASE, exprNodeToMsg, pNode);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tlvEncodeObj(pEncoder, WHEN_THEN_CODE_WHEN, nodeToMsg, pNode->pWhen);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tlvEncodeObj(pEncoder, WHEN_THEN_CODE_THEN, nodeToMsg, pNode->pThen);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t msgToWhenThenNode(STlvDecoder* pDecoder, void* pObj) {
|
||||
SWhenThenNode* pNode = (SWhenThenNode*)pObj;
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
STlv* pTlv = NULL;
|
||||
tlvForEach(pDecoder, pTlv, code) {
|
||||
switch (pTlv->type) {
|
||||
case WHEN_THEN_CODE_EXPR_BASE:
|
||||
code = tlvDecodeObjFromTlv(pTlv, msgToExprNode, &pNode->node);
|
||||
break;
|
||||
case WHEN_THEN_CODE_WHEN:
|
||||
code = msgToNodeFromTlv(pTlv, (void**)&pNode->pWhen);
|
||||
break;
|
||||
case WHEN_THEN_CODE_THEN:
|
||||
code = msgToNodeFromTlv(pTlv, (void**)&pNode->pThen);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
enum { CASE_WHEN_CODE_EXPR_BASE = 1, CASE_WHEN_CODE_CASE, CASE_WHEN_CODE_ELSE, CASE_WHEN_CODE_WHEN_THEN_LIST };
|
||||
|
||||
static int32_t caseWhenNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
||||
const SCaseWhenNode* pNode = (const SCaseWhenNode*)pObj;
|
||||
|
||||
int32_t code = tlvEncodeObj(pEncoder, CASE_WHEN_CODE_EXPR_BASE, exprNodeToMsg, pNode);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tlvEncodeObj(pEncoder, CASE_WHEN_CODE_CASE, nodeToMsg, pNode->pCase);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tlvEncodeObj(pEncoder, CASE_WHEN_CODE_ELSE, nodeToMsg, pNode->pElse);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tlvEncodeObj(pEncoder, CASE_WHEN_CODE_WHEN_THEN_LIST, nodeListToMsg, pNode->pWhenThenList);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t msgToCaseWhenNode(STlvDecoder* pDecoder, void* pObj) {
|
||||
SCaseWhenNode* pNode = (SCaseWhenNode*)pObj;
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
STlv* pTlv = NULL;
|
||||
tlvForEach(pDecoder, pTlv, code) {
|
||||
switch (pTlv->type) {
|
||||
case CASE_WHEN_CODE_EXPR_BASE:
|
||||
code = tlvDecodeObjFromTlv(pTlv, msgToExprNode, &pNode->node);
|
||||
break;
|
||||
case CASE_WHEN_CODE_CASE:
|
||||
code = msgToNodeFromTlv(pTlv, (void**)&pNode->pCase);
|
||||
break;
|
||||
case CASE_WHEN_CODE_ELSE:
|
||||
code = msgToNodeFromTlv(pTlv, (void**)&pNode->pElse);
|
||||
break;
|
||||
case CASE_WHEN_CODE_WHEN_THEN_LIST:
|
||||
code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pWhenThenList);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
enum {
|
||||
PHY_NODE_CODE_OUTPUT_DESC = 1,
|
||||
PHY_NODE_CODE_CONDITIONS,
|
||||
|
@ -2294,7 +2380,8 @@ static int32_t msgToPhysiAggNode(STlvDecoder* pDecoder, void* pObj) {
|
|||
|
||||
enum {
|
||||
PHY_EXCHANGE_CODE_BASE_NODE = 1,
|
||||
PHY_EXCHANGE_CODE_SRC_GROUP_ID,
|
||||
PHY_EXCHANGE_CODE_SRC_START_GROUP_ID,
|
||||
PHY_EXCHANGE_CODE_SRC_END_GROUP_ID,
|
||||
PHY_EXCHANGE_CODE_SINGLE_CHANNEL,
|
||||
PHY_EXCHANGE_CODE_SRC_ENDPOINTS
|
||||
};
|
||||
|
@ -2304,7 +2391,10 @@ static int32_t physiExchangeNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
|||
|
||||
int32_t code = tlvEncodeObj(pEncoder, PHY_EXCHANGE_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tlvEncodeI32(pEncoder, PHY_EXCHANGE_CODE_SRC_GROUP_ID, pNode->srcGroupId);
|
||||
code = tlvEncodeI32(pEncoder, PHY_EXCHANGE_CODE_SRC_START_GROUP_ID, pNode->srcStartGroupId);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tlvEncodeI32(pEncoder, PHY_EXCHANGE_CODE_SRC_END_GROUP_ID, pNode->srcEndGroupId);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tlvEncodeBool(pEncoder, PHY_EXCHANGE_CODE_SINGLE_CHANNEL, pNode->singleChannel);
|
||||
|
@ -2326,8 +2416,11 @@ static int32_t msgToPhysiExchangeNode(STlvDecoder* pDecoder, void* pObj) {
|
|||
case PHY_EXCHANGE_CODE_BASE_NODE:
|
||||
code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
|
||||
break;
|
||||
case PHY_EXCHANGE_CODE_SRC_GROUP_ID:
|
||||
code = tlvDecodeI32(pTlv, &pNode->srcGroupId);
|
||||
case PHY_EXCHANGE_CODE_SRC_START_GROUP_ID:
|
||||
code = tlvDecodeI32(pTlv, &pNode->srcStartGroupId);
|
||||
break;
|
||||
case PHY_EXCHANGE_CODE_SRC_END_GROUP_ID:
|
||||
code = tlvDecodeI32(pTlv, &pNode->srcEndGroupId);
|
||||
break;
|
||||
case PHY_EXCHANGE_CODE_SINGLE_CHANNEL:
|
||||
code = tlvDecodeBool(pTlv, &pNode->singleChannel);
|
||||
|
@ -3434,9 +3527,16 @@ static int32_t specificNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
|||
code = slotDescNodeToMsg(pObj, pEncoder);
|
||||
break;
|
||||
case QUERY_NODE_DOWNSTREAM_SOURCE:
|
||||
return downstreamSourceNodeToMsg(pObj, pEncoder);
|
||||
code = downstreamSourceNodeToMsg(pObj, pEncoder);
|
||||
break;
|
||||
case QUERY_NODE_LEFT_VALUE:
|
||||
break;
|
||||
case QUERY_NODE_WHEN_THEN:
|
||||
code = whenThenNodeToMsg(pObj, pEncoder);
|
||||
break;
|
||||
case QUERY_NODE_CASE_WHEN:
|
||||
code = caseWhenNodeToMsg(pObj, pEncoder);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
|
||||
case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN:
|
||||
code = physiScanNodeToMsg(pObj, pEncoder);
|
||||
|
@ -3563,9 +3663,15 @@ static int32_t msgToSpecificNode(STlvDecoder* pDecoder, void* pObj) {
|
|||
code = msgToSlotDescNode(pDecoder, pObj);
|
||||
break;
|
||||
case QUERY_NODE_DOWNSTREAM_SOURCE:
|
||||
return msgToDownstreamSourceNode(pDecoder, pObj);
|
||||
code = msgToDownstreamSourceNode(pDecoder, pObj);
|
||||
case QUERY_NODE_LEFT_VALUE:
|
||||
break;
|
||||
case QUERY_NODE_WHEN_THEN:
|
||||
code = msgToWhenThenNode(pDecoder, pObj);
|
||||
break;
|
||||
case QUERY_NODE_CASE_WHEN:
|
||||
code = msgToCaseWhenNode(pDecoder, pObj);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
|
||||
case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN:
|
||||
code = msgToPhysiScanNode(pDecoder, pObj);
|
||||
|
|
|
@ -146,6 +146,25 @@ static EDealRes dispatchExpr(SNode* pNode, ETraversalOrder order, FNodeWalker wa
|
|||
case QUERY_NODE_TARGET:
|
||||
res = walkExpr(((STargetNode*)pNode)->pExpr, order, walker, pContext);
|
||||
break;
|
||||
case QUERY_NODE_WHEN_THEN: {
|
||||
SWhenThenNode* pWhenThen = (SWhenThenNode*)pNode;
|
||||
res = walkExpr(pWhenThen->pWhen, order, walker, pContext);
|
||||
if (DEAL_RES_ERROR != res && DEAL_RES_END != res) {
|
||||
res = walkExpr(pWhenThen->pThen, order, walker, pContext);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_CASE_WHEN: {
|
||||
SCaseWhenNode* pCaseWhen = (SCaseWhenNode*)pNode;
|
||||
res = walkExpr(pCaseWhen->pCase, order, walker, pContext);
|
||||
if (DEAL_RES_ERROR != res && DEAL_RES_END != res) {
|
||||
res = walkExpr(pCaseWhen->pElse, order, walker, pContext);
|
||||
}
|
||||
if (DEAL_RES_ERROR != res && DEAL_RES_END != res) {
|
||||
res = walkExprs(pCaseWhen->pWhenThenList, order, walker, pContext);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -291,6 +310,25 @@ static EDealRes rewriteExpr(SNode** pRawNode, ETraversalOrder order, FNodeRewrit
|
|||
case QUERY_NODE_TARGET:
|
||||
res = rewriteExpr(&(((STargetNode*)pNode)->pExpr), order, rewriter, pContext);
|
||||
break;
|
||||
case QUERY_NODE_WHEN_THEN: {
|
||||
SWhenThenNode* pWhenThen = (SWhenThenNode*)pNode;
|
||||
res = rewriteExpr(&pWhenThen->pWhen, order, rewriter, pContext);
|
||||
if (DEAL_RES_ERROR != res && DEAL_RES_END != res) {
|
||||
res = rewriteExpr(&pWhenThen->pThen, order, rewriter, pContext);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_CASE_WHEN: {
|
||||
SCaseWhenNode* pCaseWhen = (SCaseWhenNode*)pNode;
|
||||
res = rewriteExpr(&pCaseWhen->pCase, order, rewriter, pContext);
|
||||
if (DEAL_RES_ERROR != res && DEAL_RES_END != res) {
|
||||
res = rewriteExpr(&pCaseWhen->pElse, order, rewriter, pContext);
|
||||
}
|
||||
if (DEAL_RES_ERROR != res && DEAL_RES_END != res) {
|
||||
res = rewriteExprs(pCaseWhen->pWhenThenList, order, rewriter, pContext);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -291,6 +291,10 @@ SNode* nodesMakeNode(ENodeType type) {
|
|||
return makeNode(type, sizeof(SLeftValueNode));
|
||||
case QUERY_NODE_COLUMN_REF:
|
||||
return makeNode(type, sizeof(SColumnDefNode));
|
||||
case QUERY_NODE_WHEN_THEN:
|
||||
return makeNode(type, sizeof(SWhenThenNode));
|
||||
case QUERY_NODE_CASE_WHEN:
|
||||
return makeNode(type, sizeof(SCaseWhenNode));
|
||||
case QUERY_NODE_SET_OPERATOR:
|
||||
return makeNode(type, sizeof(SSetOperator));
|
||||
case QUERY_NODE_SELECT_STMT:
|
||||
|
@ -738,7 +742,21 @@ void nodesDestroyNode(SNode* pNode) {
|
|||
break;
|
||||
}
|
||||
case QUERY_NODE_LEFT_VALUE: // no pointer field
|
||||
case QUERY_NODE_COLUMN_REF: // no pointer field
|
||||
break;
|
||||
case QUERY_NODE_WHEN_THEN: {
|
||||
SWhenThenNode* pStmt = (SWhenThenNode*)pNode;
|
||||
nodesDestroyNode(pStmt->pWhen);
|
||||
nodesDestroyNode(pStmt->pThen);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_CASE_WHEN: {
|
||||
SCaseWhenNode* pStmt = (SCaseWhenNode*)pNode;
|
||||
nodesDestroyNode(pStmt->pCase);
|
||||
nodesDestroyNode(pStmt->pElse);
|
||||
nodesDestroyList(pStmt->pWhenThenList);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_SET_OPERATOR: {
|
||||
SSetOperator* pStmt = (SSetOperator*)pNode;
|
||||
nodesDestroyList(pStmt->pProjectionList);
|
||||
|
|
|
@ -119,6 +119,8 @@ SNode* createIntervalWindowNode(SAstCreateContext* pCxt, SNode* pInterval, SNode
|
|||
SNode* createFillNode(SAstCreateContext* pCxt, EFillMode mode, SNode* pValues);
|
||||
SNode* createGroupingSetNode(SAstCreateContext* pCxt, SNode* pNode);
|
||||
SNode* createInterpTimeRange(SAstCreateContext* pCxt, SNode* pStart, SNode* pEnd);
|
||||
SNode* createWhenThenNode(SAstCreateContext* pCxt, SNode* pWhen, SNode* pThen);
|
||||
SNode* createCaseWhenNode(SAstCreateContext* pCxt, SNode* pCase, SNodeList* pWhenThenList, SNode* pElse);
|
||||
|
||||
SNode* addWhereClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pWhere);
|
||||
SNode* addPartitionByClause(SAstCreateContext* pCxt, SNode* pStmt, SNodeList* pPartitionByList);
|
||||
|
|
|
@ -625,42 +625,44 @@ stream_name(A) ::= NK_ID(B).
|
|||
cgroup_name(A) ::= NK_ID(B). { A = B; }
|
||||
|
||||
/************************************************ expression **********************************************************/
|
||||
expr_or_subquery(A) ::= expression(B). { A = B; }
|
||||
expr_or_subquery(A) ::= subquery(B). { A = B; }
|
||||
|
||||
expression(A) ::= literal(B). { A = B; }
|
||||
expression(A) ::= pseudo_column(B). { A = B; }
|
||||
expression(A) ::= column_reference(B). { A = B; }
|
||||
expression(A) ::= function_expression(B). { A = B; }
|
||||
//expression(A) ::= case_expression(B). { A = B; }
|
||||
expression(A) ::= subquery(B). { A = B; }
|
||||
expression(A) ::= case_when_expression(B). { A = B; }
|
||||
expression(A) ::= NK_LP(B) expression(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, releaseRawExprNode(pCxt, C)); }
|
||||
expression(A) ::= NK_PLUS(B) expression(C). {
|
||||
expression(A) ::= NK_PLUS(B) expr_or_subquery(C). {
|
||||
SToken t = getTokenFromRawExprNode(pCxt, C);
|
||||
A = createRawExprNodeExt(pCxt, &B, &t, releaseRawExprNode(pCxt, C));
|
||||
}
|
||||
expression(A) ::= NK_MINUS(B) expression(C). {
|
||||
expression(A) ::= NK_MINUS(B) expr_or_subquery(C). {
|
||||
SToken t = getTokenFromRawExprNode(pCxt, C);
|
||||
A = createRawExprNodeExt(pCxt, &B, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, C), NULL));
|
||||
}
|
||||
expression(A) ::= expression(B) NK_PLUS expression(C). {
|
||||
expression(A) ::= expr_or_subquery(B) NK_PLUS expr_or_subquery(C). {
|
||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
||||
SToken e = getTokenFromRawExprNode(pCxt, C);
|
||||
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)));
|
||||
}
|
||||
expression(A) ::= expression(B) NK_MINUS expression(C). {
|
||||
expression(A) ::= expr_or_subquery(B) NK_MINUS expr_or_subquery(C). {
|
||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
||||
SToken e = getTokenFromRawExprNode(pCxt, C);
|
||||
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)));
|
||||
}
|
||||
expression(A) ::= expression(B) NK_STAR expression(C). {
|
||||
expression(A) ::= expr_or_subquery(B) NK_STAR expr_or_subquery(C). {
|
||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
||||
SToken e = getTokenFromRawExprNode(pCxt, C);
|
||||
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)));
|
||||
}
|
||||
expression(A) ::= expression(B) NK_SLASH expression(C). {
|
||||
expression(A) ::= expr_or_subquery(B) NK_SLASH expr_or_subquery(C). {
|
||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
||||
SToken e = getTokenFromRawExprNode(pCxt, C);
|
||||
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)));
|
||||
}
|
||||
expression(A) ::= expression(B) NK_REM expression(C). {
|
||||
expression(A) ::= expr_or_subquery(B) NK_REM expr_or_subquery(C). {
|
||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
||||
SToken e = getTokenFromRawExprNode(pCxt, C);
|
||||
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)));
|
||||
|
@ -669,12 +671,12 @@ expression(A) ::= column_reference(B) NK_ARROW NK_STRING(C).
|
|||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
||||
A = createRawExprNodeExt(pCxt, &s, &C, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, B), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &C)));
|
||||
}
|
||||
expression(A) ::= expression(B) NK_BITAND expression(C). {
|
||||
expression(A) ::= expr_or_subquery(B) NK_BITAND expr_or_subquery(C). {
|
||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
||||
SToken e = getTokenFromRawExprNode(pCxt, C);
|
||||
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)));
|
||||
}
|
||||
expression(A) ::= expression(B) NK_BITOR expression(C). {
|
||||
expression(A) ::= expr_or_subquery(B) NK_BITOR expr_or_subquery(C). {
|
||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
||||
SToken e = getTokenFromRawExprNode(pCxt, C);
|
||||
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)));
|
||||
|
@ -682,8 +684,8 @@ expression(A) ::= expression(B) NK_BITOR expression(C).
|
|||
|
||||
%type expression_list { SNodeList* }
|
||||
%destructor expression_list { nodesDestroyList($$); }
|
||||
expression_list(A) ::= expression(B). { A = createNodeList(pCxt, releaseRawExprNode(pCxt, B)); }
|
||||
expression_list(A) ::= expression_list(B) NK_COMMA expression(C). { A = addNodeToList(pCxt, B, releaseRawExprNode(pCxt, C)); }
|
||||
expression_list(A) ::= expr_or_subquery(B). { A = createNodeList(pCxt, releaseRawExprNode(pCxt, B)); }
|
||||
expression_list(A) ::= expression_list(B) NK_COMMA expr_or_subquery(C). { A = addNodeToList(pCxt, B, releaseRawExprNode(pCxt, C)); }
|
||||
|
||||
column_reference(A) ::= column_name(B). { A = createRawExprNode(pCxt, &B, createColumnNode(pCxt, NULL, &B)); }
|
||||
column_reference(A) ::= table_name(B) NK_DOT column_name(C). { A = createRawExprNodeExt(pCxt, &B, &C, createColumnNode(pCxt, &B, &C)); }
|
||||
|
@ -700,7 +702,8 @@ pseudo_column(A) ::= WDURATION(B).
|
|||
|
||||
function_expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
||||
function_expression(A) ::= star_func(B) NK_LP star_func_para_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
||||
function_expression(A) ::= CAST(B) NK_LP expression(C) AS type_name(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); }
|
||||
function_expression(A) ::=
|
||||
CAST(B) NK_LP expr_or_subquery(C) AS type_name(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); }
|
||||
function_expression(A) ::= literal_func(B). { A = B; }
|
||||
|
||||
literal_func(A) ::= noarg_func(B) NK_LP NK_RP(C). { A = createRawExprNodeExt(pCxt, &B, &C, createFunctionNode(pCxt, &B, NULL)); }
|
||||
|
@ -735,35 +738,52 @@ star_func_para_list(A) ::= other_para_list(B).
|
|||
other_para_list(A) ::= star_func_para(B). { A = createNodeList(pCxt, B); }
|
||||
other_para_list(A) ::= other_para_list(B) NK_COMMA star_func_para(C). { A = addNodeToList(pCxt, B, C); }
|
||||
|
||||
star_func_para(A) ::= expression(B). { A = releaseRawExprNode(pCxt, B); }
|
||||
star_func_para(A) ::= expr_or_subquery(B). { A = releaseRawExprNode(pCxt, B); }
|
||||
star_func_para(A) ::= table_name(B) NK_DOT NK_STAR(C). { A = createColumnNode(pCxt, &B, &C); }
|
||||
|
||||
case_when_expression(A) ::=
|
||||
CASE(E) when_then_list(C) case_when_else_opt(D) END(F). { A = createRawExprNodeExt(pCxt, &E, &F, createCaseWhenNode(pCxt, NULL, C, D)); }
|
||||
case_when_expression(A) ::=
|
||||
CASE(E) common_expression(B) when_then_list(C) case_when_else_opt(D) END(F). { A = createRawExprNodeExt(pCxt, &E, &F, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, B), C, D)); }
|
||||
|
||||
%type when_then_list { SNodeList* }
|
||||
%destructor when_then_list { nodesDestroyList($$); }
|
||||
when_then_list(A) ::= when_then_expr(B). { A = createNodeList(pCxt, B); }
|
||||
when_then_list(A) ::= when_then_list(B) when_then_expr(C). { A = addNodeToList(pCxt, B, C); }
|
||||
|
||||
when_then_expr(A) ::= WHEN common_expression(B) THEN common_expression(C). { A = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)); }
|
||||
|
||||
case_when_else_opt(A) ::= . { A = NULL; }
|
||||
case_when_else_opt(A) ::= ELSE common_expression(B). { A = releaseRawExprNode(pCxt, B); }
|
||||
|
||||
/************************************************ predicate ***********************************************************/
|
||||
predicate(A) ::= expression(B) compare_op(C) expression(D). {
|
||||
predicate(A) ::= expr_or_subquery(B) compare_op(C) expr_or_subquery(D). {
|
||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
||||
SToken e = getTokenFromRawExprNode(pCxt, D);
|
||||
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, C, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, D)));
|
||||
}
|
||||
//predicate(A) ::= expression(B) compare_op sub_type expression(B).
|
||||
predicate(A) ::= expression(B) BETWEEN expression(C) AND expression(D). {
|
||||
predicate(A) ::=
|
||||
expr_or_subquery(B) BETWEEN expr_or_subquery(C) AND expr_or_subquery(D). {
|
||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
||||
SToken e = getTokenFromRawExprNode(pCxt, D);
|
||||
A = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D)));
|
||||
}
|
||||
predicate(A) ::= expression(B) NOT BETWEEN expression(C) AND expression(D). {
|
||||
predicate(A) ::=
|
||||
expr_or_subquery(B) NOT BETWEEN expr_or_subquery(C) AND expr_or_subquery(D). {
|
||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
||||
SToken e = getTokenFromRawExprNode(pCxt, D);
|
||||
A = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D)));
|
||||
}
|
||||
predicate(A) ::= expression(B) IS NULL(C). {
|
||||
predicate(A) ::= expr_or_subquery(B) IS NULL(C). {
|
||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
||||
A = createRawExprNodeExt(pCxt, &s, &C, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, B), NULL));
|
||||
}
|
||||
predicate(A) ::= expression(B) IS NOT NULL(C). {
|
||||
predicate(A) ::= expr_or_subquery(B) IS NOT NULL(C). {
|
||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
||||
A = createRawExprNodeExt(pCxt, &s, &C, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, B), NULL));
|
||||
}
|
||||
predicate(A) ::= expression(B) in_op(C) in_predicate_value(D). {
|
||||
predicate(A) ::= expr_or_subquery(B) in_op(C) in_predicate_value(D). {
|
||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
||||
SToken e = getTokenFromRawExprNode(pCxt, D);
|
||||
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, C, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, D)));
|
||||
|
@ -813,7 +833,7 @@ boolean_primary(A) ::= predicate(B).
|
|||
boolean_primary(A) ::= NK_LP(C) boolean_value_expression(B) NK_RP(D). { A = createRawExprNodeExt(pCxt, &C, &D, releaseRawExprNode(pCxt, B)); }
|
||||
|
||||
/************************************************ common_expression ********************************************/
|
||||
common_expression(A) ::= expression(B). { A = B; }
|
||||
common_expression(A) ::= expr_or_subquery(B). { A = B; }
|
||||
common_expression(A) ::= boolean_value_expression(B). { A = B; }
|
||||
|
||||
/************************************************ from_clause_opt *********************************************************/
|
||||
|
@ -894,7 +914,7 @@ partition_by_clause_opt(A) ::= PARTITION BY expression_list(B).
|
|||
twindow_clause_opt(A) ::= . { A = NULL; }
|
||||
twindow_clause_opt(A) ::=
|
||||
SESSION NK_LP column_reference(B) NK_COMMA duration_literal(C) NK_RP. { A = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)); }
|
||||
twindow_clause_opt(A) ::= STATE_WINDOW NK_LP expression(B) NK_RP. { A = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, B)); }
|
||||
twindow_clause_opt(A) ::= STATE_WINDOW NK_LP expr_or_subquery(B) NK_RP. { A = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, B)); }
|
||||
twindow_clause_opt(A) ::=
|
||||
INTERVAL NK_LP duration_literal(B) NK_RP sliding_opt(C) fill_opt(D). { A = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, B), NULL, C, D); }
|
||||
twindow_clause_opt(A) ::=
|
||||
|
@ -923,14 +943,15 @@ group_by_clause_opt(A) ::= GROUP BY group_by_list(B).
|
|||
|
||||
%type group_by_list { SNodeList* }
|
||||
%destructor group_by_list { nodesDestroyList($$); }
|
||||
group_by_list(A) ::= expression(B). { A = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, B))); }
|
||||
group_by_list(A) ::= group_by_list(B) NK_COMMA expression(C). { A = addNodeToList(pCxt, B, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, C))); }
|
||||
group_by_list(A) ::= expr_or_subquery(B). { A = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, B))); }
|
||||
group_by_list(A) ::= group_by_list(B) NK_COMMA expr_or_subquery(C). { A = addNodeToList(pCxt, B, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, C))); }
|
||||
|
||||
having_clause_opt(A) ::= . { A = NULL; }
|
||||
having_clause_opt(A) ::= HAVING search_condition(B). { A = B; }
|
||||
|
||||
range_opt(A) ::= . { A = NULL; }
|
||||
range_opt(A) ::= RANGE NK_LP expression(B) NK_COMMA expression(C) NK_RP. { A = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)); }
|
||||
range_opt(A) ::=
|
||||
RANGE NK_LP expr_or_subquery(B) NK_COMMA expr_or_subquery(C) NK_RP. { A = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)); }
|
||||
|
||||
every_opt(A) ::= . { A = NULL; }
|
||||
every_opt(A) ::= EVERY NK_LP duration_literal(B) NK_RP. { A = releaseRawExprNode(pCxt, B); }
|
||||
|
@ -974,6 +995,7 @@ limit_clause_opt(A) ::= LIMIT NK_INTEGER(C) NK_COMMA NK_INTEGER(B).
|
|||
|
||||
/************************************************ subquery ************************************************************/
|
||||
subquery(A) ::= NK_LP(B) query_expression(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, C); }
|
||||
subquery(A) ::= NK_LP(B) subquery(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, releaseRawExprNode(pCxt, C)); }
|
||||
|
||||
/************************************************ search_condition ****************************************************/
|
||||
search_condition(A) ::= common_expression(B). { A = releaseRawExprNode(pCxt, B); }
|
||||
|
@ -986,7 +1008,7 @@ sort_specification_list(A) ::=
|
|||
sort_specification_list(B) NK_COMMA sort_specification(C). { A = addNodeToList(pCxt, B, C); }
|
||||
|
||||
sort_specification(A) ::=
|
||||
expression(B) ordering_specification_opt(C) null_ordering_opt(D). { A = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, B), C, D); }
|
||||
expr_or_subquery(B) ordering_specification_opt(C) null_ordering_opt(D). { A = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, B), C, D); }
|
||||
|
||||
%type ordering_specification_opt EOrder
|
||||
%destructor ordering_specification_opt { }
|
||||
|
|
|
@ -647,6 +647,25 @@ SNode* createInterpTimeRange(SAstCreateContext* pCxt, SNode* pStart, SNode* pEnd
|
|||
return createBetweenAnd(pCxt, createPrimaryKeyCol(pCxt, NULL), pStart, pEnd);
|
||||
}
|
||||
|
||||
SNode* createWhenThenNode(SAstCreateContext* pCxt, SNode* pWhen, SNode* pThen) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SWhenThenNode* pWhenThen = (SWhenThenNode*)nodesMakeNode(QUERY_NODE_WHEN_THEN);
|
||||
CHECK_OUT_OF_MEM(pWhenThen);
|
||||
pWhenThen->pWhen = pWhen;
|
||||
pWhenThen->pThen = pThen;
|
||||
return (SNode*)pWhenThen;
|
||||
}
|
||||
|
||||
SNode* createCaseWhenNode(SAstCreateContext* pCxt, SNode* pCase, SNodeList* pWhenThenList, SNode* pElse) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SCaseWhenNode* pCaseWhen = (SCaseWhenNode*)nodesMakeNode(QUERY_NODE_CASE_WHEN);
|
||||
CHECK_OUT_OF_MEM(pCaseWhen);
|
||||
pCaseWhen->pCase = pCase;
|
||||
pCaseWhen->pWhenThenList = pWhenThenList;
|
||||
pCaseWhen->pElse = pElse;
|
||||
return (SNode*)pCaseWhen;
|
||||
}
|
||||
|
||||
SNode* setProjectionAlias(SAstCreateContext* pCxt, SNode* pNode, SToken* pAlias) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
trimEscape(pAlias);
|
||||
|
|
|
@ -54,6 +54,7 @@ static SKeyword keywordTable[] = {
|
|||
{"CACHE", TK_CACHE},
|
||||
{"CACHEMODEL", TK_CACHEMODEL},
|
||||
{"CACHESIZE", TK_CACHESIZE},
|
||||
{"CASE", TK_CASE},
|
||||
{"CAST", TK_CAST},
|
||||
{"CLIENT_VERSION", TK_CLIENT_VERSION},
|
||||
{"CLUSTER", TK_CLUSTER},
|
||||
|
@ -82,7 +83,9 @@ static SKeyword keywordTable[] = {
|
|||
{"DOUBLE", TK_DOUBLE},
|
||||
{"DROP", TK_DROP},
|
||||
{"DURATION", TK_DURATION},
|
||||
{"ELSE", TK_ELSE},
|
||||
{"ENABLE", TK_ENABLE},
|
||||
{"END", TK_END},
|
||||
{"EXISTS", TK_EXISTS},
|
||||
{"EXPIRED", TK_EXPIRED},
|
||||
{"EXPLAIN", TK_EXPLAIN},
|
||||
|
@ -205,6 +208,7 @@ static SKeyword keywordTable[] = {
|
|||
{"TAG", TK_TAG},
|
||||
{"TAGS", TK_TAGS},
|
||||
{"TBNAME", TK_TBNAME},
|
||||
{"THEN", TK_THEN},
|
||||
{"TIMESTAMP", TK_TIMESTAMP},
|
||||
{"TIMEZONE", TK_TIMEZONE},
|
||||
{"TINYINT", TK_TINYINT},
|
||||
|
@ -240,6 +244,7 @@ static SKeyword keywordTable[] = {
|
|||
{"WAL_ROLL_PERIOD", TK_WAL_ROLL_PERIOD},
|
||||
{"WAL_SEGMENT_SIZE", TK_WAL_SEGMENT_SIZE},
|
||||
{"WATERMARK", TK_WATERMARK},
|
||||
{"WHEN", TK_WHEN},
|
||||
{"WHERE", TK_WHERE},
|
||||
{"WINDOW_CLOSE", TK_WINDOW_CLOSE},
|
||||
{"WITH", TK_WITH},
|
||||
|
|
|
@ -264,6 +264,8 @@ static bool beforeHaving(ESqlClause clause) { return clause < SQL_CLAUSE_HAVING;
|
|||
|
||||
static bool afterHaving(ESqlClause clause) { return clause > SQL_CLAUSE_HAVING; }
|
||||
|
||||
static bool beforeWindow(ESqlClause clause) { return clause < SQL_CLAUSE_WINDOW; }
|
||||
|
||||
static bool hasSameTableAlias(SArray* pTables) {
|
||||
if (taosArrayGetSize(pTables) < 2) {
|
||||
return false;
|
||||
|
@ -1476,6 +1478,10 @@ static int32_t translateWindowPseudoColumnFunc(STranslateContext* pCxt, SFunctio
|
|||
if (!isSelectStmt(pCxt->pCurrStmt) || NULL == ((SSelectStmt*)pCxt->pCurrStmt)->pWindow) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_WINDOW_PC);
|
||||
}
|
||||
if (beforeWindow(pCxt->currClause)) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_WINDOW_PC, "There mustn't be %s",
|
||||
pFunc->functionName);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1807,6 +1813,59 @@ static EDealRes translateLogicCond(STranslateContext* pCxt, SLogicConditionNode*
|
|||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
static int32_t createCastFunc(STranslateContext* pCxt, SNode* pExpr, SDataType dt, SNode** pCast) {
|
||||
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
if (NULL == pFunc) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
strcpy(pFunc->functionName, "cast");
|
||||
pFunc->node.resType = dt;
|
||||
if (TSDB_CODE_SUCCESS != nodesListMakeAppend(&pFunc->pParameterList, pExpr)) {
|
||||
nodesDestroyNode((SNode*)pFunc);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != getFuncInfo(pCxt, pFunc)) {
|
||||
nodesClearList(pFunc->pParameterList);
|
||||
pFunc->pParameterList = NULL;
|
||||
nodesDestroyNode((SNode*)pFunc);
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)pExpr)->aliasName);
|
||||
}
|
||||
*pCast = (SNode*)pFunc;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static EDealRes translateWhenThen(STranslateContext* pCxt, SWhenThenNode* pWhenThen) {
|
||||
pWhenThen->node.resType = ((SExprNode*)pWhenThen->pThen)->resType;
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
static EDealRes translateCaseWhen(STranslateContext* pCxt, SCaseWhenNode* pCaseWhen) {
|
||||
bool first = true;
|
||||
SNode* pNode = NULL;
|
||||
FOREACH(pNode, pCaseWhen->pWhenThenList) {
|
||||
if (first) {
|
||||
pCaseWhen->node.resType = ((SExprNode*)pNode)->resType;
|
||||
} else if (!dataTypeEqual(&pCaseWhen->node.resType, &((SExprNode*)pNode)->resType)) {
|
||||
SWhenThenNode* pWhenThen = (SWhenThenNode*)pNode;
|
||||
SNode* pCastFunc = NULL;
|
||||
if (TSDB_CODE_SUCCESS != createCastFunc(pCxt, pWhenThen->pThen, pCaseWhen->node.resType, &pCastFunc)) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, "CASE WHEN data type mismatch");
|
||||
}
|
||||
pWhenThen->pThen = pCastFunc;
|
||||
pWhenThen->node.resType = pCaseWhen->node.resType;
|
||||
}
|
||||
}
|
||||
if (NULL != pCaseWhen->pElse && !dataTypeEqual(&pCaseWhen->node.resType, &((SExprNode*)pCaseWhen->pElse)->resType)) {
|
||||
SNode* pCastFunc = NULL;
|
||||
if (TSDB_CODE_SUCCESS != createCastFunc(pCxt, pCaseWhen->pElse, pCaseWhen->node.resType, &pCastFunc)) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, "CASE WHEN data type mismatch");
|
||||
}
|
||||
pCaseWhen->pElse = pCastFunc;
|
||||
((SExprNode*)pCaseWhen->pElse)->resType = pCaseWhen->node.resType;
|
||||
}
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
static EDealRes doTranslateExpr(SNode** pNode, void* pContext) {
|
||||
STranslateContext* pCxt = (STranslateContext*)pContext;
|
||||
switch (nodeType(*pNode)) {
|
||||
|
@ -1822,6 +1881,10 @@ static EDealRes doTranslateExpr(SNode** pNode, void* pContext) {
|
|||
return translateLogicCond(pCxt, (SLogicConditionNode*)*pNode);
|
||||
case QUERY_NODE_TEMP_TABLE:
|
||||
return translateExprSubquery(pCxt, ((STempTableNode*)*pNode)->pSubquery);
|
||||
case QUERY_NODE_WHEN_THEN:
|
||||
return translateWhenThen(pCxt, (SWhenThenNode*)*pNode);
|
||||
case QUERY_NODE_CASE_WHEN:
|
||||
return translateCaseWhen(pCxt, (SCaseWhenNode*)*pNode);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -2213,6 +2276,17 @@ static int32_t setTableCacheLastMode(STranslateContext* pCxt, SSelectStmt* pSele
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t checkJoinTable(STranslateContext* pCxt, SJoinTableNode* pJoinTable) {
|
||||
if ((QUERY_NODE_TEMP_TABLE == nodeType(pJoinTable->pLeft) &&
|
||||
!isTimeLineQuery(((STempTableNode*)pJoinTable->pLeft)->pSubquery)) ||
|
||||
(QUERY_NODE_TEMP_TABLE == nodeType(pJoinTable->pRight) &&
|
||||
!isTimeLineQuery(((STempTableNode*)pJoinTable->pRight)->pSubquery))) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_SUPPORT_JOIN,
|
||||
"Join requires valid time series input");
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
switch (nodeType(pTable)) {
|
||||
|
@ -2259,6 +2333,9 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = translateTable(pCxt, pJoinTable->pRight);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkJoinTable(pCxt, pJoinTable);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pJoinTable->table.precision = calcJoinTablePrecision(pJoinTable);
|
||||
pJoinTable->table.singleTable = joinTableIsSingleTable(pJoinTable);
|
||||
|
@ -3208,27 +3285,6 @@ static SNode* createSetOperProject(const char* pTableAlias, SNode* pNode) {
|
|||
return (SNode*)pCol;
|
||||
}
|
||||
|
||||
static int32_t createCastFunc(STranslateContext* pCxt, SNode* pExpr, SDataType dt, SNode** pCast) {
|
||||
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
if (NULL == pFunc) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
strcpy(pFunc->functionName, "cast");
|
||||
pFunc->node.resType = dt;
|
||||
if (TSDB_CODE_SUCCESS != nodesListMakeAppend(&pFunc->pParameterList, pExpr)) {
|
||||
nodesDestroyNode((SNode*)pFunc);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != getFuncInfo(pCxt, pFunc)) {
|
||||
nodesClearList(pFunc->pParameterList);
|
||||
pFunc->pParameterList = NULL;
|
||||
nodesDestroyNode((SNode*)pFunc);
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)pExpr)->aliasName);
|
||||
}
|
||||
*pCast = (SNode*)pFunc;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateSetOperProject(STranslateContext* pCxt, SSetOperator* pSetOperator) {
|
||||
SNodeList* pLeftProjections = getProjectList(pSetOperator->pLeft);
|
||||
SNodeList* pRightProjections = getProjectList(pSetOperator->pRight);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -60,6 +60,9 @@ TEST_F(ParserSelectTest, expression) {
|
|||
run("SELECT ts > 0, c1 between 10 and 20 and c2 = 'qaz' FROM t1");
|
||||
|
||||
run("SELECT c1 | 10, c2 & 20, c4 | c5 FROM t1");
|
||||
|
||||
run("SELECT CASE WHEN ts > '2020-1-1 10:10:10' THEN c1 + 10 ELSE c1 - 10 END FROM t1 "
|
||||
"WHERE CASE c1 WHEN c3 + 20 THEN c3 - 1 WHEN c3 + 10 THEN c3 - 2 ELSE 10 END > 0");
|
||||
}
|
||||
|
||||
TEST_F(ParserSelectTest, condition) {
|
||||
|
@ -312,6 +315,8 @@ TEST_F(ParserSelectTest, subquery) {
|
|||
run("SELECT _C0 FROM (SELECT _ROWTS, ts FROM st1s1)");
|
||||
|
||||
run("SELECT ts FROM (SELECT t1.ts FROM st1s1 t1)");
|
||||
|
||||
run("(((SELECT t1.ts FROM st1s1 t1)))");
|
||||
}
|
||||
|
||||
TEST_F(ParserSelectTest, subquerySemanticCheck) {
|
||||
|
@ -445,4 +450,11 @@ TEST_F(ParserSelectTest, withoutFromSemanticCheck) {
|
|||
run("SELECT TBNAME", TSDB_CODE_PAR_INVALID_TBNAME);
|
||||
}
|
||||
|
||||
TEST_F(ParserSelectTest, joinSemanticCheck) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("SELECT * FROM (SELECT tag1, SUM(c1) s FROM st1 GROUP BY tag1) t1, st1 t2 where t1.tag1 = t2.tag1",
|
||||
TSDB_CODE_PAR_NOT_SUPPORT_JOIN);
|
||||
}
|
||||
|
||||
} // namespace ParserTest
|
||||
|
|
|
@ -1046,7 +1046,8 @@ static int32_t doCreateExchangePhysiNode(SPhysiPlanContext* pCxt, SExchangeLogic
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
pExchange->srcGroupId = pExchangeLogicNode->srcGroupId;
|
||||
pExchange->srcStartGroupId = pExchangeLogicNode->srcStartGroupId;
|
||||
pExchange->srcEndGroupId = pExchangeLogicNode->srcEndGroupId;
|
||||
*pPhyNode = (SPhysiNode*)pExchange;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -1425,7 +1426,8 @@ static int32_t createExchangePhysiNodeByMerge(SMergePhysiNode* pMerge) {
|
|||
if (NULL == pExchange) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pExchange->srcGroupId = pMerge->srcGroupId;
|
||||
pExchange->srcStartGroupId = pMerge->srcGroupId;
|
||||
pExchange->srcEndGroupId = pMerge->srcGroupId;
|
||||
pExchange->singleChannel = true;
|
||||
pExchange->node.pParent = (SPhysiNode*)pMerge;
|
||||
pExchange->node.pOutputDataBlockDesc = (SDataBlockDescNode*)nodesCloneNode((SNode*)pMerge->node.pOutputDataBlockDesc);
|
||||
|
|
|
@ -84,7 +84,8 @@ static int32_t splCreateExchangeNode(SSplitContext* pCxt, SLogicNode* pChild, SE
|
|||
if (NULL == pExchange) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pExchange->srcGroupId = pCxt->groupId;
|
||||
pExchange->srcStartGroupId = pCxt->groupId;
|
||||
pExchange->srcEndGroupId = pCxt->groupId;
|
||||
pExchange->node.precision = pChild->precision;
|
||||
pExchange->node.pTargets = nodesCloneList(pChild->pTargets);
|
||||
if (NULL == pExchange->node.pTargets) {
|
||||
|
@ -112,7 +113,8 @@ static int32_t splCreateExchangeNodeForSubplan(SSplitContext* pCxt, SLogicSubpla
|
|||
|
||||
static bool splIsChildSubplan(SLogicNode* pLogicNode, int32_t groupId) {
|
||||
if (QUERY_NODE_LOGIC_PLAN_EXCHANGE == nodeType(pLogicNode)) {
|
||||
return ((SExchangeLogicNode*)pLogicNode)->srcGroupId == groupId;
|
||||
return groupId >= ((SExchangeLogicNode*)pLogicNode)->srcStartGroupId &&
|
||||
groupId <= ((SExchangeLogicNode*)pLogicNode)->srcEndGroupId;
|
||||
}
|
||||
|
||||
if (QUERY_NODE_LOGIC_PLAN_MERGE == nodeType(pLogicNode)) {
|
||||
|
@ -1184,6 +1186,7 @@ static int32_t unionSplitSubplan(SSplitContext* pCxt, SLogicSubplan* pUnionSubpl
|
|||
if (TSDB_CODE_SUCCESS != code) {
|
||||
break;
|
||||
}
|
||||
++(pCxt->groupId);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
nodesDestroyList(pSubplanChildren);
|
||||
|
@ -1207,12 +1210,14 @@ static bool unAllSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan,
|
|||
return false;
|
||||
}
|
||||
|
||||
static int32_t unAllSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SProjectLogicNode* pProject) {
|
||||
static int32_t unAllSplCreateExchangeNode(SSplitContext* pCxt, int32_t startGroupId, SLogicSubplan* pSubplan,
|
||||
SProjectLogicNode* pProject) {
|
||||
SExchangeLogicNode* pExchange = (SExchangeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE);
|
||||
if (NULL == pExchange) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pExchange->srcGroupId = pCxt->groupId;
|
||||
pExchange->srcStartGroupId = startGroupId;
|
||||
pExchange->srcEndGroupId = pCxt->groupId - 1;
|
||||
pExchange->node.precision = pProject->node.precision;
|
||||
pExchange->node.pTargets = nodesCloneList(pProject->node.pTargets);
|
||||
if (NULL == pExchange->node.pTargets) {
|
||||
|
@ -1246,11 +1251,11 @@ static int32_t unionAllSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t startGroupId = pCxt->groupId;
|
||||
int32_t code = unionSplitSubplan(pCxt, info.pSubplan, (SLogicNode*)info.pProject);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = unAllSplCreateExchangeNode(pCxt, info.pSubplan, info.pProject);
|
||||
code = unAllSplCreateExchangeNode(pCxt, startGroupId, info.pSubplan, info.pProject);
|
||||
}
|
||||
++(pCxt->groupId);
|
||||
pCxt->split = true;
|
||||
return code;
|
||||
}
|
||||
|
@ -1260,12 +1265,14 @@ typedef struct SUnionDistinctSplitInfo {
|
|||
SLogicSubplan* pSubplan;
|
||||
} SUnionDistinctSplitInfo;
|
||||
|
||||
static int32_t unDistSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SAggLogicNode* pAgg) {
|
||||
static int32_t unDistSplCreateExchangeNode(SSplitContext* pCxt, int32_t startGroupId, SLogicSubplan* pSubplan,
|
||||
SAggLogicNode* pAgg) {
|
||||
SExchangeLogicNode* pExchange = (SExchangeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE);
|
||||
if (NULL == pExchange) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pExchange->srcGroupId = pCxt->groupId;
|
||||
pExchange->srcStartGroupId = startGroupId;
|
||||
pExchange->srcEndGroupId = pCxt->groupId - 1;
|
||||
pExchange->node.precision = pAgg->node.precision;
|
||||
pExchange->node.pTargets = nodesCloneList(pAgg->pGroupKeys);
|
||||
if (NULL == pExchange->node.pTargets) {
|
||||
|
@ -1293,11 +1300,11 @@ static int32_t unionDistinctSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan)
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t startGroupId = pCxt->groupId;
|
||||
int32_t code = unionSplitSubplan(pCxt, info.pSubplan, (SLogicNode*)info.pAgg);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = unDistSplCreateExchangeNode(pCxt, info.pSubplan, info.pAgg);
|
||||
code = unDistSplCreateExchangeNode(pCxt, startGroupId, info.pSubplan, info.pAgg);
|
||||
}
|
||||
++(pCxt->groupId);
|
||||
pCxt->split = true;
|
||||
return code;
|
||||
}
|
||||
|
@ -1430,7 +1437,7 @@ static const SSplitRule splitRuleSet[] = {
|
|||
{.pName = "SingleTableJoinSplit", .splitFunc = singleTableJoinSplit},
|
||||
{.pName = "UnionAllSplit", .splitFunc = unionAllSplit},
|
||||
{.pName = "UnionDistinctSplit", .splitFunc = unionDistinctSplit},
|
||||
{.pName = "SmaIndexSplit", .splitFunc = smaIndexSplit},
|
||||
{.pName = "SmaIndexSplit", .splitFunc = smaIndexSplit}, // not used yet
|
||||
{.pName = "InsertSelectSplit", .splitFunc = insertSelectSplit}
|
||||
};
|
||||
// clang-format on
|
||||
|
|
|
@ -63,7 +63,7 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo
|
|||
static int32_t setSubplanExecutionNode(SPhysiNode* pNode, int32_t groupId, SDownstreamSourceNode* pSource) {
|
||||
if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == nodeType(pNode)) {
|
||||
SExchangePhysiNode* pExchange = (SExchangePhysiNode*)pNode;
|
||||
if (pExchange->srcGroupId == groupId) {
|
||||
if (groupId >= pExchange->srcStartGroupId && groupId <= pExchange->srcEndGroupId) {
|
||||
return nodesListMakeStrictAppend(&pExchange->pSrcEndPoints, nodesCloneNode((SNode*)pSource));
|
||||
}
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_MERGE == nodeType(pNode)) {
|
||||
|
|
|
@ -40,6 +40,13 @@ TEST_F(PlanBasicTest, whereClause) {
|
|||
run("SELECT ts, c1 FROM t1 WHERE ts > NOW AND ts IS NULL AND (c1 > 0 OR c3 < 20)");
|
||||
}
|
||||
|
||||
TEST_F(PlanBasicTest, caseWhen) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("SELECT CASE WHEN ts > '2020-1-1 10:10:10' THEN c1 + 10 ELSE c1 - 10 END FROM t1 "
|
||||
"WHERE CASE c1 WHEN c2 + 20 THEN c4 - 1 WHEN c2 + 10 THEN c4 - 2 ELSE 10 END > 0");
|
||||
}
|
||||
|
||||
TEST_F(PlanBasicTest, func) {
|
||||
useDb("root", "test");
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@ TEST_F(PlanJoinTest, basic) {
|
|||
run("SELECT t1.*, t2.* FROM st1s1 t1, st1s2 t2 WHERE t1.ts = t2.ts");
|
||||
|
||||
run("SELECT t1.c1, t2.c1 FROM st1s1 t1 JOIN st1s2 t2 ON t1.ts = t2.ts");
|
||||
|
||||
run("SELECT t1.c1, t2.c1 FROM st1 t1 JOIN st2 t2 ON t1.ts = t2.ts");
|
||||
}
|
||||
|
||||
TEST_F(PlanJoinTest, complex) {
|
||||
|
@ -56,9 +58,3 @@ TEST_F(PlanJoinTest, multiJoin) {
|
|||
|
||||
run("SELECT t1.c1, t2.c1 FROM st1s1 t1 JOIN st1s2 t2 ON t1.ts = t2.ts JOIN st1s3 t3 ON t1.ts = t3.ts");
|
||||
}
|
||||
|
||||
TEST_F(PlanJoinTest, stable) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("SELECT t1.c1, t2.c1 FROM st1 t1 JOIN st2 t2 ON t1.ts = t2.ts ");
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ typedef struct SFilterRange {
|
|||
|
||||
typedef bool (*rangeCompFunc) (const void *, const void *, const void *, const void *, __compar_fn_t);
|
||||
typedef int32_t(*filter_desc_compare_func)(const void *, const void *);
|
||||
typedef bool(*filter_exec_func)(void *, int32_t, int8_t**, SColumnDataAgg *, int16_t);
|
||||
typedef bool(*filter_exec_func)(void *info, int32_t numOfRows, SColumnInfoData* p, SColumnDataAgg *statis, int16_t numOfCols);
|
||||
typedef int32_t (*filer_get_col_from_name)(void *, int32_t, char*, void **);
|
||||
|
||||
typedef struct SFilterRangeCompare {
|
||||
|
|
|
@ -2976,14 +2976,12 @@ _return:
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols) {
|
||||
bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, SColumnInfoData* pRes, SColumnDataAgg *statis, int16_t numOfCols) {
|
||||
SFilterInfo *info = (SFilterInfo *)pinfo;
|
||||
bool all = true;
|
||||
uint32_t *unitIdx = NULL;
|
||||
|
||||
if (*p == NULL) {
|
||||
*p = taosMemoryCalloc(numOfRows, sizeof(int8_t));
|
||||
}
|
||||
int8_t* p = (int8_t*)pRes->pData;
|
||||
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
//FILTER_UNIT_CLR_F(info);
|
||||
|
@ -3002,35 +3000,35 @@ bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, int8_t** p,
|
|||
uint8_t optr = cunit->optr;
|
||||
|
||||
if (colDataIsNull((SColumnInfoData *)(cunit->colData), 0, i, NULL)) {
|
||||
(*p)[i] = optr == OP_TYPE_IS_NULL ? true : false;
|
||||
p[i] = (optr == OP_TYPE_IS_NULL) ? true : false;
|
||||
} else {
|
||||
if (optr == OP_TYPE_IS_NOT_NULL) {
|
||||
(*p)[i] = 1;
|
||||
p[i] = 1;
|
||||
} else if (optr == OP_TYPE_IS_NULL) {
|
||||
(*p)[i] = 0;
|
||||
p[i] = 0;
|
||||
} else if (cunit->rfunc >= 0) {
|
||||
(*p)[i] = (*gRangeCompare[cunit->rfunc])(colData, colData, cunit->valData, cunit->valData2, gDataCompare[cunit->func]);
|
||||
p[i] = (*gRangeCompare[cunit->rfunc])(colData, colData, cunit->valData, cunit->valData2, gDataCompare[cunit->func]);
|
||||
} else {
|
||||
(*p)[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, colData, cunit->valData);
|
||||
p[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, colData, cunit->valData);
|
||||
}
|
||||
|
||||
//FILTER_UNIT_SET_R(info, uidx, p[i]);
|
||||
//FILTER_UNIT_SET_F(info, uidx);
|
||||
}
|
||||
|
||||
if ((*p)[i] == 0) {
|
||||
if (p[i] == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((*p)[i]) {
|
||||
if (p[i]) {
|
||||
break;
|
||||
}
|
||||
|
||||
unitIdx += unitNum;
|
||||
}
|
||||
|
||||
if ((*p)[i] == 0) {
|
||||
if (p[i] == 0) {
|
||||
all = false;
|
||||
}
|
||||
}
|
||||
|
@ -3040,7 +3038,7 @@ bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, int8_t** p,
|
|||
|
||||
|
||||
|
||||
int32_t filterExecuteBasedOnStatis(SFilterInfo *info, int32_t numOfRows, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols, bool* all) {
|
||||
int32_t filterExecuteBasedOnStatis(SFilterInfo *info, int32_t numOfRows, SColumnInfoData* p, SColumnDataAgg *statis, int16_t numOfCols, bool* all) {
|
||||
if (statis && numOfRows >= FILTER_RM_UNIT_MIN_ROWS) {
|
||||
info->blkFlag = 0;
|
||||
|
||||
|
@ -3058,7 +3056,6 @@ int32_t filterExecuteBasedOnStatis(SFilterInfo *info, int32_t numOfRows, int8_t*
|
|||
assert(info->unitNum > 1);
|
||||
|
||||
*all = filterExecuteBasedOnStatisImpl(info, numOfRows, p, statis, numOfCols);
|
||||
|
||||
goto _return;
|
||||
}
|
||||
}
|
||||
|
@ -3067,59 +3064,55 @@ int32_t filterExecuteBasedOnStatis(SFilterInfo *info, int32_t numOfRows, int8_t*
|
|||
|
||||
_return:
|
||||
info->blkFlag = 0;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static FORCE_INLINE bool filterExecuteImplAll(void *info, int32_t numOfRows, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols) {
|
||||
static FORCE_INLINE bool filterExecuteImplAll(void *info, int32_t numOfRows, SColumnInfoData* p, SColumnDataAgg *statis, int16_t numOfCols) {
|
||||
return true;
|
||||
}
|
||||
static FORCE_INLINE bool filterExecuteImplEmpty(void *info, int32_t numOfRows, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols) {
|
||||
|
||||
static FORCE_INLINE bool filterExecuteImplEmpty(void *info, int32_t numOfRows, SColumnInfoData* p, SColumnDataAgg *statis, int16_t numOfCols) {
|
||||
return false;
|
||||
}
|
||||
static FORCE_INLINE bool filterExecuteImplIsNull(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols) {
|
||||
|
||||
static FORCE_INLINE bool filterExecuteImplIsNull(void *pinfo, int32_t numOfRows, SColumnInfoData* pRes, SColumnDataAgg *statis, int16_t numOfCols) {
|
||||
SFilterInfo *info = (SFilterInfo *)pinfo;
|
||||
bool all = true;
|
||||
|
||||
if (filterExecuteBasedOnStatis(info, numOfRows, p, statis, numOfCols, &all) == 0) {
|
||||
return all;
|
||||
}
|
||||
int8_t* p = (int8_t*)pRes->pData;
|
||||
|
||||
if (*p == NULL) {
|
||||
*p = taosMemoryCalloc(numOfRows, sizeof(int8_t));
|
||||
if (filterExecuteBasedOnStatis(info, numOfRows, pRes, statis, numOfCols, &all) == 0) {
|
||||
return all;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
uint32_t uidx = info->groups[0].unitIdxs[0];
|
||||
void *colData = colDataGetData((SColumnInfoData *)info->cunits[uidx].colData, i);
|
||||
(*p)[i] = ((colData == NULL) || colDataIsNull((SColumnInfoData *)info->cunits[uidx].colData, 0, i, NULL));
|
||||
p[i] = ((colData == NULL) || colDataIsNull((SColumnInfoData *)info->cunits[uidx].colData, 0, i, NULL));
|
||||
|
||||
if ((*p)[i] == 0) {
|
||||
if (p[i] == 0) {
|
||||
all = false;
|
||||
}
|
||||
}
|
||||
|
||||
return all;
|
||||
}
|
||||
static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols) {
|
||||
static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows, SColumnInfoData* pRes, SColumnDataAgg *statis, int16_t numOfCols) {
|
||||
SFilterInfo *info = (SFilterInfo *)pinfo;
|
||||
bool all = true;
|
||||
|
||||
if (filterExecuteBasedOnStatis(info, numOfRows, p, statis, numOfCols, &all) == 0) {
|
||||
if (filterExecuteBasedOnStatis(info, numOfRows, pRes, statis, numOfCols, &all) == 0) {
|
||||
return all;
|
||||
}
|
||||
|
||||
if (*p == NULL) {
|
||||
*p = taosMemoryCalloc(numOfRows, sizeof(int8_t));
|
||||
}
|
||||
int8_t* p = (int8_t*)pRes->pData;
|
||||
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
uint32_t uidx = info->groups[0].unitIdxs[0];
|
||||
void *colData = colDataGetData((SColumnInfoData *)info->cunits[uidx].colData, i);
|
||||
|
||||
(*p)[i] = ((colData != NULL) && !colDataIsNull((SColumnInfoData *)info->cunits[uidx].colData, 0, i, NULL));
|
||||
if ((*p)[i] == 0) {
|
||||
p[i] = ((colData != NULL) && !colDataIsNull((SColumnInfoData *)info->cunits[uidx].colData, 0, i, NULL));
|
||||
if (p[i] == 0) {
|
||||
all = false;
|
||||
}
|
||||
}
|
||||
|
@ -3127,7 +3120,7 @@ static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows
|
|||
return all;
|
||||
}
|
||||
|
||||
bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols) {
|
||||
bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, SColumnInfoData* pRes, SColumnDataAgg *statis, int16_t numOfCols) {
|
||||
SFilterInfo *info = (SFilterInfo *)pinfo;
|
||||
bool all = true;
|
||||
uint16_t dataSize = info->cunits[0].dataSize;
|
||||
|
@ -3136,13 +3129,11 @@ bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t** p, SColumnD
|
|||
void *valData2 = info->cunits[0].valData2;
|
||||
__compar_fn_t func = gDataCompare[info->cunits[0].func];
|
||||
|
||||
if (filterExecuteBasedOnStatis(info, numOfRows, p, statis, numOfCols, &all) == 0) {
|
||||
if (filterExecuteBasedOnStatis(info, numOfRows, pRes, statis, numOfCols, &all) == 0) {
|
||||
return all;
|
||||
}
|
||||
|
||||
if (*p == NULL) {
|
||||
*p = taosMemoryCalloc(numOfRows, sizeof(int8_t));
|
||||
}
|
||||
int8_t* p = (int8_t*) pRes->pData;
|
||||
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
void *colData = colDataGetData((SColumnInfoData *)info->cunits[0].colData, i);
|
||||
|
@ -3152,9 +3143,9 @@ bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t** p, SColumnD
|
|||
continue;
|
||||
}
|
||||
|
||||
(*p)[i] = (*rfunc)(colData, colData, valData, valData2, func);
|
||||
p[i] = (*rfunc)(colData, colData, valData, valData2, func);
|
||||
|
||||
if ((*p)[i] == 0) {
|
||||
if (p[i] == 0) {
|
||||
all = false;
|
||||
}
|
||||
}
|
||||
|
@ -3162,23 +3153,21 @@ bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t** p, SColumnD
|
|||
return all;
|
||||
}
|
||||
|
||||
bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols) {
|
||||
bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, SColumnInfoData* pRes, SColumnDataAgg *statis, int16_t numOfCols) {
|
||||
SFilterInfo *info = (SFilterInfo *)pinfo;
|
||||
bool all = true;
|
||||
|
||||
if (filterExecuteBasedOnStatis(info, numOfRows, p, statis, numOfCols, &all) == 0) {
|
||||
if (filterExecuteBasedOnStatis(info, numOfRows, pRes, statis, numOfCols, &all) == 0) {
|
||||
return all;
|
||||
}
|
||||
|
||||
if (*p == NULL) {
|
||||
*p = taosMemoryCalloc(numOfRows, sizeof(int8_t));
|
||||
}
|
||||
int8_t* p = (int8_t*) pRes->pData;
|
||||
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
uint32_t uidx = info->groups[0].unitIdxs[0];
|
||||
void *colData = colDataGetData((SColumnInfoData *)info->cunits[uidx].colData, i);
|
||||
if (colData == NULL || colDataIsNull_s((SColumnInfoData *)info->cunits[uidx].colData, i)) {
|
||||
(*p)[i] = 0;
|
||||
p[i] = 0;
|
||||
all = false;
|
||||
continue;
|
||||
}
|
||||
|
@ -3191,14 +3180,14 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDa
|
|||
qError("castConvert1 taosUcs4ToMbs error");
|
||||
}else{
|
||||
varDataSetLen(newColData, len);
|
||||
(*p)[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, newColData, info->cunits[uidx].valData);
|
||||
p[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, newColData, info->cunits[uidx].valData);
|
||||
}
|
||||
taosMemoryFreeClear(newColData);
|
||||
}else{
|
||||
(*p)[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, colData, info->cunits[uidx].valData);
|
||||
p[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, colData, info->cunits[uidx].valData);
|
||||
}
|
||||
|
||||
if ((*p)[i] == 0) {
|
||||
if (p[i] == 0) {
|
||||
all = false;
|
||||
}
|
||||
}
|
||||
|
@ -3207,17 +3196,15 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDa
|
|||
}
|
||||
|
||||
|
||||
bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols) {
|
||||
bool filterExecuteImpl(void *pinfo, int32_t numOfRows, SColumnInfoData* pRes, SColumnDataAgg *statis, int16_t numOfCols) {
|
||||
SFilterInfo *info = (SFilterInfo *)pinfo;
|
||||
bool all = true;
|
||||
|
||||
if (filterExecuteBasedOnStatis(info, numOfRows, p, statis, numOfCols, &all) == 0) {
|
||||
if (filterExecuteBasedOnStatis(info, numOfRows, pRes, statis, numOfCols, &all) == 0) {
|
||||
return all;
|
||||
}
|
||||
|
||||
if (*p == NULL) {
|
||||
*p = taosMemoryCalloc(numOfRows, sizeof(int8_t));
|
||||
}
|
||||
int8_t* p = (int8_t*) pRes->pData;
|
||||
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
//FILTER_UNIT_CLR_F(info);
|
||||
|
@ -3235,14 +3222,14 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAg
|
|||
uint8_t optr = cunit->optr;
|
||||
|
||||
if (colData == NULL || colDataIsNull((SColumnInfoData *)(cunit->colData), 0, i, NULL)) {
|
||||
(*p)[i] = optr == OP_TYPE_IS_NULL ? true : false;
|
||||
p[i] = optr == OP_TYPE_IS_NULL ? true : false;
|
||||
} else {
|
||||
if (optr == OP_TYPE_IS_NOT_NULL) {
|
||||
(*p)[i] = 1;
|
||||
p[i] = 1;
|
||||
} else if (optr == OP_TYPE_IS_NULL) {
|
||||
(*p)[i] = 0;
|
||||
p[i] = 0;
|
||||
} else if (cunit->rfunc >= 0) {
|
||||
(*p)[i] = (*gRangeCompare[cunit->rfunc])(colData, colData, cunit->valData, cunit->valData2, gDataCompare[cunit->func]);
|
||||
p[i] = (*gRangeCompare[cunit->rfunc])(colData, colData, cunit->valData, cunit->valData2, gDataCompare[cunit->func]);
|
||||
} else {
|
||||
if(cunit->dataType == TSDB_DATA_TYPE_NCHAR && (cunit->optr == OP_TYPE_MATCH || cunit->optr == OP_TYPE_NMATCH)){
|
||||
char *newColData = taosMemoryCalloc(cunit->dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1);
|
||||
|
@ -3251,11 +3238,11 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAg
|
|||
qError("castConvert1 taosUcs4ToMbs error");
|
||||
}else{
|
||||
varDataSetLen(newColData, len);
|
||||
(*p)[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, newColData, cunit->valData);
|
||||
p[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, newColData, cunit->valData);
|
||||
}
|
||||
taosMemoryFreeClear(newColData);
|
||||
}else{
|
||||
(*p)[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, colData, cunit->valData);
|
||||
p[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, colData, cunit->valData);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3263,17 +3250,17 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAg
|
|||
//FILTER_UNIT_SET_F(info, uidx);
|
||||
}
|
||||
|
||||
if ((*p)[i] == 0) {
|
||||
if (p[i] == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((*p)[i]) {
|
||||
if (p[i]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((*p)[i] == 0) {
|
||||
if (p[i] == 0) {
|
||||
all = false;
|
||||
}
|
||||
}
|
||||
|
@ -4026,38 +4013,63 @@ _return:
|
|||
FLT_RET(code);
|
||||
}
|
||||
|
||||
bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols) {
|
||||
bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData** p, SColumnDataAgg *statis, int16_t numOfCols, int32_t *pResultStatus) {
|
||||
if (NULL == info) {
|
||||
*pResultStatus = FILTER_RESULT_ALL_QUALIFIED;
|
||||
return false;
|
||||
}
|
||||
|
||||
SScalarParam output = {0};
|
||||
SDataType type = {.type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)};
|
||||
|
||||
int32_t code = sclCreateColumnInfoData(&type, pSrc->info.rows, &output);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (info->scalarMode) {
|
||||
SScalarParam output = {0};
|
||||
|
||||
SDataType type = {.type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)};
|
||||
int32_t code = sclCreateColumnInfoData(&type, pSrc->info.rows, &output);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
||||
SArray *pList = taosArrayInit(1, POINTER_BYTES);
|
||||
taosArrayPush(pList, &pSrc);
|
||||
|
||||
FLT_ERR_RET(scalarCalculate(info->sclCtx.node, pList, &output));
|
||||
*p = taosMemoryMalloc(output.numOfRows * sizeof(bool));
|
||||
|
||||
memcpy(*p, output.columnData->pData, output.numOfRows);
|
||||
colDataDestroy(output.columnData);
|
||||
taosMemoryFree(output.columnData);
|
||||
*p = output.columnData;
|
||||
|
||||
taosArrayDestroy(pList);
|
||||
|
||||
if (output.numOfQualified == output.numOfRows) {
|
||||
*pResultStatus = FILTER_RESULT_ALL_QUALIFIED;
|
||||
} else if (output.numOfQualified == 0) {
|
||||
*pResultStatus = FILTER_RESULT_NONE_QUALIFIED;
|
||||
} else {
|
||||
*pResultStatus = FILTER_RESULT_PARTIAL_QUALIFIED;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
*p = output.columnData;
|
||||
output.numOfRows = pSrc->info.rows;
|
||||
|
||||
bool keep = (*info->func)(info, pSrc->info.rows, *p, statis, numOfCols);
|
||||
|
||||
// todo this should be return during filter procedure
|
||||
int32_t num = 0;
|
||||
for(int32_t i = 0; i < output.numOfRows; ++i) {
|
||||
if (((int8_t*)((*p)->pData))[i] == 1) {
|
||||
++num;
|
||||
}
|
||||
}
|
||||
|
||||
if (num == output.numOfRows) {
|
||||
*pResultStatus = FILTER_RESULT_ALL_QUALIFIED;
|
||||
} else if (num == 0) {
|
||||
*pResultStatus = FILTER_RESULT_NONE_QUALIFIED;
|
||||
} else {
|
||||
*pResultStatus = FILTER_RESULT_PARTIAL_QUALIFIED;
|
||||
}
|
||||
|
||||
return keep;
|
||||
}
|
||||
|
||||
return (*info->func)(info, pSrc->info.rows, p, statis, numOfCols);
|
||||
}
|
||||
|
||||
|
||||
typedef struct SClassifyConditionCxt {
|
||||
bool hasPrimaryKey;
|
||||
bool hasTagIndexCol;
|
||||
|
|
|
@ -606,6 +606,8 @@ int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *o
|
|||
SCL_ERR_JRET(code);
|
||||
}
|
||||
|
||||
int32_t numOfQualified = 0;
|
||||
|
||||
bool value = false;
|
||||
bool complete = true;
|
||||
for (int32_t i = 0; i < rowNum; ++i) {
|
||||
|
@ -631,6 +633,9 @@ int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *o
|
|||
|
||||
if (complete) {
|
||||
colDataAppend(output->columnData, i, (char*) &value, false);
|
||||
if (value) {
|
||||
numOfQualified++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -639,8 +644,9 @@ int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *o
|
|||
output->numOfRows = 0;
|
||||
}
|
||||
|
||||
_return:
|
||||
output->numOfQualified = numOfQualified;
|
||||
|
||||
_return:
|
||||
sclFreeParamList(params, paramNum);
|
||||
SCL_RET(code);
|
||||
}
|
||||
|
@ -1242,6 +1248,7 @@ int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) {
|
|||
colInfoDataEnsureCapacity(pDst->columnData, res->numOfRows);
|
||||
colDataAssign(pDst->columnData, res->columnData, res->numOfRows, NULL);
|
||||
pDst->numOfRows = res->numOfRows;
|
||||
pDst->numOfQualified = res->numOfQualified;
|
||||
}
|
||||
|
||||
sclFreeParam(res);
|
||||
|
@ -1249,7 +1256,6 @@ int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) {
|
|||
}
|
||||
|
||||
_return:
|
||||
//nodesDestroyNode(pNode);
|
||||
sclFreeRes(ctx.pRes);
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -1475,19 +1475,19 @@ void vectorMathMinus(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pO
|
|||
|
||||
void vectorAssign(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) {
|
||||
SColumnInfoData *pOutputCol = pOut->columnData;
|
||||
|
||||
pOut->numOfRows = pLeft->numOfRows;
|
||||
|
||||
// if (IS_HELPER_NULL(pRight->columnData, 0)) {
|
||||
if(colDataIsNull_s(pRight->columnData, 0)){
|
||||
for (int32_t i = 0; i < pOut->numOfRows; ++i) {
|
||||
colDataAppend(pOutputCol, i, NULL, true);
|
||||
}
|
||||
colDataAppendNNULL(pOutputCol, 0, pOut->numOfRows);
|
||||
} else {
|
||||
char* d = colDataGetData(pRight->columnData, 0);
|
||||
for (int32_t i = 0; i < pOut->numOfRows; ++i) {
|
||||
colDataAppend(pOutputCol, i, colDataGetData(pRight->columnData, 0), false);
|
||||
colDataAppend(pOutputCol, i, d, false);
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT(pRight->numOfQualified == 1 || pRight->numOfQualified == 0);
|
||||
pOut->numOfQualified = pRight->numOfQualified * pOut->numOfRows;
|
||||
}
|
||||
|
||||
void vectorConcat(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _ord) {
|
||||
|
@ -1646,38 +1646,60 @@ void vectorBitOr(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut,
|
|||
doReleaseVec(pRightCol, rightConvert);
|
||||
}
|
||||
|
||||
#define VEC_COM_INNER(pCol, index1, index2) \
|
||||
for (; i < pCol->numOfRows && i >= 0; i += step) {\
|
||||
if (IS_HELPER_NULL(pLeft->columnData, index1) || IS_HELPER_NULL(pRight->columnData, index2)) {\
|
||||
bool res = false;\
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);\
|
||||
continue;\
|
||||
}\
|
||||
char *pLeftData = colDataGetData(pLeft->columnData, index1);\
|
||||
char *pRightData = colDataGetData(pRight->columnData, index2);\
|
||||
int64_t leftOut = 0;\
|
||||
int64_t rightOut = 0;\
|
||||
bool freeLeft = false;\
|
||||
bool freeRight = false;\
|
||||
bool isJsonnull = false;\
|
||||
bool result = convertJsonValue(&fp, optr, GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight),\
|
||||
&pLeftData, &pRightData, &leftOut, &rightOut, &isJsonnull, &freeLeft, &freeRight);\
|
||||
if(isJsonnull){\
|
||||
ASSERT(0);\
|
||||
}\
|
||||
if(!pLeftData || !pRightData){\
|
||||
result = false;\
|
||||
}\
|
||||
if(!result){\
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t*)&result);\
|
||||
}else{\
|
||||
bool res = filterDoCompare(fp, optr, pLeftData, pRightData);\
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);\
|
||||
}\
|
||||
if(freeLeft) taosMemoryFreeClear(pLeftData);\
|
||||
if(freeRight) taosMemoryFreeClear(pRightData);\
|
||||
int32_t doVectorCompareImpl(int32_t numOfRows, SScalarParam *pOut, int32_t startIndex, int32_t step, __compar_fn_t fp,
|
||||
SScalarParam *pLeft, SScalarParam *pRight, int32_t optr) {
|
||||
int32_t num = 0;
|
||||
|
||||
for (int32_t i = startIndex; i < numOfRows && i >= 0; i += step) {
|
||||
int32_t leftIndex = (i >= pLeft->numOfRows)? 0:i;
|
||||
int32_t rightIndex = (i >= pRight->numOfRows)? 0:i;
|
||||
|
||||
if (IS_HELPER_NULL(pLeft->columnData, leftIndex) || IS_HELPER_NULL(pRight->columnData, rightIndex)) {
|
||||
bool res = false;
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t *)&res);
|
||||
continue;
|
||||
}
|
||||
|
||||
char * pLeftData = colDataGetData(pLeft->columnData, leftIndex);
|
||||
char * pRightData = colDataGetData(pRight->columnData, rightIndex);
|
||||
int64_t leftOut = 0;
|
||||
int64_t rightOut = 0;
|
||||
bool freeLeft = false;
|
||||
bool freeRight = false;
|
||||
bool isJsonnull = false;
|
||||
|
||||
bool result = convertJsonValue(&fp, optr, GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight), &pLeftData, &pRightData,
|
||||
&leftOut, &rightOut, &isJsonnull, &freeLeft, &freeRight);
|
||||
if (isJsonnull) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
if (!pLeftData || !pRightData) {
|
||||
result = false;
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t *)&result);
|
||||
} else {
|
||||
bool res = filterDoCompare(fp, optr, pLeftData, pRightData);
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t *)&res);
|
||||
if (res) {
|
||||
++num;
|
||||
}
|
||||
}
|
||||
|
||||
if (freeLeft) {
|
||||
taosMemoryFreeClear(pLeftData);
|
||||
}
|
||||
|
||||
if (freeRight) {
|
||||
taosMemoryFreeClear(pRightData);
|
||||
}
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord, int32_t optr) {
|
||||
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1;
|
||||
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
|
||||
|
@ -1704,16 +1726,12 @@ void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *
|
|||
char *pLeftData = colDataGetData(pLeft->columnData, i);
|
||||
bool res = filterDoCompare(fp, optr, pLeftData, pRight->pHashFilter);
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);
|
||||
if (res) {
|
||||
pOut->numOfQualified++;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
VEC_COM_INNER(pLeft, i, i)
|
||||
} else if (pRight->numOfRows == 1) {
|
||||
VEC_COM_INNER(pLeft, i, 0)
|
||||
} else if (pLeft->numOfRows == 1) {
|
||||
VEC_COM_INNER(pRight, 0, i)
|
||||
} else { // normal compare
|
||||
pOut->numOfQualified = doVectorCompareImpl(pOut->numOfRows, pOut, i, step, fp, pLeft, pRight, optr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "tmsg.h"
|
||||
#include "tref.h"
|
||||
#include "trpc.h"
|
||||
#include "tglobal.h"
|
||||
|
||||
void schFreeTask(SSchJob *pJob, SSchTask *pTask) {
|
||||
schDeregisterTaskHb(pJob, pTask);
|
||||
|
@ -870,8 +871,12 @@ int32_t schLaunchTaskImpl(void *param) {
|
|||
SCH_TASK_ELOG("failed to create physical plan, code:%s, msg:%p, len:%d", tstrerror(code), pTask->msg,
|
||||
pTask->msgLen);
|
||||
SCH_ERR_JRET(code);
|
||||
} else {
|
||||
SCH_TASK_DLOGL("physical plan len:%d, %s", pTask->msgLen, pTask->msg);
|
||||
} else if (tsQueryPlannerTrace) {
|
||||
char *msg = NULL;
|
||||
int32_t msgLen = 0;
|
||||
qSubPlanToString(plan, &msg, &msgLen);
|
||||
SCH_TASK_DLOGL("physical plan len:%d, %s", msgLen, msg);
|
||||
taosMemoryFree(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ $tb = $tbPrefix . $i
|
|||
print =============== step1
|
||||
sql drop database -x step1
|
||||
step1:
|
||||
sql create database $db
|
||||
sql create database $db vgroups 2
|
||||
sql use $db
|
||||
sql create table $tb (ts timestamp, speed int)
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ if $data[0][2] != redoAction then
|
|||
return -1
|
||||
endi
|
||||
|
||||
if $data[0][3] != d1 then
|
||||
if $data[0][4] != d1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
@ -120,7 +120,7 @@ if $system_content != Windows_NT then
|
|||
return -1
|
||||
endi
|
||||
|
||||
if $data[0][3] != d2 then
|
||||
if $data[0][4] != d2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ class TDTestCase:
|
|||
|
||||
|
||||
# create stream
|
||||
tdSql.execute('''create stream current_stream into stream_max_stable_1 as select _wstart as start, _wend as end, max(q_int) as max_int, min(q_bigint) as min_int from stable_1 where ts is not null interval (5s);''')
|
||||
tdSql.execute('''create stream current_stream into stream_max_stable_1 as select _wstart as start, _wend as wend, max(q_int) as max_int, min(q_bigint) as min_int from stable_1 where ts is not null interval (5s);''')
|
||||
|
||||
# insert data
|
||||
for i in range(num_random*n):
|
||||
|
@ -185,20 +185,20 @@ class TDTestCase:
|
|||
tdSql.checkData(0,0,num_random*n)
|
||||
|
||||
# stream data check
|
||||
tdSql.query("select start,end,max_int from stream_max_stable_1 ;")
|
||||
tdSql.query("select start,wend,max_int from stream_max_stable_1 ;")
|
||||
tdSql.checkRows(20)
|
||||
tdSql.query("select sum(max_int) from stream_max_stable_1 ;")
|
||||
stream_data_1 = tdSql.queryResult[0][0]
|
||||
tdSql.query("select sum(min_int) from stream_max_stable_1 ;")
|
||||
stream_data_2 = tdSql.queryResult[0][0]
|
||||
tdSql.query("select sum(max_int),sum(min_int) from (select _wstart as start, _wend as end, max(q_int) as max_int, min(q_bigint) as min_int from stable_1 where ts is not null interval (5s));")
|
||||
tdSql.query("select sum(max_int),sum(min_int) from (select _wstart as start, _wend as wend, max(q_int) as max_int, min(q_bigint) as min_int from stable_1 where ts is not null interval (5s));")
|
||||
sql_data_1 = tdSql.queryResult[0][0]
|
||||
sql_data_2 = tdSql.queryResult[0][1]
|
||||
|
||||
self.stream_value_check(stream_data_1,sql_data_1)
|
||||
self.stream_value_check(stream_data_2,sql_data_2)
|
||||
|
||||
tdSql.query("select sum(max_int),sum(min_int) from (select _wstart as start, _wend as end, max(q_int) as max_int, min(q_bigint) as min_int from stable_1 interval (5s));")
|
||||
tdSql.query("select sum(max_int),sum(min_int) from (select _wstart as start, _wend as wend, max(q_int) as max_int, min(q_bigint) as min_int from stable_1 interval (5s));")
|
||||
sql_data_1 = tdSql.queryResult[0][0]
|
||||
sql_data_2 = tdSql.queryResult[0][1]
|
||||
|
||||
|
|
|
@ -595,11 +595,11 @@ class TDTestCase:
|
|||
tdSql.checkData(2, i, 15)
|
||||
|
||||
tdSql.query(f"select interp(c0),interp(c1),interp(c2),interp(c3) from {dbname}.{tbname} range('2020-02-09 00:00:05', '2020-02-13 00:00:05') every(1d) fill(linear)")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkCols(4)
|
||||
|
||||
for i in range (tdSql.queryCols):
|
||||
tdSql.checkData(0, i, 15)
|
||||
tdSql.checkData(0, i, 13)
|
||||
|
||||
tdLog.printNoPrefix("==========step10:test error cases")
|
||||
|
||||
|
|
Loading…
Reference in New Issue