Merge branch '3.0' into fix/3_liaohj
This commit is contained in:
commit
5184e444df
|
@ -49,7 +49,7 @@ TDengine ODBC driver supports two kinds of connections to TDengine cluster, nati
|
|||
|
||||
4.2 [Connection Type]: required field, we choose "WebSocket"
|
||||
|
||||
4.3 [URL]: required field, the URL for the ODBC data source, for example, `http://localhost:6041` is the URL for a local TDengine cluster, `https://gw.cloud.taosdata.com?token=your_token` is the URL for a TDengine cloud service.
|
||||
4.3 [URL]: required field, the URL for the ODBC data source, for example, `http://localhost:6041` is the URL for a local TDengine cluster.
|
||||
|
||||
4.4 [Database]: optional field, the default database to access
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ If you want to start your application in a container, you need to add the corres
|
|||
FROM ubuntu:20.04
|
||||
RUN apt-get update && apt-get install -y wget
|
||||
ENV TDENGINE_VERSION=3.0.0.0
|
||||
RUN wget -c https://www.taosdata.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
|
||||
RUN wget -c https://tdengine.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
|
||||
&& tar xvf TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
|
||||
&& cd TDengine-client-${TDENGINE_VERSION} \
|
||||
&& ./install_client.sh \
|
||||
|
@ -229,7 +229,7 @@ Here is the full Dockerfile:
|
|||
```docker
|
||||
FROM golang:1.17.6-buster as builder
|
||||
ENV TDENGINE_VERSION=3.0.0.0
|
||||
RUN wget -c https://www.taosdata.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
|
||||
RUN wget -c https://tdengine.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
|
||||
&& tar xvf TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
|
||||
&& cd TDengine-client-${TDENGINE_VERSION} \
|
||||
&& ./install_client.sh \
|
||||
|
@ -245,7 +245,7 @@ RUN go build
|
|||
FROM ubuntu:20.04
|
||||
RUN apt-get update && apt-get install -y wget
|
||||
ENV TDENGINE_VERSION=3.0.0.0
|
||||
RUN wget -c https://www.taosdata.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
|
||||
RUN wget -c https://tdengine.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
|
||||
&& tar xvf TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
|
||||
&& cd TDengine-client-${TDENGINE_VERSION} \
|
||||
&& ./install_client.sh \
|
||||
|
|
|
@ -8,7 +8,7 @@ description: This document describes how to deploy TDengine on Kubernetes.
|
|||
|
||||
As a time series database for Cloud Native architecture design, TDengine supports Kubernetes deployment. Firstly we introduce how to use YAML files to create a highly available TDengine cluster from scratch step by step for production usage, and highlight the common operations of TDengine in Kubernetes environment.
|
||||
|
||||
To meet [high availability ](https://docs.taosdata.com/tdinternal/high-availability/)requirements, clusters need to meet the following requirements:
|
||||
To meet [high availability](../../tdinternal/high-availability/) requirements, clusters need to meet the following requirements:
|
||||
|
||||
- 3 or more dnodes: multiple vnodes in the same vgroup of TDengine are not allowed to be distributed in one dnode at the same time, so if you create a database with 3 replicas, the number of dnodes is greater than or equal to 3
|
||||
- 3 mnodes: mnode is responsible for the management of the entire TDengine cluster. The default number of mnode in TDengine cluster is only one. If the dnode where the mnode located is dropped, the entire cluster is unavailable.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
title: Insert
|
||||
sidebar_label: Insert
|
||||
description: This document describes how to insert data into TDengine.
|
||||
description: This document describes the SQL commands and syntax for inserting data into TDengine.
|
||||
---
|
||||
|
||||
## Syntax
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
title: Data Subscription
|
||||
title: Data Subscription SQL Reference
|
||||
sidebar_label: Data Subscription
|
||||
description: This document describes the SQL statements related to the data subscription component of TDengine.
|
||||
---
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
title: Stream Processing
|
||||
title: Stream Processing SQL Reference
|
||||
sidebar_label: Stream Processing
|
||||
description: This document describes the SQL statements related to the stream processing component of TDengine.
|
||||
---
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
title: User-Defined Functions (UDF)
|
||||
title: User-Defined Functions (UDF) SQL Reference
|
||||
sidebar_label: User-Defined Functions
|
||||
description: This document describes the SQL statements related to user-defined functions (UDF) in TDengine.
|
||||
---
|
||||
|
|
|
@ -19,7 +19,7 @@ Users should not use taosdump to back up raw data, environment settings, hardwar
|
|||
|
||||
There are two ways to install taosdump:
|
||||
|
||||
- Install the taosTools official installer. Please find taosTools from [Release History](https://docs.taosdata.com/releases/tools/) page and download and install it.
|
||||
- Install the taosTools official installer. Please find taosTools from [Release History](../../releases/tools/) page and download and install it.
|
||||
|
||||
- Compile taos-tools separately and install it. Please refer to the [taos-tools](https://github.com/taosdata/taos-tools) repository for details.
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
title: TDinsight - Grafana-based Zero-Dependency Monitoring Solution for TDengine
|
||||
title: TDinsight
|
||||
sidebar_label: TDinsight
|
||||
description: This document describes TDinsight, a monitoring solution for TDengine.
|
||||
---
|
||||
|
|
|
@ -19,7 +19,7 @@ With TDengine ODBC driver, PowerBI can access time series data stored in TDengin
|
|||
|
||||
## Install Driver
|
||||
|
||||
Depending on your TDengine server version, download appropriate version of TDengine client package from TDengine website [Download Link](https://docs.taosdata.com/get-started/package/), or TDengine explorer if you are using a local TDengine cluster. Install the TDengine client package on same Windows machine where PowerBI is running.
|
||||
Depending on your TDengine server version, download appropriate version of TDengine client package from TDengine website [Download Link](../../get-started/package/), or TDengine explorer if you are using a local TDengine cluster. Install the TDengine client package on same Windows machine where PowerBI is running.
|
||||
|
||||
### Configure Data Source
|
||||
|
||||
|
@ -38,7 +38,7 @@ To better use Power BI to analyze the data stored in TDengine, you need to under
|
|||
|
||||
1. Dimention: it's normally category (text) data to describe such information as device, collection point, model. In the supertable template of TDengine, we use tag columns to store the dimention information. You can use SQL like `select distinct tbname, tag1, tag2 from supertable` to get dimentions.
|
||||
|
||||
2. Metric: quantitive (numeric) fileds that can be calculated, like SUM, AVERAGE, MINIMUM. If the collecting frequency is 1 second, then there are 31,536,000 records in one year, it will be too low efficient to import so big data into Power BI. In TDengine, you can use data partition query, window partition query, in combination with pseudo columns related to window, to import downsampled data into Power BI. For more details, please refer to [TDengine Specialized Queries](https://docs.taosdata.com/taos-sql/distinguished/)。
|
||||
2. Metric: quantitive (numeric) fileds that can be calculated, like SUM, AVERAGE, MINIMUM. If the collecting frequency is 1 second, then there are 31,536,000 records in one year, it will be too low efficient to import so big data into Power BI. In TDengine, you can use data partition query, window partition query, in combination with pseudo columns related to window, to import downsampled data into Power BI. For more details, please refer to [TDengine Specialized Queries](../../taos-sql/distinguished/)。
|
||||
|
||||
- Window partition query: for example, thermal meters collect one data per second, but you need to query the average temperature every 10 minutes, you can use window subclause to get the downsampling data you need. The corresponding SQL is like `select tbname, _wstart date,avg(temperature) temp from table interval(10m)`, in which _wstart is a pseudo column indicting the start time of a widow, 10m is the duration of the window, `avg(temperature)` indicates the aggregate value inside a window.
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
title: Quickly Build IT DevOps Visualization System with TDengine + Telegraf + Grafana
|
||||
title: IT Visualization with TDengine + Telegraf + Grafana
|
||||
sidebar_label: TDengine + Telegraf + Grafana
|
||||
description: This document describes how to create an IT visualization system by integrating TDengine with Telegraf and Grafana.
|
||||
---
|
||||
|
|
|
@ -184,8 +184,6 @@ TDengine supports the standard JDBC 3.0 interface for manipulating databases, bu
|
|||
|
||||
To facilitate historical data migration, we provide a plug-in for the data synchronization tool DataX, which can automatically write data into TDengine.The automatic data migration of DataX can only support the data migration process of a single value model.
|
||||
|
||||
For the specific usage of DataX and how to use DataX to write data to TDengine, please refer to [DataX-based TDengine Data Migration Tool](https://www.taosdata.com/engineering/16401.html).
|
||||
|
||||
After migrating via DataX, we found that we can significantly improve the efficiency of migrating historical data by starting multiple processes and migrating numerous metrics simultaneously. The following are some records of the migration process. We provide these as a reference for application migration.
|
||||
|
||||
| Number of datax instances (number of concurrent processes) | Migration record speed (pieces/second) |
|
||||
|
|
|
@ -6,7 +6,7 @@ description: This document provides download links for all released versions of
|
|||
|
||||
taosTools installation packages can be downloaded at the following links:
|
||||
|
||||
For other historical version installers, please visit [here](https://www.taosdata.com/all-downloads).
|
||||
For other historical version installers, please visit [here](https://tdengine.com/downloads/historical/).
|
||||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
use taos::*;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
let dsn = "taos://localhost:6030";
|
||||
let builder = TaosBuilder::from_dsn(dsn)?;
|
||||
|
||||
let taos = builder.build()?;
|
||||
|
||||
// ANCHOR: create_db_and_table
|
||||
let db = "power";
|
||||
// create database
|
||||
taos.exec_many([
|
||||
format!("DROP DATABASE IF EXISTS `{db}`"),
|
||||
format!("CREATE DATABASE `{db}`"),
|
||||
format!("USE `{db}`"),
|
||||
])
|
||||
.await?;
|
||||
|
||||
// create table
|
||||
taos.exec_many([
|
||||
// create super table
|
||||
"CREATE TABLE `meters` (`ts` TIMESTAMP, `current` FLOAT, `voltage` INT, `phase` FLOAT) \
|
||||
TAGS (`groupid` INT, `location` BINARY(24))",
|
||||
]).await?;
|
||||
// ANCHOR_END: create_db_and_table
|
||||
|
||||
// ANCHOR: insert_data
|
||||
let inserted = taos.exec("INSERT INTO " +
|
||||
"power.d1001 USING power.meters TAGS(2,'California.SanFrancisco') " +
|
||||
"VALUES " +
|
||||
"(NOW + 1a, 10.30000, 219, 0.31000) " +
|
||||
"(NOW + 2a, 12.60000, 218, 0.33000) " +
|
||||
"(NOW + 3a, 12.30000, 221, 0.31000) " +
|
||||
"power.d1002 USING power.meters TAGS(3, 'California.SanFrancisco') " +
|
||||
"VALUES " +
|
||||
"(NOW + 1a, 10.30000, 218, 0.25000) ").await?;
|
||||
|
||||
println!("inserted: {} rows", inserted);
|
||||
// ANCHOR_END: insert_data
|
||||
|
||||
// ANCHOR: query_data
|
||||
let mut result = taos.query("SELECT * FROM power.meters").await?;
|
||||
|
||||
for field in result.fields() {
|
||||
println!("got field: {}", field.name());
|
||||
}
|
||||
|
||||
let mut rows = result.rows();
|
||||
let mut nrows = 0;
|
||||
while let Some(row) = rows.try_next().await? {
|
||||
for (col, (name, value)) in row.enumerate() {
|
||||
println!(
|
||||
"[{}] got value in col {} (named `{:>8}`): {}",
|
||||
nrows, col, name, value
|
||||
);
|
||||
}
|
||||
nrows += 1;
|
||||
}
|
||||
// ANCHOR_END: query_data
|
||||
|
||||
// ANCHOR: query_with_req_id
|
||||
let result = taos.query_with_req_id("SELECT * FROM power.meters", 0).await?;
|
||||
// ANCHOR_END: query_with_req_id
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
use taos_query::common::SchemalessPrecision;
|
||||
use taos_query::common::SchemalessProtocol;
|
||||
use taos_query::common::SmlDataBuilder;
|
||||
|
||||
use crate::AsyncQueryable;
|
||||
use crate::AsyncTBuilder;
|
||||
use crate::TaosBuilder;
|
||||
|
||||
async fn put() -> anyhow::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "taos=debug");
|
||||
pretty_env_logger::init();
|
||||
let dsn =
|
||||
std::env::var("TDENGINE_ClOUD_DSN").unwrap_or("http://localhost:6041".to_string());
|
||||
log::debug!("dsn: {:?}", &dsn);
|
||||
|
||||
let client = TaosBuilder::from_dsn(dsn)?.build().await?;
|
||||
|
||||
let db = "power";
|
||||
|
||||
client.exec(format!("drop database if exists {db}")).await?;
|
||||
|
||||
client
|
||||
.exec(format!("create database if not exists {db}"))
|
||||
.await?;
|
||||
|
||||
// should specify database before insert
|
||||
client.exec(format!("use {db}")).await?;
|
||||
|
||||
// SchemalessProtocol::Line
|
||||
let data = [
|
||||
"meters,groupid=2,location=California.SanFrancisco current=10.3000002f64,voltage=219i32,phase=0.31f64 1626006833639000000",
|
||||
]
|
||||
.map(String::from)
|
||||
.to_vec();
|
||||
|
||||
let sml_data = SmlDataBuilder::default()
|
||||
.protocol(SchemalessProtocol::Line)
|
||||
.precision(SchemalessPrecision::Millisecond)
|
||||
.data(data.clone())
|
||||
.ttl(1000)
|
||||
.req_id(100u64)
|
||||
.build()?;
|
||||
assert_eq!(client.put(&sml_data).await?, ());
|
||||
|
||||
// SchemalessProtocol::Telnet
|
||||
let data = [
|
||||
"meters.current 1648432611249 10.3 location=California.SanFrancisco group=2",
|
||||
]
|
||||
.map(String::from)
|
||||
.to_vec();
|
||||
|
||||
let sml_data = SmlDataBuilder::default()
|
||||
.protocol(SchemalessProtocol::Telnet)
|
||||
.precision(SchemalessPrecision::Millisecond)
|
||||
.data(data.clone())
|
||||
.ttl(1000)
|
||||
.req_id(200u64)
|
||||
.build()?;
|
||||
assert_eq!(client.put(&sml_data).await?, ());
|
||||
|
||||
// SchemalessProtocol::Json
|
||||
let data = [
|
||||
r#"[{"metric": "meters.current", "timestamp": 1681345954000, "value": 10.3, "tags": {"location": "California.SanFrancisco", "groupid": 2}}, {"metric": "meters.voltage", "timestamp": 1648432611249, "value": 219, "tags": {"location": "California.LosAngeles", "groupid": 1}}, {"metric": "meters.current", "timestamp": 1648432611250, "value": 12.6, "tags": {"location": "California.SanFrancisco", "groupid": 2}}, {"metric": "meters.voltage", "timestamp": 1648432611250, "value": 221, "tags": {"location": "California.LosAngeles", "groupid": 1}}]"#
|
||||
]
|
||||
.map(String::from)
|
||||
.to_vec();
|
||||
|
||||
let sml_data = SmlDataBuilder::default()
|
||||
.protocol(SchemalessProtocol::Json)
|
||||
.precision(SchemalessPrecision::Millisecond)
|
||||
.data(data.clone())
|
||||
.ttl(1000)
|
||||
.req_id(300u64)
|
||||
.build()?;
|
||||
assert_eq!(client.put(&sml_data).await?, ());
|
||||
|
||||
client.exec(format!("drop database if exists {db}")).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
use taos::*;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
let taos = TaosBuilder::from_dsn("taos://")?.build().await?;
|
||||
|
||||
taos.exec("DROP DATABASE IF EXISTS power").await?;
|
||||
taos.create_database("power").await?;
|
||||
taos.use_database("power").await?;
|
||||
taos.exec("CREATE STABLE IF NOT EXISTS meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)").await?;
|
||||
|
||||
let mut stmt = Stmt::init(&taos).await?;
|
||||
stmt.prepare("INSERT INTO ? USING meters TAGS(?, ?) VALUES(?, ?, ?, ?)").await?;
|
||||
|
||||
const NUM_TABLES: usize = 10;
|
||||
const NUM_ROWS: usize = 10;
|
||||
for i in 0..NUM_TABLES {
|
||||
let table_name = format!("d{}", i);
|
||||
let tags = vec![Value::VarChar("California.SanFransico".into()), Value::Int(2)];
|
||||
stmt.set_tbname_tags(&table_name, &tags).await?;
|
||||
for j in 0..NUM_ROWS {
|
||||
let values = vec![
|
||||
ColumnView::from_millis_timestamp(vec![1648432611249 + j as i64]),
|
||||
ColumnView::from_floats(vec![10.3 + j as f32]),
|
||||
ColumnView::from_ints(vec![219 + j as i32]),
|
||||
ColumnView::from_floats(vec![0.31 + j as f32]),
|
||||
];
|
||||
stmt.bind(&values).await?;
|
||||
}
|
||||
stmt.add_batch().await?;
|
||||
}
|
||||
|
||||
// execute.
|
||||
let rows = stmt.execute().await?;
|
||||
assert_eq!(rows, NUM_TABLES * NUM_ROWS);
|
||||
Ok(())
|
||||
}
|
|
@ -0,0 +1,166 @@
|
|||
use std::time::Duration;
|
||||
use std::str::FromStr;
|
||||
|
||||
use taos::*;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
pretty_env_logger::formatted_timed_builder()
|
||||
.filter_level(log::LevelFilter::Info)
|
||||
.init();
|
||||
use taos_query::prelude::*;
|
||||
let dsn = "taos://localhost:6030".to_string();
|
||||
log::info!("dsn: {}", dsn);
|
||||
let mut dsn = Dsn::from_str(&dsn)?;
|
||||
|
||||
let taos = TaosBuilder::from_dsn(&dsn)?.build().await?;
|
||||
|
||||
// prepare database and table
|
||||
taos.exec_many([
|
||||
"drop topic if exists topic_meters",
|
||||
"drop database if exists power",
|
||||
"create database if not exists power WAL_RETENTION_PERIOD 86400",
|
||||
"use power",
|
||||
|
||||
"CREATE STABLE IF NOT EXISTS power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))",
|
||||
|
||||
"create table if not exists power.d001 using power.meters tags(1,'location')",
|
||||
|
||||
])
|
||||
.await?;
|
||||
|
||||
taos.exec_many([
|
||||
"drop database if exists db2",
|
||||
"create database if not exists db2 wal_retention_period 3600",
|
||||
"use db2",
|
||||
])
|
||||
.await?;
|
||||
|
||||
// ANCHOR: create_topic
|
||||
taos.exec_many([
|
||||
"CREATE TOPIC IF NOT EXISTS topic_meters AS SELECT ts, current, voltage, phase, groupid, location FROM power.meters",
|
||||
])
|
||||
.await?;
|
||||
// ANCHOR_END: create_topic
|
||||
|
||||
// ANCHOR: create_consumer
|
||||
dsn.params.insert("group.id".to_string(), "abc".to_string());
|
||||
dsn.params.insert("auto.offset.reset".to_string(), "earliest".to_string());
|
||||
|
||||
let builder = TmqBuilder::from_dsn(&dsn)?;
|
||||
let mut consumer = builder.build().await?;
|
||||
// ANCHOR_END: create_consumer
|
||||
|
||||
// ANCHOR: subscribe
|
||||
consumer.subscribe(["topic_meters"]).await?;
|
||||
// ANCHOR_END: subscribe
|
||||
|
||||
// ANCHOR: consume
|
||||
{
|
||||
let mut stream = consumer.stream_with_timeout(Timeout::from_secs(1));
|
||||
|
||||
while let Some((offset, message)) = stream.try_next().await? {
|
||||
|
||||
let topic: &str = offset.topic();
|
||||
let database = offset.database();
|
||||
let vgroup_id = offset.vgroup_id();
|
||||
log::debug!(
|
||||
"topic: {}, database: {}, vgroup_id: {}",
|
||||
topic,
|
||||
database,
|
||||
vgroup_id
|
||||
);
|
||||
|
||||
match message {
|
||||
MessageSet::Meta(meta) => {
|
||||
log::info!("Meta");
|
||||
let raw = meta.as_raw_meta().await?;
|
||||
taos.write_raw_meta(&raw).await?;
|
||||
|
||||
let json = meta.as_json_meta().await?;
|
||||
let sql = json.to_string();
|
||||
if let Err(err) = taos.exec(sql).await {
|
||||
println!("maybe error: {}", err);
|
||||
}
|
||||
}
|
||||
MessageSet::Data(data) => {
|
||||
log::info!("Data");
|
||||
while let Some(data) = data.fetch_raw_block().await? {
|
||||
log::debug!("data: {:?}", data);
|
||||
}
|
||||
}
|
||||
MessageSet::MetaData(meta, data) => {
|
||||
log::info!("MetaData");
|
||||
let raw = meta.as_raw_meta().await?;
|
||||
taos.write_raw_meta(&raw).await?;
|
||||
|
||||
let json = meta.as_json_meta().await?;
|
||||
let sql = json.to_string();
|
||||
if let Err(err) = taos.exec(sql).await {
|
||||
println!("maybe error: {}", err);
|
||||
}
|
||||
|
||||
while let Some(data) = data.fetch_raw_block().await? {
|
||||
log::debug!("data: {:?}", data);
|
||||
}
|
||||
}
|
||||
}
|
||||
consumer.commit(offset).await?;
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: consume
|
||||
|
||||
// ANCHOR: assignments
|
||||
let assignments = consumer.assignments().await.unwrap();
|
||||
log::info!("assignments: {:?}", assignments);
|
||||
// ANCHOR_END: assignments
|
||||
|
||||
// seek offset
|
||||
for topic_vec_assignment in assignments {
|
||||
let topic = &topic_vec_assignment.0;
|
||||
let vec_assignment = topic_vec_assignment.1;
|
||||
for assignment in vec_assignment {
|
||||
let vgroup_id = assignment.vgroup_id();
|
||||
let current = assignment.current_offset();
|
||||
let begin = assignment.begin();
|
||||
let end = assignment.end();
|
||||
log::debug!(
|
||||
"topic: {}, vgroup_id: {}, current offset: {} begin {}, end: {}",
|
||||
topic,
|
||||
vgroup_id,
|
||||
current,
|
||||
begin,
|
||||
end
|
||||
);
|
||||
// ANCHOR: seek_offset
|
||||
let res = consumer.offset_seek(topic, vgroup_id, end).await;
|
||||
if res.is_err() {
|
||||
log::error!("seek offset error: {:?}", res);
|
||||
let a = consumer.assignments().await.unwrap();
|
||||
log::error!("assignments: {:?}", a);
|
||||
}
|
||||
// ANCHOR_END: seek_offset
|
||||
}
|
||||
|
||||
let topic_assignment = consumer.topic_assignment(topic).await;
|
||||
log::debug!("topic assignment: {:?}", topic_assignment);
|
||||
}
|
||||
|
||||
// after seek offset
|
||||
let assignments = consumer.assignments().await.unwrap();
|
||||
log::info!("after seek offset assignments: {:?}", assignments);
|
||||
|
||||
// ANCHOR: unsubscribe
|
||||
consumer.unsubscribe().await;
|
||||
// ANCHOR_END: unsubscribe
|
||||
|
||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||
|
||||
taos.exec_many([
|
||||
"drop database db2",
|
||||
"drop topic topic_meters",
|
||||
"drop database power",
|
||||
])
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
|
@ -267,7 +267,7 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq2** pReq, const SSDataBlock* pData
|
|||
|
||||
bool alreadyAddGroupId(char* ctbName);
|
||||
bool isAutoTableName(char* ctbName);
|
||||
void buildCtbNameAddGroupId(char* ctbName, uint64_t groupId);
|
||||
void buildCtbNameAddGroupId(const char* stbName, char* ctbName, uint64_t groupId);
|
||||
char* buildCtbNameByGroupId(const char* stbName, uint64_t groupId);
|
||||
int32_t buildCtbNameByGroupIdImpl(const char* stbName, uint64_t groupId, char* pBuf);
|
||||
|
||||
|
|
|
@ -61,9 +61,6 @@ typedef enum {
|
|||
int32_t grantCheck(EGrantType grant);
|
||||
int32_t grantCheckExpire(EGrantType grant);
|
||||
char* tGetMachineId();
|
||||
#ifdef TD_UNIQ_GRANT
|
||||
int32_t grantCheckLE(EGrantType grant);
|
||||
#endif
|
||||
|
||||
// #ifndef GRANTS_CFG
|
||||
#ifdef TD_ENTERPRISE
|
||||
|
@ -76,7 +73,7 @@ int32_t grantCheckLE(EGrantType grant);
|
|||
{.name = "state", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "cpu_cores", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "cpu_cores", .bytes = 13 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
}
|
||||
#else
|
||||
#define GRANTS_SCHEMA \
|
||||
|
@ -88,7 +85,7 @@ int32_t grantCheckLE(EGrantType grant);
|
|||
{.name = "state", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "cpu_cores", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "cpu_cores", .bytes = 13 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
}
|
||||
#endif
|
||||
// #define GRANT_CFG_ADD
|
||||
|
|
|
@ -61,7 +61,7 @@ typedef struct SStreamTask SStreamTask;
|
|||
typedef struct SStreamQueue SStreamQueue;
|
||||
typedef struct SStreamTaskSM SStreamTaskSM;
|
||||
|
||||
#define SSTREAM_TASK_VER 3
|
||||
#define SSTREAM_TASK_VER 4
|
||||
#define SSTREAM_TASK_INCOMPATIBLE_VER 1
|
||||
#define SSTREAM_TASK_NEED_CONVERT_VER 2
|
||||
#define SSTREAM_TASK_SUBTABLE_CHANGED_VER 3
|
||||
|
|
|
@ -359,21 +359,24 @@ static const SSysDbTableSchema userCompactsDetailSchema[] = {
|
|||
{.name = "start_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema useGrantsFullSchema[] = {
|
||||
static const SSysDbTableSchema userGrantsFullSchema[] = {
|
||||
{.name = "grant_name", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "display_name", .bytes = 256 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "expire", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "limits", .bytes = 512 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema useGrantsLogsSchema[] = {
|
||||
static const SSysDbTableSchema userGrantsLogsSchema[] = {
|
||||
{.name = "state", .bytes = 1536 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "active", .bytes = 512 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "machine", .bytes = TSDB_GRANT_LOG_COL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema useMachinesSchema[] = {
|
||||
static const SSysDbTableSchema userMachinesSchema[] = {
|
||||
{.name = "id", .bytes = TSDB_CLUSTER_ID_LEN + 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
#ifndef TD_UNIQ_GRANT
|
||||
{.name = "dnode_num", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
#endif
|
||||
{.name = "machine", .bytes = 7552 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
};
|
||||
|
||||
|
@ -406,9 +409,9 @@ static const SSysTableMeta infosMeta[] = {
|
|||
{TSDB_INS_TABLE_VIEWS, userViewsSchema, tListLen(userViewsSchema), false},
|
||||
{TSDB_INS_TABLE_COMPACTS, userCompactsSchema, tListLen(userCompactsSchema), false},
|
||||
{TSDB_INS_TABLE_COMPACT_DETAILS, userCompactsDetailSchema, tListLen(userCompactsDetailSchema), false},
|
||||
{TSDB_INS_TABLE_GRANTS_FULL, useGrantsFullSchema, tListLen(useGrantsFullSchema), true},
|
||||
{TSDB_INS_TABLE_GRANTS_LOGS, useGrantsLogsSchema, tListLen(useGrantsLogsSchema), true},
|
||||
{TSDB_INS_TABLE_MACHINES, useMachinesSchema, tListLen(useMachinesSchema), true},
|
||||
{TSDB_INS_TABLE_GRANTS_FULL, userGrantsFullSchema, tListLen(userGrantsFullSchema), true},
|
||||
{TSDB_INS_TABLE_GRANTS_LOGS, userGrantsLogsSchema, tListLen(userGrantsLogsSchema), true},
|
||||
{TSDB_INS_TABLE_MACHINES, userMachinesSchema, tListLen(userMachinesSchema), true},
|
||||
{TSDB_INS_TABLE_ARBGROUPS, arbGroupsSchema, tListLen(arbGroupsSchema), true},
|
||||
};
|
||||
|
||||
|
|
|
@ -2141,10 +2141,14 @@ _end:
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void buildCtbNameAddGroupId(char* ctbName, uint64_t groupId){
|
||||
void buildCtbNameAddGroupId(const char* stbName, char* ctbName, uint64_t groupId){
|
||||
char tmp[TSDB_TABLE_NAME_LEN] = {0};
|
||||
if (stbName == NULL){
|
||||
snprintf(tmp, TSDB_TABLE_NAME_LEN, "_%"PRIu64, groupId);
|
||||
ctbName[TSDB_TABLE_NAME_LEN - strlen(tmp) - 1] = 0; // put groupId to the end
|
||||
}else{
|
||||
snprintf(tmp, TSDB_TABLE_NAME_LEN, "_%s_%"PRIu64, stbName, groupId);
|
||||
}
|
||||
ctbName[TSDB_TABLE_NAME_LEN - strlen(tmp) - 1] = 0; // put stbname + groupId to the end
|
||||
strcat(ctbName, tmp);
|
||||
}
|
||||
|
||||
|
@ -2154,6 +2158,7 @@ bool isAutoTableName(char* ctbName) { return (strlen(ctbName) == 34 && ctbName[0
|
|||
|
||||
bool alreadyAddGroupId(char* ctbName) {
|
||||
size_t len = strlen(ctbName);
|
||||
if (len == 0) return false;
|
||||
size_t _location = len - 1;
|
||||
while (_location > 0) {
|
||||
if (ctbName[_location] < '0' || ctbName[_location] > '9') {
|
||||
|
|
|
@ -21,11 +21,5 @@
|
|||
int32_t grantCheck(EGrantType grant) { return TSDB_CODE_SUCCESS; }
|
||||
int32_t grantCheckExpire(EGrantType grant) { return TSDB_CODE_SUCCESS; }
|
||||
|
||||
#ifdef TD_UNIQ_GRANT
|
||||
int32_t grantCheckLE(EGrantType grant) { return TSDB_CODE_SUCCESS; }
|
||||
#endif
|
||||
#else
|
||||
#ifdef TD_UNIQ_GRANT
|
||||
int32_t grantCheckExpire(EGrantType grant) { return TSDB_CODE_SUCCESS; }
|
||||
#endif
|
||||
#endif
|
|
@ -51,8 +51,8 @@
|
|||
|
||||
#define ENCODESQL() \
|
||||
do { \
|
||||
if (pReq->sqlLen > 0 && pReq->sql != NULL) { \
|
||||
if (tEncodeI32(&encoder, pReq->sqlLen) < 0) return -1; \
|
||||
if (pReq->sqlLen > 0 && pReq->sql != NULL) { \
|
||||
if (tEncodeBinary(&encoder, pReq->sql, pReq->sqlLen) < 0) return -1; \
|
||||
} \
|
||||
} while (0)
|
||||
|
@ -3025,7 +3025,7 @@ int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) {
|
|||
|
||||
ENCODESQL();
|
||||
|
||||
if (tEncodeI32(&encoder, pReq->withArbitrator) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->withArbitrator) < 0) return -1;
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
||||
|
@ -3140,7 +3140,7 @@ int32_t tSerializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) {
|
|||
if (tEncodeI32(&encoder, pReq->walRetentionSize) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->keepTimeOffset) < 0) return -1;
|
||||
ENCODESQL();
|
||||
if (tEncodeI32(&encoder, pReq->withArbitrator) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->withArbitrator) < 0) return -1;
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
|
|
|
@ -35,6 +35,7 @@ int32_t mndSetCreateArbGroupRedoLogs(STrans *pTrans, SArbGroup *pGroup);
|
|||
int32_t mndSetCreateArbGroupUndoLogs(STrans *pTrans, SArbGroup *pGroup);
|
||||
int32_t mndSetCreateArbGroupCommitLogs(STrans *pTrans, SArbGroup *pGroup);
|
||||
|
||||
int32_t mndSetDropArbGroupPrepareLogs(STrans *pTrans, SArbGroup *pGroup);
|
||||
int32_t mndSetDropArbGroupCommitLogs(STrans *pTrans, SArbGroup *pGroup);
|
||||
|
||||
bool mndUpdateArbGroupByHeartBeat(SArbGroup *pGroup, SVArbHbRspMember *pRspMember, int64_t nowMs, int32_t dnodeId,
|
||||
|
|
|
@ -217,8 +217,6 @@ typedef struct {
|
|||
uint16_t port;
|
||||
char fqdn[TSDB_FQDN_LEN];
|
||||
char ep[TSDB_EP_LEN];
|
||||
char active[TSDB_ACTIVE_KEY_LEN];
|
||||
char connActive[TSDB_CONN_ACTIVE_KEY_LEN];
|
||||
char machineId[TSDB_MACHINE_ID_LEN + 1];
|
||||
} SDnodeObj;
|
||||
|
||||
|
|
|
@ -260,6 +260,14 @@ int32_t mndSetCreateArbGroupCommitLogs(STrans *pTrans, SArbGroup *pGroup) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t mndSetDropArbGroupPrepareLogs(STrans *pTrans, SArbGroup *pGroup) {
|
||||
SSdbRaw *pRedoRaw = mndArbGroupActionEncode(pGroup);
|
||||
if (pRedoRaw == NULL) return -1;
|
||||
if (mndTransAppendPrepareLog(pTrans, pRedoRaw) != 0) return -1;
|
||||
if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_DROPPING) != 0) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndSetDropArbGroupRedoLogs(STrans *pTrans, SArbGroup *pGroup) {
|
||||
SSdbRaw *pRedoRaw = mndArbGroupActionEncode(pGroup);
|
||||
if (pRedoRaw == NULL) return -1;
|
||||
|
@ -537,15 +545,25 @@ static int32_t mndProcessArbCheckSyncTimer(SRpcMsg *pReq) {
|
|||
|
||||
bool member0IsTimeout = mndCheckArbMemberHbTimeout(&arbGroupDup, 0, nowMs);
|
||||
bool member1IsTimeout = mndCheckArbMemberHbTimeout(&arbGroupDup, 1, nowMs);
|
||||
int32_t currentAssignedDnodeId = arbGroupDup.assignedLeader.dnodeId;
|
||||
SArbAssignedLeader *pAssignedLeader = &arbGroupDup.assignedLeader;
|
||||
int32_t currentAssignedDnodeId = pAssignedLeader->dnodeId;
|
||||
|
||||
// 1. both of the two members are timeout => skip
|
||||
// 1. has assigned && is sync => send req
|
||||
if (currentAssignedDnodeId != 0 && arbGroupDup.isSync == true) {
|
||||
(void)mndSendArbSetAssignedLeaderReq(pMnode, currentAssignedDnodeId, vgId, arbToken, term,
|
||||
pAssignedLeader->token);
|
||||
mInfo("vgId:%d, arb send set assigned leader to dnodeId:%d", vgId, currentAssignedDnodeId);
|
||||
sdbRelease(pSdb, pArbGroup);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 2. both of the two members are timeout => skip
|
||||
if (member0IsTimeout && member1IsTimeout) {
|
||||
sdbRelease(pSdb, pArbGroup);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 2. no member is timeout => check sync
|
||||
// 3. no member is timeout => check sync
|
||||
if (member0IsTimeout == false && member1IsTimeout == false) {
|
||||
// no assigned leader and not sync
|
||||
if (currentAssignedDnodeId == 0 && !arbGroupDup.isSync) {
|
||||
|
@ -556,7 +574,7 @@ static int32_t mndProcessArbCheckSyncTimer(SRpcMsg *pReq) {
|
|||
continue;
|
||||
}
|
||||
|
||||
// 3. one of the members is timeout => set assigned leader
|
||||
// 4. one of the members is timeout => set assigned leader
|
||||
int32_t candidateIndex = member0IsTimeout ? 1 : 0;
|
||||
SArbGroupMember *pMember = &arbGroupDup.members[candidateIndex];
|
||||
|
||||
|
@ -581,8 +599,7 @@ static int32_t mndProcessArbCheckSyncTimer(SRpcMsg *pReq) {
|
|||
continue;
|
||||
}
|
||||
|
||||
// no assigned leader => write to sdb
|
||||
if (currentAssignedDnodeId == 0) {
|
||||
// is sync && no assigned leader => write to sdb
|
||||
SArbGroup newGroup = {0};
|
||||
mndArbGroupDupObj(&arbGroupDup, &newGroup);
|
||||
mndArbGroupSetAssignedLeader(&newGroup, candidateIndex);
|
||||
|
@ -594,13 +611,6 @@ static int32_t mndProcessArbCheckSyncTimer(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
mInfo("vgId:%d, arb pull up set assigned leader to dnodeId:%d", vgId, pMember->info.dnodeId);
|
||||
sdbRelease(pSdb, pArbGroup);
|
||||
continue;
|
||||
}
|
||||
|
||||
// isSync == true && dnodeId match => send request to dnode
|
||||
(void)mndSendArbSetAssignedLeaderReq(pMnode, pMember->info.dnodeId, vgId, arbToken, term, pMember->state.token);
|
||||
mInfo("vgId:%d, arb send set assigned leader to dnodeId:%d", vgId, pMember->info.dnodeId);
|
||||
|
||||
sdbRelease(pSdb, pArbGroup);
|
||||
}
|
||||
|
@ -666,8 +676,15 @@ static int32_t mndProcessArbUpdateGroupReq(SRpcMsg *pReq) {
|
|||
newGroup.version = req.version;
|
||||
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
SArbGroup *pOldGroup = sdbAcquire(pMnode->pSdb, SDB_ARBGROUP, &newGroup.vgId);
|
||||
if (!pOldGroup) {
|
||||
mInfo("vgId:%d, arb skip to update arbgroup, since no obj found", newGroup.vgId);
|
||||
return 0;
|
||||
}
|
||||
sdbRelease(pMnode->pSdb, pOldGroup);
|
||||
|
||||
if (mndArbGroupUpdateTrans(pMnode, &newGroup) != 0) {
|
||||
mError("vgId:%d, arb failed to update arbgroup, since %s", req.vgId, terrstr());
|
||||
mError("vgId:%d, arb failed to update arbgroup, since %s", newGroup.vgId, terrstr());
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
|
@ -1055,6 +1072,7 @@ static int32_t mndRetrieveArbGroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
|
|||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->isSync, false);
|
||||
|
||||
if (pGroup->assignedLeader.dnodeId != 0) {
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->assignedLeader.dnodeId, false);
|
||||
|
||||
|
@ -1062,6 +1080,13 @@ static int32_t mndRetrieveArbGroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
|
|||
STR_WITH_MAXSIZE_TO_VARSTR(token, pGroup->assignedLeader.token, TSDB_ARB_TOKEN_SIZE + VARSTR_HEADER_SIZE);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)token, false);
|
||||
} else {
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetNULL(pColInfo, numOfRows);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetNULL(pColInfo, numOfRows);
|
||||
}
|
||||
|
||||
taosThreadMutexUnlock(&pGroup->mutex);
|
||||
|
||||
|
|
|
@ -292,16 +292,16 @@ static void storeOffsetRows(SMnode *pMnode, SMqHbReq *req, SMqConsumerObj *pCons
|
|||
static int32_t buildMqHbRsp(SRpcMsg *pMsg, SMqHbRsp *rsp){
|
||||
int32_t tlen = tSerializeSMqHbRsp(NULL, 0, rsp);
|
||||
if (tlen <= 0){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_TMQ_INVALID_MSG;
|
||||
}
|
||||
void *buf = rpcMallocCont(tlen);
|
||||
if (buf == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if(tSerializeSMqHbRsp(buf, tlen, rsp) != 0){
|
||||
if(tSerializeSMqHbRsp(buf, tlen, rsp) <= 0){
|
||||
rpcFreeCont(buf);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_TMQ_INVALID_MSG;
|
||||
}
|
||||
pMsg->info.rsp = buf;
|
||||
pMsg->info.rspLen = tlen;
|
||||
|
@ -316,7 +316,7 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) {
|
|||
SMqConsumerObj *pConsumer = NULL;
|
||||
|
||||
if (tDeserializeSMqHbReq(pMsg->pCont, pMsg->contLen, &req) < 0) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_TMQ_INVALID_MSG;
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
|
|
@ -438,7 +438,8 @@ static int32_t mndCheckInChangeDbCfg(SMnode *pMnode, SDbCfg *pOldCfg, SDbCfg *pN
|
|||
if (pNewCfg->daysToKeep0 < pNewCfg->daysPerFile) return -1;
|
||||
if (pNewCfg->daysToKeep0 > pNewCfg->daysToKeep1) return -1;
|
||||
if (pNewCfg->daysToKeep1 > pNewCfg->daysToKeep2) return -1;
|
||||
if (pNewCfg->keepTimeOffset < TSDB_MIN_KEEP_TIME_OFFSET || pNewCfg->keepTimeOffset > TSDB_MAX_KEEP_TIME_OFFSET) return -1;
|
||||
if (pNewCfg->keepTimeOffset < TSDB_MIN_KEEP_TIME_OFFSET || pNewCfg->keepTimeOffset > TSDB_MAX_KEEP_TIME_OFFSET)
|
||||
return -1;
|
||||
if (pNewCfg->walFsyncPeriod < TSDB_MIN_FSYNC_PERIOD || pNewCfg->walFsyncPeriod > TSDB_MAX_FSYNC_PERIOD) return -1;
|
||||
if (pNewCfg->walLevel < TSDB_MIN_WAL_LEVEL || pNewCfg->walLevel > TSDB_MAX_WAL_LEVEL) return -1;
|
||||
if (pNewCfg->cacheLast < TSDB_CACHE_MODEL_NONE || pNewCfg->cacheLast > TSDB_CACHE_MODEL_BOTH) return -1;
|
||||
|
@ -452,6 +453,10 @@ static int32_t mndCheckInChangeDbCfg(SMnode *pMnode, SDbCfg *pOldCfg, SDbCfg *pN
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
if (pNewCfg->replications != 2 && pOldCfg->replications == 2) {
|
||||
terrno = TSDB_CODE_OPS_NOT_SUPPORT;
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
if (pNewCfg->replications != 1 && pNewCfg->replications != 3) return -1;
|
||||
#endif
|
||||
|
@ -940,7 +945,7 @@ static int32_t mndSetDbCfgFromAlterDbReq(SDbObj *pDb, SAlterDbReq *pAlter) {
|
|||
terrno = 0;
|
||||
}
|
||||
|
||||
if (pAlter->withArbitrator != pDb->cfg.withArbitrator) {
|
||||
if (pAlter->withArbitrator >= TSDB_MIN_DB_WITH_ARBITRATOR && pAlter->withArbitrator != pDb->cfg.withArbitrator) {
|
||||
pDb->cfg.withArbitrator = pAlter->withArbitrator;
|
||||
pDb->vgVersion++;
|
||||
terrno = 0;
|
||||
|
@ -1204,6 +1209,25 @@ static int32_t mndSetDropDbPrepareLogs(SMnode *pMnode, STrans *pTrans, SDbObj *p
|
|||
if (mndTransAppendPrepareLog(pTrans, pRedoRaw) != 0) return -1;
|
||||
if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_DROPPING) != 0) return -1;
|
||||
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
void *pIter = NULL;
|
||||
|
||||
while (1) {
|
||||
SArbGroup *pArbGroup = NULL;
|
||||
pIter = sdbFetch(pSdb, SDB_ARBGROUP, pIter, (void **)&pArbGroup);
|
||||
if (pIter == NULL) break;
|
||||
|
||||
if (pArbGroup->dbUid == pDb->uid) {
|
||||
if (mndSetDropArbGroupPrepareLogs(pTrans,pArbGroup) != 0) {
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
sdbRelease(pSdb, pArbGroup);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
sdbRelease(pSdb, pArbGroup);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,9 @@ int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) {
|
|||
if (tEncodeI32(pEncoder, innerSz) < 0) return -1;
|
||||
for (int32_t j = 0; j < innerSz; j++) {
|
||||
SStreamTask *pTask = taosArrayGetP(pArray, j);
|
||||
if (pTask->ver < SSTREAM_TASK_SUBTABLE_CHANGED_VER){
|
||||
pTask->ver = SSTREAM_TASK_VER;
|
||||
}
|
||||
if (tEncodeStreamTask(pEncoder, pTask) < 0) return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "taos_monitor.h"
|
||||
|
||||
#define TSDB_DNODE_VER_NUMBER 2
|
||||
#define TSDB_DNODE_RESERVE_SIZE 64
|
||||
#define TSDB_DNODE_RESERVE_SIZE 40
|
||||
|
||||
static const char *offlineReason[] = {
|
||||
"",
|
||||
|
@ -183,11 +183,10 @@ static SSdbRaw *mndDnodeActionEncode(SDnodeObj *pDnode) {
|
|||
SDB_SET_INT64(pRaw, dataPos, pDnode->updateTime, _OVER)
|
||||
SDB_SET_INT16(pRaw, dataPos, pDnode->port, _OVER)
|
||||
SDB_SET_BINARY(pRaw, dataPos, pDnode->fqdn, TSDB_FQDN_LEN, _OVER)
|
||||
SDB_SET_BINARY(pRaw, dataPos, pDnode->machineId, TSDB_MACHINE_ID_LEN, _OVER)
|
||||
SDB_SET_RESERVE(pRaw, dataPos, TSDB_DNODE_RESERVE_SIZE, _OVER)
|
||||
SDB_SET_INT16(pRaw, dataPos, TSDB_ACTIVE_KEY_LEN, _OVER)
|
||||
SDB_SET_BINARY(pRaw, dataPos, pDnode->active, TSDB_ACTIVE_KEY_LEN, _OVER)
|
||||
SDB_SET_INT16(pRaw, dataPos, TSDB_CONN_ACTIVE_KEY_LEN, _OVER)
|
||||
SDB_SET_BINARY(pRaw, dataPos, pDnode->connActive, TSDB_CONN_ACTIVE_KEY_LEN, _OVER)
|
||||
SDB_SET_INT16(pRaw, dataPos, 0, _OVER) // forward/backward compatible
|
||||
SDB_SET_INT16(pRaw, dataPos, 0, _OVER) // forward/backward compatible
|
||||
SDB_SET_DATALEN(pRaw, dataPos, _OVER);
|
||||
|
||||
terrno = 0;
|
||||
|
@ -227,13 +226,14 @@ static SSdbRow *mndDnodeActionDecode(SSdbRaw *pRaw) {
|
|||
SDB_GET_INT64(pRaw, dataPos, &pDnode->updateTime, _OVER)
|
||||
SDB_GET_INT16(pRaw, dataPos, &pDnode->port, _OVER)
|
||||
SDB_GET_BINARY(pRaw, dataPos, pDnode->fqdn, TSDB_FQDN_LEN, _OVER)
|
||||
SDB_GET_BINARY(pRaw, dataPos, pDnode->machineId, TSDB_MACHINE_ID_LEN, _OVER)
|
||||
SDB_GET_RESERVE(pRaw, dataPos, TSDB_DNODE_RESERVE_SIZE, _OVER)
|
||||
if (sver > 1) {
|
||||
int16_t keyLen = 0;
|
||||
SDB_GET_INT16(pRaw, dataPos, &keyLen, _OVER)
|
||||
SDB_GET_BINARY(pRaw, dataPos, pDnode->active, keyLen, _OVER)
|
||||
SDB_GET_BINARY(pRaw, dataPos, NULL, keyLen, _OVER)
|
||||
SDB_GET_INT16(pRaw, dataPos, &keyLen, _OVER)
|
||||
SDB_GET_BINARY(pRaw, dataPos, pDnode->connActive, keyLen, _OVER)
|
||||
SDB_GET_BINARY(pRaw, dataPos, NULL, keyLen, _OVER)
|
||||
}
|
||||
|
||||
terrno = 0;
|
||||
|
@ -271,12 +271,7 @@ static int32_t mndDnodeActionUpdate(SSdb *pSdb, SDnodeObj *pOld, SDnodeObj *pNew
|
|||
mTrace("dnode:%d, perform update action, old row:%p new row:%p", pOld->id, pOld, pNew);
|
||||
pOld->updateTime = pNew->updateTime;
|
||||
#ifdef TD_ENTERPRISE
|
||||
if (strncmp(pOld->active, pNew->active, TSDB_ACTIVE_KEY_LEN) != 0) {
|
||||
strncpy(pOld->active, pNew->active, TSDB_ACTIVE_KEY_LEN);
|
||||
}
|
||||
if (strncmp(pOld->connActive, pNew->connActive, TSDB_CONN_ACTIVE_KEY_LEN) != 0) {
|
||||
strncpy(pOld->connActive, pNew->connActive, TSDB_CONN_ACTIVE_KEY_LEN);
|
||||
}
|
||||
tstrncpy(pOld->machineId, pNew->machineId, TSDB_MACHINE_ID_LEN + 1);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@ -716,6 +711,35 @@ _OVER:
|
|||
*/
|
||||
}
|
||||
|
||||
static int32_t mndUpdateDnodeObj(SMnode *pMnode, SDnodeObj *pDnode) {
|
||||
int32_t code = 0;
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, NULL, "update-dnode-obj");
|
||||
if (pTrans == NULL) {
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
pDnode->updateTime = taosGetTimestampMs();
|
||||
|
||||
SSdbRaw *pCommitRaw = mndDnodeActionEncode(pDnode);
|
||||
if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) {
|
||||
mError("trans:%d, failed to append commit log since %s", pTrans->id, terrstr());
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) {
|
||||
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
_exit:
|
||||
mndTransDrop(pTrans);
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
SStatusReq statusReq = {0};
|
||||
|
@ -885,8 +909,9 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
pDnode->numOfDiskCfg = statusReq.numOfDiskCfg;
|
||||
pDnode->memAvail = statusReq.memAvail;
|
||||
pDnode->memTotal = statusReq.memTotal;
|
||||
if (pDnode->machineId[0] == 0 && statusReq.machineId[0] != 0) {
|
||||
if (memcmp(pDnode->machineId, statusReq.machineId, TSDB_MACHINE_ID_LEN) != 0) {
|
||||
tstrncpy(pDnode->machineId, statusReq.machineId, TSDB_MACHINE_ID_LEN + 1);
|
||||
mndUpdateDnodeObj(pMnode, pDnode);
|
||||
}
|
||||
|
||||
SStatusRsp statusRsp = {0};
|
||||
|
|
|
@ -1104,14 +1104,16 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
|
|||
} else if (createReq.tagVer > 0 || createReq.colVer > 0) {
|
||||
int32_t tagDelta = createReq.tagVer - pStb->tagVer;
|
||||
int32_t colDelta = createReq.colVer - pStb->colVer;
|
||||
int32_t verDelta = tagDelta + colDelta;
|
||||
mInfo("stb:%s, already exist while create, input tagVer:%d colVer:%d, exist tagVer:%d colVer:%d",
|
||||
createReq.name, createReq.tagVer, createReq.colVer, pStb->tagVer, pStb->colVer);
|
||||
if (tagDelta <= 0 && colDelta <= 0) {
|
||||
mInfo("stb:%s, schema version is not incremented and nothing needs to be done", createReq.name);
|
||||
code = 0;
|
||||
goto _OVER;
|
||||
} else if ((tagDelta == 1 || colDelta == 1) && (verDelta == 1)) {
|
||||
} else if ((tagDelta == 1 && colDelta == 0) ||
|
||||
(tagDelta == 0 && colDelta == 1) ||
|
||||
(pStb->colVer == 1 && createReq.colVer > 1) ||
|
||||
(pStb->tagVer == 1 && createReq.tagVer > 1)) {
|
||||
isAlter = true;
|
||||
mInfo("stb:%s, schema version is only increased by 1 number, do alter operation", createReq.name);
|
||||
} else {
|
||||
|
|
|
@ -434,7 +434,9 @@ int32_t mndPersistTaskDeployReq(STrans *pTrans, SStreamTask *pTask) {
|
|||
SEncoder encoder;
|
||||
tEncoderInit(&encoder, NULL, 0);
|
||||
|
||||
if (pTask->ver < SSTREAM_TASK_SUBTABLE_CHANGED_VER){
|
||||
pTask->ver = SSTREAM_TASK_VER;
|
||||
}
|
||||
tEncodeStreamTask(&encoder, pTask);
|
||||
|
||||
int32_t size = encoder.pos;
|
||||
|
|
|
@ -79,6 +79,7 @@ int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData) {
|
|||
int32_t nKey = 0;
|
||||
int32_t nData = 0;
|
||||
STbDbKey key;
|
||||
SMetaInfo info;
|
||||
|
||||
*ppData = NULL;
|
||||
for (;;) {
|
||||
|
@ -91,7 +92,8 @@ int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData) {
|
|||
goto _exit;
|
||||
}
|
||||
|
||||
if (key.version < pReader->sver) {
|
||||
if (key.version < pReader->sver //
|
||||
|| metaGetInfo(pReader->pMeta, key.uid, &info, NULL) == TSDB_CODE_NOT_FOUND) {
|
||||
tdbTbcMoveToNext(pReader->pTbc);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -71,8 +71,8 @@ int32_t tqBuildDeleteReq(STQ* pTq, const char* stbFullName, const SSDataBlock* p
|
|||
if (varTbName != NULL && varTbName != (void*)-1) {
|
||||
name = taosMemoryCalloc(1, TSDB_TABLE_NAME_LEN);
|
||||
memcpy(name, varDataVal(varTbName), varDataLen(varTbName));
|
||||
if (newSubTableRule && !isAutoTableName(name) && !alreadyAddGroupId(name) && groupId != 0) {
|
||||
buildCtbNameAddGroupId(name, groupId);
|
||||
if (newSubTableRule && !isAutoTableName(name) && !alreadyAddGroupId(name) && groupId != 0 && stbFullName) {
|
||||
buildCtbNameAddGroupId(stbFullName, name, groupId);
|
||||
}
|
||||
} else if (stbFullName) {
|
||||
name = buildCtbNameByGroupId(stbFullName, groupId);
|
||||
|
@ -182,10 +182,10 @@ void setCreateTableMsgTableName(SVCreateTbReq* pCreateTableReq, SSDataBlock* pDa
|
|||
int64_t gid, bool newSubTableRule) {
|
||||
if (pDataBlock->info.parTbName[0]) {
|
||||
if (newSubTableRule && !isAutoTableName(pDataBlock->info.parTbName) &&
|
||||
!alreadyAddGroupId(pDataBlock->info.parTbName) && gid != 0) {
|
||||
!alreadyAddGroupId(pDataBlock->info.parTbName) && gid != 0 && stbFullName) {
|
||||
pCreateTableReq->name = taosMemoryCalloc(1, TSDB_TABLE_NAME_LEN);
|
||||
strcpy(pCreateTableReq->name, pDataBlock->info.parTbName);
|
||||
buildCtbNameAddGroupId(pCreateTableReq->name, gid);
|
||||
buildCtbNameAddGroupId(stbFullName, pCreateTableReq->name, gid);
|
||||
// tqDebug("gen name from:%s", pDataBlock->info.parTbName);
|
||||
} else {
|
||||
pCreateTableReq->name = taosStrdup(pDataBlock->info.parTbName);
|
||||
|
@ -671,10 +671,14 @@ int32_t setDstTableDataUid(SVnode* pVnode, SStreamTask* pTask, SSDataBlock* pDat
|
|||
memset(dstTableName, 0, TSDB_TABLE_NAME_LEN);
|
||||
buildCtbNameByGroupIdImpl(stbFullName, groupId, dstTableName);
|
||||
} else {
|
||||
if (pTask->ver >= SSTREAM_TASK_SUBTABLE_CHANGED_VER && pTask->subtableWithoutMd5 != 1 &&
|
||||
!isAutoTableName(dstTableName) && !alreadyAddGroupId(dstTableName) && groupId != 0) {
|
||||
if (pTask->subtableWithoutMd5 != 1 && !isAutoTableName(dstTableName) &&
|
||||
!alreadyAddGroupId(dstTableName) && groupId != 0) {
|
||||
tqDebug("s-task:%s append groupId:%" PRId64 " for generated dstTable:%s", id, groupId, dstTableName);
|
||||
buildCtbNameAddGroupId(dstTableName, groupId);
|
||||
if(pTask->ver == SSTREAM_TASK_SUBTABLE_CHANGED_VER){
|
||||
buildCtbNameAddGroupId(NULL, dstTableName, groupId);
|
||||
}else if(pTask->ver > SSTREAM_TASK_SUBTABLE_CHANGED_VER && stbFullName) {
|
||||
buildCtbNameAddGroupId(stbFullName, dstTableName, groupId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -642,8 +642,8 @@ SColVal *tsdbRowIterNext(STSDBRowIter *pIter) {
|
|||
return &pIter->cv;
|
||||
}
|
||||
|
||||
if (pIter->iColData < pIter->pRow->pBlockData->nColData) {
|
||||
tColDataGetValue(&pIter->pRow->pBlockData->aColData[pIter->iColData], pIter->pRow->iRow, &pIter->cv);
|
||||
if (pIter->iColData <= pIter->pRow->pBlockData->nColData) {
|
||||
tColDataGetValue(&pIter->pRow->pBlockData->aColData[pIter->iColData - 1], pIter->pRow->iRow, &pIter->cv);
|
||||
++pIter->iColData;
|
||||
return &pIter->cv;
|
||||
} else {
|
||||
|
|
|
@ -879,7 +879,7 @@ static int32_t sysTableGetGeomText(char* iGeom, int32_t nGeom, char** output, in
|
|||
char* outputWKT = NULL;
|
||||
|
||||
if (nGeom == 0) {
|
||||
if (!(*output = strdup(""))) code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (!(*output = taosStrdup(""))) code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
*nOutput = 0;
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -747,16 +747,52 @@ insert_query(A) ::= INSERT INTO full_table_name(C) query_or_subquery(B).
|
|||
|
||||
/************************************************ tags_literal *************************************************************/
|
||||
tags_literal(A) ::= NK_INTEGER(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B, NULL); }
|
||||
tags_literal(A) ::= NK_INTEGER(B) NK_PLUS duration_literal(C). {
|
||||
SToken l = B;
|
||||
SToken r = getTokenFromRawExprNode(pCxt, C);
|
||||
l.n = (r.z + r.n) - l.z;
|
||||
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
|
||||
}
|
||||
tags_literal(A) ::= NK_INTEGER(B) NK_MINUS duration_literal(C). {
|
||||
SToken l = B;
|
||||
SToken r = getTokenFromRawExprNode(pCxt, C);
|
||||
l.n = (r.z + r.n) - l.z;
|
||||
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
|
||||
}
|
||||
tags_literal(A) ::= NK_PLUS(B) NK_INTEGER(C). {
|
||||
SToken t = B;
|
||||
t.n = (C.z + C.n) - B.z;
|
||||
A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL);
|
||||
}
|
||||
tags_literal(A) ::= NK_PLUS(B) NK_INTEGER NK_PLUS duration_literal(C). {
|
||||
SToken l = B;
|
||||
SToken r = getTokenFromRawExprNode(pCxt, C);
|
||||
l.n = (r.z + r.n) - l.z;
|
||||
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
|
||||
}
|
||||
tags_literal(A) ::= NK_PLUS(B) NK_INTEGER NK_MINUS duration_literal(C). {
|
||||
SToken l = B;
|
||||
SToken r = getTokenFromRawExprNode(pCxt, C);
|
||||
l.n = (r.z + r.n) - l.z;
|
||||
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
|
||||
}
|
||||
tags_literal(A) ::= NK_MINUS(B) NK_INTEGER(C). {
|
||||
SToken t = B;
|
||||
t.n = (C.z + C.n) - B.z;
|
||||
A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL);
|
||||
}
|
||||
tags_literal(A) ::= NK_MINUS(B) NK_INTEGER NK_PLUS duration_literal(C). {
|
||||
SToken l = B;
|
||||
SToken r = getTokenFromRawExprNode(pCxt, C);
|
||||
l.n = (r.z + r.n) - l.z;
|
||||
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
|
||||
}
|
||||
tags_literal(A) ::= NK_MINUS(B) NK_INTEGER NK_MINUS duration_literal(C). {
|
||||
SToken l = B;
|
||||
SToken r = getTokenFromRawExprNode(pCxt, C);
|
||||
l.n = (r.z + r.n) - l.z;
|
||||
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
|
||||
}
|
||||
tags_literal(A) ::= NK_FLOAT(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &B, NULL); }
|
||||
tags_literal(A) ::= NK_PLUS(B) NK_FLOAT(C). {
|
||||
SToken t = B;
|
||||
|
@ -770,29 +806,113 @@ tags_literal(A) ::= NK_MINUS(B) NK_FLOAT(C).
|
|||
}
|
||||
|
||||
tags_literal(A) ::= NK_BIN(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B, NULL); }
|
||||
tags_literal(A) ::= NK_BIN(B) NK_PLUS duration_literal(C). {
|
||||
SToken l = B;
|
||||
SToken r = getTokenFromRawExprNode(pCxt, C);
|
||||
l.n = (r.z + r.n) - l.z;
|
||||
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
|
||||
}
|
||||
tags_literal(A) ::= NK_BIN(B) NK_MINUS duration_literal(C). {
|
||||
SToken l = B;
|
||||
SToken r = getTokenFromRawExprNode(pCxt, C);
|
||||
l.n = (r.z + r.n) - l.z;
|
||||
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
|
||||
}
|
||||
tags_literal(A) ::= NK_PLUS(B) NK_BIN(C). {
|
||||
SToken t = B;
|
||||
t.n = (C.z + C.n) - B.z;
|
||||
A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL);
|
||||
}
|
||||
tags_literal(A) ::= NK_PLUS(B) NK_BIN NK_PLUS duration_literal(C). {
|
||||
SToken l = B;
|
||||
SToken r = getTokenFromRawExprNode(pCxt, C);
|
||||
l.n = (r.z + r.n) - l.z;
|
||||
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
|
||||
}
|
||||
tags_literal(A) ::= NK_PLUS(B) NK_BIN NK_MINUS duration_literal(C). {
|
||||
SToken l = B;
|
||||
SToken r = getTokenFromRawExprNode(pCxt, C);
|
||||
l.n = (r.z + r.n) - l.z;
|
||||
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
|
||||
}
|
||||
tags_literal(A) ::= NK_MINUS(B) NK_BIN(C). {
|
||||
SToken t = B;
|
||||
t.n = (C.z + C.n) - B.z;
|
||||
A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL);
|
||||
}
|
||||
tags_literal(A) ::= NK_MINUS(B) NK_BIN NK_PLUS duration_literal(C). {
|
||||
SToken l = B;
|
||||
SToken r = getTokenFromRawExprNode(pCxt, C);
|
||||
l.n = (r.z + r.n) - l.z;
|
||||
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
|
||||
}
|
||||
tags_literal(A) ::= NK_MINUS(B) NK_BIN NK_MINUS duration_literal(C). {
|
||||
SToken l = B;
|
||||
SToken r = getTokenFromRawExprNode(pCxt, C);
|
||||
l.n = (r.z + r.n) - l.z;
|
||||
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
|
||||
}
|
||||
tags_literal(A) ::= NK_HEX(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B, NULL); }
|
||||
tags_literal(A) ::= NK_HEX(B) NK_PLUS duration_literal(C). {
|
||||
SToken l = B;
|
||||
SToken r = getTokenFromRawExprNode(pCxt, C);
|
||||
l.n = (r.z + r.n) - l.z;
|
||||
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
|
||||
}
|
||||
tags_literal(A) ::= NK_HEX(B) NK_MINUS duration_literal(C). {
|
||||
SToken l = B;
|
||||
SToken r = getTokenFromRawExprNode(pCxt, C);
|
||||
l.n = (r.z + r.n) - l.z;
|
||||
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
|
||||
}
|
||||
tags_literal(A) ::= NK_PLUS(B) NK_HEX(C). {
|
||||
SToken t = B;
|
||||
t.n = (C.z + C.n) - B.z;
|
||||
A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL);
|
||||
}
|
||||
tags_literal(A) ::= NK_PLUS(B) NK_HEX NK_PLUS duration_literal(C). {
|
||||
SToken l = B;
|
||||
SToken r = getTokenFromRawExprNode(pCxt, C);
|
||||
l.n = (r.z + r.n) - l.z;
|
||||
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
|
||||
}
|
||||
tags_literal(A) ::= NK_PLUS(B) NK_HEX NK_MINUS duration_literal(C). {
|
||||
SToken l = B;
|
||||
SToken r = getTokenFromRawExprNode(pCxt, C);
|
||||
l.n = (r.z + r.n) - l.z;
|
||||
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
|
||||
}
|
||||
tags_literal(A) ::= NK_MINUS(B) NK_HEX(C). {
|
||||
SToken t = B;
|
||||
t.n = (C.z + C.n) - B.z;
|
||||
A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL);
|
||||
}
|
||||
tags_literal(A) ::= NK_MINUS(B) NK_HEX NK_PLUS duration_literal(C). {
|
||||
SToken l = B;
|
||||
SToken r = getTokenFromRawExprNode(pCxt, C);
|
||||
l.n = (r.z + r.n) - l.z;
|
||||
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
|
||||
}
|
||||
tags_literal(A) ::= NK_MINUS(B) NK_HEX NK_MINUS duration_literal(C). {
|
||||
SToken l = B;
|
||||
SToken r = getTokenFromRawExprNode(pCxt, C);
|
||||
l.n = (r.z + r.n) - l.z;
|
||||
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
|
||||
}
|
||||
|
||||
tags_literal(A) ::= NK_STRING(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B, NULL); }
|
||||
tags_literal(A) ::= NK_STRING(B) NK_PLUS duration_literal(C). {
|
||||
SToken l = B;
|
||||
SToken r = getTokenFromRawExprNode(pCxt, C);
|
||||
l.n = (r.z + r.n) - l.z;
|
||||
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
|
||||
}
|
||||
tags_literal(A) ::= NK_STRING(B) NK_MINUS duration_literal(C). {
|
||||
SToken l = B;
|
||||
SToken r = getTokenFromRawExprNode(pCxt, C);
|
||||
l.n = (r.z + r.n) - l.z;
|
||||
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
|
||||
}
|
||||
tags_literal(A) ::= NK_BOOL(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &B, NULL); }
|
||||
tags_literal(A) ::= NULL(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_NULL, &B, NULL); }
|
||||
|
||||
|
|
|
@ -1299,7 +1299,7 @@ SNode* createAlterDatabaseOptions(SAstCreateContext* pCxt) {
|
|||
pOptions->sstTrigger = -1;
|
||||
pOptions->tablePrefix = -1;
|
||||
pOptions->tableSuffix = -1;
|
||||
pOptions->withArbitrator = TSDB_DEFAULT_DB_WITH_ARBITRATOR;
|
||||
pOptions->withArbitrator = -1;
|
||||
return (SNode*)pOptions;
|
||||
}
|
||||
|
||||
|
|
|
@ -969,7 +969,7 @@ static int32_t parseTagsClauseImpl(SInsertParseContext* pCxt, SVnodeModifyOpStmt
|
|||
}
|
||||
|
||||
_exit:
|
||||
for (int32_t i = 0; i < TARRAY_SIZE(pTagVals); ++i) {
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pTagVals); ++i) {
|
||||
STagVal* p = (STagVal*)TARRAY_GET_ELEM(pTagVals, i);
|
||||
if (IS_VAR_DATA_TYPE(p->type)) {
|
||||
taosMemoryFreeClear(p->pData);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -580,12 +580,15 @@ int32_t streamSearchAndAddBlock(SStreamTask* pTask, SStreamDispatchReq* pReqs, S
|
|||
} else {
|
||||
char ctbName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
if (pDataBlock->info.parTbName[0]) {
|
||||
if(pTask->ver >= SSTREAM_TASK_SUBTABLE_CHANGED_VER &&
|
||||
pTask->subtableWithoutMd5 != 1 &&
|
||||
if(pTask->subtableWithoutMd5 != 1 &&
|
||||
!isAutoTableName(pDataBlock->info.parTbName) &&
|
||||
!alreadyAddGroupId(pDataBlock->info.parTbName) &&
|
||||
groupId != 0){
|
||||
buildCtbNameAddGroupId(pDataBlock->info.parTbName, groupId);
|
||||
if(pTask->ver == SSTREAM_TASK_SUBTABLE_CHANGED_VER){
|
||||
buildCtbNameAddGroupId(NULL, pDataBlock->info.parTbName, groupId);
|
||||
}else if(pTask->ver > SSTREAM_TASK_SUBTABLE_CHANGED_VER) {
|
||||
buildCtbNameAddGroupId(pTask->outputInfo.shuffleDispatcher.stbFullName, pDataBlock->info.parTbName, groupId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
buildCtbNameByGroupIdImpl(pTask->outputInfo.shuffleDispatcher.stbFullName, groupId, pDataBlock->info.parTbName);
|
||||
|
|
|
@ -542,7 +542,6 @@ int32_t streamMetaSaveTask(SStreamMeta* pMeta, SStreamTask* pTask) {
|
|||
void* buf = NULL;
|
||||
int32_t len;
|
||||
int32_t code;
|
||||
pTask->ver = SSTREAM_TASK_VER;
|
||||
tEncodeSize(tEncodeStreamTask, pTask, len, code);
|
||||
if (code < 0) {
|
||||
return -1;
|
||||
|
@ -552,6 +551,9 @@ int32_t streamMetaSaveTask(SStreamMeta* pMeta, SStreamTask* pTask) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (pTask->ver < SSTREAM_TASK_SUBTABLE_CHANGED_VER){
|
||||
pTask->ver = SSTREAM_TASK_VER;
|
||||
}
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, buf, len);
|
||||
tEncodeStreamTask(&encoder, pTask);
|
||||
|
|
|
@ -216,7 +216,7 @@ int32_t tDecodeStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
|
|||
|
||||
if (tStartDecode(pDecoder) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &pTask->ver) < 0) return -1;
|
||||
if (pTask->ver <= SSTREAM_TASK_INCOMPATIBLE_VER) return -1;
|
||||
if (pTask->ver <= SSTREAM_TASK_INCOMPATIBLE_VER || pTask->ver > SSTREAM_TASK_VER) return -1;
|
||||
|
||||
if (tDecodeI64(pDecoder, &pTask->id.streamId) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pTask->id.taskId) < 0) return -1;
|
||||
|
@ -287,7 +287,9 @@ int32_t tDecodeStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
|
|||
if (tDecodeCStrTo(pDecoder, pTask->outputInfo.shuffleDispatcher.stbFullName) < 0) return -1;
|
||||
}
|
||||
if (tDecodeI64(pDecoder, &pTask->info.triggerParam) < 0) return -1;
|
||||
if (pTask->ver >= SSTREAM_TASK_SUBTABLE_CHANGED_VER){
|
||||
if (tDecodeI8(pDecoder, &pTask->subtableWithoutMd5) < 0) return -1;
|
||||
}
|
||||
if (tDecodeCStrTo(pDecoder, pTask->reserve) < 0) return -1;
|
||||
|
||||
tEndDecode(pDecoder);
|
||||
|
|
|
@ -91,6 +91,7 @@ int32_t syncNodeOnAppendEntriesReply(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
|
|||
|
||||
taosThreadMutexLock(&ths->arbTokenMutex);
|
||||
syncUtilGenerateArbToken(ths->myNodeInfo.nodeId, ths->vgId, ths->arbToken);
|
||||
sInfo("vgId:%d, assigned leader to leader, arbToken:%s", ths->vgId, ths->arbToken);
|
||||
taosThreadMutexUnlock(&ths->arbTokenMutex);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -302,8 +302,16 @@ int32_t syncBecomeAssignedLeader(SSyncNode* ths, SRpcMsg* pRpcMsg) {
|
|||
goto _OVER;
|
||||
}
|
||||
syncNodeBecomeAssignedLeader(ths);
|
||||
|
||||
if (syncNodeAppendNoop(ths) < 0) {
|
||||
sError("vgId:%d, assigned leader failed to append noop entry since %s", ths->vgId, terrstr());
|
||||
}
|
||||
}
|
||||
errcode = TSDB_CODE_SUCCESS;
|
||||
} else {
|
||||
sInfo("vgId:%d, skip to set assigned leader, token mismatch, local:%s, msg:%s", ths->vgId, ths->arbToken,
|
||||
req.memberToken);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
SVArbSetAssignedLeaderRsp rsp = {0};
|
||||
|
@ -1056,6 +1064,7 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo, int32_t vnodeVersion) {
|
|||
pSyncNode->arbTerm = -1;
|
||||
taosThreadMutexInit(&pSyncNode->arbTokenMutex, NULL);
|
||||
syncUtilGenerateArbToken(pSyncNode->myNodeInfo.nodeId, pSyncInfo->vgId, pSyncNode->arbToken);
|
||||
sInfo("vgId:%d, arb token:%s", pSyncNode->vgId, pSyncNode->arbToken);
|
||||
|
||||
// init peersNum, peers, peersId
|
||||
pSyncNode->peersNum = pSyncNode->raftCfg.cfg.totalReplicaNum - 1;
|
||||
|
|
|
@ -866,9 +866,14 @@ int32_t syncLogReplRecover(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEn
|
|||
SyncTerm term = -1;
|
||||
SyncIndex firstVer = pNode->pLogStore->syncLogBeginIndex(pNode->pLogStore);
|
||||
SyncIndex index = TMIN(pMsg->matchIndex, pNode->pLogBuf->matchIndex);
|
||||
errno = 0;
|
||||
|
||||
if (pMsg->matchIndex < pNode->pLogBuf->matchIndex) {
|
||||
term = syncLogReplGetPrevLogTerm(pMgr, pNode, index + 1);
|
||||
if (term < 0 && (errno == ENFILE || errno == EMFILE)) {
|
||||
sError("vgId:%d, failed to get prev log term since %s. index:%" PRId64, pNode->vgId, terrstr(), index + 1);
|
||||
return -1;
|
||||
}
|
||||
if ((index + 1 < firstVer) || (term < 0) ||
|
||||
(term != pMsg->lastMatchTerm && (index + 1 == firstVer || index == firstVer))) {
|
||||
ASSERT(term >= 0 || terrno == TSDB_CODE_WAL_LOG_NOT_EXIST);
|
||||
|
|
|
@ -585,11 +585,12 @@ void* destroyConnPool(SCliThrd* pThrd) {
|
|||
static SCliConn* getConnFromPool(SCliThrd* pThrd, char* key, bool* exceed) {
|
||||
void* pool = pThrd->pool;
|
||||
STrans* pTranInst = pThrd->pTransInst;
|
||||
SConnList* plist = taosHashGet((SHashObj*)pool, key, strlen(key) + 1);
|
||||
size_t klen = strlen(key);
|
||||
SConnList* plist = taosHashGet((SHashObj*)pool, key, klen);
|
||||
if (plist == NULL) {
|
||||
SConnList list = {0};
|
||||
taosHashPut((SHashObj*)pool, key, strlen(key) + 1, (void*)&list, sizeof(list));
|
||||
plist = taosHashGet(pool, key, strlen(key) + 1);
|
||||
taosHashPut((SHashObj*)pool, key, klen, (void*)&list, sizeof(list));
|
||||
plist = taosHashGet(pool, key, klen);
|
||||
|
||||
SMsgList* nList = taosMemoryCalloc(1, sizeof(SMsgList));
|
||||
QUEUE_INIT(&nList->msgQ);
|
||||
|
@ -624,11 +625,12 @@ static SCliConn* getConnFromPool(SCliThrd* pThrd, char* key, bool* exceed) {
|
|||
static SCliConn* getConnFromPool2(SCliThrd* pThrd, char* key, SCliMsg** pMsg) {
|
||||
void* pool = pThrd->pool;
|
||||
STrans* pTransInst = pThrd->pTransInst;
|
||||
SConnList* plist = taosHashGet((SHashObj*)pool, key, strlen(key) + 1);
|
||||
size_t klen = strlen(key);
|
||||
SConnList* plist = taosHashGet((SHashObj*)pool, key, klen);
|
||||
if (plist == NULL) {
|
||||
SConnList list = {0};
|
||||
taosHashPut((SHashObj*)pool, key, strlen(key) + 1, (void*)&list, sizeof(list));
|
||||
plist = taosHashGet(pool, key, strlen(key) + 1);
|
||||
taosHashPut((SHashObj*)pool, key, klen, (void*)&list, sizeof(list));
|
||||
plist = taosHashGet(pool, key, klen);
|
||||
|
||||
SMsgList* nList = taosMemoryCalloc(1, sizeof(SMsgList));
|
||||
QUEUE_INIT(&nList->msgQ);
|
||||
|
@ -714,7 +716,7 @@ static void addConnToPool(void* pool, SCliConn* conn) {
|
|||
cliDestroyConnMsgs(conn, false);
|
||||
|
||||
if (conn->list == NULL) {
|
||||
conn->list = taosHashGet((SHashObj*)pool, conn->dstAddr, strlen(conn->dstAddr) + 1);
|
||||
conn->list = taosHashGet((SHashObj*)pool, conn->dstAddr, strlen(conn->dstAddr));
|
||||
}
|
||||
|
||||
SConnList* pList = conn->list;
|
||||
|
@ -1279,7 +1281,7 @@ static void cliHandleFastFail(SCliConn* pConn, int status) {
|
|||
|
||||
if (pMsg != NULL && REQUEST_NO_RESP(&pMsg->msg) &&
|
||||
(pTransInst->failFastFp != NULL && pTransInst->failFastFp(pMsg->msg.msgType))) {
|
||||
SFailFastItem* item = taosHashGet(pThrd->failFastCache, pConn->dstAddr, strlen(pConn->dstAddr) + 1);
|
||||
SFailFastItem* item = taosHashGet(pThrd->failFastCache, pConn->dstAddr, strlen(pConn->dstAddr));
|
||||
int64_t cTimestamp = taosGetTimestampMs();
|
||||
if (item != NULL) {
|
||||
int32_t elapse = cTimestamp - item->timestamp;
|
||||
|
@ -1291,7 +1293,7 @@ static void cliHandleFastFail(SCliConn* pConn, int status) {
|
|||
}
|
||||
} else {
|
||||
SFailFastItem item = {.count = 1, .timestamp = cTimestamp};
|
||||
taosHashPut(pThrd->failFastCache, pConn->dstAddr, strlen(pConn->dstAddr) + 1, &item, sizeof(SFailFastItem));
|
||||
taosHashPut(pThrd->failFastCache, pConn->dstAddr, strlen(pConn->dstAddr), &item, sizeof(SFailFastItem));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -1471,7 +1473,8 @@ FORCE_INLINE int32_t cliBuildExceptResp(SCliMsg* pMsg, STransMsg* pResp) {
|
|||
}
|
||||
static FORCE_INLINE uint32_t cliGetIpFromFqdnCache(SHashObj* cache, char* fqdn) {
|
||||
uint32_t addr = 0;
|
||||
uint32_t* v = taosHashGet(cache, fqdn, strlen(fqdn) + 1);
|
||||
size_t len = strlen(fqdn);
|
||||
uint32_t* v = taosHashGet(cache, fqdn, len);
|
||||
if (v == NULL) {
|
||||
addr = taosGetIpv4FromFqdn(fqdn);
|
||||
if (addr == 0xffffffff) {
|
||||
|
@ -1480,7 +1483,7 @@ static FORCE_INLINE uint32_t cliGetIpFromFqdnCache(SHashObj* cache, char* fqdn)
|
|||
return addr;
|
||||
}
|
||||
|
||||
taosHashPut(cache, fqdn, strlen(fqdn) + 1, &addr, sizeof(addr));
|
||||
taosHashPut(cache, fqdn, len, &addr, sizeof(addr));
|
||||
} else {
|
||||
addr = *v;
|
||||
}
|
||||
|
@ -1490,13 +1493,14 @@ static FORCE_INLINE void cliUpdateFqdnCache(SHashObj* cache, char* fqdn) {
|
|||
// impl later
|
||||
uint32_t addr = taosGetIpv4FromFqdn(fqdn);
|
||||
if (addr != 0xffffffff) {
|
||||
uint32_t* v = taosHashGet(cache, fqdn, strlen(fqdn) + 1);
|
||||
size_t len = strlen(fqdn);
|
||||
uint32_t* v = taosHashGet(cache, fqdn, len);
|
||||
if (addr != *v) {
|
||||
char old[64] = {0}, new[64] = {0};
|
||||
tinet_ntoa(old, *v);
|
||||
tinet_ntoa(new, addr);
|
||||
tWarn("update ip of fqdn:%s, old: %s, new: %s", fqdn, old, new);
|
||||
taosHashPut(cache, fqdn, strlen(fqdn) + 1, &addr, sizeof(addr));
|
||||
taosHashPut(cache, fqdn, len, &addr, sizeof(addr));
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
@ -1537,21 +1541,6 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (rpcDebugFlag & DEBUG_TRACE) {
|
||||
if (tmsgIsValid(pMsg->msg.msgType)) {
|
||||
char buf[128] = {0};
|
||||
sprintf(buf, "%s", TMSG_INFO(pMsg->msg.msgType));
|
||||
int* count = taosHashGet(pThrd->msgCount, buf, sizeof(buf));
|
||||
if (NULL == 0) {
|
||||
int localCount = 1;
|
||||
taosHashPut(pThrd->msgCount, buf, sizeof(buf), &localCount, sizeof(localCount));
|
||||
} else {
|
||||
int localCount = *count + 1;
|
||||
taosHashPut(pThrd->msgCount, buf, sizeof(buf), &localCount, sizeof(localCount));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char* fqdn = EPSET_GET_INUSE_IP(&pMsg->ctx->epSet);
|
||||
uint16_t port = EPSET_GET_INUSE_PORT(&pMsg->ctx->epSet);
|
||||
char addr[TSDB_FQDN_LEN + 64] = {0};
|
||||
|
@ -1704,9 +1693,8 @@ static void cliBatchDealReq(queue* wq, SCliThrd* pThrd) {
|
|||
uint32_t port = EPSET_GET_INUSE_PORT(&pCtx->epSet);
|
||||
char key[TSDB_FQDN_LEN + 64] = {0};
|
||||
CONN_CONSTRUCT_HASH_KEY(key, ip, port);
|
||||
|
||||
// SCliBatch** ppBatch = taosHashGet(pThrd->batchCache, key, sizeof(key));
|
||||
SCliBatchList** ppBatchList = taosHashGet(pThrd->batchCache, key, sizeof(key));
|
||||
size_t klen = strlen(key);
|
||||
SCliBatchList** ppBatchList = taosHashGet(pThrd->batchCache, key, klen);
|
||||
if (ppBatchList == NULL || *ppBatchList == NULL) {
|
||||
SCliBatchList* pBatchList = taosMemoryCalloc(1, sizeof(SCliBatchList));
|
||||
QUEUE_INIT(&pBatchList->wq);
|
||||
|
@ -1730,7 +1718,7 @@ static void cliBatchDealReq(queue* wq, SCliThrd* pThrd) {
|
|||
|
||||
QUEUE_PUSH(&pBatchList->wq, &pBatch->listq);
|
||||
|
||||
taosHashPut(pThrd->batchCache, key, sizeof(key), &pBatchList, sizeof(void*));
|
||||
taosHashPut(pThrd->batchCache, key, klen, &pBatchList, sizeof(void*));
|
||||
} else {
|
||||
if (QUEUE_IS_EMPTY(&(*ppBatchList)->wq)) {
|
||||
SCliBatch* pBatch = taosMemoryCalloc(1, sizeof(SCliBatch));
|
||||
|
@ -1800,21 +1788,6 @@ static void cliAsyncCb(uv_async_t* handle) {
|
|||
QUEUE_MOVE(&item->qmsg, &wq);
|
||||
taosThreadMutexUnlock(&item->mtx);
|
||||
|
||||
if (rpcDebugFlag & DEBUG_TRACE) {
|
||||
void* pIter = taosHashIterate(pThrd->msgCount, NULL);
|
||||
while (pIter != NULL) {
|
||||
int* count = pIter;
|
||||
size_t len = 0;
|
||||
char* key = taosHashGetKey(pIter, &len);
|
||||
if (*count != 0) {
|
||||
tDebug("key: %s count: %d", key, *count);
|
||||
}
|
||||
|
||||
pIter = taosHashIterate(pThrd->msgCount, pIter);
|
||||
}
|
||||
tDebug("all conn count: %d", pThrd->newConnCount);
|
||||
}
|
||||
|
||||
int8_t supportBatch = pTransInst->supportBatch;
|
||||
if (supportBatch == 0) {
|
||||
cliNoBatchDealReq(&wq, pThrd);
|
||||
|
@ -1971,8 +1944,9 @@ static FORCE_INLINE void destroyCmsgWrapper(void* arg, void* param) {
|
|||
if (pMsg == NULL) {
|
||||
return;
|
||||
}
|
||||
if (param != NULL) {
|
||||
|
||||
SCliThrd* pThrd = param;
|
||||
if (pMsg->msg.info.notFreeAhandle == 0 && pThrd != NULL) {
|
||||
if (pThrd->destroyAhandleFp) (*pThrd->destroyAhandleFp)(pMsg->msg.info.ahandle);
|
||||
}
|
||||
destroyCmsg(pMsg);
|
||||
|
@ -1984,12 +1958,9 @@ static FORCE_INLINE void destroyCmsgAndAhandle(void* param) {
|
|||
SCliMsg* pMsg = arg->param1;
|
||||
SCliThrd* pThrd = arg->param2;
|
||||
|
||||
tDebug("destroy Ahandle A");
|
||||
if (pThrd != NULL && pThrd->destroyAhandleFp != NULL) {
|
||||
tDebug("destroy Ahandle B");
|
||||
if (pMsg->msg.info.notFreeAhandle == 0 && pThrd != NULL && pThrd->destroyAhandleFp != NULL) {
|
||||
pThrd->destroyAhandleFp(pMsg->ctx->ahandle);
|
||||
}
|
||||
tDebug("destroy Ahandle C");
|
||||
|
||||
transDestroyConnCtx(pMsg->ctx);
|
||||
transFreeMsg(pMsg->msg.pCont);
|
||||
|
@ -2411,20 +2382,6 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
|
|||
tGTrace("%s conn %p extract epset from msg", CONN_GET_INST_LABEL(pConn), pConn);
|
||||
}
|
||||
}
|
||||
if (rpcDebugFlag & DEBUG_TRACE) {
|
||||
if (tmsgIsValid(pResp->msgType - 1)) {
|
||||
char buf[128] = {0};
|
||||
sprintf(buf, "%s", TMSG_INFO(pResp->msgType - 1));
|
||||
int* count = taosHashGet(pThrd->msgCount, buf, sizeof(buf));
|
||||
if (NULL == 0) {
|
||||
int localCount = 0;
|
||||
taosHashPut(pThrd->msgCount, buf, sizeof(buf), &localCount, sizeof(localCount));
|
||||
} else {
|
||||
int localCount = *count - 1;
|
||||
taosHashPut(pThrd->msgCount, buf, sizeof(buf), &localCount, sizeof(localCount));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pCtx->pSem || pCtx->syncMsgRef != 0) {
|
||||
tGTrace("%s conn %p(sync) handle resp", CONN_GET_INST_LABEL(pConn), pConn);
|
||||
if (pCtx->pSem) {
|
||||
|
|
|
@ -41,6 +41,12 @@
|
|||
#define LOG_BUF_SIZE(x) ((x)->buffSize)
|
||||
#define LOG_BUF_MUTEX(x) ((x)->buffMutex)
|
||||
|
||||
#ifdef TD_ENTERPRISE
|
||||
#define LOG_EDITION_FLG ("E")
|
||||
#else
|
||||
#define LOG_EDITION_FLG ("C")
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
char *buffer;
|
||||
int32_t buffStart;
|
||||
|
@ -490,8 +496,9 @@ static inline int32_t taosBuildLogHead(char *buffer, const char *flags) {
|
|||
time_t curTime = timeSecs.tv_sec;
|
||||
ptm = taosLocalTime(&curTime, &Tm, NULL);
|
||||
|
||||
return sprintf(buffer, "%02d/%02d %02d:%02d:%02d.%06d %08" PRId64 " %s", ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour,
|
||||
ptm->tm_min, ptm->tm_sec, (int32_t)timeSecs.tv_usec, taosGetSelfPthreadId(), flags);
|
||||
return sprintf(buffer, "%02d/%02d %02d:%02d:%02d.%06d %08" PRId64 " %s %s", ptm->tm_mon + 1, ptm->tm_mday,
|
||||
ptm->tm_hour, ptm->tm_min, ptm->tm_sec, (int32_t)timeSecs.tv_usec, taosGetSelfPthreadId(),
|
||||
LOG_EDITION_FLG, flags);
|
||||
}
|
||||
|
||||
static inline void taosPrintLogImp(ELogLevel level, int32_t dflag, const char *buffer, int32_t len) {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "tgeosctx.h"
|
||||
#include "tlog.h"
|
||||
|
||||
#define QUEUE_THRESHOLD 1000 * 1000
|
||||
#define QUEUE_THRESHOLD (1000 * 1000)
|
||||
|
||||
typedef void *(*ThreadFp)(void *param);
|
||||
|
||||
|
|
|
@ -115,13 +115,17 @@ class TDSql:
|
|||
else:
|
||||
tdLog.info("sql:%s, check passed, no ErrInfo occurred" % (sql))
|
||||
|
||||
def error(self, sql, expectedErrno = None, expectErrInfo = None, fullMatched = True):
|
||||
def error(self, sql, expectedErrno = None, expectErrInfo = None, fullMatched = True, show = False):
|
||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||
expectErrNotOccured = True
|
||||
|
||||
if show:
|
||||
tdLog.info("sql:%s" % (sql))
|
||||
|
||||
try:
|
||||
self.cursor.execute(sql)
|
||||
except BaseException as e:
|
||||
tdLog.info("err:%s" % (e))
|
||||
expectErrNotOccured = False
|
||||
self.errno = e.errno
|
||||
error_info = repr(e)
|
||||
|
@ -161,7 +165,10 @@ class TDSql:
|
|||
|
||||
return self.error_info
|
||||
|
||||
def query(self, sql, row_tag=None, queryTimes=10, count_expected_res=None):
|
||||
def query(self, sql, row_tag=None, queryTimes=10, count_expected_res=None, show = False):
|
||||
if show:
|
||||
tdLog.info("sql:%s" % (sql))
|
||||
|
||||
self.sql = sql
|
||||
i=1
|
||||
while i <= queryTimes:
|
||||
|
|
|
@ -936,6 +936,9 @@ sql_error alter table st_bool_i1 set tag tagname="123abc"
|
|||
sql alter table st_bool_i2 set tag tagname="123"
|
||||
sql_error alter table st_bool_i3 set tag tagname=abc
|
||||
sql_error alter table st_bool_i4 set tag tagname="abc"
|
||||
sql_error alter table st_bool_i4 set tag tagname=now
|
||||
sql_error alter table st_bool_i4 set tag tagname=now()+1d
|
||||
sql_error alter table st_bool_i4 set tag tagname=1+1d
|
||||
sql_error alter table st_bool_i5 set tag tagname=" "
|
||||
sql_error alter table st_bool_i6 set tag tagname=''
|
||||
|
||||
|
|
|
@ -913,6 +913,8 @@ sql_error alter table st_int_e19 set tag tagname=123abc
|
|||
sql_error alter table st_int_e20 set tag tagname="123abc"
|
||||
sql_error alter table st_int_e22 set tag tagname=abc
|
||||
sql_error alter table st_int_e23 set tag tagname="abc"
|
||||
sql_error alter table st_int_e25 set tag tagname=1+1d
|
||||
sql_error alter table st_int_e25 set tag tagname="1"+1d
|
||||
sql_error alter table st_int_e24 set tag tagname=" "
|
||||
sql_error alter table st_int_e25 set tag tagname=''
|
||||
sql alter table st_int_e26_1 set tag tagname='123'
|
||||
|
|
|
@ -132,6 +132,77 @@ sql show tags from st_timestamp_22
|
|||
if $data05 != -1 then
|
||||
return -1
|
||||
endi
|
||||
sql create table st_timestamp_23 using mt_timestamp tags (1+ 1d )
|
||||
sql show tags from st_timestamp_23
|
||||
if $data05 != 86400001 then
|
||||
return -1
|
||||
endi
|
||||
sql create table st_timestamp_24 using mt_timestamp tags (-0 + 1d)
|
||||
sql show tags from st_timestamp_24
|
||||
if $data05 != 86400000 then
|
||||
return -1
|
||||
endi
|
||||
sql create table st_timestamp_25 using mt_timestamp tags ("-0" -1s)
|
||||
sql show tags from st_timestamp_25
|
||||
if $data05 != -1000 then
|
||||
return -1
|
||||
endi
|
||||
sql create table st_timestamp_26 using mt_timestamp tags (0b01 -1a)
|
||||
sql show tags from st_timestamp_26
|
||||
if $data05 != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql create table st_timestamp_27 using mt_timestamp tags (0b01 -1s)
|
||||
sql show tags from st_timestamp_27
|
||||
if $data05 != -999 then
|
||||
return -1
|
||||
endi
|
||||
sql create table st_timestamp_28 using mt_timestamp tags ("0x01" +1u)
|
||||
sql show tags from st_timestamp_28
|
||||
if $data05 != 1 then
|
||||
return -1
|
||||
endi
|
||||
sql create table st_timestamp_29 using mt_timestamp tags (0x01 +1b)
|
||||
sql show tags from st_timestamp_29
|
||||
if $data05 != 1 then
|
||||
return -1
|
||||
endi
|
||||
sql create table st_timestamp_30 using mt_timestamp tags (-0b00 -0a)
|
||||
sql show tags from st_timestamp_30
|
||||
if $data05 != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql create table st_timestamp_31 using mt_timestamp tags ("-0x00" +1u)
|
||||
sql show tags from st_timestamp_31
|
||||
if $data05 != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql create table st_timestamp_32 using mt_timestamp tags (-0x00 +1b)
|
||||
sql show tags from st_timestamp_32
|
||||
if $data05 != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql create table st_timestamp_33 using mt_timestamp tags (now +1b)
|
||||
sql show tags from st_timestamp_33
|
||||
if $data05 < 1711883186000 then
|
||||
return -1
|
||||
endi
|
||||
sql create table st_timestamp_34 using mt_timestamp tags ("now()" +1b)
|
||||
sql show tags from st_timestamp_34
|
||||
if $data05 < 1711883186000 then
|
||||
return -1
|
||||
endi
|
||||
sql create table st_timestamp_35 using mt_timestamp tags (today() +1d)
|
||||
sql show tags from st_timestamp_35
|
||||
if $data05 < 1711883186000 then
|
||||
return -1
|
||||
endi
|
||||
sql create table st_timestamp_36 using mt_timestamp tags ("today()" +1d)
|
||||
sql show tags from st_timestamp_36
|
||||
if $data05 < 1711883186000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
||||
## case 01: insert values for test column values
|
||||
sql insert into st_timestamp_0 values(now,NULL)
|
||||
|
@ -249,6 +320,76 @@ sql select ts, cast(c as bigint) from st_timestamp_22
|
|||
if $data01 != -1 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_23 values(now,1+ 1d )
|
||||
sql select ts, cast(c as bigint) from st_timestamp_23
|
||||
if $data01 != 86400001 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_24 values(now,-0 + 1d)
|
||||
sql select ts, cast(c as bigint) from st_timestamp_24
|
||||
if $data01 != 86400000 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_25 values(now,"-0" -1s)
|
||||
sql select ts, cast(c as bigint) from st_timestamp_25
|
||||
if $data01 != -1000 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_26 values(now,0b01 -1a)
|
||||
sql select ts, cast(c as bigint) from st_timestamp_26
|
||||
if $data01 != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_27 values(now,+0b01 -1s)
|
||||
sql select ts, cast(c as bigint) from st_timestamp_27
|
||||
if $data01 != -999 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_28 values(now,"+0x01" +1u)
|
||||
sql select ts, cast(c as bigint) from st_timestamp_28
|
||||
if $data01 != 1 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_29 values(now,0x01 +1b)
|
||||
sql select ts, cast(c as bigint) from st_timestamp_29
|
||||
if $data01 != 1 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_30 values(now,-0b00 -0a)
|
||||
sql show tags from st_timestamp_30
|
||||
if $data05 != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_31 values(now,"-0x00" +1u)
|
||||
sql show tags from st_timestamp_31
|
||||
if $data05 != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_32 values (now,-0x00 +1b)
|
||||
sql show tags from st_timestamp_32
|
||||
if $data05 != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_33 values(now,now +1b)
|
||||
sql select ts, cast(c as bigint) from st_timestamp_33
|
||||
if $data01 < 1711883186000 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_34 values(now,"now()" +1b)
|
||||
sql select ts, cast(c as bigint) from st_timestamp_34
|
||||
if $data01 < 1711883186000 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_35 values(now,today() +1d)
|
||||
sql select ts, cast(c as bigint) from st_timestamp_35
|
||||
if $data01 < 1711883186000 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_36 values(now,"today()" +1d)
|
||||
sql select ts, cast(c as bigint) from st_timestamp_36
|
||||
if $data01 < 1711883186000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
## case 02: dynamic create table for test tag values
|
||||
sql insert into st_timestamp_100 using mt_timestamp tags(NULL) values(now, NULL)
|
||||
|
@ -450,6 +591,136 @@ sql select ts, cast(c as bigint) from st_timestamp_1022
|
|||
if $data01 != -1 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_1023 using mt_timestamp tags(+1+1d) values(now,+1+ 1d )
|
||||
sql show tags from st_timestamp_1023
|
||||
if $data05 != 86400001 then
|
||||
return -1
|
||||
endi
|
||||
sql select ts, cast(c as bigint) from st_timestamp_1023
|
||||
if $data01 != 86400001 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_1024 using mt_timestamp tags(-0+1d) values(now,-0 + 1d)
|
||||
sql show tags from st_timestamp_1024
|
||||
if $data05 != 86400000 then
|
||||
return -1
|
||||
endi
|
||||
sql select ts, cast(c as bigint) from st_timestamp_1024
|
||||
if $data01 != 86400000 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_1025 using mt_timestamp tags("-0" -1s) values(now,"-0" -1s)
|
||||
sql show tags from st_timestamp_1025
|
||||
if $data05 != -1000 then
|
||||
return -1
|
||||
endi
|
||||
sql select ts, cast(c as bigint) from st_timestamp_1025
|
||||
if $data01 != -1000 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_1026 using mt_timestamp tags(+0b01-1a) values(now,+0b01 -1a)
|
||||
sql show tags from st_timestamp_1026
|
||||
if $data05 != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql select ts, cast(c as bigint) from st_timestamp_1026
|
||||
if $data01 != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_1027 using mt_timestamp tags(0b01-1s) values(now,0b01 -1s)
|
||||
sql show tags from st_timestamp_1027
|
||||
if $data05 != -999 then
|
||||
return -1
|
||||
endi
|
||||
sql select ts, cast(c as bigint) from st_timestamp_1027
|
||||
if $data01 != -999 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_1028 using mt_timestamp tags("0x01" + 1u) values(now,"0x01" +1u)
|
||||
sql show tags from st_timestamp_1028
|
||||
if $data05 != 1 then
|
||||
return -1
|
||||
endi
|
||||
sql select ts, cast(c as bigint) from st_timestamp_1028
|
||||
if $data01 != 1 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_1029 using mt_timestamp tags(+0x01 +1b) values(now,+0x01 +1b)
|
||||
sql show tags from st_timestamp_1029
|
||||
if $data05 != 1 then
|
||||
return -1
|
||||
endi
|
||||
sql select ts, cast(c as bigint) from st_timestamp_1029
|
||||
if $data01 != 1 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_1030 using mt_timestamp tags (-0b00 -0a) values(now,-0b00 -0a)
|
||||
sql show tags from st_timestamp_1030
|
||||
if $data05 != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql select ts, cast(c as bigint) from st_timestamp_1030
|
||||
if $data01 != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_1031 using mt_timestamp tags ("-0x00" +1u) values(now,"-0x00" +1u)
|
||||
sql show tags from st_timestamp_1031
|
||||
if $data05 != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql select ts, cast(c as bigint) from st_timestamp_1031
|
||||
if $data01 != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_1032 using mt_timestamp tags (-0x00 +1b) values(now,-0x00 +1b)
|
||||
sql show tags from st_timestamp_1032
|
||||
if $data05 != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql select ts, cast(c as bigint) from st_timestamp_1032
|
||||
if $data01 != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_1033 using mt_timestamp tags(now+1b) values(now,now +1b)
|
||||
sql show tags from st_timestamp_1033
|
||||
if $data05 < 1711883186000 then
|
||||
return -1
|
||||
endi
|
||||
sql select ts, cast(c as bigint) from st_timestamp_1033
|
||||
if $data01 < 1711883186000 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_1034 using mt_timestamp tags("now" +1b) values(now,"now()" +1b)
|
||||
sql show tags from st_timestamp_1034
|
||||
if $data05 < 1711883186000 then
|
||||
return -1
|
||||
endi
|
||||
sql select ts, cast(c as bigint) from st_timestamp_1034
|
||||
if $data01 < 1711883186000 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_1035 using mt_timestamp tags(today() + 1d) values(now,today() +1d)
|
||||
sql show tags from st_timestamp_1035
|
||||
if $data05 < 1711883186000 then
|
||||
return -1
|
||||
endi
|
||||
sql select ts, cast(c as bigint) from st_timestamp_1035
|
||||
if $data01 < 1711883186000 then
|
||||
return -1
|
||||
endi
|
||||
sql insert into st_timestamp_1036 using mt_timestamp tags("today" +1d) values(now,"today()" +1d)
|
||||
sql show tags from st_timestamp_1036
|
||||
if $data05 < 1711883186000 then
|
||||
return -1
|
||||
endi
|
||||
sql select ts, cast(c as bigint) from st_timestamp_1036
|
||||
if $data01 < 1711883186000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### case 03: alter tag values
|
||||
sql alter table st_timestamp_0 set tag tagname=NULL
|
||||
|
@ -567,12 +838,85 @@ sql show tags from st_timestamp_22
|
|||
if $data05 != -1 then
|
||||
return -1
|
||||
endi
|
||||
sql alter table st_timestamp_23 set tag tagname=1+ 1d
|
||||
sql show tags from st_timestamp_23
|
||||
if $data05 != 86400001 then
|
||||
return -1
|
||||
endi
|
||||
sql alter table st_timestamp_24 set tag tagname=-0 + 1d
|
||||
sql show tags from st_timestamp_24
|
||||
if $data05 != 86400000 then
|
||||
return -1
|
||||
endi
|
||||
sql alter table st_timestamp_25 set tag tagname="-0" -1s
|
||||
sql show tags from st_timestamp_25
|
||||
if $data05 != -1000 then
|
||||
return -1
|
||||
endi
|
||||
sql alter table st_timestamp_26 set tag tagname=+0b01 -1a
|
||||
sql show tags from st_timestamp_26
|
||||
if $data05 != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql alter table st_timestamp_27 set tag tagname=0b01 -1s
|
||||
sql show tags from st_timestamp_27
|
||||
if $data05 != -999 then
|
||||
return -1
|
||||
endi
|
||||
sql alter table st_timestamp_28 set tag tagname="0x01" +1u
|
||||
sql show tags from st_timestamp_28
|
||||
if $data05 != 1 then
|
||||
return -1
|
||||
endi
|
||||
sql alter table st_timestamp_29 set tag tagname=0x01 +1b
|
||||
sql show tags from st_timestamp_29
|
||||
if $data05 != 1 then
|
||||
return -1
|
||||
endi
|
||||
sql alter table st_timestamp_30 set tag tagname==-0b00 -0a
|
||||
sql show tags from st_timestamp_30
|
||||
if $data05 != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql alter table st_timestamp_31 set tag tagname="-0x00" +1u
|
||||
sql show tags from st_timestamp_31
|
||||
if $data05 != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql alter table st_timestamp_32 set tag tagname=-0x00 +1b
|
||||
sql show tags from st_timestamp_32
|
||||
if $data05 != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql alter table st_timestamp_33 set tag tagname=now +1b
|
||||
sql show tags from st_timestamp_33
|
||||
if $data05 < 1711883186000 then
|
||||
return -1
|
||||
endi
|
||||
sql alter table st_timestamp_34 set tag tagname="now()" +1b
|
||||
sql show tags from st_timestamp_34
|
||||
if $data05 < 1711883186000 then
|
||||
return -1
|
||||
endi
|
||||
sql alter table st_timestamp_35 set tag tagname=today( ) +1d
|
||||
sql show tags from st_timestamp_35
|
||||
if $data05 < 1711883186000 then
|
||||
return -1
|
||||
endi
|
||||
sql alter table st_timestamp_36 set tag tagname="today()" +1d
|
||||
sql show tags from st_timestamp_36
|
||||
if $data05 < 1711883186000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
## case 04: illegal input
|
||||
sql_error create table st_timestamp_e0 using mt_timestamp tags (123abc)
|
||||
sql_error create table st_timestamp_e0 using mt_timestamp tags ("123abc")
|
||||
sql_error create table st_timestamp_e0 using mt_timestamp tags (abc)
|
||||
sql_error create table st_timestamp_e0 using mt_timestamp tags ("abc")
|
||||
sql_error create table st_timestamp_e0 using mt_timestamp tags (now()+1d+1s)
|
||||
sql_error create table st_timestamp_e0 using mt_timestamp tags (1+1y)
|
||||
sql_error create table st_timestamp_e0 using mt_timestamp tags (0x01+1b+1a)
|
||||
sql_error create table st_timestamp_e0 using mt_timestamp tags (" ")
|
||||
sql_error create table st_timestamp_e0 using mt_timestamp tags ('')
|
||||
sql_error create table st_timestamp_104 using mt_timestamp tags ("-123.1")
|
||||
|
@ -590,5 +934,7 @@ sql_error create table st_timestamp_115 using mt_timestamp tags (922337203685477
|
|||
sql create table st_timestamp_116 using mt_timestamp tags (-9223372036854775808)
|
||||
sql_error create table st_timestamp_117 using mt_timestamp tags (-9223372036854775809)
|
||||
sql_error insert into st_timestamp_118 using mt_timestamp tags(9223372036854775807) values(9223372036854775807, 9223372036854775807)
|
||||
sql_error insert into st_timestamp_119 using mt_timestamp tags(1+1s-1s) values(now, now)
|
||||
sql_error insert into st_timestamp_120 using mt_timestamp tags(1-1s) values(now, now-1s+1d)
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
|
@ -299,6 +299,8 @@ sql_error create table st_varbinary_1012 using mt_varbinary tags(tRue)
|
|||
sql_error create table st_varbinary_1013 using mt_varbinary tags(FalsE)
|
||||
sql_error create table st_varbinary_1014 using mt_varbinary tags(noW)
|
||||
sql_error create table st_varbinary_1015 using mt_varbinary tags(toDay)
|
||||
sql_error create table st_varbinary_1016 using mt_varbinary tags(now()+1s)
|
||||
sql_error create table st_varbinary_1017 using mt_varbinary tags(1+1s)
|
||||
sql_error insert into st_varbinary_106 using mt_varbinary tags(+0123) values(now, NULL);
|
||||
sql_error insert into st_varbinary_107 using mt_varbinary tags(-01.23) values(now, NULL);
|
||||
sql_error insert into st_varbinary_108 using mt_varbinary tags(+0x01) values(now, NULL);
|
||||
|
@ -309,6 +311,8 @@ sql_error insert into st_varbinary_1012 using mt_varbinary tags(tRue) values(no
|
|||
sql_error insert into st_varbinary_1013 using mt_varbinary tags(FalsE) values(now, NULL);
|
||||
sql_error insert into st_varbinary_1014 using mt_varbinary tags(noW) values(now, NULL);
|
||||
sql_error insert into st_varbinary_1015 using mt_varbinary tags(toDay) values(now, NULL);
|
||||
sql_error insert into st_varbinary_1016 using mt_varbinary tags(now()+1s) values(now, NULL);
|
||||
sql_error insert into st_varbinary_1017 using mt_varbinary tags(1+1s) values(now, NULL);
|
||||
sql_error insert into st_varbinary_106 using mt_varbinary tags(NULL) values(now(), +0123)
|
||||
sql_error insert into st_varbinary_107 using mt_varbinary tags(NULL) values(now(), -01.23)
|
||||
sql_error insert into st_varbinary_108 using mt_varbinary tags(NULL) values(now(), +0x01)
|
||||
|
@ -319,5 +323,7 @@ sql_error insert into st_varbinary_1012 using mt_varbinary tags(NULL) values(no
|
|||
sql_error insert into st_varbinary_1013 using mt_varbinary tags(NULL) values(now(), FalsE)
|
||||
sql_error insert into st_varbinary_1014 using mt_varbinary tags(NULL) values(now(), noW)
|
||||
sql_error insert into st_varbinary_1015 using mt_varbinary tags(NULL) values(now(), toDay)
|
||||
sql_error insert into st_varbinary_1016 using mt_varbinary tags(NULL) values(now(), now()+1s)
|
||||
sql_error insert into st_varbinary_1017 using mt_varbinary tags(NULL) values(now(), 1+1s)
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
|
@ -410,6 +410,17 @@ endi
|
|||
|
||||
|
||||
# case 04: illegal input
|
||||
sql_error create table st_varchar_100 using mt_varchar tags(now+1d)
|
||||
sql_error create table st_varchar_101 using mt_varchar tags(toDay+1d)
|
||||
sql_error create table st_varchar_102 using mt_varchar tags(1+1b)
|
||||
sql_error create table st_varchar_103 using mt_varchar tags(0x01+1d)
|
||||
sql_error create table st_varchar_104 using mt_varchar tags(0b01+1s)
|
||||
sql_error insert into st_varchar_1100 using mt_varchar tags('now') values(now(),now+1d)
|
||||
sql_error insert into st_varchar_1101 using mt_varchar tags('now') values(now(),toDay+1d)
|
||||
sql_error insert into st_varchar_1102 using mt_varchar tags('now') values(now(),1+1b)
|
||||
sql_error insert into st_varchar_1103 using mt_varchar tags('now') values(now(),0x01+1d)
|
||||
sql_error insert into st_varchar_1104 using mt_varchar tags('now') values(now(),0b01+1s)
|
||||
sql_error alter table st_varchar_15 set tag tagname=now()+1d
|
||||
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import datetime
|
||||
import datetime, time
|
||||
from enum import Enum
|
||||
import binascii
|
||||
from util.log import *
|
||||
from util.sql import *
|
||||
from util.cases import *
|
||||
|
@ -45,24 +46,56 @@ class TDTestCase:
|
|||
tdSql.init(conn.cursor())
|
||||
tdSql.execute(f'drop database if exists db')
|
||||
tdSql.execute(f'create database if not exists db vgroups 1')
|
||||
tdLog.printNoPrefix("create table")
|
||||
self.__create_tb()
|
||||
|
||||
def __create_tb(self, dbname="db"):
|
||||
CREATE_STB_LIST = [ f"create table {dbname}.stb_vc (ts timestamp, c0 binary(50), c1 varchar(50)) tags(t0 varchar(50), t1 binary(50));",
|
||||
CREATE_STB_LIST = [ f"create table {dbname}.stb_vc (ts timestamp, c0 varchar(50), c1 varchar(50)) tags(t0 varchar(50), t1 varchar(50));",
|
||||
f"create table {dbname}.stb_nc (ts timestamp, c0 nchar(50), c1 nchar(50)) tags(t0 nchar(50), t1 nchar(50));",
|
||||
f"create table {dbname}.stb_bi (ts timestamp, c0 binary(50), c1 binary(50)) tags(t0 binary(50), t1 binary(50));",
|
||||
f"create table {dbname}.stb_ts (ts timestamp, c0 timestamp, c1 timestamp) tags(t0 timestamp, t1 timestamp);",
|
||||
f"create table {dbname}.stb_bo (ts timestamp, c0 bool, c1 bool) tags(t0 bool, t1 bool);",
|
||||
f"create table {dbname}.stb_vb (ts timestamp, c0 varbinary(50), c1 varbinary(50)) tags(t0 varbinary(50), t1 varbinary(50));",
|
||||
f"create table {dbname}.stb_in (ts timestamp, c0 int, c1 smallint) tags(t0 bigint, t1 tinyint);",
|
||||
f"create table {dbname}.stb_ui (ts timestamp, c0 int unsigned, c1 smallint unsigned) tags(t0 bigint unsigned, t1 tinyint unsigned);",
|
||||
f"create table {dbname}.stb_in (ts timestamp, c0 int, c1 int) tags(t0 int, t1 int);",
|
||||
f"create table {dbname}.stb_ui (ts timestamp, c0 int unsigned, c1 int unsigned) tags(t0 int unsigned, t1 int unsigned);",
|
||||
f"create table {dbname}.stb_bin (ts timestamp, c0 bigint, c1 bigint) tags(t0 bigint, t1 bigint);",
|
||||
f"create table {dbname}.stb_bui (ts timestamp, c0 bigint unsigned, c1 bigint unsigned) tags(t0 bigint unsigned, t1 bigint unsigned);",
|
||||
f"create table {dbname}.stb_sin (ts timestamp, c0 smallint, c1 smallint) tags(t0 smallint, t1 smallint);",
|
||||
f"create table {dbname}.stb_sui (ts timestamp, c0 smallint unsigned, c1 smallint unsigned) tags(t0 smallint unsigned, t1 smallint unsigned);",
|
||||
f"create table {dbname}.stb_tin (ts timestamp, c0 tinyint, c1 tinyint) tags(t0 tinyint, t1 tinyint);",
|
||||
f"create table {dbname}.stb_tui (ts timestamp, c0 tinyint unsigned, c1 tinyint unsigned) tags(t0 tinyint unsigned, t1 tinyint unsigned);",
|
||||
f"create table {dbname}.stb_fl (ts timestamp, c0 float, c1 float) tags(t0 float, t1 float);",
|
||||
f"create table {dbname}.stb_db (ts timestamp, c0 float, c1 float) tags(t0 float, t1 float);",
|
||||
f"create table {dbname}.stb_db (ts timestamp, c0 double, c1 double) tags(t0 double, t1 double);",
|
||||
f"create table {dbname}.stb_ge (ts timestamp, c0 geometry(512), c1 geometry(512)) tags(t0 geometry(512), t1 geometry(512));",
|
||||
f"create table {dbname}.stb_js (ts timestamp, c0 int) tags(t0 json);"]
|
||||
|
||||
CREATE_NTB_LIST = [ f"create table {dbname}.ntb_vc (ts timestamp, c0 binary(50), c1 varchar(50));",
|
||||
f"create table {dbname}.ntb_nc (ts timestamp, c0 nchar(50), c1 nchar(50));",
|
||||
f"create table {dbname}.ntb_bi (ts timestamp, c0 binary(50), c1 binary(50));",
|
||||
f"create table {dbname}.ntb_ts (ts timestamp, c0 timestamp, c1 timestamp);",
|
||||
f"create table {dbname}.ntb_bo (ts timestamp, c0 bool, c1 bool);",
|
||||
f"create table {dbname}.ntb_vb (ts timestamp, c0 varbinary(50), c1 varbinary(50));",
|
||||
f"create table {dbname}.ntb_in (ts timestamp, c0 int, c1 int);",
|
||||
f"create table {dbname}.ntb_ui (ts timestamp, c0 int unsigned, c1 int unsigned);",
|
||||
f"create table {dbname}.ntb_bin (ts timestamp, c0 bigint, c1 bigint);",
|
||||
f"create table {dbname}.ntb_bui (ts timestamp, c0 bigint unsigned, c1 bigint unsigned);",
|
||||
f"create table {dbname}.ntb_sin (ts timestamp, c0 smallint, c1 smallint);",
|
||||
f"create table {dbname}.ntb_sui (ts timestamp, c0 smallint unsigned, c1 smallint unsigned);",
|
||||
f"create table {dbname}.ntb_tin (ts timestamp, c0 tinyint, c1 tinyint);",
|
||||
f"create table {dbname}.ntb_tui (ts timestamp, c0 tinyint unsigned, c1 tinyint unsigned);",
|
||||
f"create table {dbname}.ntb_fl (ts timestamp, c0 float, c1 float);",
|
||||
f"create table {dbname}.ntb_db (ts timestamp, c0 double, c1 double);",
|
||||
f"create table {dbname}.ntb_ge (ts timestamp, c0 geometry(512), c1 geometry(512));"]
|
||||
for _stb in CREATE_STB_LIST:
|
||||
tdSql.execute(_stb)
|
||||
tdSql.query(f'show {dbname}.stables')
|
||||
tdSql.checkRows(len(CREATE_STB_LIST))
|
||||
|
||||
for _stb in CREATE_NTB_LIST:
|
||||
tdSql.execute(_stb)
|
||||
tdSql.query(f'show {dbname}.tables')
|
||||
tdSql.checkRows(len(CREATE_NTB_LIST))
|
||||
|
||||
def _query_check_varchar(self, result, okv, nv, row = 0, col = 0):
|
||||
for i in range(row):
|
||||
for j in range(1, col):
|
||||
|
@ -146,25 +179,62 @@ class TDTestCase:
|
|||
check_result = True
|
||||
tdSql.checkEqual(check_result, True)
|
||||
|
||||
def _query_check_varbinary(self, result, okv, nv, row = 0, col = 0):
|
||||
tdLog.info(f'[okv={okv}, nv={nv}')
|
||||
for i in range(row):
|
||||
for j in range(1, col):
|
||||
check_result = False
|
||||
if result[i][j]:
|
||||
check_item = result[i][j].decode('utf-8')
|
||||
else:
|
||||
check_item = ''
|
||||
# new_nv = None
|
||||
|
||||
def _query_check(self, dbname="db", stbname="", ctbname="", nRows = 0, okv = None, nv = None, dtype = TDDataType.NULL):
|
||||
if nv[0:1] == '\'' or nv[0:1] == '\"':
|
||||
nv = nv[1:-1]
|
||||
if okv[0:1] == '\'' or okv[0:1] == '\"':
|
||||
okv = okv[1:-1]
|
||||
|
||||
# if nv[0:2] == '\\x' or nv[0:2] == '\\X':
|
||||
# nv = nv[1:]
|
||||
# elif nv == '' or nv =="":
|
||||
# new_nv = nv
|
||||
# elif nv.isspace():
|
||||
# new_nv = nv
|
||||
# else:
|
||||
# hex_text = binascii.hexlify(nv.encode())
|
||||
# new_nv = '/x' + hex_text.decode().upper()
|
||||
# tdLog.info(f"okv={okv}, nv={nv}, check_item={check_item}")
|
||||
if check_item == None:
|
||||
check_item = 'null'
|
||||
if check_item in okv or check_item in nv:
|
||||
check_result = True
|
||||
tdSql.checkEqual(check_result, True)
|
||||
|
||||
def _query_check(self, dbname="db", stbname="", ctbname="", ntbname="",nRows = 0, okv = None, nv = None, dtype = TDDataType.NULL):
|
||||
result = None
|
||||
if stbname:
|
||||
if dtype != TDDataType.GEOMETRY: # geometry query by py connector need to be supported
|
||||
tdSql.query(f'select * from {dbname}.{stbname}')
|
||||
tdSql.checkRows(nRows)
|
||||
result = tdSql.queryResult
|
||||
else:
|
||||
tdSql.query(f'select * from {dbname}.{ntbname}')
|
||||
tdSql.checkRows(nRows)
|
||||
result = tdSql.queryResult
|
||||
|
||||
if dtype == TDDataType.VARCHAR or dtype == TDDataType.NCHAR:
|
||||
|
||||
if dtype == TDDataType.VARCHAR or dtype == TDDataType.NCHAR or dtype == TDDataType.BINARY:
|
||||
self._query_check_varchar(result, okv, nv, nRows, 4)
|
||||
elif dtype == TDDataType.TIMESTAMP:
|
||||
self._query_check_timestamp(result, okv, nv, nRows, 4)
|
||||
elif dtype == TDDataType.BOOL:
|
||||
self._query_check_bool(result, okv, nv, nRows, 4)
|
||||
elif dtype == TDDataType.VARBINARY:
|
||||
pass
|
||||
elif dtype == TDDataType.INT:
|
||||
self._query_check_varbinary(result, okv, nv, nRows, 4)
|
||||
elif dtype == TDDataType.INT or dtype == TDDataType.BIGINT or dtype == TDDataType.SMALLINT or dtype == TDDataType.TINYINT:
|
||||
self._query_check_int(result, okv, nv, nRows, 4)
|
||||
elif dtype == TDDataType.UINT:
|
||||
elif dtype == TDDataType.UINT or dtype == TDDataType.UBIGINT or dtype == TDDataType.USMALLINT or dtype == TDDataType.UTINYINT:
|
||||
self._query_check_int(result, okv, nv, nRows, 4)
|
||||
elif dtype == TDDataType.FLOAT or dtype == TDDataType.DOUBLE:
|
||||
self._query_check_int(result, okv, nv, nRows, 4)
|
||||
|
@ -176,75 +246,138 @@ class TDTestCase:
|
|||
if ctbname != "":
|
||||
tdSql.execute(f'drop table {dbname}.{ctbname}')
|
||||
|
||||
def __insert_query_common(self, dbname="db", stbname="", ctbname="", oklist=[], kolist=[], okv=None, dtype = TDDataType.NULL):
|
||||
tdLog.info(f'{dbname}.{stbname} {ctbname}, oklist:%d, kolist:%d'%(len(oklist), len(kolist)))
|
||||
tdSql.checkEqual(34, len(oklist) + len(kolist))
|
||||
def __insert_query_common(self, dbname="db", stbname="", ctbname="", ntbname="", oklist=[], kolist=[], okv=None, dtype = TDDataType.NULL):
|
||||
tdLog.info(f'[Begin]{dbname}.{stbname} {ctbname}, oklist:%d, kolist:%d, TDDataType:%s'%(len(oklist), len(kolist), dtype))
|
||||
# tdSql.checkEqual(34, len(oklist) + len(kolist))
|
||||
|
||||
for _l in kolist:
|
||||
for _e in _l:
|
||||
tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, {okv})' %(_e))
|
||||
tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, %s)' %(_e))
|
||||
tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, %s)' %(_e, _e))
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, %s) values(now, {okv}, {okv})' %(_e))
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, {okv}) values(now, {okv}, {okv})' %(_e))
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, %s, {okv})' %(_e))
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, {okv}, %s)' %(_e))
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, %s, %s)' %(_e, _e))
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, {okv}, {okv})')
|
||||
self._query_check(dbname,stbname, "", 1, okv, _e, dtype)
|
||||
tdSql.execute(f'alter table {dbname}.{ctbname} set tag t0 = {okv}')
|
||||
tdSql.error(f'alter table {dbname}.{ctbname} set tag t0 = %s' %(_e))
|
||||
tdSql.error(f'alter table {dbname}.{ctbname} set tag t1 = %s' %(_e))
|
||||
# tdLog.info(f'[ko:verify value "{_e}"]')
|
||||
# create sub-table manually, check tag
|
||||
tdLog.info('[ko:create sub-table manually, check tag]')
|
||||
tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, {okv})' %(_e), show=True)
|
||||
tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, %s)' %(_e), show=True)
|
||||
tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, %s)' %(_e, _e), show=True)
|
||||
|
||||
# create sub-table automatically, check tag
|
||||
tdLog.info('[ko:create sub-table automatically, check tag]')
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, %s) values(now, {okv}, {okv})' %(_e), show=True)
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, {okv}) values(now, {okv}, {okv})' %(_e), show=True)
|
||||
|
||||
# create sub-table automatically, check value
|
||||
tdLog.info('[ko:create sub-table automatically, check value]')
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, %s, {okv})' %(_e), show=True)
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, {okv}, %s)' %(_e), show=True)
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, %s, %s)' %(_e, _e), show=True)
|
||||
|
||||
# check alter table tag
|
||||
tdLog.info('[ko:check alter table tag]')
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, {okv}, {okv})', show=True)
|
||||
# self._query_check(dbname,stbname, "", None, 1, okv, _e, dtype)
|
||||
# tdSql.execute(f'alter table {dbname}.{ctbname} set tag t0 = {okv}', show=True)
|
||||
tdSql.error(f'alter table {dbname}.{ctbname} set tag t0 = %s' %(_e), show=True)
|
||||
tdSql.error(f'alter table {dbname}.{ctbname} set tag t1 = %s' %(_e), show=True)
|
||||
tdSql.execute(f'drop table {dbname}.{ctbname}')
|
||||
|
||||
# insert into value by supper-table, check tag & value
|
||||
tdLog.info('[ko:insert into value by supper-table, check tag & value]')
|
||||
tdSql.error(f'insert into {dbname}.{stbname}(tbname, t0, t1, ts, c0, c1) values("{ctbname}_1", %s, {okv}, now, {okv}, {okv})' %(_e), show=True)
|
||||
tdSql.error(f'insert into {dbname}.{stbname}(tbname, t0, t1, ts, c0, c1) values("{ctbname}_2", {okv},{okv}, now + 1s, {okv}, %s)' %(_e), show=True)
|
||||
tdSql.error(f'insert into {dbname}.{stbname}(tbname, t0, t1, ts, c0, c1) values("{ctbname}_3", %s, %s, now + 2s, %s, %s)' %(_e, _e, _e, _e), show=True)
|
||||
|
||||
# insert into normal table, check value
|
||||
tdLog.info('[ko:insert into normal table, check value]')
|
||||
tdSql.error(f'insert into {dbname}.{ntbname} values(now, %s, {okv})' %(_e), show=True)
|
||||
tdSql.error(f'insert into {dbname}.{ntbname} values(now, {okv}, %s)' %(_e), show=True)
|
||||
tdSql.error(f'insert into {dbname}.{ntbname} values(now, %s, %s)' %(_e, _e), show=True)
|
||||
|
||||
for _l in oklist:
|
||||
for _e in _l:
|
||||
tdLog.info(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, {okv})' %(_e))
|
||||
tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, {okv})' %(_e))
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} values(now + 0s, %s, {okv})' %(_e))
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} values(now + 1s, {okv}, %s)' %(_e))
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} values(now + 2s, %s, %s)' %(_e, _e))
|
||||
tdLog.info(f'insert into {dbname}.{ctbname} values(now + 0s, %s, {okv})' %(_e))
|
||||
tdLog.info(f'insert into {dbname}.{ctbname} values(now + 1s, {okv}, %s)' %(_e))
|
||||
tdLog.info(f'insert into {dbname}.{ctbname} values(now + 2s, %s, %s)' %(_e, _e))
|
||||
tdSql.execute(f'alter table {dbname}.{ctbname} set tag t0 = %s' %(_e))
|
||||
tdSql.execute(f'alter table {dbname}.{ctbname} set tag t1 = %s' %(_e))
|
||||
self._query_check(dbname,stbname, ctbname, 3, okv, _e, dtype)
|
||||
tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, %s)' %(_e, _e))
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} values(now, %s, %s)' %(_e, _e))
|
||||
self._query_check(dbname,stbname, ctbname, 1, okv, _e, dtype)
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, {okv}) values(now, %s, {okv})' %(_e, _e))
|
||||
self._query_check(dbname,stbname, ctbname, 1, okv, _e, dtype)
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, %s) values(now, {okv}, %s)' %(_e, _e))
|
||||
self._query_check(dbname,stbname, ctbname, 1, okv, _e, dtype)
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, %s) values(now, %s, %s)' %(_e, _e, _e, _e))
|
||||
self._query_check(dbname,stbname, ctbname, 1, okv, _e, dtype)
|
||||
tdLog.info(f'[ok:verify value "{_e}"]')
|
||||
# 1. create sub-table manually, check tag
|
||||
tdLog.info('[ok:create sub-table manually, check tag]')
|
||||
tdSql.execute(f'create table {dbname}.{ctbname}_1 using {dbname}.{stbname} tags({_e}, {okv})', show=True)
|
||||
tdSql.execute(f'create table {dbname}.{ctbname}_2 using {dbname}.{stbname} tags({okv}, %s)' %(_e), show=True)
|
||||
tdSql.execute(f'create table {dbname}.{ctbname}_3 using {dbname}.{stbname} tags(%s, %s)' %(_e, _e), show=True)
|
||||
|
||||
|
||||
# 1.1 insert into sub-table, check value
|
||||
tdLog.info('[ok:insert into sub-table, check value]')
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname}_1 values(now + 0s, %s, {okv})' %(_e), show=True)
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname}_2 values(now + 1s, {okv}, %s)' %(_e), show=True)
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname}_3 values(now + 2s, %s, %s)' %(_e, _e), show=True)
|
||||
|
||||
# 1.2 check alter table tag
|
||||
tdLog.info('[ok:check alter table tag]')
|
||||
tdSql.execute(f'alter table {dbname}.{ctbname}_1 set tag t1 = %s' %(_e), show=True)
|
||||
tdSql.execute(f'alter table {dbname}.{ctbname}_2 set tag t0 = %s' %(_e), show=True)
|
||||
|
||||
# 1.3 check table data
|
||||
tdLog.info('[ok:check table data]')
|
||||
self._query_check(dbname, stbname, f'{ctbname}_1', None, 3, okv, _e, dtype)
|
||||
self._query_check(dbname, stbname, f'{ctbname}_2', None, 2, okv, _e, dtype)
|
||||
self._query_check(dbname, stbname, f'{ctbname}_3', None, 1, okv, _e, dtype)
|
||||
|
||||
# 2. insert into value by creating sub-table automatically, check tag & value
|
||||
tdLog.info('[ok:insert into value by creating sub-table automatically, check tag & value]')
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname}_1 using {dbname}.{stbname} tags(%s, {okv}) values(now, %s, {okv})' %(_e, _e), show=True)
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname}_2 using {dbname}.{stbname} tags({okv}, %s) values(now + 1s, {okv}, %s)' %(_e, _e), show=True)
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname}_3 using {dbname}.{stbname} tags(%s, %s) values(now + 2s, %s, %s)' %(_e, _e, _e, _e), show=True)
|
||||
|
||||
self._query_check(dbname, stbname, f'{ctbname}_1', None, 3, okv, _e, dtype)
|
||||
self._query_check(dbname, stbname, f'{ctbname}_2', None, 2, okv, _e, dtype)
|
||||
self._query_check(dbname, stbname, f'{ctbname}_3', None, 1, okv, _e, dtype)
|
||||
|
||||
# 3. insert into value by supper-table, check tag & value
|
||||
tdLog.info('[ok:insert into value by supper-table, check tag & value]')
|
||||
tdSql.execute(f'insert into {dbname}.{stbname}(tbname, t0, t1, ts, c0, c1) values("{ctbname}_1", %s, {okv}, now, %s, {okv})' %(_e, _e), show=True)
|
||||
tdSql.execute(f'insert into {dbname}.{stbname}(tbname, t0, t1, ts, c0, c1) values("{ctbname}_2", {okv}, %s, now + 1s, {okv}, %s)' %(_e, _e), show=True)
|
||||
tdSql.execute(f'insert into {dbname}.{stbname}(tbname, t0, t1, ts, c0, c1) values("{ctbname}_3", %s, %s, now + 2s, %s, %s)' %(_e, _e, _e, _e), show=True)
|
||||
|
||||
self._query_check(dbname, stbname, f'{ctbname}_1', None, 3, okv, _e, dtype)
|
||||
self._query_check(dbname, stbname, f'{ctbname}_2', None, 2, okv, _e, dtype)
|
||||
self._query_check(dbname, stbname, f'{ctbname}_3', None, 1, okv, _e, dtype)
|
||||
|
||||
# 4. insert value into normal table
|
||||
tdLog.info('[ok:insert value into normal table]')
|
||||
tdSql.execute(f'insert into {dbname}.{ntbname} values(now, %s, {okv})' %(_e), show=True)
|
||||
tdSql.execute(f'insert into {dbname}.{ntbname} values(now + 1s, {okv}, %s)' %(_e), show=True)
|
||||
tdSql.execute(f'insert into {dbname}.{ntbname} values(now + 2s, %s, %s)' %(_e, _e), show=True)
|
||||
|
||||
if dtype != TDDataType.GEOMETRY:
|
||||
# self._query_check(dbname, None, None, ntbname, 3, okv, _e, dtype)
|
||||
tdSql.query(f'select * from {dbname}.{ntbname}')
|
||||
tdSql.checkRows(3)
|
||||
tdSql.query(f'delete from {dbname}.{ntbname}')
|
||||
|
||||
def __insert_query_json(self, dbname="db", stbname="", ctbname="", oklist=[], kolist=[], okv=None):
|
||||
tdLog.info(f'{dbname}.{stbname} {ctbname}, oklist:%d, kolist:%d'%(len(oklist), len(kolist)))
|
||||
tdSql.checkEqual(34, len(oklist) + len(kolist))
|
||||
# tdSql.checkEqual(34, len(oklist) + len(kolist))
|
||||
|
||||
for _l in kolist:
|
||||
for _e in _l:
|
||||
tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s)' %(_e))
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags(%s) values(now, 1)' %(_e))
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}) values(now, 1)')
|
||||
tdSql.query(f'select * from {dbname}.{stbname}')
|
||||
tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s)' %(_e), show=True)
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags(%s) values(now, 1)' %(_e), show=True)
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}) values(now, 1)', show=True)
|
||||
tdSql.query(f'select * from {dbname}.{stbname}', show=True)
|
||||
tdSql.checkRows(1)
|
||||
tdSql.execute(f'alter table {dbname}.{ctbname} set tag t0 = {okv}')
|
||||
tdSql.error(f'alter table {dbname}.{ctbname} set tag t0 = %s' %(_e))
|
||||
tdSql.execute(f'drop table {dbname}.{ctbname}')
|
||||
tdSql.execute(f'alter table {dbname}.{ctbname} set tag t0 = {okv}', show=True)
|
||||
tdSql.error(f'alter table {dbname}.{ctbname} set tag t0 = %s' %(_e), show=True)
|
||||
tdSql.execute(f'drop table {dbname}.{ctbname}', show=True)
|
||||
for _l in oklist:
|
||||
for _e in _l:
|
||||
tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s)' %(_e))
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} values(now, 1)')
|
||||
tdSql.execute(f'alter table {dbname}.{ctbname} set tag t0 = %s' %(_e))
|
||||
tdSql.query(f'select * from {dbname}.{stbname}')
|
||||
tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s)' %(_e), show=True)
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} values(now, 1)', show=True)
|
||||
tdSql.execute(f'alter table {dbname}.{ctbname} set tag t0 = %s' %(_e), show=True)
|
||||
tdSql.query(f'select * from {dbname}.{stbname}', show=True)
|
||||
tdSql.checkRows(1)
|
||||
tdSql.execute(f'drop table {dbname}.{ctbname}')
|
||||
tdSql.execute(f'drop table {dbname}.{ctbname}', show=True)
|
||||
|
||||
def __insert_query_exec(self):
|
||||
STR_EMPTY = ['\'\'', "\"\"", '\' \'', "\" \""]
|
||||
STR_INTEGER_P = ["\"42\"", '\'+42\'', '\'+0\'', '\'-0\'', '\'0x2A\'', '\'-0X0\'', '\'+0x0\'', '\'0B00101010\'', '\'-0b00\'']
|
||||
STR_CHINESE = ['\'年年岁岁,花相似\'']
|
||||
STR_CHINESE_ILLEGAL = ['\'洛阳城东桃李花,飞来飞去落谁家。幽闺女儿爱颜色,坐见落花长叹息。今岁花开君不待。明年花开复谁在。故人不共洛阳东,今来空对落花风。年年岁岁花相似,岁岁年年人不同\'']
|
||||
STR_INTEGER_P = ["\"42\"", '\'+42\'', '\'+0\'', '\'1\'','\'-0\'', '\'0x2A\'', '\'-0X0\'', '\'+0x0\'', '\'0B00101010\'', '\'-0b00\'']
|
||||
STR_INTEGER_M = ['\'-128\'', '\'-0X1\'', '\"-0x34\"', '\'-0b01\'', '\'-0B00101010\'']
|
||||
STR_FLOAT_P = ['\'42.1\'', "\"+0.003\"", "\'-0.0\'"]
|
||||
STR_FLOAT_M = ["\"-32.001\""]
|
||||
|
@ -259,18 +392,32 @@ class TDTestCase:
|
|||
STR_TSKP_MISC = ['\'now()+1s\'', '\' now()\'', '\'now( )\'', '\'today() \'', '\'today())\'', '\'today()+1m\'', '\'today()-1w\'']
|
||||
STR_BOOL = ['\'true\'', '\'false\'', '\'TRUE\'', '\'FALSE\'', '\'tRuE\'', '\'falsE\'']
|
||||
STR_TS = ["\"2024-02-01 00:00:01.001-08:00\"", "\'2024-02-01T00:00:01.001+09:00\'", "\"2024-02-01\"", "\'2024-02-02 00:00:01\'", "\'2024-02-02 00:00:01.009\'"]
|
||||
STR_VARBIN = ['\'\\x12\'', '\'\\x13\'', '\' \\x14 \'', '\'\\x12ab\'']
|
||||
STR_TS_ILLEGAL = ["\"2023-2024-02-01 00:00:01.001-08:00\"", "\'2024-02-01T99:00:01.001+09:00\'", "\"2024-02-31\"", "\'2024-02-02 00:88:01\'", "\'2024-02-02 00:00:77.009\'"]
|
||||
STR_VARBIN = ["\'\x12\'", "\'\x13\'", "\' \x14 \'", "\'\x12ab\'"]
|
||||
STR_JSON_O = ['\'{\"k1\":\"v1\"}\'', '\' {} \'']
|
||||
STR_JSON_A = ['\'[]\'']
|
||||
STR_GEO = ['\' POINT(1.0 1.0)\'', '\'LINESTRING(1.00 +2.0, 2.1 -3.2, 5.00 5.01) \'', '\'POLYGON((1.0 1.0, -2.0 +2.0, 1.0 1.0))\'' ]
|
||||
STR_JSON_A = ['\'[]\'', '\"{\'k1\': \'v1\',\'k2\'}\"', '\"{\'k1\': \'v1\'}}\"']
|
||||
STR_GEO = ["\' POINT(1.0 1.0)\'", "\'LINESTRING(1.00 +2.0, 2.1 -3.2, 5.00 5.01) \'", "\'POLYGON((1.0 1.0, -2.0 +2.0, 1.0 1.0))\'" ]
|
||||
STR_GEO_ILLEGAL = ['\' POINT(1.0)\'', '\'LINESTRING(1.00 +2.0, -3.2, 5.00 5.01) \'', '\'POLYGON((-2.0 +2.0, 1.0 1.0))\'' ]
|
||||
STR_NULL = ['\'NuLl\'', '\'null\'', '\'NULL\'']
|
||||
STR_NONE = ['\'NoNe\'', '\'none\'', '\'NONE\'']
|
||||
STR_BINARY = ["\'\x7f8290\'", "\'\X7f8290\'", "\'x7f8290\'", "\'\\x\'"] # bug TD-29193
|
||||
STR_BINARY_ILLEGAL = ["\'\\x7f829\'"]
|
||||
|
||||
RAW_INTEGER_P = [' 42 ', '+042 ', ' +0', '0 ', '-0', '0', ' 0X2A', ' -0x0 ', '+0x0 ', ' 0B00101010', ' -0b00']
|
||||
RAW_INTEGER_M = [' -42 ', ' -0128',' -0x1', ' -0X2A', '-0b01 ', ' -0B00101010 ']
|
||||
RAW_INTEGER_INT_BOUNDARY_ILLEGAL =['2147483648', '-2147483649']
|
||||
RAW_INTEGER_UINT_BOUNDARY_ILLEGAL =['4294967296', '-1']
|
||||
RAW_INTEGER_BINT_BOUNDARY_ILLEGAL =['9223372036854775808', '-9223372036854775809']
|
||||
RAW_INTEGER_UBINT_BOUNDARY_ILLEGAL =['18446744073709551616', '-1']
|
||||
RAW_INTEGER_SINT_BOUNDARY_ILLEGAL =['32768', '-32769']
|
||||
RAW_INTEGER_USINT_BOUNDARY_ILLEGAL =['65536', '-1']
|
||||
RAW_INTEGER_TINT_BOUNDARY_ILLEGAL =['128', '-129']
|
||||
RAW_INTEGER_UTINT_BOUNDARY_ILLEGAL =['256', '-1']
|
||||
RAW_FLOAT_P = [' 123.012', ' 0.0', ' +0.0', ' -0.0 ']
|
||||
RAW_FLOAT_M = ['-128.001 ']
|
||||
RAW_FLOAT_E_P = [' 1e-100', ' +0.1E+2', ' -0.1E-10']
|
||||
RAW_FLOAT_E_M = [" -1E2 "]
|
||||
RAW_FLOAT_E_M_SPE = ["-1e-100"]
|
||||
RAW_MISC = ['123abc', "123c", '-123d', '+', '-', ' *', ' /', '% ', '&', "|", "^", "&&", "||", "!", " =", ' None ', 'NONE', 'now+1 s', 'now-1','now-1y','now+2 d',
|
||||
'today+1 s', 'today-1','today-1y','today+2 d', 'now()+1 s', 'now()-1','now()-1y','now()+2 d', 'today()+1 s', 'today()-1','today()-1y','today()+2 d']
|
||||
RAW_OPTR = ['1*10', '1+2', '-2-0','1%2', '2/0', '1&31']
|
||||
|
@ -280,68 +427,97 @@ class TDTestCase:
|
|||
RAW_TSKP_OPTR = [' noW ( ) + 1s', 'nOw( ) + 2D', 'NOW () + 000s', ' today()+1M', 'today( ) - 1w ', 'TodaY ( ) - 1U ']
|
||||
RAW_BOOL = ['true', 'false', ' TRUE ', 'FALSE ', ' tRuE', ' falsE ']
|
||||
RAW_NULL = ['NuLl', 'null ', ' NULL', ' NULL ']
|
||||
RAW_NONE = ['None', 'none ', ' NoNe', ' NONE ']
|
||||
RAW_BINARY_ILLEGAL = ['\\x7f8290', '\\X7f8290', 'x7f8290', '\\x', '\\x7f829']
|
||||
|
||||
OK_VC = [STR_EMPTY, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP,
|
||||
STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, STR_NULL, RAW_INTEGER_P, RAW_INTEGER_M, RAW_FLOAT_P, RAW_FLOAT_M,
|
||||
RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_TSK, RAW_BOOL, RAW_NULL]
|
||||
KO_VC = [RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR]
|
||||
RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_TSK, RAW_BOOL, RAW_NULL, STR_CHINESE, STR_NONE]
|
||||
KO_VC = [RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, STR_CHINESE_ILLEGAL, RAW_NONE]
|
||||
OK_NC = OK_VC
|
||||
KO_NC = KO_VC
|
||||
OK_BI = OK_VC
|
||||
KO_BI = KO_VC
|
||||
OK_TS = [STR_TSK, STR_INTEGER_P, STR_INTEGER_M, STR_TSKP, STR_TS, STR_NULL, RAW_INTEGER_P, RAW_INTEGER_M, RAW_TSK, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, RAW_NULL]
|
||||
KO_TS = [STR_EMPTY, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, STR_MISC, STR_OPTR, STR_TSK_MISC, STR_TSKP_MISC, STR_BOOL, STR_VARBIN,
|
||||
STR_JSON_O, STR_JSON_A, STR_GEO, RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_MISC, RAW_OPTR, RAW_BOOL]
|
||||
STR_JSON_O, STR_JSON_A, STR_GEO, RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_MISC, RAW_OPTR, RAW_BOOL, STR_CHINESE, STR_NONE, STR_TS_ILLEGAL,
|
||||
STR_BINARY, RAW_NONE]
|
||||
OK_BO = [STR_BOOL, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M,RAW_BOOL, STR_NULL, RAW_INTEGER_P, RAW_INTEGER_M,
|
||||
RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_NULL]
|
||||
KO_BO = [STR_EMPTY, STR_TSK, STR_TSKP, STR_TS, STR_MISC, STR_OPTR, STR_TSK_MISC, STR_TSKP_MISC, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, RAW_TSK,
|
||||
RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, RAW_MISC, RAW_OPTR]
|
||||
RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, RAW_MISC, RAW_OPTR, STR_CHINESE, STR_NONE, STR_BINARY, RAW_NONE]
|
||||
OK_VB = [STR_EMPTY, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP,
|
||||
STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, STR_NULL, RAW_NULL]
|
||||
KO_VB = [RAW_INTEGER_P, RAW_INTEGER_M, RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_TSK, RAW_BOOL, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR]
|
||||
STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, STR_NULL, RAW_NULL, STR_CHINESE, STR_NONE, STR_BINARY]
|
||||
KO_VB = [RAW_INTEGER_P, RAW_INTEGER_M, RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_TSK, RAW_BOOL, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR,
|
||||
STR_BINARY_ILLEGAL, STR_BINARY_ILLEGAL, RAW_BINARY_ILLEGAL, RAW_NONE]
|
||||
OK_IN = [STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, STR_NULL, RAW_INTEGER_P, RAW_INTEGER_M, RAW_FLOAT_P, RAW_FLOAT_M,
|
||||
RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_NULL]
|
||||
KO_IN = [STR_EMPTY, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, RAW_TSK,
|
||||
RAW_BOOL, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR]
|
||||
OK_UI = [STR_INTEGER_P, STR_FLOAT_P, STR_FLOAT_E_P, STR_NULL, RAW_INTEGER_P, RAW_FLOAT_P, RAW_FLOAT_E_P, RAW_NULL]
|
||||
KO_UI = [STR_EMPTY, STR_MISC, STR_INTEGER_M, STR_FLOAT_M, STR_FLOAT_E_M, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN,
|
||||
STR_JSON_O, STR_JSON_A, STR_GEO, RAW_TSK, RAW_BOOL, RAW_INTEGER_M, RAW_FLOAT_M, RAW_FLOAT_E_M, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR]
|
||||
BASE_KO_IN = [STR_EMPTY, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, RAW_TSK,
|
||||
RAW_BOOL, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, STR_CHINESE, STR_NONE, STR_BINARY, RAW_NONE]
|
||||
KO_IN = BASE_KO_IN + [RAW_INTEGER_INT_BOUNDARY_ILLEGAL]
|
||||
OK_BIN = OK_IN
|
||||
KO_BIN = BASE_KO_IN + [RAW_INTEGER_BINT_BOUNDARY_ILLEGAL]
|
||||
OK_SIN = OK_IN
|
||||
KO_SIN = BASE_KO_IN + [RAW_INTEGER_SINT_BOUNDARY_ILLEGAL]
|
||||
OK_TIN = OK_IN
|
||||
KO_TIN = BASE_KO_IN + [RAW_INTEGER_TINT_BOUNDARY_ILLEGAL]
|
||||
OK_UI = [STR_INTEGER_P, STR_FLOAT_P, STR_FLOAT_E_P, STR_NULL, RAW_INTEGER_P, RAW_FLOAT_P, RAW_FLOAT_E_P, RAW_NULL, RAW_FLOAT_E_M_SPE]
|
||||
BASE_KO_UI = [STR_EMPTY, STR_MISC, STR_INTEGER_M, STR_FLOAT_M, STR_FLOAT_E_M, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN,
|
||||
STR_JSON_O, STR_JSON_A, STR_GEO, RAW_TSK, RAW_BOOL, RAW_INTEGER_M, RAW_FLOAT_M, RAW_FLOAT_E_M, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR,
|
||||
STR_CHINESE, STR_NONE, RAW_NONE]
|
||||
KO_UI = BASE_KO_UI + [RAW_INTEGER_UINT_BOUNDARY_ILLEGAL]
|
||||
OK_UBINT = OK_UI
|
||||
KO_UBINT = BASE_KO_UI + [RAW_INTEGER_UBINT_BOUNDARY_ILLEGAL]
|
||||
OK_USINT = OK_UI
|
||||
KO_USINT = BASE_KO_UI + [RAW_INTEGER_USINT_BOUNDARY_ILLEGAL]
|
||||
OK_UTINT = OK_UI
|
||||
KO_UTINT = BASE_KO_UI + [RAW_INTEGER_UTINT_BOUNDARY_ILLEGAL]
|
||||
OK_FL = [RAW_INTEGER_P, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, STR_NULL, RAW_INTEGER_M, RAW_FLOAT_P, RAW_FLOAT_M,
|
||||
RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_NULL]
|
||||
KO_FL = [STR_EMPTY, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, RAW_TSK,
|
||||
RAW_BOOL, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR]
|
||||
RAW_BOOL, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, STR_CHINESE, STR_NONE, STR_BINARY, RAW_NONE]
|
||||
OK_DB = OK_FL
|
||||
KO_DB = KO_FL
|
||||
OK_GE = [STR_GEO, STR_NULL, RAW_NULL]
|
||||
KO_GE = [STR_EMPTY, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_JSON_O, STR_JSON_A, STR_VARBIN, RAW_TSK, RAW_BOOL, RAW_MISC,
|
||||
RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, RAW_INTEGER_P, RAW_INTEGER_M,
|
||||
RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M]
|
||||
RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M, STR_CHINESE, STR_NONE, STR_BINARY, STR_GEO_ILLEGAL, RAW_NONE]
|
||||
OK_JS = [STR_EMPTY, STR_JSON_O, STR_NULL, RAW_NULL]
|
||||
KO_JS = [STR_JSON_A, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_GEO, STR_VARBIN, RAW_TSK, RAW_BOOL, RAW_MISC, RAW_OPTR,
|
||||
RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, RAW_INTEGER_P, RAW_INTEGER_M,
|
||||
RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M]
|
||||
RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M, STR_CHINESE, STR_NONE, STR_BINARY, RAW_NONE]
|
||||
|
||||
TEST = [["' POINT(1.0 1.0)'"]]
|
||||
PARAM_LIST = [
|
||||
["db", "stb_vc", "ctb_vc", OK_VC, KO_VC, "\'vc\'", TDDataType.VARCHAR],
|
||||
["db", "stb_nc", "ctb_nc", OK_NC, KO_NC, "\'nc\'", TDDataType.NCHAR],
|
||||
["db", "stb_ts", "ctb_ts", OK_TS, KO_TS, "now", TDDataType.TIMESTAMP],
|
||||
["db", "stb_bo", "ctb_bo", OK_BO, KO_BO, "true", TDDataType.BOOL],
|
||||
["db", "stb_vb", "ctb_vb", OK_VB, KO_VB, "\'\\x12\'", TDDataType.VARBINARY],
|
||||
["db", "stb_in", "ctb_in", OK_IN, KO_IN, "-1", TDDataType.UINT],
|
||||
["db", "stb_ui", "ctb_ui", OK_UI, KO_UI, "1", TDDataType.UINT],
|
||||
["db", "stb_fl", "ctb_fl", OK_FL, KO_FL, "1.0", TDDataType.FLOAT],
|
||||
["db", "stb_db", "ctb_db", OK_DB, KO_DB, "1.0", TDDataType.DOUBLE],
|
||||
["db", "stb_ge", "ctb_ge", OK_GE, KO_GE, "\'POINT(1.0 1.0)\'", TDDataType.GEOMETRY]
|
||||
["db", "stb_vc", "ctb_vc", "ntb_vc", OK_VC, KO_VC, "\'vc\'", TDDataType.VARCHAR],
|
||||
["db", "stb_nc", "ctb_nc", "ntb_nc", OK_NC, KO_NC, "\'nc\'", TDDataType.NCHAR],
|
||||
["db", "stb_bi", "ctb_bi", "ntb_bi", OK_BI, KO_BI, "\'bi\'", TDDataType.BINARY],
|
||||
["db", "stb_ts", "ctb_ts", "ntb_ts", OK_TS, KO_TS, "now", TDDataType.TIMESTAMP],
|
||||
["db", "stb_bo", "ctb_bo", "ntb_bo", OK_BO, KO_BO, "true", TDDataType.BOOL],
|
||||
["db", "stb_vb", "ctb_vb", "ntb_vb", OK_VB, KO_VB, "'hello'", TDDataType.VARBINARY],
|
||||
|
||||
["db", "stb_in", "ctb_in", "ntb_in", OK_IN, KO_IN, "-1", TDDataType.INT],
|
||||
["db", "stb_ui", "ctb_ui", "ntb_ui", OK_UI, KO_UI, "1", TDDataType.UINT],
|
||||
["db", "stb_bin", "ctb_bin", "ntb_bin", OK_BIN, KO_BIN, "-1", TDDataType.BIGINT],
|
||||
["db", "stb_bui", "ctb_bui", "ntb_bui", OK_UBINT, KO_UBINT, "1", TDDataType.UBIGINT],
|
||||
["db", "stb_sin", "ctb_sin", "ntb_sin", OK_SIN, KO_SIN, "-1", TDDataType.SMALLINT],
|
||||
["db", "stb_sui", "ctb_sui", "ntb_sui", OK_USINT, KO_USINT, "1", TDDataType.USMALLINT],
|
||||
["db", "stb_tin", "ctb_tin", "ntb_tin", OK_TIN, KO_TIN, "-1", TDDataType.TINYINT],
|
||||
["db", "stb_tui", "ctb_tui", "ntb_tui", OK_UTINT, KO_UTINT, "1", TDDataType.UTINYINT],
|
||||
|
||||
["db", "stb_fl", "ctb_fl", "ntb_fl", OK_FL, KO_FL, "1.0", TDDataType.FLOAT],
|
||||
["db", "stb_db", "ctb_db", "ntb_db", OK_DB, KO_DB, "1.0", TDDataType.DOUBLE],
|
||||
["db", "stb_ge", "ctb_ge", "ntb_ge", TEST, KO_GE, "\'POINT(100.0 100.0)\'", TDDataType.GEOMETRY]
|
||||
]
|
||||
|
||||
# check with common function
|
||||
for _pl in PARAM_LIST:
|
||||
self.__insert_query_common(_pl[0], _pl[1], _pl[2], _pl[3], _pl[4], _pl[5], _pl[6])
|
||||
self.__insert_query_common(_pl[0], _pl[1], _pl[2], _pl[3], _pl[4], _pl[5], _pl[6], _pl[7])
|
||||
# check json
|
||||
self.__insert_query_json("db", "stb_js", "ctb_js", OK_JS, KO_JS, "\'{\"k1\":\"v1\",\"k2\":\"v2\"}\'")
|
||||
|
||||
|
||||
def run(self):
|
||||
tdLog.printNoPrefix("==========step1:create table")
|
||||
self.__create_tb()
|
||||
self.__insert_query_exec()
|
||||
|
||||
|
||||
|
|
|
@ -78,14 +78,55 @@ class TDTestCase:
|
|||
tdLog.info(cmd)
|
||||
os.system(cmd)
|
||||
|
||||
def case1(self):
|
||||
|
||||
tdSql.execute(f'create database if not exists d1 vgroups 1')
|
||||
tdSql.execute(f'use d1')
|
||||
tdSql.execute(f'create table st(ts timestamp, i int) tags(t int)')
|
||||
tdSql.execute(f'insert into t1 using st tags(1) values(now, 1) (now+1s, 2)')
|
||||
tdSql.execute(f'insert into t2 using st tags(2) values(now, 1) (now+1s, 2)')
|
||||
tdSql.execute(f'insert into t3 using st tags(3) values(now, 1) (now+1s, 2)')
|
||||
|
||||
tdSql.execute("create stream stream1 fill_history 1 into sta subtable(concat('new-', tname)) AS SELECT "
|
||||
"_wstart, count(*), avg(i) FROM st PARTITION BY tbname tname INTERVAL(1m)", show=True)
|
||||
|
||||
tdSql.execute("create stream stream2 fill_history 1 into stb subtable(concat('new-', tname)) AS SELECT "
|
||||
"_wstart, count(*), avg(i) FROM st PARTITION BY tbname tname INTERVAL(1m)", show=True)
|
||||
|
||||
time.sleep(2)
|
||||
tdSql.query("select * from sta")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.query("select tbname from sta order by tbname")
|
||||
if not tdSql.getData(0, 0).startswith('new-t1_1.d1.sta_'):
|
||||
tdLog.exit("error1")
|
||||
|
||||
if not tdSql.getData(1, 0).startswith('new-t2_1.d1.sta_'):
|
||||
tdLog.exit("error2")
|
||||
|
||||
if not tdSql.getData(2, 0).startswith('new-t3_1.d1.sta_'):
|
||||
tdLog.exit("error3")
|
||||
|
||||
tdSql.query("select * from stb")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.query("select tbname from stb order by tbname")
|
||||
if not tdSql.getData(0, 0).startswith('new-t1_1.d1.stb_'):
|
||||
tdLog.exit("error4")
|
||||
|
||||
if not tdSql.getData(1, 0).startswith('new-t2_1.d1.stb_'):
|
||||
tdLog.exit("error5")
|
||||
|
||||
if not tdSql.getData(2, 0).startswith('new-t3_1.d1.stb_'):
|
||||
tdLog.exit("error6")
|
||||
|
||||
# run
|
||||
def run(self):
|
||||
self.case1()
|
||||
# gen data
|
||||
random.seed(int(time.time()))
|
||||
self.taosBenchmark(" -d db -t 2 -v 2 -n 1000000 -y")
|
||||
# create stream
|
||||
tdSql.execute("use db")
|
||||
tdSql.execute("create stream stream1 fill_history 1 into sta as select count(*) as cnt from meters interval(10a);",show=True)
|
||||
tdSql.execute("create stream stream3 fill_history 1 into sta as select count(*) as cnt from meters interval(10a);",show=True)
|
||||
sql = "select count(*) from sta"
|
||||
# loop wait max 60s to check count is ok
|
||||
tdLog.info("loop wait result ...")
|
||||
|
|
|
@ -18,7 +18,7 @@ IF (TD_WEBSOCKET)
|
|||
COMMAND git clean -f -d
|
||||
BUILD_COMMAND
|
||||
COMMAND cargo update
|
||||
COMMAND RUSTFLAGS=-Ctarget-feature=-crt-static cargo build --release -p taos-ws-sys --features native-tls
|
||||
COMMAND RUSTFLAGS=-Ctarget-feature=-crt-static cargo build --release -p taos-ws-sys --features rustls
|
||||
INSTALL_COMMAND
|
||||
COMMAND cp target/release/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib
|
||||
COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include
|
||||
|
@ -37,7 +37,7 @@ IF (TD_WEBSOCKET)
|
|||
COMMAND git clean -f -d
|
||||
BUILD_COMMAND
|
||||
COMMAND cargo update
|
||||
COMMAND cargo build --release -p taos-ws-sys --features native-tls-vendored
|
||||
COMMAND cargo build --release -p taos-ws-sys --features rustls
|
||||
INSTALL_COMMAND
|
||||
COMMAND cp target/release/taosws.dll ${CMAKE_BINARY_DIR}/build/lib
|
||||
COMMAND cp target/release/taosws.dll.lib ${CMAKE_BINARY_DIR}/build/lib/taosws.lib
|
||||
|
@ -57,7 +57,7 @@ IF (TD_WEBSOCKET)
|
|||
COMMAND git clean -f -d
|
||||
BUILD_COMMAND
|
||||
COMMAND cargo update
|
||||
COMMAND cargo build --release -p taos-ws-sys --features native-tls-vendored
|
||||
COMMAND cargo build --release -p taos-ws-sys --features rustls
|
||||
INSTALL_COMMAND
|
||||
COMMAND cp target/release/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib
|
||||
COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include
|
||||
|
|
Loading…
Reference in New Issue