Merge branch 'main' into yu285-patch-16
This commit is contained in:
commit
3c1ccf13d4
|
@ -80,7 +80,7 @@ These pseudocolumns occur after the aggregation clause.
|
||||||
`FILL` clause is used to specify how to fill when there is data missing in any window, including:
|
`FILL` clause is used to specify how to fill when there is data missing in any window, including:
|
||||||
|
|
||||||
1. NONE: No fill (the default fill mode)
|
1. NONE: No fill (the default fill mode)
|
||||||
2. VALUE: Fill with a fixed value, which should be specified together, for example `FILL(VALUE, 1.23)` Note: The value filled depends on the data type. For example, if you run FILL(VALUE 1.23) on an integer column, the value 1 is filled. If multiple columns in select list need to be filled, then in the fill clause there must be a fill value for each of these columns, for example, `SELECT _wstart, min(c1), max(c1) FROM ... FILL(VALUE, 0, 0)`.
|
2. VALUE: Fill with a fixed value, which should be specified together, for example `FILL(VALUE, 1.23)` Note: The value filled depends on the data type. For example, if you run FILL(VALUE 1.23) on an integer column, the value 1 is filled. If multiple columns in select list need to be filled, then in the fill clause there must be a fill value for each of these columns, for example, `SELECT _wstart, min(c1), max(c1) FROM ... FILL(VALUE, 0, 0)`. Note that only exprs in select list that contains normal cols need to specify fill value, exprs like `_wstart`, `_wend`, `_wduration`, `_wstart + 1a`, `now`, `1+1`, partition keys like tbname(when using partition by) don't need to specify fill value. But exprs like `timediff(last(ts), _wstart)` need to specify fill value.
|
||||||
3. PREV: Fill with the previous non-NULL value, `FILL(PREV)`
|
3. PREV: Fill with the previous non-NULL value, `FILL(PREV)`
|
||||||
4. NULL: Fill with NULL, `FILL(NULL)`
|
4. NULL: Fill with NULL, `FILL(NULL)`
|
||||||
5. LINEAR: Fill with the closest non-NULL value, `FILL(LINEAR)`
|
5. LINEAR: Fill with the closest non-NULL value, `FILL(LINEAR)`
|
||||||
|
|
|
@ -27,11 +27,15 @@ The preceding SQL command shows all dnodes in the cluster with the ID, endpoint,
|
||||||
## Delete a DNODE
|
## Delete a DNODE
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
DROP DNODE dnode_id
|
DROP DNODE dnode_id [force] [unsafe]
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that deleting a dnode does not stop its process. You must stop the process after the dnode is deleted.
|
Note that deleting a dnode does not stop its process. You must stop the process after the dnode is deleted.
|
||||||
|
|
||||||
|
Only online node is allowed to be deleted. Drop is executed with force option if the offline node need to be deleted.
|
||||||
|
|
||||||
|
Drop is executed with unsafe option if the node with single replica is offline, and the data on it is not able to be restored.
|
||||||
|
|
||||||
## Modify Dnode Configuration
|
## Modify Dnode Configuration
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package com.taos.example;
|
package com.taos.example;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.taosdata.jdbc.TSDBDriver;
|
import com.taosdata.jdbc.TSDBDriver;
|
||||||
import com.taosdata.jdbc.tmq.*;
|
import com.taosdata.jdbc.tmq.*;
|
||||||
|
import com.taosdata.jdbc.utils.JsonUtil;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
@ -60,7 +61,7 @@ public class ConsumerLoopFull {
|
||||||
// ANCHOR_END: create_consumer
|
// ANCHOR_END: create_consumer
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void pollExample(TaosConsumer<ResultBean> consumer) throws SQLException {
|
public static void pollExample(TaosConsumer<ResultBean> consumer) throws SQLException, JsonProcessingException {
|
||||||
// ANCHOR: poll_data_code_piece
|
// ANCHOR: poll_data_code_piece
|
||||||
List<String> topics = Collections.singletonList("topic_meters");
|
List<String> topics = Collections.singletonList("topic_meters");
|
||||||
try {
|
try {
|
||||||
|
@ -73,7 +74,7 @@ public class ConsumerLoopFull {
|
||||||
for (ConsumerRecord<ResultBean> record : records) {
|
for (ConsumerRecord<ResultBean> record : records) {
|
||||||
ResultBean bean = record.value();
|
ResultBean bean = record.value();
|
||||||
// Add your data processing logic here
|
// Add your data processing logic here
|
||||||
System.out.println("data: " + JSON.toJSONString(bean));
|
System.out.println("data: " + JsonUtil.getObjectMapper().writeValueAsString(bean));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -91,7 +92,7 @@ public class ConsumerLoopFull {
|
||||||
// ANCHOR_END: poll_data_code_piece
|
// ANCHOR_END: poll_data_code_piece
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void seekExample(TaosConsumer<ResultBean> consumer) throws SQLException {
|
public static void seekExample(TaosConsumer<ResultBean> consumer) throws SQLException, JsonProcessingException {
|
||||||
// ANCHOR: consumer_seek
|
// ANCHOR: consumer_seek
|
||||||
List<String> topics = Collections.singletonList("topic_meters");
|
List<String> topics = Collections.singletonList("topic_meters");
|
||||||
try {
|
try {
|
||||||
|
@ -99,7 +100,7 @@ public class ConsumerLoopFull {
|
||||||
consumer.subscribe(topics);
|
consumer.subscribe(topics);
|
||||||
System.out.println("Subscribe topics successfully.");
|
System.out.println("Subscribe topics successfully.");
|
||||||
Set<TopicPartition> assignment = consumer.assignment();
|
Set<TopicPartition> assignment = consumer.assignment();
|
||||||
System.out.println("Now assignment: " + JSON.toJSONString(assignment));
|
System.out.println("Now assignment: " + JsonUtil.getObjectMapper().writeValueAsString(assignment));
|
||||||
|
|
||||||
ConsumerRecords<ResultBean> records = ConsumerRecords.emptyRecord();
|
ConsumerRecords<ResultBean> records = ConsumerRecords.emptyRecord();
|
||||||
// make sure we have got some data
|
// make sure we have got some data
|
||||||
|
@ -125,7 +126,7 @@ public class ConsumerLoopFull {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void commitExample(TaosConsumer<ResultBean> consumer) throws SQLException {
|
public static void commitExample(TaosConsumer<ResultBean> consumer) throws SQLException, JsonProcessingException {
|
||||||
// ANCHOR: commit_code_piece
|
// ANCHOR: commit_code_piece
|
||||||
List<String> topics = Collections.singletonList("topic_meters");
|
List<String> topics = Collections.singletonList("topic_meters");
|
||||||
try {
|
try {
|
||||||
|
@ -135,7 +136,7 @@ public class ConsumerLoopFull {
|
||||||
for (ConsumerRecord<ResultBean> record : records) {
|
for (ConsumerRecord<ResultBean> record : records) {
|
||||||
ResultBean bean = record.value();
|
ResultBean bean = record.value();
|
||||||
// Add your data processing logic here
|
// Add your data processing logic here
|
||||||
System.out.println("data: " + JSON.toJSONString(bean));
|
System.out.println("data: " + JsonUtil.getObjectMapper().writeValueAsString(bean));
|
||||||
}
|
}
|
||||||
if (!records.isEmpty()) {
|
if (!records.isEmpty()) {
|
||||||
// after processing the data, commit the offset manually
|
// after processing the data, commit the offset manually
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.taos.example;
|
package com.taos.example;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.taosdata.jdbc.TSDBDriver;
|
import com.taosdata.jdbc.TSDBDriver;
|
||||||
|
import com.taosdata.jdbc.utils.JsonUtil;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
|
@ -31,7 +31,11 @@ public class ConsumerLoopImp {
|
||||||
final AbsConsumerLoop consumerLoop = new AbsConsumerLoop() {
|
final AbsConsumerLoop consumerLoop = new AbsConsumerLoop() {
|
||||||
@Override
|
@Override
|
||||||
public void process(ResultBean result) {
|
public void process(ResultBean result) {
|
||||||
System.out.println("data: " + JSON.toJSONString(result));
|
try{
|
||||||
|
System.out.println("data: " + JsonUtil.getObjectMapper().writeValueAsString(result));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package com.taos.example;
|
package com.taos.example;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.taosdata.jdbc.TSDBDriver;
|
import com.taosdata.jdbc.TSDBDriver;
|
||||||
import com.taosdata.jdbc.tmq.*;
|
import com.taosdata.jdbc.tmq.*;
|
||||||
|
import com.taosdata.jdbc.utils.JsonUtil;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
@ -60,7 +61,7 @@ public class WsConsumerLoopFull {
|
||||||
// ANCHOR_END: create_consumer
|
// ANCHOR_END: create_consumer
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void pollExample(TaosConsumer<ResultBean> consumer) throws SQLException {
|
public static void pollExample(TaosConsumer<ResultBean> consumer) throws SQLException, JsonProcessingException {
|
||||||
// ANCHOR: poll_data_code_piece
|
// ANCHOR: poll_data_code_piece
|
||||||
List<String> topics = Collections.singletonList("topic_meters");
|
List<String> topics = Collections.singletonList("topic_meters");
|
||||||
try {
|
try {
|
||||||
|
@ -73,7 +74,7 @@ public class WsConsumerLoopFull {
|
||||||
for (ConsumerRecord<ResultBean> record : records) {
|
for (ConsumerRecord<ResultBean> record : records) {
|
||||||
ResultBean bean = record.value();
|
ResultBean bean = record.value();
|
||||||
// Add your data processing logic here
|
// Add your data processing logic here
|
||||||
System.out.println("data: " + JSON.toJSONString(bean));
|
System.out.println("data: " + JsonUtil.getObjectMapper().writeValueAsString(bean));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -91,7 +92,7 @@ public class WsConsumerLoopFull {
|
||||||
// ANCHOR_END: poll_data_code_piece
|
// ANCHOR_END: poll_data_code_piece
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void seekExample(TaosConsumer<ResultBean> consumer) throws SQLException {
|
public static void seekExample(TaosConsumer<ResultBean> consumer) throws SQLException, JsonProcessingException {
|
||||||
// ANCHOR: consumer_seek
|
// ANCHOR: consumer_seek
|
||||||
List<String> topics = Collections.singletonList("topic_meters");
|
List<String> topics = Collections.singletonList("topic_meters");
|
||||||
try {
|
try {
|
||||||
|
@ -99,7 +100,7 @@ public class WsConsumerLoopFull {
|
||||||
consumer.subscribe(topics);
|
consumer.subscribe(topics);
|
||||||
System.out.println("Subscribe topics successfully.");
|
System.out.println("Subscribe topics successfully.");
|
||||||
Set<TopicPartition> assignment = consumer.assignment();
|
Set<TopicPartition> assignment = consumer.assignment();
|
||||||
System.out.println("Now assignment: " + JSON.toJSONString(assignment));
|
System.out.println("Now assignment: " + JsonUtil.getObjectMapper().writeValueAsString(assignment));
|
||||||
|
|
||||||
ConsumerRecords<ResultBean> records = ConsumerRecords.emptyRecord();
|
ConsumerRecords<ResultBean> records = ConsumerRecords.emptyRecord();
|
||||||
// make sure we have got some data
|
// make sure we have got some data
|
||||||
|
@ -125,7 +126,7 @@ public class WsConsumerLoopFull {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void commitExample(TaosConsumer<ResultBean> consumer) throws SQLException {
|
public static void commitExample(TaosConsumer<ResultBean> consumer) throws SQLException, JsonProcessingException {
|
||||||
// ANCHOR: commit_code_piece
|
// ANCHOR: commit_code_piece
|
||||||
List<String> topics = Collections.singletonList("topic_meters");
|
List<String> topics = Collections.singletonList("topic_meters");
|
||||||
try {
|
try {
|
||||||
|
@ -135,7 +136,7 @@ public class WsConsumerLoopFull {
|
||||||
for (ConsumerRecord<ResultBean> record : records) {
|
for (ConsumerRecord<ResultBean> record : records) {
|
||||||
ResultBean bean = record.value();
|
ResultBean bean = record.value();
|
||||||
// Add your data processing logic here
|
// Add your data processing logic here
|
||||||
System.out.println("data: " + JSON.toJSONString(bean));
|
System.out.println("data: " + JsonUtil.getObjectMapper().writeValueAsString(bean));
|
||||||
}
|
}
|
||||||
if (!records.isEmpty()) {
|
if (!records.isEmpty()) {
|
||||||
// after processing the data, commit the offset manually
|
// after processing the data, commit the offset manually
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.taos.example;
|
package com.taos.example;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.taosdata.jdbc.TSDBDriver;
|
import com.taosdata.jdbc.TSDBDriver;
|
||||||
|
import com.taosdata.jdbc.utils.JsonUtil;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
|
@ -28,7 +28,11 @@ public abstract class WsConsumerLoopImp {
|
||||||
final AbsConsumerLoop consumerLoop = new AbsConsumerLoop() {
|
final AbsConsumerLoop consumerLoop = new AbsConsumerLoop() {
|
||||||
@Override
|
@Override
|
||||||
public void process(ResultBean result) {
|
public void process(ResultBean result) {
|
||||||
System.out.println("data: " + JSON.toJSONString(result));
|
try{
|
||||||
|
System.out.println("data: " + JsonUtil.getObjectMapper().writeValueAsString(result));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,9 @@ public class DataBaseMonitor {
|
||||||
public DataBaseMonitor init() throws SQLException {
|
public DataBaseMonitor init() throws SQLException {
|
||||||
if (conn == null) {
|
if (conn == null) {
|
||||||
String jdbcURL = System.getenv("TDENGINE_JDBC_URL");
|
String jdbcURL = System.getenv("TDENGINE_JDBC_URL");
|
||||||
|
if (jdbcURL == null || jdbcURL == ""){
|
||||||
|
jdbcURL = "jdbc:TAOS://localhost:6030?user=root&password=taosdata";
|
||||||
|
}
|
||||||
conn = DriverManager.getConnection(jdbcURL);
|
conn = DriverManager.getConnection(jdbcURL);
|
||||||
stmt = conn.createStatement();
|
stmt = conn.createStatement();
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,9 @@ public class SQLWriter {
|
||||||
*/
|
*/
|
||||||
private static Connection getConnection() throws SQLException {
|
private static Connection getConnection() throws SQLException {
|
||||||
String jdbcURL = System.getenv("TDENGINE_JDBC_URL");
|
String jdbcURL = System.getenv("TDENGINE_JDBC_URL");
|
||||||
|
if (jdbcURL == null || jdbcURL == ""){
|
||||||
|
jdbcURL = "jdbc:TAOS://localhost:6030?user=root&password=taosdata";
|
||||||
|
}
|
||||||
return DriverManager.getConnection(jdbcURL);
|
return DriverManager.getConnection(jdbcURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,37 @@ public class TestAll {
|
||||||
stmt.execute("drop database if exists " + dbName);
|
stmt.execute("drop database if exists " + dbName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
waitTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dropTopic(String topicName) throws SQLException {
|
||||||
|
String jdbcUrl = "jdbc:TAOS://localhost:6030?user=root&password=taosdata";
|
||||||
|
try (Connection conn = DriverManager.getConnection(jdbcUrl)) {
|
||||||
|
try (Statement stmt = conn.createStatement()) {
|
||||||
|
stmt.execute("drop topic if exists " + topicName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
waitTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void waitTransaction() throws SQLException {
|
||||||
|
|
||||||
|
String jdbcUrl = "jdbc:TAOS://localhost:6030?user=root&password=taosdata";
|
||||||
|
try (Connection conn = DriverManager.getConnection(jdbcUrl)) {
|
||||||
|
try (Statement stmt = conn.createStatement()) {
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
stmt.execute("show transactions");
|
||||||
|
try (ResultSet resultSet = stmt.getResultSet()) {
|
||||||
|
if (resultSet.next()) {
|
||||||
|
int count = resultSet.getInt(1);
|
||||||
|
if (count == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertData() throws SQLException {
|
public void insertData() throws SQLException {
|
||||||
|
@ -104,14 +135,20 @@ public class TestAll {
|
||||||
SubscribeDemo.main(args);
|
SubscribeDemo.main(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
@Test
|
||||||
// public void testSubscribeJni() throws SQLException, InterruptedException {
|
public void testSubscribeJni() throws SQLException, InterruptedException {
|
||||||
// dropDB("power");
|
dropTopic("topic_meters");
|
||||||
// ConsumerLoopFull.main(args);
|
dropDB("power");
|
||||||
// }
|
ConsumerLoopFull.main(args);
|
||||||
// @Test
|
dropTopic("topic_meters");
|
||||||
// public void testSubscribeWs() throws SQLException, InterruptedException {
|
dropDB("power");
|
||||||
// dropDB("power");
|
}
|
||||||
// WsConsumerLoopFull.main(args);
|
@Test
|
||||||
// }
|
public void testSubscribeWs() throws SQLException, InterruptedException {
|
||||||
|
dropTopic("topic_meters");
|
||||||
|
dropDB("power");
|
||||||
|
WsConsumerLoopFull.main(args);
|
||||||
|
dropTopic("topic_meters");
|
||||||
|
dropDB("power");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ docker pull tdengine/tdengine:latest
|
||||||
或者指定版本的容器镜像:
|
或者指定版本的容器镜像:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
docker pull tdengine/tdengine:3.0.1.4
|
docker pull tdengine/tdengine:3.3.3.0
|
||||||
```
|
```
|
||||||
|
|
||||||
然后只需执行下面的命令:
|
然后只需执行下面的命令:
|
||||||
|
|
|
@ -163,7 +163,7 @@ charset 的有效值是 UTF-8。
|
||||||
|
|
||||||
| 参数名称 | 参数说明 |
|
| 参数名称 | 参数说明 |
|
||||||
| :----------------: | :---------------------------------------------: |
|
| :----------------: | :---------------------------------------------: |
|
||||||
| numOfCommitThreads | 写入线程的最大数量,取值范围 0-1024,缺省值为 4 |
|
| numOfCommitThreads | 落盘线程的最大数量,取值范围 0-1024,缺省值为 4 |
|
||||||
|
|
||||||
### 日志相关
|
### 日志相关
|
||||||
|
|
||||||
|
@ -223,11 +223,11 @@ lossyColumns float|double
|
||||||
|
|
||||||
| 参数名称 | 参数说明 |
|
| 参数名称 | 参数说明 |
|
||||||
| :--------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|
| :--------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|
||||||
| enableCoreFile | crash 时是否生成 core 文件;0: 不生成,1:生成;默认值 为 1; 不同的启动方式,生成 core 文件的目录如下:1、systemctl start taosd 启动:生成的 core 在根目录下 <br/> 2、手动启动,就在 taosd 执行目录下。 |
|
| enableCoreFile | crash 时是否生成 core 文件;0: 不生成,1:生成;默认值为 1; 不同的启动方式,生成 core 文件的目录如下:1、systemctl start taosd 启动:生成的 core 在根目录下 <br/> 2、手动启动,就在 taosd 执行目录下。 |
|
||||||
| udf | 是否启动 UDF 服务;0: 不启动,1:启动;默认值 为 0 |
|
| udf | 是否启动 UDF 服务;0: 不启动,1:启动;默认值为 0 |
|
||||||
| ttlChangeOnWrite | ttl 到期时间是否伴随表的修改操作改变; 0: 不改变,1:改变 ;默认值 为 |
|
| ttlChangeOnWrite | ttl 到期时间是否伴随表的修改操作改变; 0: 不改变,1:改变;默认值为 0 |
|
||||||
| tmqMaxTopicNum | 订阅最多可建立的 topic 数量; 取值范围 1-10000;缺省值 为20 |
|
| tmqMaxTopicNum | 订阅最多可建立的 topic 数量; 取值范围 1-10000;缺省值为20 |
|
||||||
| maxTsmaNum | 集群内可创建的TSMA个数;取值范围:0-3;缺省值: 3 |
|
| maxTsmaNum | 集群内可创建的TSMA个数;取值范围:0-3;缺省值为 3 |
|
||||||
|
|
||||||
|
|
||||||
## taosd 监控指标
|
## taosd 监控指标
|
||||||
|
|
|
@ -10,7 +10,7 @@ TDengine 客户端驱动提供了应用编程所需要的全部 API,并且在
|
||||||
|
|
||||||
| 参数名称 | 参数含义 |
|
| 参数名称 | 参数含义 |
|
||||||
|:-----------:|:----------------------------------------------------------:|
|
|:-----------:|:----------------------------------------------------------:|
|
||||||
|firstEp | taos 启动时,主动连接的集群中首个 dnode 的 endpoint,缺省值:${hostname}:6030,若无法获取 ${hostname},则赋值为 localhost |
|
|firstEp | taos 启动时,主动连接的集群中首个 dnode 的 endpoint,缺省值:hostname:6030,若无法获取该服务器的 hostname,则赋值为 localhost |
|
||||||
|secondEp | 启动时,如果 firstEp 连接不上,尝试连接集群中第二个 dnode 的 endpoint,没有缺省值 |
|
|secondEp | 启动时,如果 firstEp 连接不上,尝试连接集群中第二个 dnode 的 endpoint,没有缺省值 |
|
||||||
|numOfRpcSessions | 一个客户端能创建的最大连接数,取值范围:10-50000000(单位为毫秒);缺省值:500000 |
|
|numOfRpcSessions | 一个客户端能创建的最大连接数,取值范围:10-50000000(单位为毫秒);缺省值:500000 |
|
||||||
|telemetryReporting | 是否上传 telemetry,0: 不上传,1: 上传;缺省值:1 |
|
|telemetryReporting | 是否上传 telemetry,0: 不上传,1: 上传;缺省值:1 |
|
||||||
|
|
|
@ -8,7 +8,7 @@ taosExplorer 是一个为用户提供 TDengine 实例的可视化管理交互工
|
||||||
|
|
||||||
## 安装
|
## 安装
|
||||||
|
|
||||||
taosEexplorer 无需单独安装,从 TDengine 3.3.0.0 版本开始,它随着 TDengine 安装包一起发布,安装完成后,就可以看到 `taos-explorer` 服务。如果按照 GitHub 里步骤自己编译 TDengine 源代码生成的安装包不包含 taosExplorer。
|
taosExplorer 无需单独安装,从 TDengine 3.3.0.0 版本开始,它随着 TDengine 安装包一起发布,安装完成后,就可以看到 `taos-explorer` 服务。如果按照 GitHub 里步骤自己编译 TDengine 源代码生成的安装包不包含 taosExplorer。
|
||||||
|
|
||||||
## 配置
|
## 配置
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ CREATE TABLE [IF NOT EXISTS] USING [db_name.]stb_name (field1_name [, field2_nam
|
||||||
|
|
||||||
**参数说明**
|
**参数说明**
|
||||||
|
|
||||||
1. FILE 语法表示数据来自于 CSV 文件(英文逗号分隔、英文单引号括住每个值),CSV 文件无需表头。CSV 文件中应仅包含 table name 与 tag 值。如需插入数据,请参考数据写入章节。
|
1. FILE 语法表示数据来自于 CSV 文件(英文逗号分隔、英文单引号括住每个值),CSV 文件无需表头。CSV 文件中应仅包含 table name 与 tag 值。如需插入数据,请参考'数据写入'章节。
|
||||||
2. 为指定的 stb_name 创建子表,该超级表必须已经存在。
|
2. 为指定的 stb_name 创建子表,该超级表必须已经存在。
|
||||||
3. field_name 列表顺序与 CSV 文件各列内容顺序一致。列表中不允许出现重复项,且必须包含 `tbname`,可包含零个或多个超级表中已定义的标签列。未包含在列表中的标签值将被设置为 NULL。
|
3. field_name 列表顺序与 CSV 文件各列内容顺序一致。列表中不允许出现重复项,且必须包含 `tbname`,可包含零个或多个超级表中已定义的标签列。未包含在列表中的标签值将被设置为 NULL。
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ INSERT INTO
|
||||||
|
|
||||||
2. VALUES 语法表示了要插入的一行或多行数据。
|
2. VALUES 语法表示了要插入的一行或多行数据。
|
||||||
|
|
||||||
3. FILE 语法表示数据来自于 CSV 文件(英文逗号分隔、英文单引号括住每个值),CSV 文件无需表头。
|
3. FILE 语法表示数据来自于 CSV 文件(英文逗号分隔、英文单引号括住每个值),CSV 文件无需表头。如仅需创建子表,请参考'表'章节。
|
||||||
|
|
||||||
4. `INSERT ... VALUES` 语句和 `INSERT ... FILE` 语句均可以在一条 INSERT 语句中同时向多个表插入数据。
|
4. `INSERT ... VALUES` 语句和 `INSERT ... FILE` 语句均可以在一条 INSERT 语句中同时向多个表插入数据。
|
||||||
|
|
||||||
|
@ -154,12 +154,20 @@ INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) FILE '/tmp/c
|
||||||
INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) FILE '/tmp/csvfile_21001.csv'
|
INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) FILE '/tmp/csvfile_21001.csv'
|
||||||
d21002 USING meters (groupId) TAGS (2) FILE '/tmp/csvfile_21002.csv';
|
d21002 USING meters (groupId) TAGS (2) FILE '/tmp/csvfile_21002.csv';
|
||||||
```
|
```
|
||||||
## 超级表语法
|
## 向超级表插入数据并自动创建子表
|
||||||
|
|
||||||
自动建表, 表名通过tbname列指定
|
自动建表, 表名通过 tbname 列指定
|
||||||
```sql
|
```sql
|
||||||
INSERT INTO meters(tbname, location, groupId, ts, current, voltage, phase)
|
INSERT INTO meters(tbname, location, groupId, ts, current, voltage, phase)
|
||||||
values('d31001', 'California.SanFrancisco', 2, '2021-07-13 14:06:34.630', 10.2, 219, 0.32)
|
VALUES ('d31001', 'California.SanFrancisco', 2, '2021-07-13 14:06:34.630', 10.2, 219, 0.32)
|
||||||
('d31001', 'California.SanFrancisco', 2, '2021-07-13 14:06:35.779', 10.15, 217, 0.33)
|
('d31001', 'California.SanFrancisco', 2, '2021-07-13 14:06:35.779', 10.15, 217, 0.33)
|
||||||
('d31002', NULL, 2, '2021-07-13 14:06:34.255', 10.15, 217, 0.33)
|
('d31002', NULL, 2, '2021-07-13 14:06:34.255', 10.15, 217, 0.33)
|
||||||
```
|
```
|
||||||
|
## 通过 CSV 文件向超级表插入数据并自动创建子表
|
||||||
|
|
||||||
|
根据 csv 文件内容,为 超级表创建子表,并填充相应 column 与 tag
|
||||||
|
|
||||||
|
```sql
|
||||||
|
INSERT INTO meters(tbname, location, groupId, ts, current, voltage, phase)
|
||||||
|
FILE '/tmp/csvfile_21002.csv'
|
||||||
|
```
|
||||||
|
|
|
@ -76,7 +76,7 @@ window_clause: {
|
||||||
FILL 语句指定某一窗口区间数据缺失的情况下的填充模式。填充模式包括以下几种:
|
FILL 语句指定某一窗口区间数据缺失的情况下的填充模式。填充模式包括以下几种:
|
||||||
|
|
||||||
1. 不进行填充:NONE(默认填充模式)。
|
1. 不进行填充:NONE(默认填充模式)。
|
||||||
2. VALUE 填充:固定值填充,此时需要指定填充的数值。例如:FILL(VALUE, 1.23)。这里需要注意,最终填充的值受由相应列的类型决定,如 FILL(VALUE, 1.23),相应列为 INT 类型,则填充值为 1, 若查询列表中有多列需要FILL, 则需要给每一个FILL列指定VALUE, 如`SELECT _wstart, min(c1), max(c1) FROM ... FILL(VALUE, 0, 0)`。
|
2. VALUE 填充:固定值填充,此时需要指定填充的数值。例如:FILL(VALUE, 1.23)。这里需要注意,最终填充的值受由相应列的类型决定,如 FILL(VALUE, 1.23),相应列为 INT 类型,则填充值为 1, 若查询列表中有多列需要 FILL, 则需要给每一个 FILL 列指定 VALUE, 如 `SELECT _wstart, min(c1), max(c1) FROM ... FILL(VALUE, 0, 0)`, 注意, SELECT 表达式中只有包含普通列时才需要指定 FILL VALUE, 如 `_wstart`, `_wstart+1a`, `now`, `1+1` 以及使用 partition by 时的 partition key (如 tbname)都不需要指定 VALUE, 如 `timediff(last(ts), _wstart)` 则需要指定VALUE。
|
||||||
3. PREV 填充:使用前一个非 NULL 值填充数据。例如:FILL(PREV)。
|
3. PREV 填充:使用前一个非 NULL 值填充数据。例如:FILL(PREV)。
|
||||||
4. NULL 填充:使用 NULL 填充数据。例如:FILL(NULL)。
|
4. NULL 填充:使用 NULL 填充数据。例如:FILL(NULL)。
|
||||||
5. LINEAR 填充:根据前后距离最近的非 NULL 值做线性插值填充。例如:FILL(LINEAR)。
|
5. LINEAR 填充:根据前后距离最近的非 NULL 值做线性插值填充。例如:FILL(LINEAR)。
|
||||||
|
|
|
@ -33,7 +33,7 @@ description: 对 JSON 类型如何使用的详细说明
|
||||||
|
|
||||||
## 支持的操作
|
## 支持的操作
|
||||||
|
|
||||||
1. 在 where 条件中时,支持函数 match/nmatch/between and/like/and/or/is null/is no null,不支持 in
|
1. 在 where 条件中时,支持函数 match/nmatch/between and/like/and/or/is null/is not null,不支持 in
|
||||||
|
|
||||||
```
|
```
|
||||||
select * from s1 where info->'k1' match 'v*';
|
select * from s1 where info->'k1' match 'v*';
|
||||||
|
|
|
@ -27,11 +27,15 @@ SHOW DNODES;
|
||||||
## 删除数据节点
|
## 删除数据节点
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
DROP DNODE dnode_id
|
DROP DNODE dnode_id [force] [unsafe]
|
||||||
```
|
```
|
||||||
|
|
||||||
注意删除 dnode 不等于停止相应的进程。实际中推荐先将一个 dnode 删除之后再停止其所对应的进程。
|
注意删除 dnode 不等于停止相应的进程。实际中推荐先将一个 dnode 删除之后再停止其所对应的进程。
|
||||||
|
|
||||||
|
只有在线节点可以被删除。如果要强制删除离线节点,需要执行强制删除操作, 即指定force选项。
|
||||||
|
|
||||||
|
当节点上存在单副本,并且节点处于离线,如果要强制删除该节点,需要执行非安全删除,即制定unsafe,并且数据不可再恢复。
|
||||||
|
|
||||||
## 修改数据节点配置
|
## 修改数据节点配置
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
|
|
|
@ -151,8 +151,9 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId,
|
||||||
* @param tversion
|
* @param tversion
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int32_t qGetQueryTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* tableName, int32_t* sversion,
|
int32_t qGetQueryTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, int32_t dbNameBuffLen, char* tableName,
|
||||||
int32_t* tversion, int32_t idx, bool* tbGet);
|
int32_t tbaleNameBuffLen, int32_t* sversion, int32_t* tversion, int32_t idx,
|
||||||
|
bool* tbGet);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main task execution function, including query on both table and multiple tables,
|
* The main task execution function, including query on both table and multiple tables,
|
||||||
|
|
|
@ -333,6 +333,7 @@ typedef struct SFillLogicNode {
|
||||||
SNode* pWStartTs;
|
SNode* pWStartTs;
|
||||||
SNode* pValues; // SNodeListNode
|
SNode* pValues; // SNodeListNode
|
||||||
STimeWindow timeRange;
|
STimeWindow timeRange;
|
||||||
|
SNodeList* pFillNullExprs;
|
||||||
} SFillLogicNode;
|
} SFillLogicNode;
|
||||||
|
|
||||||
typedef struct SSortLogicNode {
|
typedef struct SSortLogicNode {
|
||||||
|
@ -677,6 +678,7 @@ typedef struct SFillPhysiNode {
|
||||||
SNode* pWStartTs; // SColumnNode
|
SNode* pWStartTs; // SColumnNode
|
||||||
SNode* pValues; // SNodeListNode
|
SNode* pValues; // SNodeListNode
|
||||||
STimeWindow timeRange;
|
STimeWindow timeRange;
|
||||||
|
SNodeList* pFillNullExprs;
|
||||||
} SFillPhysiNode;
|
} SFillPhysiNode;
|
||||||
|
|
||||||
typedef SFillPhysiNode SStreamFillPhysiNode;
|
typedef SFillPhysiNode SStreamFillPhysiNode;
|
||||||
|
|
|
@ -917,6 +917,11 @@ int32_t taosGetErrSize();
|
||||||
#define TSDB_CODE_FUNC_INVALID_RES_LENGTH TAOS_DEF_ERROR_CODE(0, 0x280E)
|
#define TSDB_CODE_FUNC_INVALID_RES_LENGTH TAOS_DEF_ERROR_CODE(0, 0x280E)
|
||||||
#define TSDB_CODE_FUNC_HISTOGRAM_ERROR TAOS_DEF_ERROR_CODE(0, 0x280F)
|
#define TSDB_CODE_FUNC_HISTOGRAM_ERROR TAOS_DEF_ERROR_CODE(0, 0x280F)
|
||||||
#define TSDB_CODE_FUNC_PERCENTILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x2810)
|
#define TSDB_CODE_FUNC_PERCENTILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x2810)
|
||||||
|
#define TSDB_CODE_FUNC_FUNTION_PARA_RANGE TAOS_DEF_ERROR_CODE(0, 0x2811)
|
||||||
|
#define TSDB_CODE_FUNC_FUNTION_PARA_PRIMTS TAOS_DEF_ERROR_CODE(0, 0x2812)
|
||||||
|
#define TSDB_CODE_FUNC_FUNTION_PARA_PK TAOS_DEF_ERROR_CODE(0, 0x2813)
|
||||||
|
#define TSDB_CODE_FUNC_FUNTION_PARA_HAS_COL TAOS_DEF_ERROR_CODE(0, 0x2814)
|
||||||
|
#define TSDB_CODE_FUNC_FUNCTION_HISTO_TYPE TAOS_DEF_ERROR_CODE(0, 0x2815)
|
||||||
|
|
||||||
|
|
||||||
//udf
|
//udf
|
||||||
|
|
|
@ -56,7 +56,7 @@ int32_t tsShellActivityTimer = 3; // second
|
||||||
// queue & threads
|
// queue & threads
|
||||||
int32_t tsNumOfRpcThreads = 1;
|
int32_t tsNumOfRpcThreads = 1;
|
||||||
int32_t tsNumOfRpcSessions = 30000;
|
int32_t tsNumOfRpcSessions = 30000;
|
||||||
int32_t tsShareConnLimit = 8;
|
int32_t tsShareConnLimit = 10;
|
||||||
int32_t tsReadTimeout = 900;
|
int32_t tsReadTimeout = 900;
|
||||||
int32_t tsTimeToGetAvailableConn = 500000;
|
int32_t tsTimeToGetAvailableConn = 500000;
|
||||||
int32_t tsKeepAliveIdle = 60;
|
int32_t tsKeepAliveIdle = 60;
|
||||||
|
|
|
@ -36,12 +36,13 @@ typedef struct SVnodeMgmt {
|
||||||
SSingleWorker mgmtWorker;
|
SSingleWorker mgmtWorker;
|
||||||
SSingleWorker mgmtMultiWorker;
|
SSingleWorker mgmtMultiWorker;
|
||||||
SHashObj *hash;
|
SHashObj *hash;
|
||||||
|
SHashObj *closedHash;
|
||||||
TdThreadRwlock lock;
|
TdThreadRwlock lock;
|
||||||
SVnodesStat state;
|
SVnodesStat state;
|
||||||
STfs *pTfs;
|
STfs *pTfs;
|
||||||
TdThread thread;
|
TdThread thread;
|
||||||
bool stop;
|
bool stop;
|
||||||
TdThreadMutex createLock;
|
TdThreadMutex fileLock;
|
||||||
} SVnodeMgmt;
|
} SVnodeMgmt;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -94,7 +95,7 @@ SVnodeObj *vmAcquireVnode(SVnodeMgmt *pMgmt, int32_t vgId);
|
||||||
SVnodeObj *vmAcquireVnodeImpl(SVnodeMgmt *pMgmt, int32_t vgId, bool strict);
|
SVnodeObj *vmAcquireVnodeImpl(SVnodeMgmt *pMgmt, int32_t vgId, bool strict);
|
||||||
void vmReleaseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode);
|
void vmReleaseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode);
|
||||||
int32_t vmOpenVnode(SVnodeMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl);
|
int32_t vmOpenVnode(SVnodeMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl);
|
||||||
void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode, bool commitAndRemoveWal);
|
void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode, bool commitAndRemoveWal, bool keepClosed);
|
||||||
|
|
||||||
// vmHandle.c
|
// vmHandle.c
|
||||||
SArray *vmGetMsgHandles();
|
SArray *vmGetMsgHandles();
|
||||||
|
@ -111,6 +112,7 @@ int32_t vmProcessArbHeartBeatReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *numOfVnodes);
|
int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *numOfVnodes);
|
||||||
int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt);
|
int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt);
|
||||||
int32_t vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes, SVnodeObj ***ppVnodes);
|
int32_t vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes, SVnodeObj ***ppVnodes);
|
||||||
|
int32_t vmGetAllVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes, SVnodeObj ***ppVnodes);
|
||||||
|
|
||||||
// vmWorker.c
|
// vmWorker.c
|
||||||
int32_t vmStartWorker(SVnodeMgmt *pMgmt);
|
int32_t vmStartWorker(SVnodeMgmt *pMgmt);
|
||||||
|
|
|
@ -19,6 +19,54 @@
|
||||||
|
|
||||||
#define MAX_CONTENT_LEN 2 * 1024 * 1024
|
#define MAX_CONTENT_LEN 2 * 1024 * 1024
|
||||||
|
|
||||||
|
int32_t vmGetAllVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes, SVnodeObj ***ppVnodes) {
|
||||||
|
(void)taosThreadRwlockRdlock(&pMgmt->lock);
|
||||||
|
|
||||||
|
int32_t num = 0;
|
||||||
|
int32_t size = taosHashGetSize(pMgmt->hash);
|
||||||
|
int32_t closedSize = taosHashGetSize(pMgmt->closedHash);
|
||||||
|
size += closedSize;
|
||||||
|
SVnodeObj **pVnodes = taosMemoryCalloc(size, sizeof(SVnodeObj *));
|
||||||
|
if (pVnodes == NULL) {
|
||||||
|
(void)taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *pIter = taosHashIterate(pMgmt->hash, NULL);
|
||||||
|
while (pIter) {
|
||||||
|
SVnodeObj **ppVnode = pIter;
|
||||||
|
SVnodeObj *pVnode = *ppVnode;
|
||||||
|
if (pVnode && num < size) {
|
||||||
|
int32_t refCount = atomic_add_fetch_32(&pVnode->refCount, 1);
|
||||||
|
// dTrace("vgId:%d, acquire vnode list, ref:%d", pVnode->vgId, refCount);
|
||||||
|
pVnodes[num++] = (*ppVnode);
|
||||||
|
pIter = taosHashIterate(pMgmt->hash, pIter);
|
||||||
|
} else {
|
||||||
|
taosHashCancelIterate(pMgmt->hash, pIter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pIter = taosHashIterate(pMgmt->closedHash, NULL);
|
||||||
|
while (pIter) {
|
||||||
|
SVnodeObj **ppVnode = pIter;
|
||||||
|
SVnodeObj *pVnode = *ppVnode;
|
||||||
|
if (pVnode && num < size) {
|
||||||
|
int32_t refCount = atomic_add_fetch_32(&pVnode->refCount, 1);
|
||||||
|
// dTrace("vgId:%d, acquire vnode list, ref:%d", pVnode->vgId, refCount);
|
||||||
|
pVnodes[num++] = (*ppVnode);
|
||||||
|
pIter = taosHashIterate(pMgmt->closedHash, pIter);
|
||||||
|
} else {
|
||||||
|
taosHashCancelIterate(pMgmt->closedHash, pIter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(void)taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
|
*numOfVnodes = num;
|
||||||
|
*ppVnodes = pVnodes;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes, SVnodeObj ***ppVnodes) {
|
int32_t vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes, SVnodeObj ***ppVnodes) {
|
||||||
(void)taosThreadRwlockRdlock(&pMgmt->lock);
|
(void)taosThreadRwlockRdlock(&pMgmt->lock);
|
||||||
|
|
||||||
|
@ -203,6 +251,8 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) {
|
||||||
SVnodeObj **ppVnodes = NULL;
|
SVnodeObj **ppVnodes = NULL;
|
||||||
char file[PATH_MAX] = {0};
|
char file[PATH_MAX] = {0};
|
||||||
char realfile[PATH_MAX] = {0};
|
char realfile[PATH_MAX] = {0};
|
||||||
|
int32_t lino = 0;
|
||||||
|
int32_t ret = -1;
|
||||||
|
|
||||||
int32_t nBytes = snprintf(file, sizeof(file), "%s%svnodes_tmp.json", pMgmt->path, TD_DIRSEP);
|
int32_t nBytes = snprintf(file, sizeof(file), "%s%svnodes_tmp.json", pMgmt->path, TD_DIRSEP);
|
||||||
if (nBytes <= 0 || nBytes >= sizeof(file)) {
|
if (nBytes <= 0 || nBytes >= sizeof(file)) {
|
||||||
|
@ -215,8 +265,7 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfVnodes = 0;
|
int32_t numOfVnodes = 0;
|
||||||
code = vmGetVnodeListFromHash(pMgmt, &numOfVnodes, &ppVnodes);
|
TAOS_CHECK_GOTO(vmGetAllVnodeListFromHash(pMgmt, &numOfVnodes, &ppVnodes), &lino, _OVER);
|
||||||
if (code) goto _OVER;
|
|
||||||
|
|
||||||
// terrno = TSDB_CODE_OUT_OF_MEMORY;
|
// terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
pJson = tjsonCreateObject();
|
pJson = tjsonCreateObject();
|
||||||
|
@ -224,39 +273,56 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
if ((code = vmEncodeVnodeList(pJson, ppVnodes, numOfVnodes)) != 0) goto _OVER;
|
TAOS_CHECK_GOTO(vmEncodeVnodeList(pJson, ppVnodes, numOfVnodes), &lino, _OVER);
|
||||||
|
|
||||||
buffer = tjsonToString(pJson);
|
buffer = tjsonToString(pJson);
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
code = TSDB_CODE_INVALID_JSON_FORMAT;
|
code = TSDB_CODE_INVALID_JSON_FORMAT;
|
||||||
|
lino = __LINE__;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = taosThreadMutexLock(&pMgmt->fileLock);
|
||||||
|
if (code != 0) {
|
||||||
|
lino = __LINE__;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto _OVER;
|
lino = __LINE__;
|
||||||
|
goto _OVER1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t len = strlen(buffer);
|
int32_t len = strlen(buffer);
|
||||||
if (taosWriteFile(pFile, buffer, len) <= 0) {
|
if (taosWriteFile(pFile, buffer, len) <= 0) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto _OVER;
|
lino = __LINE__;
|
||||||
|
goto _OVER1;
|
||||||
}
|
}
|
||||||
if (taosFsyncFile(pFile) < 0) {
|
if (taosFsyncFile(pFile) < 0) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
goto _OVER;
|
lino = __LINE__;
|
||||||
|
goto _OVER1;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = taosCloseFile(&pFile);
|
code = taosCloseFile(&pFile);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
goto _OVER;
|
lino = __LINE__;
|
||||||
|
goto _OVER1;
|
||||||
}
|
}
|
||||||
TAOS_CHECK_GOTO(taosRenameFile(file, realfile), NULL, _OVER);
|
TAOS_CHECK_GOTO(taosRenameFile(file, realfile), &lino, _OVER1);
|
||||||
|
|
||||||
dInfo("succeed to write vnodes file:%s, vnodes:%d", realfile, numOfVnodes);
|
dInfo("succeed to write vnodes file:%s, vnodes:%d", realfile, numOfVnodes);
|
||||||
|
|
||||||
|
_OVER1:
|
||||||
|
ret = taosThreadMutexUnlock(&pMgmt->fileLock);
|
||||||
|
if (ret != 0) {
|
||||||
|
dError("failed to unlock since %s", tstrerror(ret));
|
||||||
|
}
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
if (pJson != NULL) tjsonDelete(pJson);
|
if (pJson != NULL) tjsonDelete(pJson);
|
||||||
if (buffer != NULL) taosMemoryFree(buffer);
|
if (buffer != NULL) taosMemoryFree(buffer);
|
||||||
|
@ -272,7 +338,8 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
dError("failed to write vnodes file:%s since %s, vnodes:%d", realfile, tstrerror(code), numOfVnodes);
|
dError("failed to write vnodes file:%s at line:%d since %s, vnodes:%d", realfile, lino, tstrerror(code),
|
||||||
|
numOfVnodes);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -415,27 +415,30 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = taosThreadMutexLock(&pMgmt->createLock);
|
|
||||||
if (code != 0) {
|
|
||||||
dError("vgId:%d, failed to lock since %s", req.vgId, tstrerror(code));
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
code = vmWriteVnodeListToFile(pMgmt);
|
code = vmWriteVnodeListToFile(pMgmt);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
code = terrno != 0 ? terrno : code;
|
code = terrno != 0 ? terrno : code;
|
||||||
int32_t ret = taosThreadMutexUnlock(&pMgmt->createLock);
|
|
||||||
if (ret != 0) {
|
|
||||||
dError("vgId:%d, failed to unlock since %s", req.vgId, tstrerror(ret));
|
|
||||||
}
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
int32_t ret = taosThreadMutexUnlock(&pMgmt->createLock);
|
|
||||||
if (ret != 0) {
|
|
||||||
dError("vgId:%d, failed to unlock since %s", req.vgId, tstrerror(ret));
|
|
||||||
}
|
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
|
int32_t r = 0;
|
||||||
|
r = taosThreadRwlockWrlock(&pMgmt->lock);
|
||||||
|
if (r != 0) {
|
||||||
|
dError("vgId:%d, failed to lock since %s", req.vgId, tstrerror(r));
|
||||||
|
}
|
||||||
|
if (r == 0) {
|
||||||
|
dInfo("vgId:%d, remove from hash", req.vgId);
|
||||||
|
r = taosHashRemove(pMgmt->hash, &req.vgId, sizeof(int32_t));
|
||||||
|
if (r != 0) {
|
||||||
|
dError("vgId:%d, failed to remove vnode since %s", req.vgId, tstrerror(r));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
r = taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
|
if (r != 0) {
|
||||||
|
dError("vgId:%d, failed to unlock since %s", req.vgId, tstrerror(r));
|
||||||
|
}
|
||||||
vnodeClose(pImpl);
|
vnodeClose(pImpl);
|
||||||
vnodeDestroy(0, path, pMgmt->pTfs, 0);
|
vnodeDestroy(0, path, pMgmt->pTfs, 0);
|
||||||
} else {
|
} else {
|
||||||
|
@ -535,7 +538,7 @@ int32_t vmProcessAlterVnodeTypeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
tstrncpy(wrapperCfg.path, pVnode->path, sizeof(wrapperCfg.path));
|
tstrncpy(wrapperCfg.path, pVnode->path, sizeof(wrapperCfg.path));
|
||||||
|
|
||||||
bool commitAndRemoveWal = vnodeShouldRemoveWal(pVnode->pImpl);
|
bool commitAndRemoveWal = vnodeShouldRemoveWal(pVnode->pImpl);
|
||||||
vmCloseVnode(pMgmt, pVnode, commitAndRemoveWal);
|
vmCloseVnode(pMgmt, pVnode, commitAndRemoveWal, true);
|
||||||
|
|
||||||
int32_t diskPrimary = wrapperCfg.diskPrimary;
|
int32_t diskPrimary = wrapperCfg.diskPrimary;
|
||||||
char path[TSDB_FILENAME_LEN] = {0};
|
char path[TSDB_FILENAME_LEN] = {0};
|
||||||
|
@ -683,7 +686,7 @@ int32_t vmProcessAlterHashRangeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
dInfo("vgId:%d, close vnode", srcVgId);
|
dInfo("vgId:%d, close vnode", srcVgId);
|
||||||
vmCloseVnode(pMgmt, pVnode, true);
|
vmCloseVnode(pMgmt, pVnode, true, false);
|
||||||
|
|
||||||
int32_t diskPrimary = wrapperCfg.diskPrimary;
|
int32_t diskPrimary = wrapperCfg.diskPrimary;
|
||||||
char srcPath[TSDB_FILENAME_LEN] = {0};
|
char srcPath[TSDB_FILENAME_LEN] = {0};
|
||||||
|
@ -792,7 +795,7 @@ int32_t vmProcessAlterVnodeReplicaReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
tstrncpy(wrapperCfg.path, pVnode->path, sizeof(wrapperCfg.path));
|
tstrncpy(wrapperCfg.path, pVnode->path, sizeof(wrapperCfg.path));
|
||||||
|
|
||||||
bool commitAndRemoveWal = vnodeShouldRemoveWal(pVnode->pImpl);
|
bool commitAndRemoveWal = vnodeShouldRemoveWal(pVnode->pImpl);
|
||||||
vmCloseVnode(pMgmt, pVnode, commitAndRemoveWal);
|
vmCloseVnode(pMgmt, pVnode, commitAndRemoveWal, true);
|
||||||
|
|
||||||
int32_t diskPrimary = wrapperCfg.diskPrimary;
|
int32_t diskPrimary = wrapperCfg.diskPrimary;
|
||||||
char path[TSDB_FILENAME_LEN] = {0};
|
char path[TSDB_FILENAME_LEN] = {0};
|
||||||
|
@ -860,7 +863,7 @@ int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
vmCloseVnode(pMgmt, pVnode, false);
|
vmCloseVnode(pMgmt, pVnode, false, false);
|
||||||
if (vmWriteVnodeListToFile(pMgmt) != 0) {
|
if (vmWriteVnodeListToFile(pMgmt) != 0) {
|
||||||
dError("vgId:%d, failed to write vnode list since %s", vgId, terrstr());
|
dError("vgId:%d, failed to write vnode list since %s", vgId, terrstr());
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,16 +166,34 @@ int32_t vmOpenVnode(SVnodeMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) {
|
||||||
(void)taosThreadRwlockWrlock(&pMgmt->lock);
|
(void)taosThreadRwlockWrlock(&pMgmt->lock);
|
||||||
SVnodeObj *pOld = NULL;
|
SVnodeObj *pOld = NULL;
|
||||||
int32_t r = taosHashGetDup(pMgmt->hash, &pVnode->vgId, sizeof(int32_t), (void *)&pOld);
|
int32_t r = taosHashGetDup(pMgmt->hash, &pVnode->vgId, sizeof(int32_t), (void *)&pOld);
|
||||||
|
if (r != 0) {
|
||||||
|
dError("vgId:%d, failed to get vnode from hash", pVnode->vgId);
|
||||||
|
}
|
||||||
if (pOld) {
|
if (pOld) {
|
||||||
vmFreeVnodeObj(&pOld);
|
vmFreeVnodeObj(&pOld);
|
||||||
}
|
}
|
||||||
int32_t code = taosHashPut(pMgmt->hash, &pVnode->vgId, sizeof(int32_t), &pVnode, sizeof(SVnodeObj *));
|
int32_t code = taosHashPut(pMgmt->hash, &pVnode->vgId, sizeof(int32_t), &pVnode, sizeof(SVnodeObj *));
|
||||||
|
|
||||||
|
pOld = NULL;
|
||||||
|
r = taosHashGetDup(pMgmt->closedHash, &pVnode->vgId, sizeof(int32_t), (void *)&pOld);
|
||||||
|
if (r != 0) {
|
||||||
|
dError("vgId:%d, failed to get vnode from closedHash", pVnode->vgId);
|
||||||
|
}
|
||||||
|
if (pOld) {
|
||||||
|
vmFreeVnodeObj(&pOld);
|
||||||
|
}
|
||||||
|
|
||||||
|
dInfo("vgId:%d, remove from closedHash", pVnode->vgId);
|
||||||
|
r = taosHashRemove(pMgmt->closedHash, &pVnode->vgId, sizeof(int32_t));
|
||||||
|
if (r != 0) {
|
||||||
|
dError("vgId:%d, failed to remove vnode from hash", pVnode->vgId);
|
||||||
|
}
|
||||||
(void)taosThreadRwlockUnlock(&pMgmt->lock);
|
(void)taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode, bool commitAndRemoveWal) {
|
void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode, bool commitAndRemoveWal, bool keepClosed) {
|
||||||
char path[TSDB_FILENAME_LEN] = {0};
|
char path[TSDB_FILENAME_LEN] = {0};
|
||||||
bool atExit = true;
|
bool atExit = true;
|
||||||
|
|
||||||
|
@ -185,7 +203,40 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode, bool commitAndRemoveWal)
|
||||||
|
|
||||||
(void)taosThreadRwlockWrlock(&pMgmt->lock);
|
(void)taosThreadRwlockWrlock(&pMgmt->lock);
|
||||||
int32_t r = taosHashRemove(pMgmt->hash, &pVnode->vgId, sizeof(int32_t));
|
int32_t r = taosHashRemove(pMgmt->hash, &pVnode->vgId, sizeof(int32_t));
|
||||||
|
if (r != 0) {
|
||||||
|
dError("vgId:%d, failed to remove vnode from hash", pVnode->vgId);
|
||||||
|
}
|
||||||
|
if (keepClosed) {
|
||||||
|
SVnodeObj *pClosedVnode = taosMemoryCalloc(1, sizeof(SVnodeObj));
|
||||||
|
(void)memset(pClosedVnode, 0, sizeof(SVnodeObj));
|
||||||
|
if (pVnode == NULL) {
|
||||||
|
dError("vgId:%d, failed to alloc vnode since %s", pVnode->vgId, terrstr());
|
||||||
(void)taosThreadRwlockUnlock(&pMgmt->lock);
|
(void)taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pClosedVnode->vgId = pVnode->vgId;
|
||||||
|
pClosedVnode->dropped = pVnode->dropped;
|
||||||
|
pClosedVnode->vgVersion = pVnode->vgVersion;
|
||||||
|
pClosedVnode->diskPrimary = pVnode->diskPrimary;
|
||||||
|
pClosedVnode->toVgId = pVnode->toVgId;
|
||||||
|
|
||||||
|
SVnodeObj *pOld = NULL;
|
||||||
|
r = taosHashGetDup(pMgmt->closedHash, &pVnode->vgId, sizeof(int32_t), (void *)&pOld);
|
||||||
|
if (r != 0) {
|
||||||
|
dError("vgId:%d, failed to get vnode from closedHash", pVnode->vgId);
|
||||||
|
}
|
||||||
|
if (pOld) {
|
||||||
|
vmFreeVnodeObj(&pOld);
|
||||||
|
}
|
||||||
|
dInfo("vgId:%d, put vnode to closedHash", pVnode->vgId);
|
||||||
|
r = taosHashPut(pMgmt->closedHash, &pVnode->vgId, sizeof(int32_t), &pClosedVnode, sizeof(SVnodeObj *));
|
||||||
|
if (r != 0) {
|
||||||
|
dError("vgId:%d, failed to put vnode to closedHash", pVnode->vgId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(void)taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
|
|
||||||
vmReleaseVnode(pMgmt, pVnode);
|
vmReleaseVnode(pMgmt, pVnode);
|
||||||
|
|
||||||
if (pVnode->failed) {
|
if (pVnode->failed) {
|
||||||
|
@ -362,9 +413,15 @@ static void *vmOpenVnodeInThread(void *param) {
|
||||||
static int32_t vmOpenVnodes(SVnodeMgmt *pMgmt) {
|
static int32_t vmOpenVnodes(SVnodeMgmt *pMgmt) {
|
||||||
pMgmt->hash = taosHashInit(TSDB_MIN_VNODES, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK);
|
pMgmt->hash = taosHashInit(TSDB_MIN_VNODES, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK);
|
||||||
if (pMgmt->hash == NULL) {
|
if (pMgmt->hash == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
dError("failed to init vnode hash since %s", terrstr());
|
dError("failed to init vnode hash since %s", terrstr());
|
||||||
return -1;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
pMgmt->closedHash =
|
||||||
|
taosHashInit(TSDB_MIN_VNODES, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK);
|
||||||
|
if (pMgmt->hash == NULL) {
|
||||||
|
dError("failed to init vnode closed hash since %s", terrstr());
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWrapperCfg *pCfgs = NULL;
|
SWrapperCfg *pCfgs = NULL;
|
||||||
|
@ -459,7 +516,7 @@ static void *vmCloseVnodeInThread(void *param) {
|
||||||
pMgmt->state.openVnodes, pMgmt->state.totalVnodes);
|
pMgmt->state.openVnodes, pMgmt->state.totalVnodes);
|
||||||
tmsgReportStartup("vnode-close", stepDesc);
|
tmsgReportStartup("vnode-close", stepDesc);
|
||||||
|
|
||||||
vmCloseVnode(pMgmt, pVnode, false);
|
vmCloseVnode(pMgmt, pVnode, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
dInfo("thread:%d, numOfVnodes:%d is closed", pThread->threadIndex, pThread->vnodeNum);
|
dInfo("thread:%d, numOfVnodes:%d is closed", pThread->threadIndex, pThread->vnodeNum);
|
||||||
|
@ -537,6 +594,18 @@ static void vmCloseVnodes(SVnodeMgmt *pMgmt) {
|
||||||
pMgmt->hash = NULL;
|
pMgmt->hash = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *pIter = taosHashIterate(pMgmt->closedHash, NULL);
|
||||||
|
while (pIter) {
|
||||||
|
SVnodeObj **ppVnode = pIter;
|
||||||
|
vmFreeVnodeObj(ppVnode);
|
||||||
|
pIter = taosHashIterate(pMgmt->closedHash, pIter);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pMgmt->closedHash != NULL) {
|
||||||
|
taosHashCleanup(pMgmt->closedHash);
|
||||||
|
pMgmt->closedHash = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
dInfo("total vnodes:%d are all closed", numOfVnodes);
|
dInfo("total vnodes:%d are all closed", numOfVnodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -545,7 +614,7 @@ static void vmCleanup(SVnodeMgmt *pMgmt) {
|
||||||
vmStopWorker(pMgmt);
|
vmStopWorker(pMgmt);
|
||||||
vnodeCleanup();
|
vnodeCleanup();
|
||||||
(void)taosThreadRwlockDestroy(&pMgmt->lock);
|
(void)taosThreadRwlockDestroy(&pMgmt->lock);
|
||||||
(void)taosThreadMutexDestroy(&pMgmt->createLock);
|
(void)taosThreadMutexDestroy(&pMgmt->fileLock);
|
||||||
taosMemoryFree(pMgmt);
|
taosMemoryFree(pMgmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,7 +706,7 @@ static int32_t vmInit(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = taosThreadMutexInit(&pMgmt->createLock, NULL);
|
code = taosThreadMutexInit(&pMgmt->fileLock, NULL);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
|
|
@ -15,13 +15,10 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mndArbGroup.h"
|
#include "mndArbGroup.h"
|
||||||
#include "audit.h"
|
|
||||||
#include "mndDb.h"
|
#include "mndDb.h"
|
||||||
#include "mndDnode.h"
|
#include "mndDnode.h"
|
||||||
#include "mndPrivilege.h"
|
|
||||||
#include "mndShow.h"
|
#include "mndShow.h"
|
||||||
#include "mndTrans.h"
|
#include "mndTrans.h"
|
||||||
#include "mndUser.h"
|
|
||||||
#include "mndVgroup.h"
|
#include "mndVgroup.h"
|
||||||
|
|
||||||
#define ARBGROUP_VER_NUMBER 1
|
#define ARBGROUP_VER_NUMBER 1
|
||||||
|
@ -245,11 +242,11 @@ static int32_t mndArbGroupActionUpdate(SSdb *pSdb, SArbGroup *pOld, SArbGroup *p
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) {
|
for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) {
|
||||||
(void)memcpy(pOld->members[i].state.token, pNew->members[i].state.token, TSDB_ARB_TOKEN_SIZE);
|
tstrncpy(pOld->members[i].state.token, pNew->members[i].state.token, TSDB_ARB_TOKEN_SIZE);
|
||||||
}
|
}
|
||||||
pOld->isSync = pNew->isSync;
|
pOld->isSync = pNew->isSync;
|
||||||
pOld->assignedLeader.dnodeId = pNew->assignedLeader.dnodeId;
|
pOld->assignedLeader.dnodeId = pNew->assignedLeader.dnodeId;
|
||||||
(void)memcpy(pOld->assignedLeader.token, pNew->assignedLeader.token, TSDB_ARB_TOKEN_SIZE);
|
tstrncpy(pOld->assignedLeader.token, pNew->assignedLeader.token, TSDB_ARB_TOKEN_SIZE);
|
||||||
pOld->assignedLeader.acked = pNew->assignedLeader.acked;
|
pOld->assignedLeader.acked = pNew->assignedLeader.acked;
|
||||||
pOld->version++;
|
pOld->version++;
|
||||||
|
|
||||||
|
@ -834,12 +831,12 @@ static int32_t mndProcessArbUpdateGroupBatchReq(SRpcMsg *pReq) {
|
||||||
newGroup.dbUid = pUpdateGroup->dbUid;
|
newGroup.dbUid = pUpdateGroup->dbUid;
|
||||||
for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) {
|
for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) {
|
||||||
newGroup.members[i].info.dnodeId = pUpdateGroup->members[i].dnodeId;
|
newGroup.members[i].info.dnodeId = pUpdateGroup->members[i].dnodeId;
|
||||||
(void)memcpy(newGroup.members[i].state.token, pUpdateGroup->members[i].token, TSDB_ARB_TOKEN_SIZE);
|
tstrncpy(newGroup.members[i].state.token, pUpdateGroup->members[i].token, TSDB_ARB_TOKEN_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
newGroup.isSync = pUpdateGroup->isSync;
|
newGroup.isSync = pUpdateGroup->isSync;
|
||||||
newGroup.assignedLeader.dnodeId = pUpdateGroup->assignedLeader.dnodeId;
|
newGroup.assignedLeader.dnodeId = pUpdateGroup->assignedLeader.dnodeId;
|
||||||
(void)memcpy(newGroup.assignedLeader.token, pUpdateGroup->assignedLeader.token, TSDB_ARB_TOKEN_SIZE);
|
tstrncpy(newGroup.assignedLeader.token, pUpdateGroup->assignedLeader.token, TSDB_ARB_TOKEN_SIZE);
|
||||||
newGroup.assignedLeader.acked = pUpdateGroup->assignedLeader.acked;
|
newGroup.assignedLeader.acked = pUpdateGroup->assignedLeader.acked;
|
||||||
newGroup.version = pUpdateGroup->version;
|
newGroup.version = pUpdateGroup->version;
|
||||||
|
|
||||||
|
@ -897,7 +894,7 @@ static void mndArbGroupSetAssignedLeader(SArbGroup *pGroup, int32_t index) {
|
||||||
SArbGroupMember *pMember = &pGroup->members[index];
|
SArbGroupMember *pMember = &pGroup->members[index];
|
||||||
|
|
||||||
pGroup->assignedLeader.dnodeId = pMember->info.dnodeId;
|
pGroup->assignedLeader.dnodeId = pMember->info.dnodeId;
|
||||||
(void)strncpy(pGroup->assignedLeader.token, pMember->state.token, TSDB_ARB_TOKEN_SIZE);
|
tstrncpy(pGroup->assignedLeader.token, pMember->state.token, TSDB_ARB_TOKEN_SIZE);
|
||||||
pGroup->assignedLeader.acked = false;
|
pGroup->assignedLeader.acked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -979,7 +976,7 @@ bool mndUpdateArbGroupByHeartBeat(SArbGroup *pGroup, SVArbHbRspMember *pRspMembe
|
||||||
|
|
||||||
// update token
|
// update token
|
||||||
mndArbGroupDupObj(pGroup, pNewGroup);
|
mndArbGroupDupObj(pGroup, pNewGroup);
|
||||||
(void)memcpy(pNewGroup->members[index].state.token, pRspMember->memberToken, TSDB_ARB_TOKEN_SIZE);
|
tstrncpy(pNewGroup->members[index].state.token, pRspMember->memberToken, TSDB_ARB_TOKEN_SIZE);
|
||||||
pNewGroup->isSync = false;
|
pNewGroup->isSync = false;
|
||||||
|
|
||||||
bool resetAssigned = false;
|
bool resetAssigned = false;
|
||||||
|
|
|
@ -400,8 +400,8 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
|
||||||
pSdb->commitTerm = pSdb->applyTerm;
|
pSdb->commitTerm = pSdb->applyTerm;
|
||||||
pSdb->commitConfig = pSdb->applyConfig;
|
pSdb->commitConfig = pSdb->applyConfig;
|
||||||
memcpy(pSdb->tableVer, tableVer, sizeof(tableVer));
|
memcpy(pSdb->tableVer, tableVer, sizeof(tableVer));
|
||||||
mInfo("read sdb file:%s success, commit index:%" PRId64 " term:%" PRId64 " config:%" PRId64, file, pSdb->commitIndex,
|
mInfo("vgId:1, trans:0, read sdb file:%s success, commit index:%" PRId64 " term:%" PRId64 " config:%" PRId64, file,
|
||||||
pSdb->commitTerm, pSdb->commitConfig);
|
pSdb->commitIndex, pSdb->commitTerm, pSdb->commitConfig);
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
if ((ret = taosCloseFile(&pFile)) != 0) {
|
if ((ret = taosCloseFile(&pFile)) != 0) {
|
||||||
|
@ -573,7 +573,8 @@ static int32_t sdbWriteFileImp(SSdb *pSdb, int32_t skip_type) {
|
||||||
pSdb->commitIndex = pSdb->applyIndex;
|
pSdb->commitIndex = pSdb->applyIndex;
|
||||||
pSdb->commitTerm = pSdb->applyTerm;
|
pSdb->commitTerm = pSdb->applyTerm;
|
||||||
pSdb->commitConfig = pSdb->applyConfig;
|
pSdb->commitConfig = pSdb->applyConfig;
|
||||||
mInfo("write sdb file success, commit index:%" PRId64 " term:%" PRId64 " config:%" PRId64 " file:%s",
|
mInfo("vgId:1, trans:0, write sdb file success, commit index:%" PRId64 " term:%" PRId64 " config:%" PRId64
|
||||||
|
" file:%s",
|
||||||
pSdb->commitIndex, pSdb->commitTerm, pSdb->commitConfig, curfile);
|
pSdb->commitIndex, pSdb->commitTerm, pSdb->commitConfig, curfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -610,8 +611,8 @@ int32_t sdbWriteFile(SSdb *pSdb, int32_t delta) {
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
mError("failed to write sdb file since %s", tstrerror(code));
|
mError("failed to write sdb file since %s", tstrerror(code));
|
||||||
} else {
|
} else {
|
||||||
mInfo("write sdb file success, apply index:%" PRId64 " term:%" PRId64 " config:%" PRId64, pSdb->applyIndex,
|
mInfo("vgId:1, trans:0, write sdb file success, apply index:%" PRId64 ", term:%" PRId64 ", config:%" PRId64,
|
||||||
pSdb->applyTerm, pSdb->applyConfig);
|
pSdb->applyIndex, pSdb->applyTerm, pSdb->applyConfig);
|
||||||
}
|
}
|
||||||
(void)taosThreadMutexUnlock(&pSdb->filelock);
|
(void)taosThreadMutexUnlock(&pSdb->filelock);
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -723,11 +723,9 @@ static int32_t tsdbCacheDropTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid,
|
||||||
rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch;
|
rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch;
|
||||||
{
|
{
|
||||||
SLastCol *pLastCol = NULL;
|
SLastCol *pLastCol = NULL;
|
||||||
|
if (values_list[0] != NULL) {
|
||||||
code = tsdbCacheDeserialize(values_list[0], values_list_sizes[0], &pLastCol);
|
code = tsdbCacheDeserialize(values_list[0], values_list_sizes[0], &pLastCol);
|
||||||
if (code == TSDB_CODE_INVALID_PARA) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbTrace("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
|
||||||
tstrerror(code));
|
|
||||||
} else if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
goto _exit;
|
goto _exit;
|
||||||
|
@ -736,13 +734,12 @@ static int32_t tsdbCacheDropTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid,
|
||||||
rocksdb_writebatch_delete(wb, keys_list[0], klen);
|
rocksdb_writebatch_delete(wb, keys_list[0], klen);
|
||||||
}
|
}
|
||||||
taosMemoryFreeClear(pLastCol);
|
taosMemoryFreeClear(pLastCol);
|
||||||
|
}
|
||||||
|
|
||||||
pLastCol = NULL;
|
pLastCol = NULL;
|
||||||
|
if (values_list[1] != NULL) {
|
||||||
code = tsdbCacheDeserialize(values_list[1], values_list_sizes[1], &pLastCol);
|
code = tsdbCacheDeserialize(values_list[1], values_list_sizes[1], &pLastCol);
|
||||||
if (code == TSDB_CODE_INVALID_PARA) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbTrace("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
|
||||||
tstrerror(code));
|
|
||||||
} else if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
goto _exit;
|
goto _exit;
|
||||||
|
@ -751,6 +748,7 @@ static int32_t tsdbCacheDropTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid,
|
||||||
rocksdb_writebatch_delete(wb, keys_list[1], klen);
|
rocksdb_writebatch_delete(wb, keys_list[1], klen);
|
||||||
}
|
}
|
||||||
taosMemoryFreeClear(pLastCol);
|
taosMemoryFreeClear(pLastCol);
|
||||||
|
}
|
||||||
|
|
||||||
rocksdb_free(values_list[0]);
|
rocksdb_free(values_list[0]);
|
||||||
rocksdb_free(values_list[1]);
|
rocksdb_free(values_list[1]);
|
||||||
|
@ -1218,15 +1216,14 @@ static int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SArray
|
||||||
SColVal *pColVal = &updCtx->colVal;
|
SColVal *pColVal = &updCtx->colVal;
|
||||||
|
|
||||||
SLastCol *pLastCol = NULL;
|
SLastCol *pLastCol = NULL;
|
||||||
|
if (values_list[i] != NULL) {
|
||||||
code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol);
|
code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol);
|
||||||
if (code == TSDB_CODE_INVALID_PARA) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbTrace("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
|
||||||
tstrerror(code));
|
|
||||||
} else if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("tsdb/cache: vgId:%d, deserialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code));
|
tsdbError("tsdb/cache: vgId:%d, deserialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code));
|
||||||
|
@ -1692,15 +1689,14 @@ static int32_t tsdbCacheLoadFromRocks(STsdb *pTsdb, tb_uid_t uid, SArray *pLastA
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (values_list[i] != NULL) {
|
||||||
code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol);
|
code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol);
|
||||||
if (code == TSDB_CODE_INVALID_PARA) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbTrace("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
|
||||||
tstrerror(code));
|
|
||||||
} else if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
SLastCol *pToFree = pLastCol;
|
SLastCol *pToFree = pLastCol;
|
||||||
SIdxKey *idxKey = &((SIdxKey *)TARRAY_DATA(remainCols))[j];
|
SIdxKey *idxKey = &((SIdxKey *)TARRAY_DATA(remainCols))[j];
|
||||||
if (pLastCol && pLastCol->cacheStatus != TSDB_LAST_CACHE_NO_CACHE) {
|
if (pLastCol && pLastCol->cacheStatus != TSDB_LAST_CACHE_NO_CACHE) {
|
||||||
|
@ -1959,15 +1955,14 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE
|
||||||
rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch;
|
rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch;
|
||||||
for (int i = 0; i < numKeys; ++i) {
|
for (int i = 0; i < numKeys; ++i) {
|
||||||
SLastCol *pLastCol = NULL;
|
SLastCol *pLastCol = NULL;
|
||||||
|
if (values_list[i] != NULL) {
|
||||||
code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol);
|
code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol);
|
||||||
if (code == TSDB_CODE_INVALID_PARA) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbTrace("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
|
||||||
tstrerror(code));
|
|
||||||
} else if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
SIdxKey *idxKey = taosArrayGet(remainCols, i);
|
SIdxKey *idxKey = taosArrayGet(remainCols, i);
|
||||||
SLastKey *pLastKey = &idxKey->key;
|
SLastKey *pLastKey = &idxKey->key;
|
||||||
if (NULL != pLastCol && (pLastCol->rowKey.ts <= eKey && pLastCol->rowKey.ts >= sKey)) {
|
if (NULL != pLastCol && (pLastCol->rowKey.ts <= eKey && pLastCol->rowKey.ts >= sKey)) {
|
||||||
|
|
|
@ -35,6 +35,7 @@ typedef struct SFillColInfo {
|
||||||
SExprInfo* pExpr;
|
SExprInfo* pExpr;
|
||||||
bool notFillCol; // denote if this column needs fill operation
|
bool notFillCol; // denote if this column needs fill operation
|
||||||
SVariant fillVal;
|
SVariant fillVal;
|
||||||
|
bool fillNull;
|
||||||
} SFillColInfo;
|
} SFillColInfo;
|
||||||
|
|
||||||
typedef struct SFillLinearInfo {
|
typedef struct SFillLinearInfo {
|
||||||
|
@ -125,12 +126,14 @@ void taosFillSetInputDataBlock(struct SFillInfo* pFillInfo, const struc
|
||||||
void taosFillUpdateStartTimestampInfo(SFillInfo* pFillInfo, int64_t ts);
|
void taosFillUpdateStartTimestampInfo(SFillInfo* pFillInfo, int64_t ts);
|
||||||
bool taosFillNotStarted(const SFillInfo* pFillInfo);
|
bool taosFillNotStarted(const SFillInfo* pFillInfo);
|
||||||
SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfFillExpr, SExprInfo* pNotFillExpr,
|
SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfFillExpr, SExprInfo* pNotFillExpr,
|
||||||
int32_t numOfNotFillCols, const struct SNodeListNode* val);
|
int32_t numOfNotFillCols, SExprInfo* pFillNullExpr, int32_t numOfFillNullExprs,
|
||||||
|
const struct SNodeListNode* val);
|
||||||
bool taosFillHasMoreResults(struct SFillInfo* pFillInfo);
|
bool taosFillHasMoreResults(struct SFillInfo* pFillInfo);
|
||||||
|
|
||||||
int32_t taosCreateFillInfo(TSKEY skey, int32_t numOfFillCols, int32_t numOfNotFillCols, int32_t capacity,
|
int32_t taosCreateFillInfo(TSKEY skey, int32_t numOfFillCols, int32_t numOfNotFillCols, int32_t fillNullCols,
|
||||||
SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol, int32_t slotId,
|
int32_t capacity, SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol,
|
||||||
int32_t order, const char* id, SExecTaskInfo* pTaskInfo, SFillInfo** ppFillInfo);
|
int32_t slotId, int32_t order, const char* id, SExecTaskInfo* pTaskInfo,
|
||||||
|
SFillInfo** ppFillInfo);
|
||||||
|
|
||||||
void* taosDestroyFillInfo(struct SFillInfo* pFillInfo);
|
void* taosDestroyFillInfo(struct SFillInfo* pFillInfo);
|
||||||
int32_t taosFillResultDataBlock(struct SFillInfo* pFillInfo, SSDataBlock* p, int32_t capacity);
|
int32_t taosFillResultDataBlock(struct SFillInfo* pFillInfo, SSDataBlock* p, int32_t capacity);
|
||||||
|
|
|
@ -86,7 +86,7 @@ int32_t createAnomalywindowOperatorInfo(SOperatorInfo* downstream, SPhysiNode* p
|
||||||
|
|
||||||
pOperator->exprSupp.hasWindowOrGroup = true;
|
pOperator->exprSupp.hasWindowOrGroup = true;
|
||||||
pInfo->tsSlotId = ((SColumnNode*)pAnomalyNode->window.pTspk)->slotId;
|
pInfo->tsSlotId = ((SColumnNode*)pAnomalyNode->window.pTspk)->slotId;
|
||||||
strncpy(pInfo->anomalyOpt, pAnomalyNode->anomalyOpt, sizeof(pInfo->anomalyOpt));
|
tstrncpy(pInfo->anomalyOpt, pAnomalyNode->anomalyOpt, sizeof(pInfo->anomalyOpt));
|
||||||
|
|
||||||
if (pAnomalyNode->window.pExprs != NULL) {
|
if (pAnomalyNode->window.pExprs != NULL) {
|
||||||
int32_t numOfScalarExpr = 0;
|
int32_t numOfScalarExpr = 0;
|
||||||
|
|
|
@ -320,7 +320,7 @@ static int32_t initDataSource(int32_t numOfSources, SExchangeInfo* pInfo, const
|
||||||
if (!pInfo->pTaskId) {
|
if (!pInfo->pTaskId) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
strncpy(pInfo->pTaskId, id, len);
|
tstrncpy(pInfo->pTaskId, id, len);
|
||||||
for (int32_t i = 0; i < numOfSources; ++i) {
|
for (int32_t i = 0; i < numOfSources; ++i) {
|
||||||
SSourceDataInfo dataInfo = {0};
|
SSourceDataInfo dataInfo = {0};
|
||||||
dataInfo.status = EX_SOURCE_DATA_NOT_READY;
|
dataInfo.status = EX_SOURCE_DATA_NOT_READY;
|
||||||
|
|
|
@ -545,8 +545,9 @@ int32_t qUpdateTableListForStreamScanner(qTaskInfo_t tinfo, const SArray* tableI
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qGetQueryTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* tableName, int32_t* sversion,
|
int32_t qGetQueryTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, int32_t dbNameBuffLen, char* tableName,
|
||||||
int32_t* tversion, int32_t idx, bool* tbGet) {
|
int32_t tbaleNameBuffLen, int32_t* sversion, int32_t* tversion, int32_t idx,
|
||||||
|
bool* tbGet) {
|
||||||
*tbGet = false;
|
*tbGet = false;
|
||||||
|
|
||||||
if (tinfo == NULL || dbName == NULL || tableName == NULL) {
|
if (tinfo == NULL || dbName == NULL || tableName == NULL) {
|
||||||
|
@ -567,12 +568,12 @@ int32_t qGetQueryTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* table
|
||||||
*sversion = pSchemaInfo->sw->version;
|
*sversion = pSchemaInfo->sw->version;
|
||||||
*tversion = pSchemaInfo->tversion;
|
*tversion = pSchemaInfo->tversion;
|
||||||
if (pSchemaInfo->dbname) {
|
if (pSchemaInfo->dbname) {
|
||||||
strcpy(dbName, pSchemaInfo->dbname);
|
tstrncpy(dbName, pSchemaInfo->dbname, dbNameBuffLen);
|
||||||
} else {
|
} else {
|
||||||
dbName[0] = 0;
|
dbName[0] = 0;
|
||||||
}
|
}
|
||||||
if (pSchemaInfo->tablename) {
|
if (pSchemaInfo->tablename) {
|
||||||
strcpy(tableName, pSchemaInfo->tablename);
|
tstrncpy(tableName, pSchemaInfo->tablename, tbaleNameBuffLen);
|
||||||
} else {
|
} else {
|
||||||
tableName[0] = 0;
|
tableName[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ typedef struct SFillOperatorInfo {
|
||||||
SExprInfo* pExprInfo;
|
SExprInfo* pExprInfo;
|
||||||
int32_t numOfExpr;
|
int32_t numOfExpr;
|
||||||
SExprSupp noFillExprSupp;
|
SExprSupp noFillExprSupp;
|
||||||
|
SExprSupp fillNullExprSupp;
|
||||||
} SFillOperatorInfo;
|
} SFillOperatorInfo;
|
||||||
|
|
||||||
static void destroyFillOperatorInfo(void* param);
|
static void destroyFillOperatorInfo(void* param);
|
||||||
|
@ -140,6 +141,15 @@ void doApplyScalarCalculation(SOperatorInfo* pOperator, SSDataBlock* pBlock, int
|
||||||
code = projectApplyFunctions(pNoFillSupp->pExprInfo, pInfo->pRes, pBlock, pNoFillSupp->pCtx, pNoFillSupp->numOfExprs,
|
code = projectApplyFunctions(pNoFillSupp->pExprInfo, pInfo->pRes, pBlock, pNoFillSupp->pCtx, pNoFillSupp->numOfExprs,
|
||||||
NULL);
|
NULL);
|
||||||
QUERY_CHECK_CODE(code, lino, _end);
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
if (pInfo->fillNullExprSupp.pExprInfo) {
|
||||||
|
pInfo->pRes->info.rows = 0;
|
||||||
|
code = setInputDataBlock(&pInfo->fillNullExprSupp, pBlock, order, scanFlag, false);
|
||||||
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
code = projectApplyFunctions(pInfo->fillNullExprSupp.pExprInfo, pInfo->pRes, pBlock, pInfo->fillNullExprSupp.pCtx,
|
||||||
|
pInfo->fillNullExprSupp.numOfExprs, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
pInfo->pRes->info.id.groupId = pBlock->info.id.groupId;
|
pInfo->pRes->info.id.groupId = pBlock->info.id.groupId;
|
||||||
|
|
||||||
_end:
|
_end:
|
||||||
|
@ -327,6 +337,7 @@ void destroyFillOperatorInfo(void* param) {
|
||||||
pInfo->pFinalRes = NULL;
|
pInfo->pFinalRes = NULL;
|
||||||
|
|
||||||
cleanupExprSupp(&pInfo->noFillExprSupp);
|
cleanupExprSupp(&pInfo->noFillExprSupp);
|
||||||
|
cleanupExprSupp(&pInfo->fillNullExprSupp);
|
||||||
|
|
||||||
taosMemoryFreeClear(pInfo->p);
|
taosMemoryFreeClear(pInfo->p);
|
||||||
taosArrayDestroy(pInfo->matchInfo.pList);
|
taosArrayDestroy(pInfo->matchInfo.pList);
|
||||||
|
@ -334,10 +345,11 @@ void destroyFillOperatorInfo(void* param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t numOfCols, SExprInfo* pNotFillExpr,
|
static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t numOfCols, SExprInfo* pNotFillExpr,
|
||||||
int32_t numOfNotFillCols, SNodeListNode* pValNode, STimeWindow win, int32_t capacity,
|
int32_t numOfNotFillCols, SExprInfo* pFillNullExpr, int32_t numOfFillNullExprs,
|
||||||
const char* id, SInterval* pInterval, int32_t fillType, int32_t order,
|
SNodeListNode* pValNode, STimeWindow win, int32_t capacity, const char* id,
|
||||||
SExecTaskInfo* pTaskInfo) {
|
SInterval* pInterval, int32_t fillType, int32_t order, SExecTaskInfo* pTaskInfo) {
|
||||||
SFillColInfo* pColInfo = createFillColInfo(pExpr, numOfCols, pNotFillExpr, numOfNotFillCols, pValNode);
|
SFillColInfo* pColInfo =
|
||||||
|
createFillColInfo(pExpr, numOfCols, pNotFillExpr, numOfNotFillCols, pFillNullExpr, numOfFillNullExprs, pValNode);
|
||||||
if (!pColInfo) {
|
if (!pColInfo) {
|
||||||
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
|
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
|
||||||
return terrno;
|
return terrno;
|
||||||
|
@ -348,8 +360,8 @@ static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t
|
||||||
// STimeWindow w = {0};
|
// STimeWindow w = {0};
|
||||||
// getInitialStartTimeWindow(pInterval, startKey, &w, order == TSDB_ORDER_ASC);
|
// getInitialStartTimeWindow(pInterval, startKey, &w, order == TSDB_ORDER_ASC);
|
||||||
pInfo->pFillInfo = NULL;
|
pInfo->pFillInfo = NULL;
|
||||||
int32_t code = taosCreateFillInfo(startKey, numOfCols, numOfNotFillCols, capacity, pInterval, fillType, pColInfo,
|
int32_t code = taosCreateFillInfo(startKey, numOfCols, numOfNotFillCols, numOfFillNullExprs, capacity, pInterval,
|
||||||
pInfo->primaryTsCol, order, id, pTaskInfo, &pInfo->pFillInfo);
|
fillType, pColInfo, pInfo->primaryTsCol, order, id, pTaskInfo, &pInfo->pFillInfo);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
|
@ -455,6 +467,13 @@ int32_t createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode* pPhyFi
|
||||||
initExprSupp(pNoFillSupp, pNoFillSupp->pExprInfo, pNoFillSupp->numOfExprs, &pTaskInfo->storageAPI.functionStore);
|
initExprSupp(pNoFillSupp, pNoFillSupp->pExprInfo, pNoFillSupp->numOfExprs, &pTaskInfo->storageAPI.functionStore);
|
||||||
QUERY_CHECK_CODE(code, lino, _error);
|
QUERY_CHECK_CODE(code, lino, _error);
|
||||||
|
|
||||||
|
code = createExprInfo(pPhyFillNode->pFillNullExprs, NULL, &pInfo->fillNullExprSupp.pExprInfo,
|
||||||
|
&pInfo->fillNullExprSupp.numOfExprs);
|
||||||
|
QUERY_CHECK_CODE(code, lino, _error);
|
||||||
|
code = initExprSupp(&pInfo->fillNullExprSupp, pInfo->fillNullExprSupp.pExprInfo, pInfo->fillNullExprSupp.numOfExprs,
|
||||||
|
&pTaskInfo->storageAPI.functionStore);
|
||||||
|
QUERY_CHECK_CODE(code, lino, _error);
|
||||||
|
|
||||||
SInterval* pInterval =
|
SInterval* pInterval =
|
||||||
QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL == downstream->operatorType
|
QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL == downstream->operatorType
|
||||||
? &((SMergeAlignedIntervalAggOperatorInfo*)downstream->info)->intervalAggOperatorInfo->interval
|
? &((SMergeAlignedIntervalAggOperatorInfo*)downstream->info)->intervalAggOperatorInfo->interval
|
||||||
|
@ -482,7 +501,9 @@ int32_t createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode* pPhyFi
|
||||||
code = extractColMatchInfo(pPhyFillNode->pFillExprs, pPhyFillNode->node.pOutputDataBlockDesc, &numOfOutputCols,
|
code = extractColMatchInfo(pPhyFillNode->pFillExprs, pPhyFillNode->node.pOutputDataBlockDesc, &numOfOutputCols,
|
||||||
COL_MATCH_FROM_SLOT_ID, &pInfo->matchInfo);
|
COL_MATCH_FROM_SLOT_ID, &pInfo->matchInfo);
|
||||||
|
|
||||||
|
QUERY_CHECK_CODE(code, lino, _error);
|
||||||
code = initFillInfo(pInfo, pExprInfo, pInfo->numOfExpr, pNoFillSupp->pExprInfo, pNoFillSupp->numOfExprs,
|
code = initFillInfo(pInfo, pExprInfo, pInfo->numOfExpr, pNoFillSupp->pExprInfo, pNoFillSupp->numOfExprs,
|
||||||
|
pInfo->fillNullExprSupp.pExprInfo, pInfo->fillNullExprSupp.numOfExprs,
|
||||||
(SNodeListNode*)pPhyFillNode->pValues, pPhyFillNode->timeRange, pResultInfo->capacity,
|
(SNodeListNode*)pPhyFillNode->pValues, pPhyFillNode->timeRange, pResultInfo->capacity,
|
||||||
pTaskInfo->id.str, pInterval, type, order, pTaskInfo);
|
pTaskInfo->id.str, pInterval, type, order, pTaskInfo);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
|
|
@ -6345,7 +6345,7 @@ int32_t fillTableCountScanDataBlock(STableCountScanSupp* pSupp, char* dbName, ch
|
||||||
QUERY_CHECK_NULL(colInfoData, code, lino, _end, terrno);
|
QUERY_CHECK_NULL(colInfoData, code, lino, _end, terrno);
|
||||||
if (strlen(stbName) != 0) {
|
if (strlen(stbName) != 0) {
|
||||||
char varStbName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
char varStbName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
strncpy(varDataVal(varStbName), stbName, TSDB_TABLE_NAME_LEN);
|
tstrncpy(varDataVal(varStbName), stbName, TSDB_TABLE_NAME_LEN);
|
||||||
varDataSetLen(varStbName, strlen(stbName));
|
varDataSetLen(varStbName, strlen(stbName));
|
||||||
code = colDataSetVal(colInfoData, 0, varStbName, false);
|
code = colDataSetVal(colInfoData, 0, varStbName, false);
|
||||||
QUERY_CHECK_CODE(code, lino, _end);
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
|
|
@ -1201,7 +1201,7 @@ static SStreamFillSupporter* initStreamFillSup(SStreamFillPhysiNode* pPhyFillNod
|
||||||
QUERY_CHECK_CODE(code, lino, _end);
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
pFillSup->pAllColInfo = createFillColInfo(pFillExprInfo, pFillSup->numOfFillCols, noFillExprInfo, numOfNotFillCols,
|
pFillSup->pAllColInfo = createFillColInfo(pFillExprInfo, pFillSup->numOfFillCols, noFillExprInfo, numOfNotFillCols,
|
||||||
(const SNodeListNode*)(pPhyFillNode->pValues));
|
NULL, 0, (const SNodeListNode*)(pPhyFillNode->pValues));
|
||||||
if (pFillSup->pAllColInfo == NULL) {
|
if (pFillSup->pAllColInfo == NULL) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
lino = __LINE__;
|
lino = __LINE__;
|
||||||
|
|
|
@ -497,6 +497,7 @@ void destroyStreamFinalIntervalOperatorInfo(void* param) {
|
||||||
blockDataDestroy(pInfo->pMidRetriveRes);
|
blockDataDestroy(pInfo->pMidRetriveRes);
|
||||||
blockDataDestroy(pInfo->pMidPulloverRes);
|
blockDataDestroy(pInfo->pMidPulloverRes);
|
||||||
if (pInfo->pUpdatedMap != NULL) {
|
if (pInfo->pUpdatedMap != NULL) {
|
||||||
|
// free flushed pos
|
||||||
tSimpleHashSetFreeFp(pInfo->pUpdatedMap, destroyFlusedppPos);
|
tSimpleHashSetFreeFp(pInfo->pUpdatedMap, destroyFlusedppPos);
|
||||||
tSimpleHashCleanup(pInfo->pUpdatedMap);
|
tSimpleHashCleanup(pInfo->pUpdatedMap);
|
||||||
pInfo->pUpdatedMap = NULL;
|
pInfo->pUpdatedMap = NULL;
|
||||||
|
@ -1967,7 +1968,6 @@ int32_t createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiN
|
||||||
code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str,
|
code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str,
|
||||||
pInfo->pState, &pTaskInfo->storageAPI.functionStore);
|
pInfo->pState, &pTaskInfo->storageAPI.functionStore);
|
||||||
QUERY_CHECK_CODE(code, lino, _error);
|
QUERY_CHECK_CODE(code, lino, _error);
|
||||||
tSimpleHashSetFreeFp(pInfo->aggSup.pResultRowHashTable, destroyFlusedppPos);
|
|
||||||
|
|
||||||
code = initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window);
|
code = initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window);
|
||||||
QUERY_CHECK_CODE(code, lino, _error);
|
QUERY_CHECK_CODE(code, lino, _error);
|
||||||
|
@ -5358,7 +5358,6 @@ int32_t createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiNode*
|
||||||
code = initAggSup(pSup, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str, pInfo->pState,
|
code = initAggSup(pSup, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str, pInfo->pState,
|
||||||
&pTaskInfo->storageAPI.functionStore);
|
&pTaskInfo->storageAPI.functionStore);
|
||||||
QUERY_CHECK_CODE(code, lino, _error);
|
QUERY_CHECK_CODE(code, lino, _error);
|
||||||
tSimpleHashSetFreeFp(pInfo->aggSup.pResultRowHashTable, destroyFlusedppPos);
|
|
||||||
|
|
||||||
if (pIntervalPhyNode->window.pExprs != NULL) {
|
if (pIntervalPhyNode->window.pExprs != NULL) {
|
||||||
int32_t numOfScalar = 0;
|
int32_t numOfScalar = 0;
|
||||||
|
|
|
@ -425,7 +425,7 @@ static bool sysTableIsOperatorCondOnOneTable(SNode* pCond, char* condTable) {
|
||||||
SValueNode* pValue = (SValueNode*)node->pRight;
|
SValueNode* pValue = (SValueNode*)node->pRight;
|
||||||
if (pValue->node.resType.type == TSDB_DATA_TYPE_NCHAR || pValue->node.resType.type == TSDB_DATA_TYPE_VARCHAR) {
|
if (pValue->node.resType.type == TSDB_DATA_TYPE_NCHAR || pValue->node.resType.type == TSDB_DATA_TYPE_VARCHAR) {
|
||||||
char* value = nodesGetValueFromNode(pValue);
|
char* value = nodesGetValueFromNode(pValue);
|
||||||
strncpy(condTable, varDataVal(value), TSDB_TABLE_NAME_LEN);
|
tstrncpy(condTable, varDataVal(value), TSDB_TABLE_NAME_LEN);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -914,41 +914,41 @@ _end:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t convertTagDataToStr(char* str, int type, void* buf, int32_t bufSize, int32_t* len) {
|
int32_t convertTagDataToStr(char* str, int32_t strBuffLen, int type, void* buf, int32_t bufSize, int32_t* len) {
|
||||||
int32_t n = 0;
|
int32_t n = 0;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TSDB_DATA_TYPE_NULL:
|
case TSDB_DATA_TYPE_NULL:
|
||||||
n = sprintf(str, "null");
|
n = tsnprintf(str, strBuffLen, "null");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_BOOL:
|
case TSDB_DATA_TYPE_BOOL:
|
||||||
n = sprintf(str, (*(int8_t*)buf) ? "true" : "false");
|
n = tsnprintf(str, strBuffLen, (*(int8_t*)buf) ? "true" : "false");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_TINYINT:
|
case TSDB_DATA_TYPE_TINYINT:
|
||||||
n = sprintf(str, "%d", *(int8_t*)buf);
|
n = tsnprintf(str, strBuffLen, "%d", *(int8_t*)buf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_SMALLINT:
|
case TSDB_DATA_TYPE_SMALLINT:
|
||||||
n = sprintf(str, "%d", *(int16_t*)buf);
|
n = tsnprintf(str, strBuffLen, "%d", *(int16_t*)buf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_INT:
|
case TSDB_DATA_TYPE_INT:
|
||||||
n = sprintf(str, "%d", *(int32_t*)buf);
|
n = tsnprintf(str, strBuffLen, "%d", *(int32_t*)buf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_BIGINT:
|
case TSDB_DATA_TYPE_BIGINT:
|
||||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||||
n = sprintf(str, "%" PRId64, *(int64_t*)buf);
|
n = tsnprintf(str, strBuffLen, "%" PRId64, *(int64_t*)buf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_FLOAT:
|
case TSDB_DATA_TYPE_FLOAT:
|
||||||
n = sprintf(str, "%.5f", GET_FLOAT_VAL(buf));
|
n = tsnprintf(str, strBuffLen, "%.5f", GET_FLOAT_VAL(buf));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_DOUBLE:
|
case TSDB_DATA_TYPE_DOUBLE:
|
||||||
n = sprintf(str, "%.9f", GET_DOUBLE_VAL(buf));
|
n = tsnprintf(str, strBuffLen, "%.9f", GET_DOUBLE_VAL(buf));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
case TSDB_DATA_TYPE_BINARY:
|
||||||
|
@ -973,19 +973,19 @@ int32_t convertTagDataToStr(char* str, int type, void* buf, int32_t bufSize, int
|
||||||
n = length;
|
n = length;
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_UTINYINT:
|
case TSDB_DATA_TYPE_UTINYINT:
|
||||||
n = sprintf(str, "%u", *(uint8_t*)buf);
|
n = tsnprintf(str, strBuffLen, "%u", *(uint8_t*)buf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_USMALLINT:
|
case TSDB_DATA_TYPE_USMALLINT:
|
||||||
n = sprintf(str, "%u", *(uint16_t*)buf);
|
n = tsnprintf(str, strBuffLen, "%u", *(uint16_t*)buf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_UINT:
|
case TSDB_DATA_TYPE_UINT:
|
||||||
n = sprintf(str, "%u", *(uint32_t*)buf);
|
n = tsnprintf(str, strBuffLen, "%u", *(uint32_t*)buf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_UBIGINT:
|
case TSDB_DATA_TYPE_UBIGINT:
|
||||||
n = sprintf(str, "%" PRIu64, *(uint64_t*)buf);
|
n = tsnprintf(str, strBuffLen, "%" PRIu64, *(uint64_t*)buf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -1065,14 +1065,21 @@ static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo,
|
||||||
int8_t tagType = (*smrSuperTable).me.stbEntry.schemaTag.pSchema[i].type;
|
int8_t tagType = (*smrSuperTable).me.stbEntry.schemaTag.pSchema[i].type;
|
||||||
pColInfoData = taosArrayGet(dataBlock->pDataBlock, 4);
|
pColInfoData = taosArrayGet(dataBlock->pDataBlock, 4);
|
||||||
QUERY_CHECK_NULL(pColInfoData, code, lino, _end, terrno);
|
QUERY_CHECK_NULL(pColInfoData, code, lino, _end, terrno);
|
||||||
|
int32_t tagStrBufflen = 32;
|
||||||
char tagTypeStr[VARSTR_HEADER_SIZE + 32];
|
char tagTypeStr[VARSTR_HEADER_SIZE + 32];
|
||||||
int tagTypeLen = sprintf(varDataVal(tagTypeStr), "%s", tDataTypes[tagType].name);
|
int tagTypeLen = tsnprintf(varDataVal(tagTypeStr), tagStrBufflen, "%s", tDataTypes[tagType].name);
|
||||||
|
tagStrBufflen -= tagTypeLen;
|
||||||
|
if (tagStrBufflen <= 0) {
|
||||||
|
code = TSDB_CODE_INVALID_PARA;
|
||||||
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
}
|
||||||
|
|
||||||
if (tagType == TSDB_DATA_TYPE_NCHAR) {
|
if (tagType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
tagTypeLen += sprintf(
|
tagTypeLen += tsnprintf(
|
||||||
varDataVal(tagTypeStr) + tagTypeLen, "(%d)",
|
varDataVal(tagTypeStr) + tagTypeLen, tagStrBufflen, "(%d)",
|
||||||
(int32_t)(((*smrSuperTable).me.stbEntry.schemaTag.pSchema[i].bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE));
|
(int32_t)(((*smrSuperTable).me.stbEntry.schemaTag.pSchema[i].bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE));
|
||||||
} else if (IS_VAR_DATA_TYPE(tagType)) {
|
} else if (IS_VAR_DATA_TYPE(tagType)) {
|
||||||
tagTypeLen += sprintf(varDataVal(tagTypeStr) + tagTypeLen, "(%d)",
|
tagTypeLen += tsnprintf(varDataVal(tagTypeStr) + tagTypeLen, tagStrBufflen, "(%d)",
|
||||||
(int32_t)((*smrSuperTable).me.stbEntry.schemaTag.pSchema[i].bytes - VARSTR_HEADER_SIZE));
|
(int32_t)((*smrSuperTable).me.stbEntry.schemaTag.pSchema[i].bytes - VARSTR_HEADER_SIZE));
|
||||||
}
|
}
|
||||||
varDataSetLen(tagTypeStr, tagTypeLen);
|
varDataSetLen(tagTypeStr, tagTypeLen);
|
||||||
|
@ -1127,7 +1134,7 @@ static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo,
|
||||||
QUERY_CHECK_NULL(tagVarChar, code, lino, _end, terrno);
|
QUERY_CHECK_NULL(tagVarChar, code, lino, _end, terrno);
|
||||||
int32_t len = -1;
|
int32_t len = -1;
|
||||||
if (tagLen > 0)
|
if (tagLen > 0)
|
||||||
convertTagDataToStr(varDataVal(tagVarChar), tagType, tagData, tagLen, &len);
|
convertTagDataToStr(varDataVal(tagVarChar), bufSize + 1 - VARSTR_HEADER_SIZE, tagType, tagData, tagLen, &len);
|
||||||
else
|
else
|
||||||
len = 0;
|
len = 0;
|
||||||
varDataSetLen(tagVarChar, len);
|
varDataSetLen(tagVarChar, len);
|
||||||
|
@ -1197,13 +1204,19 @@ static int32_t sysTableUserColsFillOneTableCols(const SSysTableScanInfo* pInfo,
|
||||||
int8_t colType = schemaRow->pSchema[i].type;
|
int8_t colType = schemaRow->pSchema[i].type;
|
||||||
pColInfoData = taosArrayGet(dataBlock->pDataBlock, 4);
|
pColInfoData = taosArrayGet(dataBlock->pDataBlock, 4);
|
||||||
QUERY_CHECK_NULL(pColInfoData, code, lino, _end, terrno);
|
QUERY_CHECK_NULL(pColInfoData, code, lino, _end, terrno);
|
||||||
|
int32_t colStrBufflen = 32;
|
||||||
char colTypeStr[VARSTR_HEADER_SIZE + 32];
|
char colTypeStr[VARSTR_HEADER_SIZE + 32];
|
||||||
int colTypeLen = sprintf(varDataVal(colTypeStr), "%s", tDataTypes[colType].name);
|
int colTypeLen = tsnprintf(varDataVal(colTypeStr), colStrBufflen, "%s", tDataTypes[colType].name);
|
||||||
|
colStrBufflen -= colTypeLen;
|
||||||
|
if (colStrBufflen <= 0) {
|
||||||
|
code = TSDB_CODE_INVALID_PARA;
|
||||||
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
}
|
||||||
if (colType == TSDB_DATA_TYPE_VARCHAR) {
|
if (colType == TSDB_DATA_TYPE_VARCHAR) {
|
||||||
colTypeLen += sprintf(varDataVal(colTypeStr) + colTypeLen, "(%d)",
|
colTypeLen += tsnprintf(varDataVal(colTypeStr) + colTypeLen, colStrBufflen, "(%d)",
|
||||||
(int32_t)(schemaRow->pSchema[i].bytes - VARSTR_HEADER_SIZE));
|
(int32_t)(schemaRow->pSchema[i].bytes - VARSTR_HEADER_SIZE));
|
||||||
} else if (colType == TSDB_DATA_TYPE_NCHAR) {
|
} else if (colType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
colTypeLen += sprintf(varDataVal(colTypeStr) + colTypeLen, "(%d)",
|
colTypeLen += tsnprintf(varDataVal(colTypeStr) + colTypeLen, colStrBufflen, "(%d)",
|
||||||
(int32_t)((schemaRow->pSchema[i].bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE));
|
(int32_t)((schemaRow->pSchema[i].bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE));
|
||||||
}
|
}
|
||||||
varDataSetLen(colTypeStr, colTypeLen);
|
varDataSetLen(colTypeStr, colTypeLen);
|
||||||
|
@ -2019,8 +2032,7 @@ static EDealRes getDBNameFromConditionWalker(SNode* pNode, void* pContext) {
|
||||||
|
|
||||||
SValueNode* node = (SValueNode*)pNode;
|
SValueNode* node = (SValueNode*)pNode;
|
||||||
char* dbName = nodesGetValueFromNode(node);
|
char* dbName = nodesGetValueFromNode(node);
|
||||||
strncpy(pContext, varDataVal(dbName), varDataLen(dbName));
|
tstrncpy((char*)pContext, varDataVal(dbName), TSDB_DB_NAME_LEN);
|
||||||
*((char*)pContext + varDataLen(dbName)) = 0;
|
|
||||||
return DEAL_RES_END; // stop walk
|
return DEAL_RES_END; // stop walk
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -2056,11 +2068,11 @@ static int32_t doSysTableScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes)
|
||||||
getDBNameFromCondition(pInfo->pCondition, dbName);
|
getDBNameFromCondition(pInfo->pCondition, dbName);
|
||||||
if (strncasecmp(name, TSDB_INS_TABLE_COMPACTS, TSDB_TABLE_FNAME_LEN) != 0 &&
|
if (strncasecmp(name, TSDB_INS_TABLE_COMPACTS, TSDB_TABLE_FNAME_LEN) != 0 &&
|
||||||
strncasecmp(name, TSDB_INS_TABLE_COMPACT_DETAILS, TSDB_TABLE_FNAME_LEN) != 0) {
|
strncasecmp(name, TSDB_INS_TABLE_COMPACT_DETAILS, TSDB_TABLE_FNAME_LEN) != 0) {
|
||||||
sprintf(pInfo->req.db, "%d.%s", pInfo->accountId, dbName);
|
TAOS_UNUSED(tsnprintf(pInfo->req.db, sizeof(pInfo->req.db), "%d.%s", pInfo->accountId, dbName));
|
||||||
}
|
}
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_COLS, TSDB_TABLE_FNAME_LEN) == 0) {
|
} else if (strncasecmp(name, TSDB_INS_TABLE_COLS, TSDB_TABLE_FNAME_LEN) == 0) {
|
||||||
getDBNameFromCondition(pInfo->pCondition, dbName);
|
getDBNameFromCondition(pInfo->pCondition, dbName);
|
||||||
if (dbName[0]) sprintf(pInfo->req.db, "%d.%s", pInfo->accountId, dbName);
|
if (dbName[0]) TAOS_UNUSED(tsnprintf(pInfo->req.db, sizeof(pInfo->req.db), "%d.%s", pInfo->accountId, dbName));
|
||||||
(void)sysTableIsCondOnOneTable(pInfo->pCondition, pInfo->req.filterTb);
|
(void)sysTableIsCondOnOneTable(pInfo->pCondition, pInfo->req.filterTb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,10 @@
|
||||||
static int32_t doSetVal(SColumnInfoData* pDstColInfoData, int32_t rowIndex, const SGroupKeys* pKey);
|
static int32_t doSetVal(SColumnInfoData* pDstColInfoData, int32_t rowIndex, const SGroupKeys* pKey);
|
||||||
|
|
||||||
static void setNotFillColumn(SFillInfo* pFillInfo, SColumnInfoData* pDstColInfo, int32_t rowIndex, int32_t colIdx) {
|
static void setNotFillColumn(SFillInfo* pFillInfo, SColumnInfoData* pDstColInfo, int32_t rowIndex, int32_t colIdx) {
|
||||||
|
SFillColInfo* pCol = &pFillInfo->pFillCol[colIdx];
|
||||||
|
if (pCol->fillNull) {
|
||||||
|
colDataSetNULL(pDstColInfo, rowIndex);
|
||||||
|
} else {
|
||||||
SRowVal* p = NULL;
|
SRowVal* p = NULL;
|
||||||
if (pFillInfo->type == TSDB_FILL_NEXT) {
|
if (pFillInfo->type == TSDB_FILL_NEXT) {
|
||||||
p = FILL_IS_ASC_FILL(pFillInfo) ? &pFillInfo->next : &pFillInfo->prev;
|
p = FILL_IS_ASC_FILL(pFillInfo) ? &pFillInfo->next : &pFillInfo->prev;
|
||||||
|
@ -56,6 +60,7 @@ static void setNotFillColumn(SFillInfo* pFillInfo, SColumnInfoData* pDstColInfo,
|
||||||
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
||||||
T_LONG_JMP(pFillInfo->pTaskInfo->env, code);
|
T_LONG_JMP(pFillInfo->pTaskInfo->env, code);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setNullRow(SSDataBlock* pBlock, SFillInfo* pFillInfo, int32_t rowIndex) {
|
static void setNullRow(SSDataBlock* pBlock, SFillInfo* pFillInfo, int32_t rowIndex) {
|
||||||
|
@ -545,9 +550,10 @@ static int32_t taosNumOfRemainRows(SFillInfo* pFillInfo) {
|
||||||
return pFillInfo->numOfRows - pFillInfo->index;
|
return pFillInfo->numOfRows - pFillInfo->index;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosCreateFillInfo(TSKEY skey, int32_t numOfFillCols, int32_t numOfNotFillCols, int32_t capacity,
|
int32_t taosCreateFillInfo(TSKEY skey, int32_t numOfFillCols, int32_t numOfNotFillCols, int32_t fillNullCols,
|
||||||
SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol, int32_t primaryTsSlotId,
|
int32_t capacity, SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol,
|
||||||
int32_t order, const char* id, SExecTaskInfo* pTaskInfo, SFillInfo** ppFillInfo) {
|
int32_t primaryTsSlotId, int32_t order, const char* id, SExecTaskInfo* pTaskInfo,
|
||||||
|
SFillInfo** ppFillInfo) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
if (fillType == TSDB_FILL_NONE) {
|
if (fillType == TSDB_FILL_NONE) {
|
||||||
|
@ -574,7 +580,7 @@ int32_t taosCreateFillInfo(TSKEY skey, int32_t numOfFillCols, int32_t numOfNotFi
|
||||||
|
|
||||||
pFillInfo->type = fillType;
|
pFillInfo->type = fillType;
|
||||||
pFillInfo->pFillCol = pCol;
|
pFillInfo->pFillCol = pCol;
|
||||||
pFillInfo->numOfCols = numOfFillCols + numOfNotFillCols;
|
pFillInfo->numOfCols = numOfFillCols + numOfNotFillCols + fillNullCols;
|
||||||
pFillInfo->alloc = capacity;
|
pFillInfo->alloc = capacity;
|
||||||
pFillInfo->id = id;
|
pFillInfo->id = id;
|
||||||
pFillInfo->interval = *pInterval;
|
pFillInfo->interval = *pInterval;
|
||||||
|
@ -761,10 +767,11 @@ _end:
|
||||||
int64_t getFillInfoStart(struct SFillInfo* pFillInfo) { return pFillInfo->start; }
|
int64_t getFillInfoStart(struct SFillInfo* pFillInfo) { return pFillInfo->start; }
|
||||||
|
|
||||||
SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfFillExpr, SExprInfo* pNotFillExpr,
|
SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfFillExpr, SExprInfo* pNotFillExpr,
|
||||||
int32_t numOfNoFillExpr, const struct SNodeListNode* pValNode) {
|
int32_t numOfNoFillExpr, SExprInfo* pFillNullExpr, int32_t numOfFillNullExpr,
|
||||||
|
const struct SNodeListNode* pValNode) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
SFillColInfo* pFillCol = taosMemoryCalloc(numOfFillExpr + numOfNoFillExpr, sizeof(SFillColInfo));
|
SFillColInfo* pFillCol = taosMemoryCalloc(numOfFillExpr + numOfNoFillExpr + numOfFillNullExpr, sizeof(SFillColInfo));
|
||||||
if (pFillCol == NULL) {
|
if (pFillCol == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -797,6 +804,13 @@ SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfFillExpr, SExprIn
|
||||||
pFillCol[i + numOfFillExpr].notFillCol = true;
|
pFillCol[i + numOfFillExpr].notFillCol = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < numOfFillNullExpr; ++i) {
|
||||||
|
SExprInfo* pExprInfo = &pFillNullExpr[i];
|
||||||
|
pFillCol[i + numOfFillExpr + numOfNoFillExpr].pExpr = pExprInfo;
|
||||||
|
pFillCol[i + numOfFillExpr + numOfNoFillExpr].notFillCol = true;
|
||||||
|
pFillCol[i + numOfFillExpr + numOfNoFillExpr].fillNull = true;
|
||||||
|
}
|
||||||
|
|
||||||
return pFillCol;
|
return pFillCol;
|
||||||
|
|
||||||
_end:
|
_end:
|
||||||
|
|
|
@ -1147,7 +1147,8 @@ int32_t createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyN
|
||||||
pInfo->fillType = convertFillType(pInterpPhyNode->fillMode);
|
pInfo->fillType = convertFillType(pInterpPhyNode->fillMode);
|
||||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||||
|
|
||||||
pInfo->pFillColInfo = createFillColInfo(pExprInfo, numOfExprs, NULL, 0, (SNodeListNode*)pInterpPhyNode->pFillValues);
|
pInfo->pFillColInfo =
|
||||||
|
createFillColInfo(pExprInfo, numOfExprs, NULL, 0, NULL, 0, (SNodeListNode*)pInterpPhyNode->pFillValues);
|
||||||
QUERY_CHECK_NULL(pInfo->pFillColInfo, code, lino, _error, terrno);
|
QUERY_CHECK_NULL(pInfo->pFillColInfo, code, lino, _error, terrno);
|
||||||
|
|
||||||
pInfo->pLinearInfo = NULL;
|
pInfo->pLinearInfo = NULL;
|
||||||
|
|
|
@ -115,7 +115,7 @@ SSDataBlock* getDummyBlock(SOperatorInfo* pOperator) {
|
||||||
int32_t code = colDataSetVal(pColInfo, i, reinterpret_cast<const char*>(&v), false);
|
int32_t code = colDataSetVal(pColInfo, i, reinterpret_cast<const char*>(&v), false);
|
||||||
ASSERT(code == 0);
|
ASSERT(code == 0);
|
||||||
|
|
||||||
// sprintf(buf, "this is %d row", i);
|
// tsnprintf(buf, "this is %d row", i);
|
||||||
// STR_TO_VARSTR(b1, buf);
|
// STR_TO_VARSTR(b1, buf);
|
||||||
//
|
//
|
||||||
// SColumnInfoData* pColInfo2 = static_cast<SColumnInfoData*>(TARRAY_GET_ELEM(pBlock->pDataBlock, 1));
|
// SColumnInfoData* pColInfo2 = static_cast<SColumnInfoData*>(TARRAY_GET_ELEM(pBlock->pDataBlock, 1));
|
||||||
|
@ -179,7 +179,7 @@ SSDataBlock* get2ColsDummyBlock(SOperatorInfo* pOperator) {
|
||||||
code = colDataSetVal(pColInfo1, i, reinterpret_cast<const char*>(&v), false);
|
code = colDataSetVal(pColInfo1, i, reinterpret_cast<const char*>(&v), false);
|
||||||
ASSERT(code == 0);
|
ASSERT(code == 0);
|
||||||
|
|
||||||
// sprintf(buf, "this is %d row", i);
|
// tsnprintf(buf, "this is %d row", i);
|
||||||
// STR_TO_VARSTR(b1, buf);
|
// STR_TO_VARSTR(b1, buf);
|
||||||
//
|
//
|
||||||
// SColumnInfoData* pColInfo2 = static_cast<SColumnInfoData*>(TARRAY_GET_ELEM(pBlock->pDataBlock, 1));
|
// SColumnInfoData* pColInfo2 = static_cast<SColumnInfoData*>(TARRAY_GET_ELEM(pBlock->pDataBlock, 1));
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
TEST(testCase, linear_hash_Tests) {
|
TEST(testCase, linear_hash_Tests) {
|
||||||
taosSeedRand(taosGetTimestampSec());
|
taosSeedRand(taosGetTimestampSec());
|
||||||
strcpy(tsTempDir, "/tmp/");
|
tstrncpy((char*)tsTempDir, "/tmp/", sizeof(tsTempDir));
|
||||||
|
|
||||||
_hash_fn_t fn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT);
|
_hash_fn_t fn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT);
|
||||||
|
|
||||||
|
|
|
@ -22,16 +22,48 @@ extern "C" {
|
||||||
|
|
||||||
#include "functionMgtInt.h"
|
#include "functionMgtInt.h"
|
||||||
|
|
||||||
|
struct SFunctionParaInfo;
|
||||||
|
|
||||||
typedef int32_t (*FTranslateFunc)(SFunctionNode* pFunc, char* pErrBuf, int32_t len);
|
typedef int32_t (*FTranslateFunc)(SFunctionNode* pFunc, char* pErrBuf, int32_t len);
|
||||||
typedef EFuncDataRequired (*FFuncDataRequired)(SFunctionNode* pFunc, STimeWindow* pTimeWindow);
|
typedef EFuncDataRequired (*FFuncDataRequired)(SFunctionNode* pFunc, STimeWindow* pTimeWindow);
|
||||||
typedef int32_t (*FCreateMergeFuncParameters)(SNodeList* pRawParameters, SNode* pPartialRes, SNodeList** pParameters);
|
typedef int32_t (*FCreateMergeFuncParameters)(SNodeList* pRawParameters, SNode* pPartialRes, SNodeList** pParameters);
|
||||||
typedef EFuncDataRequired (*FFuncDynDataRequired)(void* pRes, SDataBlockInfo* pBlocInfo);
|
typedef EFuncDataRequired (*FFuncDynDataRequired)(void* pRes, SDataBlockInfo* pBlocInfo);
|
||||||
typedef EFuncReturnRows (*FEstimateReturnRows)(SFunctionNode* pFunc);
|
typedef EFuncReturnRows (*FEstimateReturnRows)(SFunctionNode* pFunc);
|
||||||
|
|
||||||
|
#define MAX_FUNC_PARA_NUM 16
|
||||||
|
#define MAX_FUNC_PARA_FIXED_VALUE_NUM 16
|
||||||
|
typedef struct SParamRange {
|
||||||
|
int64_t iMinVal;
|
||||||
|
int64_t iMaxVal;
|
||||||
|
} SParamRange;
|
||||||
|
|
||||||
|
typedef struct SParamInfo {
|
||||||
|
bool isLastParam;
|
||||||
|
int8_t startParam;
|
||||||
|
int8_t endParam;
|
||||||
|
uint64_t validDataType;
|
||||||
|
uint64_t validNodeType;
|
||||||
|
uint64_t paramAttribute;
|
||||||
|
uint8_t valueRangeFlag; // 0 for no range and no fixed value, 1 for value has range, 2 for fixed value
|
||||||
|
uint8_t fixedValueSize;
|
||||||
|
char* fixedStrValue[MAX_FUNC_PARA_FIXED_VALUE_NUM]; // used for input parameter
|
||||||
|
int64_t fixedNumValue[MAX_FUNC_PARA_FIXED_VALUE_NUM]; // used for input parameter
|
||||||
|
SParamRange range;
|
||||||
|
} SParamInfo;
|
||||||
|
|
||||||
|
typedef struct SFunctionParaInfo {
|
||||||
|
int8_t minParamNum;
|
||||||
|
int8_t maxParamNum;
|
||||||
|
uint8_t paramInfoPattern;
|
||||||
|
SParamInfo inputParaInfo[MAX_FUNC_PARA_NUM][MAX_FUNC_PARA_NUM];
|
||||||
|
SParamInfo outputParaInfo;
|
||||||
|
} SFunctionParaInfo;
|
||||||
|
|
||||||
typedef struct SBuiltinFuncDefinition {
|
typedef struct SBuiltinFuncDefinition {
|
||||||
const char* name;
|
const char* name;
|
||||||
EFunctionType type;
|
EFunctionType type;
|
||||||
uint64_t classification;
|
uint64_t classification;
|
||||||
|
SFunctionParaInfo parameters;
|
||||||
FTranslateFunc translateFunc;
|
FTranslateFunc translateFunc;
|
||||||
FFuncDataRequired dataRequiredFunc;
|
FFuncDataRequired dataRequiredFunc;
|
||||||
FFuncDynDataRequired dynDataRequiredFunc;
|
FFuncDynDataRequired dynDataRequiredFunc;
|
||||||
|
|
|
@ -64,6 +64,80 @@ extern "C" {
|
||||||
|
|
||||||
#define FUNC_UDF_ID_START 5000
|
#define FUNC_UDF_ID_START 5000
|
||||||
|
|
||||||
|
#define FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(n) ((uint64_t)1 << n)
|
||||||
|
#define FUNC_PARAM_SUPPORT_ALL_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(0)
|
||||||
|
#define FUNC_PARAM_SUPPORT_NUMERIC_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(1)
|
||||||
|
#define FUNC_PARAM_SUPPORT_VAR_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(2)
|
||||||
|
#define FUNC_PARAM_SUPPORT_STRING_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(3)
|
||||||
|
#define FUNC_PARAM_SUPPORT_BOOL_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(4)
|
||||||
|
#define FUNC_PARAM_SUPPORT_TINYINT_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(5)
|
||||||
|
#define FUNC_PARAM_SUPPORT_SMALLINT_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(6)
|
||||||
|
#define FUNC_PARAM_SUPPORT_INT_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(7)
|
||||||
|
#define FUNC_PARAM_SUPPORT_BIGINT_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(8)
|
||||||
|
#define FUNC_PARAM_SUPPORT_FLOAT_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(9)
|
||||||
|
#define FUNC_PARAM_SUPPORT_DOUBLE_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(10)
|
||||||
|
#define FUNC_PARAM_SUPPORT_VARCHAR_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(11)
|
||||||
|
#define FUNC_PARAM_SUPPORT_TIMESTAMP_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(12)
|
||||||
|
#define FUNC_PARAM_SUPPORT_NCHAR_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(13)
|
||||||
|
#define FUNC_PARAM_SUPPORT_UTINYINT_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(14)
|
||||||
|
#define FUNC_PARAM_SUPPORT_USMALLINT_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(15)
|
||||||
|
#define FUNC_PARAM_SUPPORT_UINT_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(16)
|
||||||
|
#define FUNC_PARAM_SUPPORT_UBIGINT_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(17)
|
||||||
|
#define FUNC_PARAM_SUPPORT_JSON_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(18)
|
||||||
|
#define FUNC_PARAM_SUPPORT_VARB_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(19)
|
||||||
|
#define FUNC_PARAM_SUPPORT_GEOMETRY_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(20)
|
||||||
|
#define FUNC_PARAM_SUPPORT_INTEGER_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(21)
|
||||||
|
#define FUNC_PARAM_SUPPORT_NULL_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(22)
|
||||||
|
#define FUNC_PARAM_SUPPORT_UNIX_TS_TYPE FUNC_MGT_FUNC_PARAM_SUPPORT_TYPE(23)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define FUNC_MGT_FUNC_PARAM_SUPPORT_NODE(n) ((uint64_t)1 << n)
|
||||||
|
#define FUNC_PARAM_SUPPORT_EXPR_NODE FUNC_MGT_FUNC_PARAM_SUPPORT_NODE(0)
|
||||||
|
#define FUNC_PARAM_SUPPORT_VALUE_NODE FUNC_MGT_FUNC_PARAM_SUPPORT_NODE(1)
|
||||||
|
#define FUNC_PARAM_SUPPORT_OPERATOR_NODE FUNC_MGT_FUNC_PARAM_SUPPORT_NODE(2)
|
||||||
|
#define FUNC_PARAM_SUPPORT_FUNCTION_NODE FUNC_MGT_FUNC_PARAM_SUPPORT_NODE(3)
|
||||||
|
#define FUNC_PARAM_SUPPORT_LOGIC_CONDITION_NODE FUNC_MGT_FUNC_PARAM_SUPPORT_NODE(4)
|
||||||
|
#define FUNC_PARAM_SUPPORT_CASE_WHEN_NODE FUNC_MGT_FUNC_PARAM_SUPPORT_NODE(5)
|
||||||
|
#define FUNC_PARAM_SUPPORT_COLUMN_NODE FUNC_MGT_FUNC_PARAM_SUPPORT_NODE(6)
|
||||||
|
#define FUNC_PARAM_SUPPORT_NOT_VALUE_NODE FUNC_MGT_FUNC_PARAM_SUPPORT_NODE(7)
|
||||||
|
|
||||||
|
#define FUNC_PARAM_NO_SPECIFIC_ATTRIBUTE 0
|
||||||
|
#define FUNC_PARAM_MUST_BE_PRIMTS 1
|
||||||
|
#define FUNC_PARAM_MUST_BE_PK 2
|
||||||
|
#define FUNC_PARAM_MUST_HAVE_COLUMN 3
|
||||||
|
#define FUNC_PARAM_MUST_BE_TIME_UNIT 4
|
||||||
|
#define FUNC_PARAM_VALUE_NODE_NOT_NULL 5
|
||||||
|
|
||||||
|
#define FUNC_PARAM_NO_SPECIFIC_VALUE 0
|
||||||
|
#define FUNC_PARAM_HAS_RANGE 1
|
||||||
|
#define FUNC_PARAM_HAS_FIXED_VALUE 2
|
||||||
|
|
||||||
|
#define FUNC_ERR_RET(c) \
|
||||||
|
do { \
|
||||||
|
int32_t _code = c; \
|
||||||
|
if (_code != TSDB_CODE_SUCCESS) { \
|
||||||
|
terrno = _code; \
|
||||||
|
return _code; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
#define FUNC_RET(c) \
|
||||||
|
do { \
|
||||||
|
int32_t _code = c; \
|
||||||
|
if (_code != TSDB_CODE_SUCCESS) { \
|
||||||
|
terrno = _code; \
|
||||||
|
} \
|
||||||
|
return _code; \
|
||||||
|
} while (0)
|
||||||
|
#define FUNC_ERR_JRET(c) \
|
||||||
|
do { \
|
||||||
|
code = c; \
|
||||||
|
if (code != TSDB_CODE_SUCCESS) { \
|
||||||
|
terrno = code; \
|
||||||
|
goto _return; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -183,7 +183,7 @@ void monGenClusterInfoTable(SMonInfo *pMonitor){
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosHashRemove(tsMonitor.metrics, metric_names[i], strlen(metric_names[i])) != 0) {
|
if (taosHashRemove(tsMonitor.metrics, metric_names[i], strlen(metric_names[i])) != 0) {
|
||||||
uError("failed to remove metric %s", metric_names[i]);
|
uTrace("failed to remove metric %s", metric_names[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -652,7 +652,7 @@ void monGenMnodeRoleTable(SMonInfo *pMonitor){
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosHashRemove(tsMonitor.metrics, mnodes_role_gauges[i], strlen(mnodes_role_gauges[i])) != 0) {
|
if (taosHashRemove(tsMonitor.metrics, mnodes_role_gauges[i], strlen(mnodes_role_gauges[i])) != 0) {
|
||||||
uError("failed to remove metric %s", mnodes_role_gauges[i]);
|
uTrace("failed to remove metric %s", mnodes_role_gauges[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -725,7 +725,7 @@ void monGenVnodeRoleTable(SMonInfo *pMonitor){
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosHashRemove(tsMonitor.metrics, vnodes_role_gauges[i], strlen(vnodes_role_gauges[i])) != 0) {
|
if (taosHashRemove(tsMonitor.metrics, vnodes_role_gauges[i], strlen(vnodes_role_gauges[i])) != 0) {
|
||||||
uError("failed to remove metric %s", vnodes_role_gauges[i]);
|
uTrace("failed to remove metric %s", vnodes_role_gauges[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,10 @@ class MonitorTest : public ::testing::Test {
|
||||||
monInit(&cfg);
|
monInit(&cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TearDownTestSuite() { monCleanup(); }
|
static void TearDownTestSuite() {
|
||||||
|
monCleanup();
|
||||||
|
taosMsleep(100);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void SetUp() override {}
|
void SetUp() override {}
|
||||||
|
|
|
@ -642,6 +642,7 @@ static int32_t logicFillCopy(const SFillLogicNode* pSrc, SFillLogicNode* pDst) {
|
||||||
CLONE_NODE_FIELD(pWStartTs);
|
CLONE_NODE_FIELD(pWStartTs);
|
||||||
CLONE_NODE_FIELD(pValues);
|
CLONE_NODE_FIELD(pValues);
|
||||||
COPY_OBJECT_FIELD(timeRange, sizeof(STimeWindow));
|
COPY_OBJECT_FIELD(timeRange, sizeof(STimeWindow));
|
||||||
|
CLONE_NODE_LIST_FIELD(pFillNullExprs);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2887,6 +2887,7 @@ static const char* jkFillPhysiPlanWStartTs = "WStartTs";
|
||||||
static const char* jkFillPhysiPlanValues = "Values";
|
static const char* jkFillPhysiPlanValues = "Values";
|
||||||
static const char* jkFillPhysiPlanStartTime = "StartTime";
|
static const char* jkFillPhysiPlanStartTime = "StartTime";
|
||||||
static const char* jkFillPhysiPlanEndTime = "EndTime";
|
static const char* jkFillPhysiPlanEndTime = "EndTime";
|
||||||
|
static const char* jkFillPhysiPlanFillNullExprs = "FillNullExprs";
|
||||||
|
|
||||||
static int32_t physiFillNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t physiFillNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
const SFillPhysiNode* pNode = (const SFillPhysiNode*)pObj;
|
const SFillPhysiNode* pNode = (const SFillPhysiNode*)pObj;
|
||||||
|
@ -2913,6 +2914,9 @@ static int32_t physiFillNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkFillPhysiPlanEndTime, pNode->timeRange.ekey);
|
code = tjsonAddIntegerToObject(pJson, jkFillPhysiPlanEndTime, pNode->timeRange.ekey);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = nodeListToJson(pJson, jkFillPhysiPlanFillNullExprs, pNode->pFillNullExprs);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2942,6 +2946,9 @@ static int32_t jsonToPhysiFillNode(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetBigIntValue(pJson, jkFillPhysiPlanEndTime, &pNode->timeRange.ekey);
|
code = tjsonGetBigIntValue(pJson, jkFillPhysiPlanEndTime, &pNode->timeRange.ekey);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = jsonToNodeList(pJson, jkFillPhysiPlanFillNullExprs, &pNode->pFillNullExprs);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3326,7 +3326,8 @@ enum {
|
||||||
PHY_FILL_CODE_WSTART,
|
PHY_FILL_CODE_WSTART,
|
||||||
PHY_FILL_CODE_VALUES,
|
PHY_FILL_CODE_VALUES,
|
||||||
PHY_FILL_CODE_TIME_RANGE,
|
PHY_FILL_CODE_TIME_RANGE,
|
||||||
PHY_FILL_CODE_INPUT_TS_ORDER
|
PHY_FILL_CODE_INPUT_TS_ORDER,
|
||||||
|
PHY_FILL_CODE_FILL_NULL_EXPRS,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int32_t physiFillNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
static int32_t physiFillNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
||||||
|
@ -3351,6 +3352,9 @@ static int32_t physiFillNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tlvEncodeObj(pEncoder, PHY_FILL_CODE_TIME_RANGE, timeWindowToMsg, &pNode->timeRange);
|
code = tlvEncodeObj(pEncoder, PHY_FILL_CODE_TIME_RANGE, timeWindowToMsg, &pNode->timeRange);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tlvEncodeObj(pEncoder, PHY_FILL_CODE_FILL_NULL_EXPRS, nodeListToMsg, pNode->pFillNullExprs);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -3383,6 +3387,9 @@ static int32_t msgToPhysiFillNode(STlvDecoder* pDecoder, void* pObj) {
|
||||||
case PHY_FILL_CODE_TIME_RANGE:
|
case PHY_FILL_CODE_TIME_RANGE:
|
||||||
code = tlvDecodeObjFromTlv(pTlv, msgToTimeWindow, (void**)&pNode->timeRange);
|
code = tlvDecodeObjFromTlv(pTlv, msgToTimeWindow, (void**)&pNode->timeRange);
|
||||||
break;
|
break;
|
||||||
|
case PHY_FILL_CODE_FILL_NULL_EXPRS:
|
||||||
|
code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pFillNullExprs);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1495,6 +1495,7 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
nodesDestroyNode(pLogicNode->pValues);
|
nodesDestroyNode(pLogicNode->pValues);
|
||||||
nodesDestroyList(pLogicNode->pFillExprs);
|
nodesDestroyList(pLogicNode->pFillExprs);
|
||||||
nodesDestroyList(pLogicNode->pNotFillExprs);
|
nodesDestroyList(pLogicNode->pNotFillExprs);
|
||||||
|
nodesDestroyList(pLogicNode->pFillNullExprs);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_LOGIC_PLAN_SORT: {
|
case QUERY_NODE_LOGIC_PLAN_SORT: {
|
||||||
|
@ -1666,6 +1667,7 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
nodesDestroyList(pPhyNode->pNotFillExprs);
|
nodesDestroyList(pPhyNode->pNotFillExprs);
|
||||||
nodesDestroyNode(pPhyNode->pWStartTs);
|
nodesDestroyNode(pPhyNode->pWStartTs);
|
||||||
nodesDestroyNode(pPhyNode->pValues);
|
nodesDestroyNode(pPhyNode->pValues);
|
||||||
|
nodesDestroyList(pPhyNode->pFillNullExprs);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION:
|
case QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION:
|
||||||
|
|
|
@ -1974,14 +1974,13 @@ static SNode* setDatabaseOptionImpl(SAstCreateContext* pCxt, SNode* pOptions, ED
|
||||||
case DB_OPTION_S3_COMPACT:
|
case DB_OPTION_S3_COMPACT:
|
||||||
pDbOptions->s3Compact = taosStr2Int8(((SToken*)pVal)->z, NULL, 10);
|
pDbOptions->s3Compact = taosStr2Int8(((SToken*)pVal)->z, NULL, 10);
|
||||||
break;
|
break;
|
||||||
case DB_OPTION_KEEP_TIME_OFFSET: {
|
case DB_OPTION_KEEP_TIME_OFFSET:
|
||||||
pDbOptions->keepTimeOffset = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
|
pDbOptions->keepTimeOffset = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
|
||||||
break;
|
break;
|
||||||
case DB_OPTION_ENCRYPT_ALGORITHM:
|
case DB_OPTION_ENCRYPT_ALGORITHM:
|
||||||
COPY_STRING_FORM_STR_TOKEN(pDbOptions->encryptAlgorithmStr, (SToken*)pVal);
|
COPY_STRING_FORM_STR_TOKEN(pDbOptions->encryptAlgorithmStr, (SToken*)pVal);
|
||||||
pDbOptions->encryptAlgorithm = TSDB_DEFAULT_ENCRYPT_ALGO;
|
pDbOptions->encryptAlgorithm = TSDB_DEFAULT_ENCRYPT_ALGO;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1603,25 +1603,6 @@ static EDealRes translateColumnUseAlias(STranslateContext* pCxt, SColumnNode** p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*pFound) {
|
if (*pFound) {
|
||||||
if (QUERY_NODE_FUNCTION == nodeType(pFoundNode) && (SQL_CLAUSE_GROUP_BY == pCxt->currClause || SQL_CLAUSE_PARTITION_BY == pCxt->currClause)) {
|
|
||||||
pCxt->errCode = getFuncInfo(pCxt, (SFunctionNode*)pFoundNode);
|
|
||||||
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
|
||||||
if (fmIsVectorFunc(((SFunctionNode*)pFoundNode)->funcId)) {
|
|
||||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION, (*pCol)->colName);
|
|
||||||
return DEAL_RES_ERROR;
|
|
||||||
} else if (fmIsPseudoColumnFunc(((SFunctionNode*)pFoundNode)->funcId)) {
|
|
||||||
if ('\0' != (*pCol)->tableAlias[0]) {
|
|
||||||
return translateColumnWithPrefix(pCxt, pCol);
|
|
||||||
} else {
|
|
||||||
return translateColumnWithoutPrefix(pCxt, pCol);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* Do nothing and replace old node with found node. */
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return DEAL_RES_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SNode* pNew = NULL;
|
SNode* pNew = NULL;
|
||||||
int32_t code = nodesCloneNode(pFoundNode, &pNew);
|
int32_t code = nodesCloneNode(pFoundNode, &pNew);
|
||||||
if (NULL == pNew) {
|
if (NULL == pNew) {
|
||||||
|
@ -1630,14 +1611,6 @@ static EDealRes translateColumnUseAlias(STranslateContext* pCxt, SColumnNode** p
|
||||||
}
|
}
|
||||||
nodesDestroyNode(*(SNode**)pCol);
|
nodesDestroyNode(*(SNode**)pCol);
|
||||||
*(SNode**)pCol = (SNode*)pNew;
|
*(SNode**)pCol = (SNode*)pNew;
|
||||||
if (QUERY_NODE_COLUMN == nodeType(pFoundNode)) {
|
|
||||||
pCxt->errCode = TSDB_CODE_SUCCESS;
|
|
||||||
if ('\0' != (*pCol)->tableAlias[0]) {
|
|
||||||
return translateColumnWithPrefix(pCxt, pCol);
|
|
||||||
} else {
|
|
||||||
return translateColumnWithoutPrefix(pCxt, pCol);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -1882,6 +1855,39 @@ static bool clauseSupportAlias(ESqlClause clause) {
|
||||||
SQL_CLAUSE_ORDER_BY == clause;
|
SQL_CLAUSE_ORDER_BY == clause;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static EDealRes translateColumnInGroupByClause(STranslateContext* pCxt, SColumnNode** pCol, bool *translateAsAlias) {
|
||||||
|
*translateAsAlias = false;
|
||||||
|
// count(*)/first(*)/last(*) and so on
|
||||||
|
if (0 == strcmp((*pCol)->colName, "*")) {
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pCxt->pParseCxt->biMode) {
|
||||||
|
SNode** ppNode = (SNode**)pCol;
|
||||||
|
bool ret;
|
||||||
|
pCxt->errCode = biRewriteToTbnameFunc(pCxt, ppNode, &ret);
|
||||||
|
if (TSDB_CODE_SUCCESS != pCxt->errCode) return DEAL_RES_ERROR;
|
||||||
|
if (ret) {
|
||||||
|
return translateFunction(pCxt, (SFunctionNode**)ppNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EDealRes res = DEAL_RES_CONTINUE;
|
||||||
|
if ('\0' != (*pCol)->tableAlias[0]) {
|
||||||
|
res = translateColumnWithPrefix(pCxt, pCol);
|
||||||
|
} else {
|
||||||
|
bool found = false;
|
||||||
|
res = translateColumnWithoutPrefix(pCxt, pCol);
|
||||||
|
if (!(*pCol)->node.asParam &&
|
||||||
|
res != DEAL_RES_CONTINUE &&
|
||||||
|
res != DEAL_RES_END && pCxt->errCode != TSDB_CODE_PAR_AMBIGUOUS_COLUMN) {
|
||||||
|
res = translateColumnUseAlias(pCxt, pCol, &found);
|
||||||
|
*translateAsAlias = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode** pCol) {
|
static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode** pCol) {
|
||||||
if (NULL == pCxt->pCurrStmt ||
|
if (NULL == pCxt->pCurrStmt ||
|
||||||
(isSelectStmt(pCxt->pCurrStmt) && NULL == ((SSelectStmt*)pCxt->pCurrStmt)->pFromTable)) {
|
(isSelectStmt(pCxt->pCurrStmt) && NULL == ((SSelectStmt*)pCxt->pCurrStmt)->pFromTable)) {
|
||||||
|
@ -5472,12 +5478,13 @@ typedef struct SReplaceGroupByAliasCxt {
|
||||||
SNodeList* pProjectionList;
|
SNodeList* pProjectionList;
|
||||||
} SReplaceGroupByAliasCxt;
|
} SReplaceGroupByAliasCxt;
|
||||||
|
|
||||||
static EDealRes replaceGroupByAliasImpl(SNode** pNode, void* pContext) {
|
static EDealRes translateGroupPartitionByImpl(SNode** pNode, void* pContext) {
|
||||||
SReplaceGroupByAliasCxt* pCxt = pContext;
|
SReplaceGroupByAliasCxt* pCxt = pContext;
|
||||||
SNodeList* pProjectionList = pCxt->pProjectionList;
|
SNodeList* pProjectionList = pCxt->pProjectionList;
|
||||||
SNode* pProject = NULL;
|
SNode* pProject = NULL;
|
||||||
if (QUERY_NODE_VALUE == nodeType(*pNode)) {
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
STranslateContext* pTransCxt = pCxt->pTranslateCxt;
|
STranslateContext* pTransCxt = pCxt->pTranslateCxt;
|
||||||
|
if (QUERY_NODE_VALUE == nodeType(*pNode)) {
|
||||||
SValueNode* pVal = (SValueNode*) *pNode;
|
SValueNode* pVal = (SValueNode*) *pNode;
|
||||||
if (DEAL_RES_ERROR == translateValue(pTransCxt, pVal)) {
|
if (DEAL_RES_ERROR == translateValue(pTransCxt, pVal)) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
|
@ -5488,43 +5495,58 @@ static EDealRes replaceGroupByAliasImpl(SNode** pNode, void* pContext) {
|
||||||
int32_t pos = getPositionValue(pVal);
|
int32_t pos = getPositionValue(pVal);
|
||||||
if (0 < pos && pos <= LIST_LENGTH(pProjectionList)) {
|
if (0 < pos && pos <= LIST_LENGTH(pProjectionList)) {
|
||||||
SNode* pNew = NULL;
|
SNode* pNew = NULL;
|
||||||
int32_t code = nodesCloneNode(nodesListGetNode(pProjectionList, pos - 1), (SNode**)&pNew);
|
code = nodesCloneNode(nodesListGetNode(pProjectionList, pos - 1), (SNode**)&pNew);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
pCxt->pTranslateCxt->errCode = code;
|
pCxt->pTranslateCxt->errCode = code;
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
}
|
}
|
||||||
nodesDestroyNode(*pNode);
|
nodesDestroyNode(*pNode);
|
||||||
*pNode = pNew;
|
*pNode = pNew;
|
||||||
return DEAL_RES_CONTINUE;
|
|
||||||
} else {
|
|
||||||
return DEAL_RES_CONTINUE;
|
|
||||||
}
|
}
|
||||||
|
code = translateExpr(pTransCxt, pNode);
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
pTransCxt->errCode = code;
|
||||||
|
return DEAL_RES_ERROR;
|
||||||
|
}
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
} else if (QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
} else if (QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
||||||
STranslateContext* pTransCxt = pCxt->pTranslateCxt;
|
bool asAlias = false;
|
||||||
return translateColumn(pTransCxt, (SColumnNode**)pNode);
|
EDealRes res = translateColumnInGroupByClause(pTransCxt, (SColumnNode**)pNode, &asAlias);
|
||||||
|
if (DEAL_RES_ERROR == res) {
|
||||||
|
return DEAL_RES_ERROR;
|
||||||
}
|
}
|
||||||
|
pTransCxt->errCode = TSDB_CODE_SUCCESS;
|
||||||
|
if (nodeType(*pNode) == QUERY_NODE_COLUMN && !asAlias) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
code = translateExpr(pTransCxt, pNode);
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
pTransCxt->errCode = code;
|
||||||
|
return DEAL_RES_ERROR;
|
||||||
|
}
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
return doTranslateExpr(pNode, pTransCxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t replaceGroupByAlias(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
static int32_t translateGroupByList(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
if (NULL == pSelect->pGroupByList) {
|
if (NULL == pSelect->pGroupByList) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
SReplaceGroupByAliasCxt cxt = {
|
SReplaceGroupByAliasCxt cxt = {
|
||||||
.pTranslateCxt = pCxt, .pProjectionList = pSelect->pProjectionList};
|
.pTranslateCxt = pCxt, .pProjectionList = pSelect->pProjectionList};
|
||||||
nodesRewriteExprsPostOrder(pSelect->pGroupByList, replaceGroupByAliasImpl, &cxt);
|
nodesRewriteExprsPostOrder(pSelect->pGroupByList, translateGroupPartitionByImpl, &cxt);
|
||||||
|
|
||||||
return pCxt->errCode;
|
return pCxt->errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t replacePartitionByAlias(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
static int32_t translatePartitionByList(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
if (NULL == pSelect->pPartitionByList) {
|
if (NULL == pSelect->pPartitionByList) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
SReplaceGroupByAliasCxt cxt = {
|
SReplaceGroupByAliasCxt cxt = {
|
||||||
.pTranslateCxt = pCxt, .pProjectionList = pSelect->pProjectionList};
|
.pTranslateCxt = pCxt, .pProjectionList = pSelect->pProjectionList};
|
||||||
nodesRewriteExprsPostOrder(pSelect->pPartitionByList, replaceGroupByAliasImpl, &cxt);
|
nodesRewriteExprsPostOrder(pSelect->pPartitionByList, translateGroupPartitionByImpl, &cxt);
|
||||||
|
|
||||||
return pCxt->errCode;
|
return pCxt->errCode;
|
||||||
}
|
}
|
||||||
|
@ -5588,11 +5610,8 @@ static int32_t translateGroupBy(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
NODES_DESTORY_LIST(pSelect->pGroupByList);
|
NODES_DESTORY_LIST(pSelect->pGroupByList);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
code = replaceGroupByAlias(pCxt, pSelect);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
pSelect->timeLineResMode = TIME_LINE_NONE;
|
pSelect->timeLineResMode = TIME_LINE_NONE;
|
||||||
code = translateExprList(pCxt, pSelect->pGroupByList);
|
code = translateGroupByList(pCxt, pSelect);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -6287,10 +6306,7 @@ static int32_t translatePartitionBy(STranslateContext* pCxt, SSelectStmt* pSelec
|
||||||
(QUERY_NODE_FUNCTION == nodeType(pPar) && FUNCTION_TYPE_TBNAME == ((SFunctionNode*)pPar)->funcType))) {
|
(QUERY_NODE_FUNCTION == nodeType(pPar) && FUNCTION_TYPE_TBNAME == ((SFunctionNode*)pPar)->funcType))) {
|
||||||
pSelect->timeLineResMode = TIME_LINE_MULTI;
|
pSelect->timeLineResMode = TIME_LINE_MULTI;
|
||||||
}
|
}
|
||||||
code = replacePartitionByAlias(pCxt, pSelect);
|
code = translatePartitionByList(pCxt, pSelect);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = translateExprList(pCxt, pSelect->pPartitionByList);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = translateExprList(pCxt, pSelect->pTags);
|
code = translateExprList(pCxt, pSelect->pTags);
|
||||||
|
|
|
@ -1279,71 +1279,139 @@ static int32_t createWindowLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct SCollectFillExprsCtx {
|
||||||
|
SHashObj* pPseudoCols;
|
||||||
|
SNodeList* pFillExprs;
|
||||||
|
SNodeList* pNotFillExprs;
|
||||||
|
bool collectAggFuncs;
|
||||||
|
SNodeList* pAggFuncCols;
|
||||||
|
} SCollectFillExprsCtx;
|
||||||
|
|
||||||
|
typedef struct SWalkFillSubExprCtx {
|
||||||
|
bool hasFillCol;
|
||||||
|
bool hasPseudoWinCol;
|
||||||
|
bool hasGroupKeyCol;
|
||||||
|
SCollectFillExprsCtx* pCollectFillCtx;
|
||||||
|
int32_t code;
|
||||||
|
} SWalkFillSubExprCtx;
|
||||||
|
|
||||||
|
static bool nodeAlreadyContained(SNodeList* pList, SNode* pNode) {
|
||||||
|
SNode* pExpr = NULL;
|
||||||
|
FOREACH(pExpr, pList) {
|
||||||
|
if (nodesEqualNode(pExpr, pNode)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static EDealRes needFillValueImpl(SNode* pNode, void* pContext) {
|
static EDealRes needFillValueImpl(SNode* pNode, void* pContext) {
|
||||||
|
SWalkFillSubExprCtx *pCtx = pContext;
|
||||||
|
EDealRes res = DEAL_RES_CONTINUE;
|
||||||
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
||||||
SColumnNode* pCol = (SColumnNode*)pNode;
|
SColumnNode* pCol = (SColumnNode*)pNode;
|
||||||
if (COLUMN_TYPE_WINDOW_START != pCol->colType && COLUMN_TYPE_WINDOW_END != pCol->colType &&
|
if (COLUMN_TYPE_WINDOW_START == pCol->colType || COLUMN_TYPE_WINDOW_END == pCol->colType ||
|
||||||
COLUMN_TYPE_WINDOW_DURATION != pCol->colType && COLUMN_TYPE_GROUP_KEY != pCol->colType) {
|
COLUMN_TYPE_WINDOW_DURATION == pCol->colType) {
|
||||||
*(bool*)pContext = true;
|
pCtx->hasPseudoWinCol = true;
|
||||||
return DEAL_RES_END;
|
pCtx->code =
|
||||||
|
taosHashPut(pCtx->pCollectFillCtx->pPseudoCols, pCol->colName, TSDB_COL_NAME_LEN, &pNode, POINTER_BYTES);
|
||||||
|
} else if (COLUMN_TYPE_GROUP_KEY == pCol->colType || COLUMN_TYPE_TBNAME == pCol->colType ||
|
||||||
|
COLUMN_TYPE_TAG == pCol->colType) {
|
||||||
|
pCtx->hasGroupKeyCol = true;
|
||||||
|
pCtx->code =
|
||||||
|
taosHashPut(pCtx->pCollectFillCtx->pPseudoCols, pCol->colName, TSDB_COL_NAME_LEN, &pNode, POINTER_BYTES);
|
||||||
|
} else {
|
||||||
|
pCtx->hasFillCol = true;
|
||||||
|
if (pCtx->pCollectFillCtx->collectAggFuncs) {
|
||||||
|
// Agg funcs has already been rewriten to columns by Interval
|
||||||
|
// Here, we return DEAL_RES_CONTINUE cause we need to collect all agg funcs
|
||||||
|
if (!nodeAlreadyContained(pCtx->pCollectFillCtx->pFillExprs, pNode) &&
|
||||||
|
!nodeAlreadyContained(pCtx->pCollectFillCtx->pAggFuncCols, pNode))
|
||||||
|
pCtx->code = nodesListMakeStrictAppend(&pCtx->pCollectFillCtx->pAggFuncCols, pNode);
|
||||||
|
} else {
|
||||||
|
res = DEAL_RES_END;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return DEAL_RES_CONTINUE;
|
}
|
||||||
|
if (pCtx->code != TSDB_CODE_SUCCESS) res = DEAL_RES_ERROR;
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool needFillValue(SNode* pNode) {
|
static void needFillValue(SNode* pNode, SWalkFillSubExprCtx* pCtx) {
|
||||||
bool hasFillCol = false;
|
nodesWalkExpr(pNode, needFillValueImpl, pCtx);
|
||||||
nodesWalkExpr(pNode, needFillValueImpl, &hasFillCol);
|
|
||||||
return hasFillCol;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t partFillExprs(SSelectStmt* pSelect, SNodeList** pFillExprs, SNodeList** pNotFillExprs) {
|
static int32_t collectFillExpr(SNode* pNode, SCollectFillExprsCtx* pCollectFillCtx) {
|
||||||
|
SNode* pNew = NULL;
|
||||||
|
SWalkFillSubExprCtx collectFillSubExprCtx = {
|
||||||
|
.hasFillCol = false, .hasPseudoWinCol = false, .hasGroupKeyCol = false, .pCollectFillCtx = pCollectFillCtx};
|
||||||
|
needFillValue(pNode, &collectFillSubExprCtx);
|
||||||
|
if (collectFillSubExprCtx.code != TSDB_CODE_SUCCESS) {
|
||||||
|
return collectFillSubExprCtx.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (collectFillSubExprCtx.hasFillCol && !pCollectFillCtx->collectAggFuncs) {
|
||||||
|
if (nodeType(pNode) == QUERY_NODE_ORDER_BY_EXPR) {
|
||||||
|
collectFillSubExprCtx.code = nodesCloneNode(((SOrderByExprNode*)pNode)->pExpr, &pNew);
|
||||||
|
} else {
|
||||||
|
collectFillSubExprCtx.code = nodesCloneNode(pNode, &pNew);
|
||||||
|
}
|
||||||
|
if (collectFillSubExprCtx.code == TSDB_CODE_SUCCESS) {
|
||||||
|
collectFillSubExprCtx.code = nodesListMakeStrictAppend(&pCollectFillCtx->pFillExprs, pNew);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return collectFillSubExprCtx.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t collectFillExprs(SSelectStmt* pSelect, SNodeList** pFillExprs, SNodeList** pNotFillExprs,
|
||||||
|
SNodeList** pPossibleFillNullCols) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
SNode* pProject = NULL;
|
SCollectFillExprsCtx collectFillCtx = {0};
|
||||||
FOREACH(pProject, pSelect->pProjectionList) {
|
SNode* pNode = NULL;
|
||||||
if (needFillValue(pProject)) {
|
collectFillCtx.pPseudoCols = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||||
SNode* pNew = NULL;
|
if (!collectFillCtx.pPseudoCols) return terrno;
|
||||||
code = nodesCloneNode(pProject, &pNew);
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
FOREACH(pNode, pSelect->pProjectionList) {
|
||||||
code = nodesListMakeStrictAppend(pFillExprs, pNew);
|
code = collectFillExpr(pNode, &collectFillCtx);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) break;
|
||||||
}
|
}
|
||||||
} else if (QUERY_NODE_VALUE != nodeType(pProject)) {
|
collectFillCtx.collectAggFuncs = true;
|
||||||
SNode* pNew = NULL;
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
code = nodesCloneNode(pProject, &pNew);
|
code = collectFillExpr(pSelect->pHaving, &collectFillCtx);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
}
|
||||||
code = nodesListMakeStrictAppend(pNotFillExprs, pNew);
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
FOREACH(pNode, pSelect->pOrderByList) {
|
||||||
|
code = collectFillExpr(pNode, &collectFillCtx);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
NODES_DESTORY_LIST(*pFillExprs);
|
void* pIter = taosHashIterate(collectFillCtx.pPseudoCols, 0);
|
||||||
NODES_DESTORY_LIST(*pNotFillExprs);
|
while (pIter) {
|
||||||
|
SNode* pNode = *(SNode**)pIter, *pNew = NULL;
|
||||||
|
code = nodesCloneNode(pNode, &pNew);
|
||||||
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
code = nodesListMakeStrictAppend(&collectFillCtx.pNotFillExprs, pNew);
|
||||||
|
}
|
||||||
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
pIter = taosHashIterate(collectFillCtx.pPseudoCols, pIter);
|
||||||
|
} else {
|
||||||
|
taosHashCancelIterate(collectFillCtx.pPseudoCols, pIter);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!pSelect->isDistinct) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
SNode* pOrderExpr = NULL;
|
TSWAP(*pFillExprs, collectFillCtx.pFillExprs);
|
||||||
FOREACH(pOrderExpr, pSelect->pOrderByList) {
|
TSWAP(*pNotFillExprs, collectFillCtx.pNotFillExprs);
|
||||||
SNode* pExpr = ((SOrderByExprNode*)pOrderExpr)->pExpr;
|
TSWAP(*pPossibleFillNullCols, collectFillCtx.pAggFuncCols);
|
||||||
if (needFillValue(pExpr)) {
|
|
||||||
SNode* pNew = NULL;
|
|
||||||
code = nodesCloneNode(pExpr, &pNew);
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = nodesListMakeStrictAppend(pFillExprs, pNew);
|
|
||||||
}
|
|
||||||
} else if (QUERY_NODE_VALUE != nodeType(pExpr)) {
|
|
||||||
SNode* pNew = NULL;
|
|
||||||
code = nodesCloneNode(pExpr, &pNew);
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = nodesListMakeStrictAppend(pNotFillExprs, pNew);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
|
||||||
NODES_DESTORY_LIST(*pFillExprs);
|
|
||||||
NODES_DESTORY_LIST(*pNotFillExprs);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
if (collectFillCtx.pFillExprs) nodesDestroyList(collectFillCtx.pFillExprs);
|
||||||
|
if (collectFillCtx.pNotFillExprs) nodesDestroyList(collectFillCtx.pNotFillExprs);
|
||||||
|
if (collectFillCtx.pAggFuncCols) nodesDestroyList(collectFillCtx.pAggFuncCols);
|
||||||
}
|
}
|
||||||
|
taosHashCleanup(collectFillCtx.pPseudoCols);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1369,13 +1437,16 @@ static int32_t createFillLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
||||||
pFill->node.resultDataOrder = pFill->node.requireDataOrder;
|
pFill->node.resultDataOrder = pFill->node.requireDataOrder;
|
||||||
pFill->node.inputTsOrder = TSDB_ORDER_ASC;
|
pFill->node.inputTsOrder = TSDB_ORDER_ASC;
|
||||||
|
|
||||||
code = partFillExprs(pSelect, &pFill->pFillExprs, &pFill->pNotFillExprs);
|
code = collectFillExprs(pSelect, &pFill->pFillExprs, &pFill->pNotFillExprs, &pFill->pFillNullExprs);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = rewriteExprsForSelect(pFill->pFillExprs, pSelect, SQL_CLAUSE_FILL, NULL);
|
code = rewriteExprsForSelect(pFill->pFillExprs, pSelect, SQL_CLAUSE_FILL, NULL);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = rewriteExprsForSelect(pFill->pNotFillExprs, pSelect, SQL_CLAUSE_FILL, NULL);
|
code = rewriteExprsForSelect(pFill->pNotFillExprs, pSelect, SQL_CLAUSE_FILL, NULL);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code && LIST_LENGTH(pFill->pFillNullExprs) > 0) {
|
||||||
|
code = createColumnByRewriteExprs(pFill->pFillNullExprs, &pFill->node.pTargets);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = createColumnByRewriteExprs(pFill->pFillExprs, &pFill->node.pTargets);
|
code = createColumnByRewriteExprs(pFill->pFillExprs, &pFill->node.pTargets);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2605,6 +2605,12 @@ static int32_t createFillPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = addDataBlockSlots(pCxt, pFill->pNotFillExprs, pFill->node.pOutputDataBlockDesc);
|
code = addDataBlockSlots(pCxt, pFill->pNotFillExprs, pFill->node.pOutputDataBlockDesc);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code && LIST_LENGTH(pFillNode->pFillNullExprs) > 0) {
|
||||||
|
code = setListSlotId(pCxt, pChildTupe->dataBlockId, -1, pFillNode->pFillNullExprs, &pFill->pFillNullExprs);
|
||||||
|
if (TSDB_CODE_SUCCESS == code ) {
|
||||||
|
code = addDataBlockSlots(pCxt, pFill->pFillNullExprs, pFill->node.pOutputDataBlockDesc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = setNodeSlotId(pCxt, pChildTupe->dataBlockId, -1, pFillNode->pWStartTs, &pFill->pWStartTs);
|
code = setNodeSlotId(pCxt, pChildTupe->dataBlockId, -1, pFillNode->pWStartTs, &pFill->pWStartTs);
|
||||||
|
|
|
@ -533,7 +533,7 @@ int32_t qwSaveTbVersionInfo(qTaskInfo_t pTaskInfo, SQWTaskCtx *ctx) {
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
tbGet = false;
|
tbGet = false;
|
||||||
code = qGetQueryTableSchemaVersion(pTaskInfo, dbFName, tbName, &tbInfo.sversion, &tbInfo.tversion, i, &tbGet);
|
code = qGetQueryTableSchemaVersion(pTaskInfo, dbFName, TSDB_DB_FNAME_LEN, tbName, TSDB_TABLE_NAME_LEN, &tbInfo.sversion, &tbInfo.tversion, i, &tbGet);
|
||||||
if (TSDB_CODE_SUCCESS != code || !tbGet) {
|
if (TSDB_CODE_SUCCESS != code || !tbGet) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ SStreamState* streamStateOpen(const char* path, void* pTask, int64_t streamId, i
|
||||||
SStreamTask* pStreamTask = pTask;
|
SStreamTask* pStreamTask = pTask;
|
||||||
pState->streamId = streamId;
|
pState->streamId = streamId;
|
||||||
pState->taskId = taskId;
|
pState->taskId = taskId;
|
||||||
sprintf(pState->pTdbState->idstr, "0x%" PRIx64 "-0x%x", pState->streamId, pState->taskId);
|
TAOS_UNUSED(tsnprintf(pState->pTdbState->idstr, sizeof(pState->pTdbState->idstr), "0x%" PRIx64 "-0x%x", pState->streamId, pState->taskId));
|
||||||
|
|
||||||
code = streamTaskSetDb(pStreamTask->pMeta, pTask, pState->pTdbState->idstr);
|
code = streamTaskSetDb(pStreamTask->pMeta, pTask, pState->pTdbState->idstr);
|
||||||
QUERY_CHECK_CODE(code, lino, _end);
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
|
|
@ -777,7 +777,7 @@ _end:
|
||||||
|
|
||||||
int32_t forceRemoveCheckpoint(SStreamFileState* pFileState, int64_t checkpointId) {
|
int32_t forceRemoveCheckpoint(SStreamFileState* pFileState, int64_t checkpointId) {
|
||||||
char keyBuf[128] = {0};
|
char keyBuf[128] = {0};
|
||||||
sprintf(keyBuf, "%s:%" PRId64 "", TASK_KEY, checkpointId);
|
TAOS_UNUSED(tsnprintf(keyBuf, sizeof(keyBuf), "%s:%" PRId64 "", TASK_KEY, checkpointId));
|
||||||
return streamDefaultDel_rocksdb(pFileState->pFileStore, keyBuf);
|
return streamDefaultDel_rocksdb(pFileState->pFileStore, keyBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -799,14 +799,14 @@ int32_t deleteExpiredCheckPoint(SStreamFileState* pFileState, TSKEY mark) {
|
||||||
}
|
}
|
||||||
memcpy(buf, val, len);
|
memcpy(buf, val, len);
|
||||||
buf[len] = 0;
|
buf[len] = 0;
|
||||||
maxCheckPointId = atol((char*)buf);
|
maxCheckPointId = taosStr2Int64((char*)buf, NULL, 10);
|
||||||
taosMemoryFree(val);
|
taosMemoryFree(val);
|
||||||
}
|
}
|
||||||
for (int64_t i = maxCheckPointId; i > 0; i--) {
|
for (int64_t i = maxCheckPointId; i > 0; i--) {
|
||||||
char buf[128] = {0};
|
char buf[128] = {0};
|
||||||
void* val = 0;
|
void* val = 0;
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
sprintf(buf, "%s:%" PRId64 "", TASK_KEY, i);
|
TAOS_UNUSED(tsnprintf(buf, sizeof(buf), "%s:%" PRId64 "", TASK_KEY, i));
|
||||||
code = streamDefaultGet_rocksdb(pFileState->pFileStore, buf, &val, &len);
|
code = streamDefaultGet_rocksdb(pFileState->pFileStore, buf, &val, &len);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
|
@ -816,7 +816,7 @@ int32_t deleteExpiredCheckPoint(SStreamFileState* pFileState, TSKEY mark) {
|
||||||
taosMemoryFree(val);
|
taosMemoryFree(val);
|
||||||
|
|
||||||
TSKEY ts;
|
TSKEY ts;
|
||||||
ts = atol((char*)buf);
|
ts = taosStr2Int64((char*)buf, NULL, 10);
|
||||||
if (ts < mark) {
|
if (ts < mark) {
|
||||||
// statekey winkey.ts < mark
|
// statekey winkey.ts < mark
|
||||||
int32_t tmpRes = forceRemoveCheckpoint(pFileState, i);
|
int32_t tmpRes = forceRemoveCheckpoint(pFileState, i);
|
||||||
|
|
|
@ -283,12 +283,12 @@ bool transAsyncPoolIsEmpty(SAsyncPool* pool);
|
||||||
if (id > 0) { \
|
if (id > 0) { \
|
||||||
SExHandle* exh2 = transAcquireExHandle(idMgt, id); \
|
SExHandle* exh2 = transAcquireExHandle(idMgt, id); \
|
||||||
if (exh2 == NULL || exh1 != exh2 || (exh2 != NULL && exh2->refId != id)) { \
|
if (exh2 == NULL || exh1 != exh2 || (exh2 != NULL && exh2->refId != id)) { \
|
||||||
tError("handle not match, exh1:%p, exh2:%p, refId:%"PRId64"", exh1, exh2, id); \
|
tDebug("handle not match, exh1:%p, exh2:%p, refId:%" PRId64 "", exh1, exh2, id); \
|
||||||
code = TSDB_CODE_INVALID_MSG; \
|
code = TSDB_CODE_INVALID_MSG; \
|
||||||
goto _return1; \
|
goto _return1; \
|
||||||
} \
|
} \
|
||||||
} else { \
|
} else { \
|
||||||
tError("invalid handle to release"); \
|
tDebug("invalid handle to release"); \
|
||||||
goto _return2; \
|
goto _return2; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
|
@ -27,7 +27,7 @@ typedef struct {
|
||||||
typedef struct SConnList {
|
typedef struct SConnList {
|
||||||
queue conns;
|
queue conns;
|
||||||
int32_t size;
|
int32_t size;
|
||||||
int32_t totaSize;
|
int32_t totalSize;
|
||||||
} SConnList;
|
} SConnList;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -855,10 +855,9 @@ static int32_t cliGetConnFromPool(SCliThrd* pThrd, const char* key, SCliConn** p
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QUEUE_IS_EMPTY(&plist->conns)) {
|
if (QUEUE_IS_EMPTY(&plist->conns)) {
|
||||||
if (plist->size >= pInst->connLimitNum) {
|
if (plist->totalSize >= pInst->connLimitNum) {
|
||||||
return TSDB_CODE_RPC_MAX_SESSIONS;
|
return TSDB_CODE_RPC_MAX_SESSIONS;
|
||||||
}
|
}
|
||||||
plist->totaSize += 1;
|
|
||||||
return TSDB_CODE_RPC_NETWORK_BUSY;
|
return TSDB_CODE_RPC_NETWORK_BUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1046,7 +1045,7 @@ static int32_t cliCreateConn(SCliThrd* pThrd, SCliConn** pCliConn, char* ip, int
|
||||||
conn->hostThrd = pThrd;
|
conn->hostThrd = pThrd;
|
||||||
conn->seq = 0;
|
conn->seq = 0;
|
||||||
|
|
||||||
conn->pQTable = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
conn->pQTable = taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
||||||
if (conn->pQTable == NULL) {
|
if (conn->pQTable == NULL) {
|
||||||
TAOS_CHECK_GOTO(terrno, NULL, _failed);
|
TAOS_CHECK_GOTO(terrno, NULL, _failed);
|
||||||
}
|
}
|
||||||
|
@ -1249,7 +1248,7 @@ static void cliHandleException(SCliConn* conn) {
|
||||||
cliDestroyAllQidFromThrd(conn);
|
cliDestroyAllQidFromThrd(conn);
|
||||||
QUEUE_REMOVE(&conn->q);
|
QUEUE_REMOVE(&conn->q);
|
||||||
if (conn->list) {
|
if (conn->list) {
|
||||||
conn->list->totaSize -= 1;
|
conn->list->totalSize -= 1;
|
||||||
conn->list = NULL;
|
conn->list = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1548,10 +1547,15 @@ static int32_t cliDoConn(SCliThrd* pThrd, SCliConn* conn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
transRefCliHandle(conn);
|
transRefCliHandle(conn);
|
||||||
|
|
||||||
|
conn->list = taosHashGet((SHashObj*)pThrd->pool, conn->dstAddr, strlen(conn->dstAddr));
|
||||||
|
if (conn->list != NULL) {
|
||||||
|
conn->list->totalSize += 1;
|
||||||
|
}
|
||||||
|
|
||||||
ret = uv_tcp_connect(&conn->connReq, (uv_tcp_t*)(conn->stream), (const struct sockaddr*)&addr, cliConnCb);
|
ret = uv_tcp_connect(&conn->connReq, (uv_tcp_t*)(conn->stream), (const struct sockaddr*)&addr, cliConnCb);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
tError("failed connect to %s since %s", conn->dstAddr, uv_err_name(ret));
|
tError("failed connect to %s since %s", conn->dstAddr, uv_err_name(ret));
|
||||||
|
|
||||||
TAOS_CHECK_GOTO(TSDB_CODE_THIRDPARTY_ERROR, &lino, _exception1);
|
TAOS_CHECK_GOTO(TSDB_CODE_THIRDPARTY_ERROR, &lino, _exception1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2363,7 +2367,7 @@ static int32_t createThrdObj(void* trans, SCliThrd** ppThrd) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pThrd->pool = createConnPool(4);
|
pThrd->pool = createConnPool(128);
|
||||||
if (pThrd->pool == NULL) {
|
if (pThrd->pool == NULL) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
TAOS_CHECK_GOTO(terrno, NULL, _end);
|
TAOS_CHECK_GOTO(terrno, NULL, _end);
|
||||||
|
@ -2382,22 +2386,22 @@ static int32_t createThrdObj(void* trans, SCliThrd** ppThrd) {
|
||||||
|
|
||||||
pThrd->destroyAhandleFp = pInst->destroyFp;
|
pThrd->destroyAhandleFp = pInst->destroyFp;
|
||||||
|
|
||||||
pThrd->fqdn2ipCache = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
pThrd->fqdn2ipCache = taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||||
if (pThrd->fqdn2ipCache == NULL) {
|
if (pThrd->fqdn2ipCache == NULL) {
|
||||||
TAOS_CHECK_GOTO(terrno, NULL, _end);
|
TAOS_CHECK_GOTO(terrno, NULL, _end);
|
||||||
}
|
}
|
||||||
|
|
||||||
pThrd->batchCache = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
pThrd->batchCache = taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||||
if (pThrd->batchCache == NULL) {
|
if (pThrd->batchCache == NULL) {
|
||||||
TAOS_CHECK_GOTO(terrno, NULL, _end);
|
TAOS_CHECK_GOTO(terrno, NULL, _end);
|
||||||
}
|
}
|
||||||
|
|
||||||
pThrd->connHeapCache = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
pThrd->connHeapCache = taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||||
if (pThrd->connHeapCache == NULL) {
|
if (pThrd->connHeapCache == NULL) {
|
||||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end);
|
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end);
|
||||||
}
|
}
|
||||||
|
|
||||||
pThrd->pIdConnTable = taosHashInit(512, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
pThrd->pIdConnTable = taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||||
if (pThrd->connHeapCache == NULL) {
|
if (pThrd->connHeapCache == NULL) {
|
||||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end);
|
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end);
|
||||||
}
|
}
|
||||||
|
@ -3739,7 +3743,7 @@ static FORCE_INLINE int8_t shouldSWitchToOtherConn(SCliConn* pConn, char* key) {
|
||||||
tTrace("conn %p get list %p from pool for key:%s", pConn, pConn->list, key);
|
tTrace("conn %p get list %p from pool for key:%s", pConn, pConn->list, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pConn->list && pConn->list->totaSize >= pInst->connLimitNum / 4) {
|
if (pConn->list && pConn->list->totalSize >= pInst->connLimitNum / 4) {
|
||||||
tWarn("%s conn %p try to remove timeout msg since too many conn created", transLabel(pInst), pConn);
|
tWarn("%s conn %p try to remove timeout msg since too many conn created", transLabel(pInst), pConn);
|
||||||
|
|
||||||
if (cliConnRemoveTimeoutMsg(pConn)) {
|
if (cliConnRemoveTimeoutMsg(pConn)) {
|
||||||
|
|
|
@ -239,7 +239,7 @@ SIpWhiteListTab* uvWhiteListCreate() {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pWhiteList->pList = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), 0, HASH_NO_LOCK);
|
pWhiteList->pList = taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), 0, HASH_NO_LOCK);
|
||||||
if (pWhiteList->pList == NULL) {
|
if (pWhiteList->pList == NULL) {
|
||||||
taosMemoryFree(pWhiteList);
|
taosMemoryFree(pWhiteList);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1333,7 +1333,7 @@ static FORCE_INLINE SSvrConn* createConn(void* hThrd) {
|
||||||
QUEUE_INIT(&exh->q);
|
QUEUE_INIT(&exh->q);
|
||||||
tTrace("%s handle %p, conn %p created, refId:%" PRId64, transLabel(pInst), exh, pConn, pConn->refId);
|
tTrace("%s handle %p, conn %p created, refId:%" PRId64, transLabel(pInst), exh, pConn, pConn->refId);
|
||||||
|
|
||||||
pConn->pQTable = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
pConn->pQTable = taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
||||||
if (pConn->pQTable == NULL) {
|
if (pConn->pQTable == NULL) {
|
||||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _end);
|
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _end);
|
||||||
}
|
}
|
||||||
|
|
|
@ -761,6 +761,11 @@ TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_SETUP_ERROR, "Function set up fail
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_INVALID_RES_LENGTH, "Function result exceed max length")
|
TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_INVALID_RES_LENGTH, "Function result exceed max length")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_HISTOGRAM_ERROR, "Function failed to calculate histogram")
|
TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_HISTOGRAM_ERROR, "Function failed to calculate histogram")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_PERCENTILE_ERROR, "Function failed to calculate percentile")
|
TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_PERCENTILE_ERROR, "Function failed to calculate percentile")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_FUNTION_PARA_RANGE, "Invalid function para range")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_FUNTION_PARA_PRIMTS, "Function parameter should be primary timestamp")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_FUNTION_PARA_PK, "Function parameter should be primary key")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_FUNTION_PARA_HAS_COL, "Function parameter should have column")
|
||||||
|
|
||||||
|
|
||||||
//udf
|
//udf
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_UDF_STOPPING, "udf is stopping")
|
TAOS_DEFINE_ERROR(TSDB_CODE_UDF_STOPPING, "udf is stopping")
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
#define LOG_MAX_LINE_SIZE (10024)
|
#define LOG_MAX_LINE_SIZE (10024)
|
||||||
#define LOG_MAX_LINE_BUFFER_SIZE (LOG_MAX_LINE_SIZE + 3)
|
#define LOG_MAX_LINE_BUFFER_SIZE (LOG_MAX_LINE_SIZE + 3)
|
||||||
|
#define LOG_MAX_STACK_LINE_SIZE (512)
|
||||||
|
#define LOG_MAX_STACK_LINE_BUFFER_SIZE (LOG_MAX_STACK_LINE_SIZE + 3)
|
||||||
#define LOG_MAX_LINE_DUMP_SIZE (1024 * 1024)
|
#define LOG_MAX_LINE_DUMP_SIZE (1024 * 1024)
|
||||||
#define LOG_MAX_LINE_DUMP_BUFFER_SIZE (LOG_MAX_LINE_DUMP_SIZE + 128)
|
#define LOG_MAX_LINE_DUMP_BUFFER_SIZE (LOG_MAX_LINE_DUMP_SIZE + 128)
|
||||||
|
|
||||||
|
@ -669,16 +671,40 @@ static inline void taosPrintLogImp(ELogLevel level, int32_t dflag, const char *b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosPrintLog(const char *flags, int32_t level, int32_t dflag, const char *format, ...) {
|
/*
|
||||||
if (!(dflag & DEBUG_FILE) && !(dflag & DEBUG_SCREEN)) return;
|
use taosPrintLogImpl_useStackBuffer to avoid stack overflow
|
||||||
|
|
||||||
char buffer[LOG_MAX_LINE_BUFFER_SIZE];
|
*/
|
||||||
|
static int8_t taosPrintLogImplUseStackBuffer(const char *flags, int32_t level, int32_t dflag, const char *format,
|
||||||
|
va_list args) {
|
||||||
|
char buffer[LOG_MAX_STACK_LINE_BUFFER_SIZE];
|
||||||
int32_t len = taosBuildLogHead(buffer, flags);
|
int32_t len = taosBuildLogHead(buffer, flags);
|
||||||
|
|
||||||
va_list argpointer;
|
int32_t writeLen = len + vsnprintf(buffer + len, LOG_MAX_STACK_LINE_BUFFER_SIZE - len - 1, format, args);
|
||||||
va_start(argpointer, format);
|
if (writeLen > LOG_MAX_STACK_LINE_SIZE) {
|
||||||
int32_t writeLen = len + vsnprintf(buffer + len, LOG_MAX_LINE_BUFFER_SIZE - len, format, argpointer);
|
return 1;
|
||||||
va_end(argpointer);
|
}
|
||||||
|
|
||||||
|
buffer[writeLen++] = '\n';
|
||||||
|
buffer[writeLen] = 0;
|
||||||
|
|
||||||
|
taosPrintLogImp(level, dflag, buffer, writeLen);
|
||||||
|
|
||||||
|
if (tsLogFp && level <= DEBUG_INFO) {
|
||||||
|
buffer[writeLen - 1] = 0;
|
||||||
|
(*tsLogFp)(taosGetTimestampMs(), level, buffer + len);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static int8_t taosPrintLogImplUseHeapBuffer(const char *flags, int32_t level, int32_t dflag, const char *format,
|
||||||
|
va_list args) {
|
||||||
|
char *buffer = taosMemoryCalloc(1, LOG_MAX_LINE_BUFFER_SIZE + 1);
|
||||||
|
if (buffer == NULL) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
int32_t len = taosBuildLogHead(buffer, flags);
|
||||||
|
|
||||||
|
int32_t writeLen = len + vsnprintf(buffer + len, LOG_MAX_LINE_BUFFER_SIZE - len - 1, format, args);
|
||||||
|
|
||||||
if (writeLen > LOG_MAX_LINE_SIZE) writeLen = LOG_MAX_LINE_SIZE;
|
if (writeLen > LOG_MAX_LINE_SIZE) writeLen = LOG_MAX_LINE_SIZE;
|
||||||
buffer[writeLen++] = '\n';
|
buffer[writeLen++] = '\n';
|
||||||
|
@ -690,6 +716,22 @@ void taosPrintLog(const char *flags, int32_t level, int32_t dflag, const char *f
|
||||||
buffer[writeLen - 1] = 0;
|
buffer[writeLen - 1] = 0;
|
||||||
(*tsLogFp)(taosGetTimestampMs(), level, buffer + len);
|
(*tsLogFp)(taosGetTimestampMs(), level, buffer + len);
|
||||||
}
|
}
|
||||||
|
taosMemoryFree(buffer);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
void taosPrintLog(const char *flags, int32_t level, int32_t dflag, const char *format, ...) {
|
||||||
|
if (!(dflag & DEBUG_FILE) && !(dflag & DEBUG_SCREEN)) return;
|
||||||
|
|
||||||
|
va_list argpointer, argpointer_copy;
|
||||||
|
va_start(argpointer, format);
|
||||||
|
va_copy(argpointer_copy, argpointer);
|
||||||
|
|
||||||
|
if (taosPrintLogImplUseStackBuffer(flags, level, dflag, format, argpointer) == 0) {
|
||||||
|
} else {
|
||||||
|
TAOS_UNUSED(taosPrintLogImplUseHeapBuffer(flags, level, dflag, format, argpointer_copy));
|
||||||
|
}
|
||||||
|
va_end(argpointer_copy);
|
||||||
|
va_end(argpointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosPrintLongString(const char *flags, int32_t level, int32_t dflag, const char *format, ...) {
|
void taosPrintLongString(const char *flags, int32_t level, int32_t dflag, const char *format, ...) {
|
||||||
|
|
|
@ -126,6 +126,13 @@ add_test(
|
||||||
COMMAND regexTest
|
COMMAND regexTest
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_executable(logTest "log.cpp")
|
||||||
|
target_link_libraries(logTest os util common gtest_main)
|
||||||
|
add_test(
|
||||||
|
NAME logTest
|
||||||
|
COMMAND logTest
|
||||||
|
)
|
||||||
|
|
||||||
add_executable(decompressTest "decompressTest.cpp")
|
add_executable(decompressTest "decompressTest.cpp")
|
||||||
target_link_libraries(decompressTest os util common gtest_main)
|
target_link_libraries(decompressTest os util common gtest_main)
|
||||||
add_test(
|
add_test(
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <random>
|
||||||
|
#include <tlog.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
TEST(log, check_log_refactor) {
|
||||||
|
const char *logDir = "/tmp";
|
||||||
|
const char *defaultLogFileNamePrefix = "taoslog";
|
||||||
|
const int32_t maxLogFileNum = 10000;
|
||||||
|
tsAsyncLog = 0;
|
||||||
|
// idxDebugFlag = 143;
|
||||||
|
strcpy(tsLogDir, (char *)logDir);
|
||||||
|
taosInitLog(tsLogDir, 10, false);
|
||||||
|
tsAsyncLog = 0;
|
||||||
|
uDebugFlag = 143;
|
||||||
|
|
||||||
|
std::string str;
|
||||||
|
str.push_back('a');
|
||||||
|
|
||||||
|
for (int i = 0; i < 10000; i += 2) {
|
||||||
|
str.push_back('a');
|
||||||
|
uError("write to file %s", str.c_str());
|
||||||
|
}
|
||||||
|
str.clear();
|
||||||
|
for (int i = 0; i < 10000; i += 2) {
|
||||||
|
str.push_back('a');
|
||||||
|
uDebug("write to file %s", str.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 10000; i += 2) {
|
||||||
|
str.push_back('a');
|
||||||
|
uInfo("write to file %s", str.c_str());
|
||||||
|
}
|
||||||
|
str.clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < 10000; i += 2) {
|
||||||
|
str.push_back('a');
|
||||||
|
uTrace("write to file %s", str.c_str());
|
||||||
|
}
|
||||||
|
taosCloseLog();
|
||||||
|
}
|
|
@ -296,7 +296,7 @@ class TDTestCase(TBase):
|
||||||
|
|
||||||
def test_error(self):
|
def test_error(self):
|
||||||
tdSql.error("select * from (select to_iso8601(ts, timezone()), timezone() from ts_4893.meters \
|
tdSql.error("select * from (select to_iso8601(ts, timezone()), timezone() from ts_4893.meters \
|
||||||
order by ts desc) limit 1000;", expectErrInfo="Not supported timzone format") # TS-5340
|
order by ts desc) limit 1000;", expectErrInfo="Invalid parameter data type : to_iso8601") # TS-5340
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
|
|
@ -189,10 +189,10 @@ $loop_count = 0
|
||||||
|
|
||||||
loop4:
|
loop4:
|
||||||
|
|
||||||
sleep 200
|
sleep 500
|
||||||
|
|
||||||
$loop_count = $loop_count + 1
|
$loop_count = $loop_count + 1
|
||||||
if $loop_count == 10 then
|
if $loop_count == 20 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
@ -324,5 +324,197 @@ if $data[29][1] != 2 then
|
||||||
goto loop7
|
goto loop7
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
print step4====
|
||||||
|
|
||||||
|
sql create database test4 vgroups 1;
|
||||||
|
sql use test4;
|
||||||
|
|
||||||
|
sql create stable st(ts timestamp,a int,b int,c int, d double) tags(ta int,tb int,tc int);
|
||||||
|
sql create table t1 using st tags(1,1,1);
|
||||||
|
sql create table t2 using st tags(2,2,2);
|
||||||
|
sql create table t3 using st tags(2,2,2);
|
||||||
|
sql create table t4 using st tags(2,2,2);
|
||||||
|
sql create table t5 using st tags(2,2,2);
|
||||||
|
sql create table t6 using st tags(2,2,2);
|
||||||
|
|
||||||
|
sql create stream streams4 trigger window_close IGNORE EXPIRED 0 into streamt as select _wstart, count(*), now from st partition by tbname interval(1s);
|
||||||
|
sql create stream streams5 trigger window_close IGNORE EXPIRED 0 into streamt1 as select _wstart, count(*), now from st partition by b interval(1s);
|
||||||
|
|
||||||
|
run tsim/stream/checkTaskStatus.sim
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791211000,1,1,1,1.1) t2 values (1648791211000,2,2,2,2.1) t3 values(1648791211000,3,3,3,3.1) t4 values(1648791211000,4,4,4,4.1) t5 values (1648791211000,5,5,5,5.1) t6 values(1648791211000,6,6,6,6.1);
|
||||||
|
|
||||||
|
sql insert into t1 values(now,1,1,1,1.1) t2 values (now,2,2,2,2.1) t3 values(now,3,3,3,3.1) t4 values(now,4,4,4,4.1) t5 values (now,5,5,5,5.1) t6 values(now,6,6,6,6.1);
|
||||||
|
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop8:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 20 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print sql select * from streamt;
|
||||||
|
sql select * from streamt;
|
||||||
|
|
||||||
|
if $rows != 6 then
|
||||||
|
print ======rows=$rows
|
||||||
|
goto loop8
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 1 then
|
||||||
|
print ======data01=$data01
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data11 != 1 then
|
||||||
|
print ======data11=$data11
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data21 != 1 then
|
||||||
|
print ======data21=$data21
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop8_1:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 20 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print sql select * from streamt1;
|
||||||
|
sql select * from streamt1;
|
||||||
|
|
||||||
|
if $rows != 6 then
|
||||||
|
print ======rows=$rows
|
||||||
|
goto loop8_1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 1 then
|
||||||
|
print ======data01=$data01
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data11 != 1 then
|
||||||
|
print ======data11=$data11
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data21 != 1 then
|
||||||
|
print ======data21=$data21
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sleep 2000
|
||||||
|
|
||||||
|
sql insert into t1 values(now,1,1,1,1.1) t2 values (now,2,2,2,2.1) t3 values(now,3,3,3,3.1) t4 values(now,4,4,4,4.1) t5 values (now,5,5,5,5.1) t6 values(now,6,6,6,6.1);
|
||||||
|
|
||||||
|
sleep 2000
|
||||||
|
|
||||||
|
sql insert into t1 values(now,1,1,1,1.1) t2 values (now,2,2,2,2.1) t3 values(now,3,3,3,3.1) t4 values(now,4,4,4,4.1) t5 values (now,5,5,5,5.1) t6 values(now,6,6,6,6.1);
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop8_1:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 20 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print sql select * from streamt order by 1 desc;
|
||||||
|
sql select * from streamt order by 1 desc;
|
||||||
|
|
||||||
|
if $data01 != 1 then
|
||||||
|
print ======data01=$data01
|
||||||
|
goto loop8_1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print sql select * from streamt1 order by 1 desc;
|
||||||
|
sql select * from streamt1 order by 1 desc;
|
||||||
|
|
||||||
|
if $data01 != 1 then
|
||||||
|
print ======data01=$data01
|
||||||
|
goto loop8_1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sleep 2000
|
||||||
|
|
||||||
|
sql insert into t1 values(now,1,1,1,1.1)
|
||||||
|
sql insert into t2 values(now,2,2,2,2.1);
|
||||||
|
sql insert into t3 values(now,3,3,3,3.1);
|
||||||
|
sql insert into t4 values(now,4,4,4,4.1);
|
||||||
|
sql insert into t5 values(now,5,5,5,5.1);
|
||||||
|
sql insert into t6 values(now,6,6,6,6.1);
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop9:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print sql select * from streamt order by 1 desc;
|
||||||
|
sql select * from streamt order by 1 desc;
|
||||||
|
|
||||||
|
if $data01 != 1 then
|
||||||
|
print ======data01=$data01
|
||||||
|
goto loop9
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data11 != 1 then
|
||||||
|
print ======data11=$data11
|
||||||
|
goto loop9
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data21 != 1 then
|
||||||
|
print ======data21=$data21
|
||||||
|
goto loop9
|
||||||
|
endi
|
||||||
|
|
||||||
|
$loop_count = 0
|
||||||
|
|
||||||
|
loop10:
|
||||||
|
|
||||||
|
sleep 200
|
||||||
|
|
||||||
|
$loop_count = $loop_count + 1
|
||||||
|
if $loop_count == 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print sql select * from streamt1 order by 1 desc;
|
||||||
|
sql select * from streamt1 order by 1 desc;
|
||||||
|
|
||||||
|
if $data01 != 1 then
|
||||||
|
print ======data01=$data01
|
||||||
|
goto loop10
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data11 != 1 then
|
||||||
|
print ======data11=$data11
|
||||||
|
goto loop10
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data21 != 1 then
|
||||||
|
print ======data21=$data21
|
||||||
|
goto loop10
|
||||||
|
endi
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -237,11 +237,123 @@ class TDTestCase:
|
||||||
tdSql.checkData(12, 1, None)
|
tdSql.checkData(12, 1, None)
|
||||||
tdSql.checkData(13, 1, None)
|
tdSql.checkData(13, 1, None)
|
||||||
|
|
||||||
|
def test_fill_with_complex_expr(self):
|
||||||
|
sql = "SELECT _wstart, _wstart + 1d, count(*), now, 1+1 FROM meters WHERE ts >= '2018-09-20 00:00:00.000' AND ts < '2018-09-20 01:00:00.000' INTERVAL(5m) FILL(NULL)"
|
||||||
|
tdSql.query(sql, queryTimes=1)
|
||||||
|
tdSql.checkRows(12)
|
||||||
|
for i in range(0, 12, 2):
|
||||||
|
tdSql.checkData(i, 2, 10)
|
||||||
|
for i in range(1, 12, 2):
|
||||||
|
tdSql.checkData(i, 2, None)
|
||||||
|
for i in range(0, 12):
|
||||||
|
firstCol = tdSql.getData(i, 0)
|
||||||
|
secondCol = tdSql.getData(i, 1)
|
||||||
|
tdLog.debug(f"firstCol: {firstCol}, secondCol: {secondCol}, secondCol - firstCol: {secondCol - firstCol}")
|
||||||
|
if secondCol - firstCol != timedelta(days=1):
|
||||||
|
tdLog.exit(f"query error: secondCol - firstCol: {secondCol - firstCol}")
|
||||||
|
nowCol = tdSql.getData(i, 3)
|
||||||
|
if nowCol is None:
|
||||||
|
tdLog.exit(f"query error: nowCol: {nowCol}")
|
||||||
|
constCol = tdSql.getData(i, 4)
|
||||||
|
if constCol != 2:
|
||||||
|
tdLog.exit(f"query error: constCol: {constCol}")
|
||||||
|
|
||||||
|
sql = "SELECT _wstart + 1d, count(*), last(ts) + 1a, timediff(_wend, last(ts)) FROM meters WHERE ts >= '2018-09-20 00:00:00.000' AND ts < '2018-09-20 01:00:00.000' INTERVAL(5m) FILL(NULL)"
|
||||||
|
tdSql.query(sql, queryTimes=1)
|
||||||
|
tdSql.checkRows(12)
|
||||||
|
for i in range(0, 12, 2):
|
||||||
|
tdSql.checkData(i, 1, 10)
|
||||||
|
tdSql.checkData(i, 3, 300000)
|
||||||
|
for i in range(1, 12, 2):
|
||||||
|
tdSql.checkData(i, 1, None)
|
||||||
|
tdSql.checkData(i, 2, None)
|
||||||
|
tdSql.checkData(i, 3, None)
|
||||||
|
|
||||||
|
sql = "SELECT count(*), tbname FROM meters WHERE ts >= '2018-09-20 00:00:00.000' AND ts < '2018-09-20 01:00:00.000' PARTITION BY tbname INTERVAL(5m) FILL(NULL)"
|
||||||
|
tdSql.query(sql, queryTimes=1)
|
||||||
|
tdSql.checkRows(120)
|
||||||
|
|
||||||
|
sql = "SELECT * from (SELECT count(*), timediff(_wend, last(ts)) + t1, tbname FROM meters WHERE ts >= '2018-09-20 00:00:00.000' AND ts < '2018-09-20 01:00:00.000' PARTITION BY tbname, t1 INTERVAL(5m) FILL(NULL) LIMIT 1) order by tbname"
|
||||||
|
tdSql.query(sql, queryTimes=1)
|
||||||
|
tdSql.checkRows(10)
|
||||||
|
j = 0
|
||||||
|
for i in range(0, 10):
|
||||||
|
tdSql.checkData(i, 1, 300000 + j)
|
||||||
|
j = j + 1
|
||||||
|
if j == 5:
|
||||||
|
j = 0
|
||||||
|
|
||||||
|
sql = "SELECT count(*), timediff(_wend, last(ts)) + t1, tbname,t1 FROM meters WHERE ts >= '2018-09-20 00:00:00.000' AND ts < '2018-09-20 01:00:00.000' PARTITION BY tbname, t1 INTERVAL(5m) FILL(NULL) ORDER BY timediff(last(ts), _wstart)"
|
||||||
|
tdSql.query(sql, queryTimes=1)
|
||||||
|
tdSql.checkRows(120)
|
||||||
|
|
||||||
|
sql = "SELECT 1+1, count(*), timediff(_wend, last(ts)) + t1 FROM meters WHERE ts >= '2018-09-20 00:00:00.000' AND ts < '2018-09-20 01:00:00.000' PARTITION BY tbname, t1 INTERVAL(5m) FILL(NULL) HAVING(timediff(last(ts), _wstart)+ t1 >= 1) ORDER BY timediff(last(ts), _wstart)"
|
||||||
|
tdSql.query(sql, queryTimes=1)
|
||||||
|
tdSql.checkRows(48)
|
||||||
|
|
||||||
|
sql = "SELECT count(*), timediff(_wend, last(ts)) + t1, timediff('2018-09-20 01:00:00', _wstart) + t1, concat(to_char(_wstart, 'HH:MI:SS__'), tbname) FROM meters WHERE ts >= '2018-09-20 00:00:00.000' AND ts < '2018-09-20 01:00:00.000' PARTITION BY tbname, t1 INTERVAL(5m) FILL(NULL) HAVING(timediff(last(ts), _wstart) + t1 >= 1) ORDER BY timediff(last(ts), _wstart), tbname"
|
||||||
|
tdSql.query(sql, queryTimes=1)
|
||||||
|
tdSql.checkRows(48)
|
||||||
|
|
||||||
|
sql = "SELECT count(*) FROM meters WHERE ts >= '2018-09-20 00:00:00.000' AND ts < '2018-09-20 01:00:00.000' PARTITION BY tbname, t1 INTERVAL(5m) FILL(NULL) HAVING(timediff(last(ts), _wstart) >= 0)"
|
||||||
|
tdSql.query(sql, queryTimes=1)
|
||||||
|
tdSql.checkRows(60)
|
||||||
|
|
||||||
|
sql = "SELECT count(*) + 1 FROM meters WHERE ts >= '2018-09-20 00:00:00.000' AND ts < '2018-09-20 01:00:00.000' PARTITION BY tbname, t1 INTERVAL(5m) FILL(NULL) HAVING(count(*) > 1)"
|
||||||
|
tdSql.query(sql, queryTimes=1)
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
sql = "SELECT count(*), timediff(_wend, last(ts)) + t1, timediff('2018-09-20 01:00:00', _wstart) + t1, concat(to_char(_wstart, 'HH:MI:SS__'), tbname) FROM meters WHERE ts >= '2018-09-20 00:00:00.000' AND ts < '2018-09-20 01:00:00.000' PARTITION BY tbname, t1 INTERVAL(5m) FILL(value, 0, 0) HAVING(timediff(last(ts), _wstart) + t1 >= 1) ORDER BY timediff(last(ts), _wstart), tbname"
|
||||||
|
tdSql.query(sql, queryTimes=1)
|
||||||
|
tdSql.checkRows(48)
|
||||||
|
sql = "SELECT count(*), timediff(_wend, last(ts)) + t1, timediff('2018-09-20 01:00:00', _wstart) + t1, concat(to_char(_wstart, 'HH:MI:SS__'), tbname) FROM meters WHERE ts >= '2018-09-20 00:00:00.000' AND ts < '2018-09-20 01:00:00.000' PARTITION BY tbname, t1 INTERVAL(5m) FILL(value, 0, 0) HAVING(count(*) >= 0) ORDER BY timediff(last(ts), _wstart), tbname"
|
||||||
|
tdSql.query(sql, queryTimes=1)
|
||||||
|
tdSql.checkRows(120)
|
||||||
|
sql = "SELECT count(*), timediff(_wend, last(ts)) + t1, timediff('2018-09-20 01:00:00', _wstart) + t1, concat(to_char(_wstart, 'HH:MI:SS__'), tbname) FROM meters WHERE ts >= '2018-09-20 00:00:00.000' AND ts < '2018-09-20 01:00:00.000' PARTITION BY tbname, t1 INTERVAL(5m) FILL(value, 0, 0) HAVING(count(*) > 0) ORDER BY timediff(last(ts), _wstart), tbname"
|
||||||
|
tdSql.query(sql, queryTimes=1)
|
||||||
|
tdSql.checkRows(60)
|
||||||
|
sql = "SELECT count(*), timediff(_wend, last(ts)) + t1, timediff('2018-09-20 01:00:00', _wstart) + t1, concat(to_char(_wstart, 'HH:MI:SS__'), tbname) FROM meters WHERE ts >= '2018-09-20 00:00:00.000' AND ts < '2018-09-20 01:00:00.000' PARTITION BY tbname INTERVAL(5m) FILL(linear) HAVING(count(*) >= 0 and t1 <= 1) ORDER BY timediff(last(ts), _wstart), tbname, t1"
|
||||||
|
tdSql.query(sql, queryTimes=1)
|
||||||
|
tdSql.checkRows(44)
|
||||||
|
sql = "SELECT count(*), timediff(_wend, last(ts)) + t1, timediff('2018-09-20 01:00:00', _wstart) + t1, concat(to_char(_wstart, 'HH:MI:SS__'), tbname) FROM meters WHERE ts >= '2018-09-20 00:00:00.000' AND ts < '2018-09-20 01:00:00.000' PARTITION BY tbname INTERVAL(5m) FILL(prev) HAVING(count(*) >= 0 and t1 > 1) ORDER BY timediff(last(ts), _wstart), tbname, t1"
|
||||||
|
tdSql.query(sql, queryTimes=1)
|
||||||
|
tdSql.checkRows(72)
|
||||||
|
|
||||||
|
sql = "SELECT 1+1, count(*), timediff(_wend, last(ts)) + t1, timediff('2018-09-20 01:00:00', _wstart) + t1, concat(to_char(_wstart, 'HH:MI:SS__'), tbname) FROM meters WHERE ts >= '2018-09-20 00:00:00.000' AND ts < '2018-09-20 01:00:00.000' PARTITION BY tbname INTERVAL(5m) FILL(linear) ORDER BY tbname, _wstart;"
|
||||||
|
tdSql.query(sql, queryTimes=1)
|
||||||
|
tdSql.checkRows(120)
|
||||||
|
for i in range(11, 120, 12):
|
||||||
|
tdSql.checkData(i, 1, None)
|
||||||
|
for i in range(0, 120):
|
||||||
|
tdSql.checkData(i, 0, 2)
|
||||||
|
|
||||||
|
sql = "SELECT count(*), timediff(_wend, last(ts)) + t1, timediff('2018-09-20 01:00:00', _wstart) + t1, concat(to_char(_wstart, 'HH:MI:SS__'), tbname) FROM meters WHERE ts >= '2018-09-20 00:00:00.000' AND ts < '2018-09-20 01:00:00.000' PARTITION BY tbname INTERVAL(5m) FILL(linear) HAVING(count(*) >= 0) ORDER BY tbname;"
|
||||||
|
tdSql.query(sql, queryTimes=1)
|
||||||
|
tdSql.checkRows(110)
|
||||||
|
for i in range(0, 110, 11):
|
||||||
|
lastCol = tdSql.getData(i, 3)
|
||||||
|
tdLog.debug(f"lastCol: {lastCol}")
|
||||||
|
if lastCol[-1:] != str(i//11):
|
||||||
|
tdLog.exit(f"query error: lastCol: {lastCol}")
|
||||||
|
|
||||||
|
sql = "SELECT 1+1, count(*), timediff(_wend, last(ts)) + t1, timediff('2018-09-20 01:00:00', _wstart) + t1,t1 FROM meters WHERE ts >= '2018-09-20 00:00:00.000' AND ts < '2018-09-20 01:00:00.000' PARTITION BY t1 INTERVAL(5m) FILL(linear) ORDER BY t1, _wstart;"
|
||||||
|
tdSql.query(sql, queryTimes=1)
|
||||||
|
tdSql.checkRows(60)
|
||||||
|
|
||||||
|
sql = "SELECT 1+1, count(*), timediff(_wend, last(ts)) + t1, timediff('2018-09-20 01:00:00', _wstart) + t1,t1 FROM meters WHERE ts >= '2018-09-20 00:00:00.000' AND ts < '2018-09-20 01:00:00.000' PARTITION BY t1 INTERVAL(5m) FILL(linear) HAVING(count(*) > 0) ORDER BY t1, _wstart;"
|
||||||
|
tdSql.query(sql, queryTimes=1)
|
||||||
|
tdSql.checkRows(55)
|
||||||
|
|
||||||
|
# TODO Fix Me!
|
||||||
|
sql = "explain SELECT count(*), timediff(_wend, last(ts)), timediff('2018-09-20 01:00:00', _wstart) FROM meters WHERE ts >= '2018-09-20 00:00:00.000' AND ts < '2018-09-20 01:00:00.000' PARTITION BY concat(tbname, 'asd') INTERVAL(5m) having(concat(tbname, 'asd') like '%asd');"
|
||||||
|
tdSql.error(sql, -2147473664) # Error: Planner internal error
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.prepareTestEnv()
|
self.prepareTestEnv()
|
||||||
self.test_partition_by_with_interval_fill_prev_new_group_fill_error()
|
self.test_partition_by_with_interval_fill_prev_new_group_fill_error()
|
||||||
self.test_fill_with_order_by()
|
self.test_fill_with_order_by()
|
||||||
self.test_fill_with_order_by2()
|
self.test_fill_with_order_by2()
|
||||||
|
self.test_fill_with_complex_expr()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
|
@ -420,7 +420,23 @@ class TDTestCase:
|
||||||
tdSql.error(f"select t2, count(*) from {self.dbname}.{self.stable} group by t2 where t2 = 1")
|
tdSql.error(f"select t2, count(*) from {self.dbname}.{self.stable} group by t2 where t2 = 1")
|
||||||
tdSql.error(f"select t2, count(*) from {self.dbname}.{self.stable} group by t2 interval(1d)")
|
tdSql.error(f"select t2, count(*) from {self.dbname}.{self.stable} group by t2 interval(1d)")
|
||||||
|
|
||||||
|
def test_TS5567(self):
|
||||||
|
tdSql.query(f"select const_col from (select 1 as const_col from {self.dbname}.{self.stable}) t group by const_col")
|
||||||
|
tdSql.checkRows(50)
|
||||||
|
tdSql.query(f"select const_col from (select 1 as const_col from {self.dbname}.{self.stable}) t partition by const_col")
|
||||||
|
tdSql.checkRows(50)
|
||||||
|
tdSql.query(f"select const_col from (select 1 as const_col, count(c1) from {self.dbname}.{self.stable} t group by c1) group by const_col")
|
||||||
|
tdSql.checkRows(10)
|
||||||
|
tdSql.query(f"select const_col from (select 1 as const_col, count(c1) from {self.dbname}.{self.stable} t group by c1) partition by const_col")
|
||||||
|
tdSql.checkRows(10)
|
||||||
|
tdSql.query(f"select const_col as c_c from (select 1 as const_col from {self.dbname}.{self.stable}) t group by c_c")
|
||||||
|
tdSql.checkRows(50)
|
||||||
|
tdSql.query(f"select const_col as c_c from (select 1 as const_col from {self.dbname}.{self.stable}) t partition by c_c")
|
||||||
|
tdSql.checkRows(50)
|
||||||
|
tdSql.query(f"select const_col from (select 1 as const_col, count(c1) from {self.dbname}.{self.stable} t group by c1) group by 1")
|
||||||
|
tdSql.checkRows(10)
|
||||||
|
tdSql.query(f"select const_col from (select 1 as const_col, count(c1) from {self.dbname}.{self.stable} t group by c1) partition by 1")
|
||||||
|
tdSql.checkRows(10)
|
||||||
def run(self):
|
def run(self):
|
||||||
tdSql.prepare()
|
tdSql.prepare()
|
||||||
self.prepare_db()
|
self.prepare_db()
|
||||||
|
@ -453,6 +469,7 @@ class TDTestCase:
|
||||||
self.test_window(nonempty_tb_num)
|
self.test_window(nonempty_tb_num)
|
||||||
self.test_event_window(nonempty_tb_num)
|
self.test_event_window(nonempty_tb_num)
|
||||||
|
|
||||||
|
self.test_TS5567()
|
||||||
|
|
||||||
## test old version before changed
|
## test old version before changed
|
||||||
# self.test_groupby('group', 0, 0)
|
# self.test_groupby('group', 0, 0)
|
||||||
|
|
Loading…
Reference in New Issue