Merge branch '3.0' into fix/snodeBackendCrash
This commit is contained in:
commit
7ab7a64eb3
|
@ -11,6 +11,7 @@ CMakeSettings.json
|
||||||
cmake-build-debug/
|
cmake-build-debug/
|
||||||
cmake-build-release/
|
cmake-build-release/
|
||||||
cscope.out
|
cscope.out
|
||||||
|
cscope.files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
debug/
|
debug/
|
||||||
release/
|
release/
|
||||||
|
|
|
@ -41,6 +41,7 @@ add_subdirectory(source)
|
||||||
add_subdirectory(tools)
|
add_subdirectory(tools)
|
||||||
add_subdirectory(utils)
|
add_subdirectory(utils)
|
||||||
add_subdirectory(examples/c)
|
add_subdirectory(examples/c)
|
||||||
|
add_subdirectory(tests)
|
||||||
include(${TD_SUPPORT_DIR}/cmake.install)
|
include(${TD_SUPPORT_DIR}/cmake.install)
|
||||||
|
|
||||||
# docs
|
# docs
|
||||||
|
|
|
@ -181,17 +181,17 @@ ELSE ()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
MESSAGE(STATUS "SIMD instructions (FMA/AVX/AVX2) is ACTIVATED")
|
MESSAGE(STATUS "SIMD instructions (FMA/AVX/AVX2) is ACTIVATED")
|
||||||
|
|
||||||
IF (COMPILER_SUPPORT_AVX512F AND COMPILER_SUPPORT_AVX512BMI)
|
# IF (COMPILER_SUPPORT_AVX512F AND COMPILER_SUPPORT_AVX512BMI)
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx512f -mavx512vbmi")
|
# SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx512f -mavx512vbmi")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx512f -mavx512vbmi")
|
# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx512f -mavx512vbmi")
|
||||||
MESSAGE(STATUS "avx512f/avx512bmi supported by compiler")
|
# MESSAGE(STATUS "avx512f/avx512bmi supported by compiler")
|
||||||
ENDIF()
|
# ENDIF()
|
||||||
|
#
|
||||||
IF (COMPILER_SUPPORT_AVX512VL)
|
# IF (COMPILER_SUPPORT_AVX512VL)
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx512vl")
|
# SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx512vl")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx512vl")
|
# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx512vl")
|
||||||
MESSAGE(STATUS "avx512vl supported by compiler")
|
# MESSAGE(STATUS "avx512vl supported by compiler")
|
||||||
ENDIF()
|
# ENDIF()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# build mode
|
# build mode
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -177,7 +177,7 @@ Just need to add the reference to [TDengine.Connector](https://www.nuget.org/pac
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="TDengine.Connector" Version="3.0.0" />
|
<PackageReference Include="TDengine.Connector" Version="3.1.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
```csharp
|
|
||||||
{{#include docs/examples/csharp/asyncQuery/Program.cs}}
|
|
||||||
```
|
|
|
@ -15,7 +15,6 @@ import CQuery from "./_c.mdx";
|
||||||
import PhpQuery from "./_php.mdx";
|
import PhpQuery from "./_php.mdx";
|
||||||
import PyAsync from "./_py_async.mdx";
|
import PyAsync from "./_py_async.mdx";
|
||||||
import NodeAsync from "./_js_async.mdx";
|
import NodeAsync from "./_js_async.mdx";
|
||||||
import CsAsync from "./_cs_async.mdx";
|
|
||||||
import CAsync from "./_c_async.mdx";
|
import CAsync from "./_c_async.mdx";
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
@ -174,9 +173,6 @@ Please note that async query can only be used with a native connection.
|
||||||
<TabItem label="Python" value="python">
|
<TabItem label="Python" value="python">
|
||||||
<PyAsync />
|
<PyAsync />
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem label="C#" value="csharp">
|
|
||||||
<CsAsync />
|
|
||||||
</TabItem>
|
|
||||||
<TabItem label="C" value="c">
|
<TabItem label="C" value="c">
|
||||||
<CAsync />
|
<CAsync />
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
|
@ -248,23 +248,23 @@ function close()
|
||||||
<TabItem value="C#" label="C#">
|
<TabItem value="C#" label="C#">
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
|
class ConsumerBuilder<TValue>
|
||||||
|
|
||||||
ConsumerBuilder(IEnumerable<KeyValuePair<string, string>> config)
|
ConsumerBuilder(IEnumerable<KeyValuePair<string, string>> config)
|
||||||
|
|
||||||
virtual IConsumer Build()
|
public IConsumer<TValue> Build()
|
||||||
|
|
||||||
Consumer(ConsumerBuilder builder)
|
|
||||||
|
|
||||||
void Subscribe(IEnumerable<string> topics)
|
void Subscribe(IEnumerable<string> topics)
|
||||||
|
|
||||||
void Subscribe(string topic)
|
void Subscribe(string topic)
|
||||||
|
|
||||||
ConsumeResult Consume(int millisecondsTimeout)
|
ConsumeResult<TValue> Consume(int millisecondsTimeout)
|
||||||
|
|
||||||
List<string> Subscription()
|
List<string> Subscription()
|
||||||
|
|
||||||
void Unsubscribe()
|
void Unsubscribe()
|
||||||
|
|
||||||
void Commit(ConsumeResult consumerResult)
|
List<TopicPartitionOffset> Commit()
|
||||||
|
|
||||||
void Close()
|
void Close()
|
||||||
```
|
```
|
||||||
|
@ -500,25 +500,19 @@ let consumer = taos.consumer({
|
||||||
<TabItem value="C#" label="C#">
|
<TabItem value="C#" label="C#">
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
using TDengineTMQ;
|
var cfg = new Dictionary<string, string>()
|
||||||
|
{
|
||||||
// Create consumer groups on demand (GourpID) and enable automatic commits (EnableAutoCommit),
|
{ "group.id", "group1" },
|
||||||
// an automatic commit interval (AutoCommitIntervalMs), and a username (TDConnectUser) and password (TDConnectPasswd)
|
{ "auto.offset.reset", "latest" },
|
||||||
var cfg = new ConsumerConfig
|
{ "td.connect.ip", "127.0.0.1" },
|
||||||
{
|
{ "td.connect.user", "root" },
|
||||||
EnableAutoCommit = "true"
|
{ "td.connect.pass", "taosdata" },
|
||||||
AutoCommitIntervalMs = "1000"
|
{ "td.connect.port", "6030" },
|
||||||
GourpId = "TDengine-TMQ-C#",
|
{ "client.id", "tmq_example" },
|
||||||
TDConnectUser = "root",
|
{ "enable.auto.commit", "true" },
|
||||||
TDConnectPasswd = "taosdata",
|
{ "msg.with.table.name", "false" },
|
||||||
AutoOffsetReset = "latest"
|
};
|
||||||
MsgWithTableName = "true",
|
var consumer = new ConsumerBuilder<Dictionary<string, object>>(cfg).Build();
|
||||||
TDConnectIp = "127.0.0.1",
|
|
||||||
TDConnectPort = "6030"
|
|
||||||
};
|
|
||||||
|
|
||||||
var consumer = new ConsumerBuilder(cfg).Build();
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
@ -747,10 +741,12 @@ while(true){
|
||||||
## Consume data
|
## Consume data
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
var consumerRes = consumer.Consume(100);
|
using (var result = consumer.Consume(500))
|
||||||
// process ConsumeResult
|
{
|
||||||
ProcessMsg(consumerRes);
|
if (result == null) continue;
|
||||||
consumer.Commit(consumerRes);
|
ProcessMsg(result);
|
||||||
|
consumer.Commit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -262,6 +262,63 @@ The following types may be returned:
|
||||||
- "INT UNSIGNED"
|
- "INT UNSIGNED"
|
||||||
- "BIGINT UNSIGNED"
|
- "BIGINT UNSIGNED"
|
||||||
- "JSON"
|
- "JSON"
|
||||||
|
- "VARBINARY"
|
||||||
|
- "GEOMETRY"
|
||||||
|
|
||||||
|
`VARBINARY` and `GEOMETRY` types return data as Hex string, example:
|
||||||
|
|
||||||
|
Prepare data
|
||||||
|
|
||||||
|
```bash
|
||||||
|
create database demo
|
||||||
|
use demo
|
||||||
|
create table t(ts timestamp,c1 varbinary(20),c2 geometry(100))
|
||||||
|
insert into t values(now,'\x7f8290','point(100 100)')
|
||||||
|
```
|
||||||
|
|
||||||
|
Execute query
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --location 'http://<fqdn>:<port>/rest/sql' \
|
||||||
|
--header 'Content-Type: text/plain' \
|
||||||
|
--header 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' \
|
||||||
|
--data 'select * from demo.t'
|
||||||
|
```
|
||||||
|
|
||||||
|
Return results
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 0,
|
||||||
|
"column_meta": [
|
||||||
|
[
|
||||||
|
"ts",
|
||||||
|
"TIMESTAMP",
|
||||||
|
8
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"c1",
|
||||||
|
"VARBINARY",
|
||||||
|
20
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"c2",
|
||||||
|
"GEOMETRY",
|
||||||
|
100
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"data": [
|
||||||
|
[
|
||||||
|
"2023-11-01T06:28:15.210Z",
|
||||||
|
"7f8290",
|
||||||
|
"010100000000000000000059400000000000005940"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"rows": 1
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- `010100000000000000000059400000000000005940` is [Well-Known Binary (WKB)](https://libgeos.org/specifications/wkb/) format for `point(100 100)`
|
||||||
|
|
||||||
#### Errors
|
#### Errors
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
||||||
.vs
|
.vs
|
||||||
asyncQuery/bin
|
.idea
|
||||||
connect/bin
|
connect/bin
|
||||||
influxdbLine/bin
|
influxdbLine/bin
|
||||||
optsJSON/bin
|
optsJSON/bin
|
||||||
|
@ -12,7 +12,6 @@ wsConnect/bin
|
||||||
wsInsert/bin
|
wsInsert/bin
|
||||||
wsQuery/bin
|
wsQuery/bin
|
||||||
wsStmt/bin
|
wsStmt/bin
|
||||||
asyncQuery/obj
|
|
||||||
connect/obj
|
connect/obj
|
||||||
influxdbLine/obj
|
influxdbLine/obj
|
||||||
optsJSON/obj
|
optsJSON/obj
|
||||||
|
|
|
@ -1,111 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using TDengineDriver;
|
|
||||||
using TDengineDriver.Impl;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace TDengineExample
|
|
||||||
{
|
|
||||||
public class AsyncQueryExample
|
|
||||||
{
|
|
||||||
static void Main()
|
|
||||||
{
|
|
||||||
IntPtr conn = GetConnection();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
QueryAsyncCallback queryAsyncCallback = new QueryAsyncCallback(QueryCallback);
|
|
||||||
TDengine.QueryAsync(conn, "select * from meters", queryAsyncCallback, IntPtr.Zero);
|
|
||||||
Thread.Sleep(2000);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
TDengine.Close(conn);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static void QueryCallback(IntPtr param, IntPtr taosRes, int code)
|
|
||||||
{
|
|
||||||
if (code == 0 && taosRes != IntPtr.Zero)
|
|
||||||
{
|
|
||||||
FetchRawBlockAsyncCallback fetchRowAsyncCallback = new FetchRawBlockAsyncCallback(FetchRawBlockCallback);
|
|
||||||
TDengine.FetchRawBlockAsync(taosRes, fetchRowAsyncCallback, param);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception($"async query data failed,code:{code},reason:{TDengine.Error(taosRes)}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Iteratively call this interface until "numOfRows" is no greater than 0.
|
|
||||||
static void FetchRawBlockCallback(IntPtr param, IntPtr taosRes, int numOfRows)
|
|
||||||
{
|
|
||||||
if (numOfRows > 0)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"{numOfRows} rows async retrieved");
|
|
||||||
IntPtr pdata = TDengine.GetRawBlock(taosRes);
|
|
||||||
List<TDengineMeta> metaList = TDengine.FetchFields(taosRes);
|
|
||||||
List<object> dataList = LibTaos.ReadRawBlock(pdata, metaList, numOfRows);
|
|
||||||
|
|
||||||
for (int i = 0; i < dataList.Count; i++)
|
|
||||||
{
|
|
||||||
if (i != 0 && (i + 1) % metaList.Count == 0)
|
|
||||||
{
|
|
||||||
Console.WriteLine("{0}\t|", dataList[i]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.Write("{0}\t|", dataList[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Console.WriteLine("");
|
|
||||||
TDengine.FetchRawBlockAsync(taosRes, FetchRawBlockCallback, param);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (numOfRows == 0)
|
|
||||||
{
|
|
||||||
Console.WriteLine("async retrieve complete.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception($"FetchRawBlockCallback callback error, error code {numOfRows}");
|
|
||||||
}
|
|
||||||
TDengine.FreeResult(taosRes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static IntPtr GetConnection()
|
|
||||||
{
|
|
||||||
string host = "localhost";
|
|
||||||
short port = 6030;
|
|
||||||
string username = "root";
|
|
||||||
string password = "taosdata";
|
|
||||||
string dbname = "power";
|
|
||||||
var conn = TDengine.Connect(host, username, password, dbname, port);
|
|
||||||
if (conn == IntPtr.Zero)
|
|
||||||
{
|
|
||||||
throw new Exception("Connect to TDengine failed");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("Connect to TDengine success");
|
|
||||||
}
|
|
||||||
return conn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// //output:
|
|
||||||
// // Connect to TDengine success
|
|
||||||
// // 8 rows async retrieved
|
|
||||||
|
|
||||||
// // 1538548685500 | 11.8 | 221 | 0.28 | california.losangeles | 2 |
|
|
||||||
// // 1538548696600 | 13.4 | 223 | 0.29 | california.losangeles | 2 |
|
|
||||||
// // 1538548685000 | 10.8 | 223 | 0.29 | california.losangeles | 3 |
|
|
||||||
// // 1538548686500 | 11.5 | 221 | 0.35 | california.losangeles | 3 |
|
|
||||||
// // 1538548685000 | 10.3 | 219 | 0.31 | california.sanfrancisco | 2 |
|
|
||||||
// // 1538548695000 | 12.6 | 218 | 0.33 | california.sanfrancisco | 2 |
|
|
||||||
// // 1538548696800 | 12.3 | 221 | 0.31 | california.sanfrancisco | 2 |
|
|
||||||
// // 1538548696650 | 10.3 | 218 | 0.25 | california.sanfrancisco | 3 |
|
|
||||||
// // async retrieve complete.
|
|
|
@ -1,15 +0,0 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<StartupObject>TDengineExample.AsyncQueryExample</StartupObject>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="TDengine.Connector" Version="3.0.*" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
|
@ -1,4 +1,5 @@
|
||||||
using TDengineDriver;
|
using TDengine.Driver;
|
||||||
|
using TDengine.Driver.Client;
|
||||||
|
|
||||||
namespace TDengineExample
|
namespace TDengineExample
|
||||||
{
|
{
|
||||||
|
@ -7,23 +8,11 @@ namespace TDengineExample
|
||||||
{
|
{
|
||||||
static void Main(String[] args)
|
static void Main(String[] args)
|
||||||
{
|
{
|
||||||
string host = "localhost";
|
var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata");
|
||||||
short port = 6030;
|
using (var client = DbDriver.Open(builder))
|
||||||
string username = "root";
|
|
||||||
string password = "taosdata";
|
|
||||||
string dbname = "";
|
|
||||||
|
|
||||||
var conn = TDengine.Connect(host, username, password, dbname, port);
|
|
||||||
if (conn == IntPtr.Zero)
|
|
||||||
{
|
{
|
||||||
throw new Exception("Connect to TDengine failed");
|
Console.WriteLine("connected");
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("Connect to TDengine success");
|
|
||||||
}
|
|
||||||
TDengine.Close(conn);
|
|
||||||
TDengine.Cleanup();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="TDengine.Connector" Version="3.0.*" />
|
<PackageReference Include="TDengine.Connector" Version="3.1.*" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 16
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 16.0.30114.105
|
VisualStudioVersion = 16.0.30114.105
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "asyncquery", "asyncQuery\asyncquery.csproj", "{E2A5F00C-14E7-40E1-A2DE-6AB2975616D3}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "connect", "connect\connect.csproj", "{CCC5042D-93FC-4AE0-B2F6-7E692FD476B7}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "connect", "connect\connect.csproj", "{CCC5042D-93FC-4AE0-B2F6-7E692FD476B7}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "influxdbline", "influxdbLine\influxdbline.csproj", "{6A24FB80-1E3C-4E2D-A5AB-914FA583874D}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "influxdbline", "influxdbLine\influxdbline.csproj", "{6A24FB80-1E3C-4E2D-A5AB-914FA583874D}"
|
||||||
|
@ -38,10 +36,6 @@ Global
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{E2A5F00C-14E7-40E1-A2DE-6AB2975616D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{E2A5F00C-14E7-40E1-A2DE-6AB2975616D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{E2A5F00C-14E7-40E1-A2DE-6AB2975616D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{E2A5F00C-14E7-40E1-A2DE-6AB2975616D3}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{CCC5042D-93FC-4AE0-B2F6-7E692FD476B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{CCC5042D-93FC-4AE0-B2F6-7E692FD476B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{CCC5042D-93FC-4AE0-B2F6-7E692FD476B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{CCC5042D-93FC-4AE0-B2F6-7E692FD476B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{CCC5042D-93FC-4AE0-B2F6-7E692FD476B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{CCC5042D-93FC-4AE0-B2F6-7E692FD476B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using TDengineDriver;
|
using TDengine.Driver;
|
||||||
|
using TDengine.Driver.Client;
|
||||||
|
|
||||||
namespace TDengineExample
|
namespace TDengineExample
|
||||||
{
|
{
|
||||||
|
@ -6,60 +7,23 @@ namespace TDengineExample
|
||||||
{
|
{
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
IntPtr conn = GetConnection();
|
var builder =
|
||||||
PrepareDatabase(conn);
|
new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata");
|
||||||
string[] lines = {
|
using (var client = DbDriver.Open(builder))
|
||||||
"meters,location=California.LosAngeles,groupid=2 current=11.8,voltage=221,phase=0.28 1648432611249",
|
|
||||||
"meters,location=California.LosAngeles,groupid=2 current=13.4,voltage=223,phase=0.29 1648432611250",
|
|
||||||
"meters,location=California.LosAngeles,groupid=3 current=10.8,voltage=223,phase=0.29 1648432611249",
|
|
||||||
"meters,location=California.LosAngeles,groupid=3 current=11.3,voltage=221,phase=0.35 1648432611250"
|
|
||||||
};
|
|
||||||
IntPtr res = TDengine.SchemalessInsert(conn, lines, lines.Length, (int)TDengineSchemalessProtocol.TSDB_SML_LINE_PROTOCOL, (int)TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_MILLI_SECONDS);
|
|
||||||
if (TDengine.ErrorNo(res) != 0)
|
|
||||||
{
|
{
|
||||||
throw new Exception("SchemalessInsert failed since " + TDengine.Error(res));
|
client.Exec("CREATE DATABASE test WAL_RETENTION_PERIOD 3600");
|
||||||
}
|
client.Exec("use test");
|
||||||
else
|
string[] lines = {
|
||||||
{
|
"meters,location=California.LosAngeles,groupid=2 current=11.8,voltage=221,phase=0.28 1648432611249",
|
||||||
int affectedRows = TDengine.AffectRows(res);
|
"meters,location=California.LosAngeles,groupid=2 current=13.4,voltage=223,phase=0.29 1648432611250",
|
||||||
Console.WriteLine($"SchemalessInsert success, affected {affectedRows} rows");
|
"meters,location=California.LosAngeles,groupid=3 current=10.8,voltage=223,phase=0.29 1648432611249",
|
||||||
}
|
"meters,location=California.LosAngeles,groupid=3 current=11.3,voltage=221,phase=0.35 1648432611250"
|
||||||
TDengine.FreeResult(res);
|
};
|
||||||
|
client.SchemalessInsert(lines,
|
||||||
}
|
TDengineSchemalessProtocol.TSDB_SML_LINE_PROTOCOL,
|
||||||
static IntPtr GetConnection()
|
TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_MILLI_SECONDS, 0, ReqId.GetReqId());
|
||||||
{
|
|
||||||
string host = "localhost";
|
|
||||||
short port = 6030;
|
|
||||||
string username = "root";
|
|
||||||
string password = "taosdata";
|
|
||||||
string dbname = "";
|
|
||||||
var conn = TDengine.Connect(host, username, password, dbname, port);
|
|
||||||
if (conn == IntPtr.Zero)
|
|
||||||
{
|
|
||||||
throw new Exception("Connect to TDengine failed");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("Connect to TDengine success");
|
|
||||||
}
|
|
||||||
return conn;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void PrepareDatabase(IntPtr conn)
|
|
||||||
{
|
|
||||||
IntPtr res = TDengine.Query(conn, "CREATE DATABASE test WAL_RETENTION_PERIOD 3600");
|
|
||||||
if (TDengine.ErrorNo(res) != 0)
|
|
||||||
{
|
|
||||||
throw new Exception("failed to create database, reason: " + TDengine.Error(res));
|
|
||||||
}
|
|
||||||
res = TDengine.Query(conn, "USE test");
|
|
||||||
if (TDengine.ErrorNo(res) != 0)
|
|
||||||
{
|
|
||||||
throw new Exception("failed to change database, reason: " + TDengine.Error(res));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="TDengine.Connector" Version="3.0.*" />
|
<PackageReference Include="TDengine.Connector" Version="3.1.*" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,69 +1,28 @@
|
||||||
using TDengineDriver;
|
using TDengine.Driver;
|
||||||
|
using TDengine.Driver.Client;
|
||||||
|
|
||||||
namespace TDengineExample
|
namespace TDengineExample
|
||||||
{
|
{
|
||||||
internal class OptsJsonExample
|
internal class OptsJsonExample
|
||||||
{
|
{
|
||||||
static void Main()
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
IntPtr conn = GetConnection();
|
var builder =
|
||||||
try
|
new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata");
|
||||||
|
using (var client = DbDriver.Open(builder))
|
||||||
{
|
{
|
||||||
PrepareDatabase(conn);
|
client.Exec("CREATE DATABASE test WAL_RETENTION_PERIOD 3600");
|
||||||
string[] lines = { "[{\"metric\": \"meters.current\", \"timestamp\": 1648432611249, \"value\": 10.3, \"tags\": {\"location\": \"California.SanFrancisco\", \"groupid\": 2}}," +
|
client.Exec("use test");
|
||||||
" {\"metric\": \"meters.voltage\", \"timestamp\": 1648432611249, \"value\": 219, \"tags\": {\"location\": \"California.LosAngeles\", \"groupid\": 1}}, " +
|
string[] lines =
|
||||||
"{\"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}}]"
|
|
||||||
};
|
|
||||||
|
|
||||||
IntPtr res = TDengine.SchemalessInsert(conn, lines, 1, (int)TDengineSchemalessProtocol.TSDB_SML_JSON_PROTOCOL, (int)TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
|
|
||||||
if (TDengine.ErrorNo(res) != 0)
|
|
||||||
{
|
{
|
||||||
throw new Exception("SchemalessInsert failed since " + TDengine.Error(res));
|
"[{\"metric\": \"meters.current\", \"timestamp\": 1648432611249, \"value\": 10.3, \"tags\": {\"location\": \"California.SanFrancisco\", \"groupid\": 2}}," +
|
||||||
}
|
" {\"metric\": \"meters.voltage\", \"timestamp\": 1648432611249, \"value\": 219, \"tags\": {\"location\": \"California.LosAngeles\", \"groupid\": 1}}, " +
|
||||||
else
|
"{\"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}}]"
|
||||||
int affectedRows = TDengine.AffectRows(res);
|
};
|
||||||
Console.WriteLine($"SchemalessInsert success, affected {affectedRows} rows");
|
client.SchemalessInsert(lines, TDengineSchemalessProtocol.TSDB_SML_JSON_PROTOCOL,
|
||||||
}
|
TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_MILLI_SECONDS, 0, ReqId.GetReqId());
|
||||||
TDengine.FreeResult(res);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
TDengine.Close(conn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static IntPtr GetConnection()
|
|
||||||
{
|
|
||||||
string host = "localhost";
|
|
||||||
short port = 6030;
|
|
||||||
string username = "root";
|
|
||||||
string password = "taosdata";
|
|
||||||
string dbname = "";
|
|
||||||
var conn = TDengine.Connect(host, username, password, dbname, port);
|
|
||||||
if (conn == IntPtr.Zero)
|
|
||||||
{
|
|
||||||
throw new Exception("Connect to TDengine failed");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("Connect to TDengine success");
|
|
||||||
}
|
|
||||||
return conn;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void PrepareDatabase(IntPtr conn)
|
|
||||||
{
|
|
||||||
IntPtr res = TDengine.Query(conn, "CREATE DATABASE test WAL_RETENTION_PERIOD 3600");
|
|
||||||
if (TDengine.ErrorNo(res) != 0)
|
|
||||||
{
|
|
||||||
throw new Exception("failed to create database, reason: " + TDengine.Error(res));
|
|
||||||
}
|
|
||||||
res = TDengine.Query(conn, "USE test");
|
|
||||||
if (TDengine.ErrorNo(res) != 0)
|
|
||||||
{
|
|
||||||
throw new Exception("failed to change database, reason: " + TDengine.Error(res));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,7 +9,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="TDengine.Connector" Version="3.0.*" />
|
<PackageReference Include="TDengine.Connector" Version="3.1.*" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,72 +1,31 @@
|
||||||
using TDengineDriver;
|
using TDengine.Driver;
|
||||||
|
using TDengine.Driver.Client;
|
||||||
|
|
||||||
namespace TDengineExample
|
namespace TDengineExample
|
||||||
{
|
{
|
||||||
internal class OptsTelnetExample
|
internal class OptsTelnetExample
|
||||||
{
|
{
|
||||||
static void Main()
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
IntPtr conn = GetConnection();
|
var builder =
|
||||||
try
|
new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata");
|
||||||
|
using (var client = DbDriver.Open(builder))
|
||||||
{
|
{
|
||||||
PrepareDatabase(conn);
|
client.Exec("CREATE DATABASE test WAL_RETENTION_PERIOD 3600");
|
||||||
|
client.Exec("USE test");
|
||||||
string[] lines = {
|
string[] lines = {
|
||||||
"meters.current 1648432611249 10.3 location=California.SanFrancisco groupid=2",
|
"meters.current 1648432611249 10.3 location=California.SanFrancisco groupid=2",
|
||||||
"meters.current 1648432611250 12.6 location=California.SanFrancisco groupid=2",
|
"meters.current 1648432611250 12.6 location=California.SanFrancisco groupid=2",
|
||||||
"meters.current 1648432611249 10.8 location=California.LosAngeles groupid=3",
|
"meters.current 1648432611249 10.8 location=California.LosAngeles groupid=3",
|
||||||
"meters.current 1648432611250 11.3 location=California.LosAngeles groupid=3",
|
"meters.current 1648432611250 11.3 location=California.LosAngeles groupid=3",
|
||||||
"meters.voltage 1648432611249 219 location=California.SanFrancisco groupid=2",
|
"meters.voltage 1648432611249 219 location=California.SanFrancisco groupid=2",
|
||||||
"meters.voltage 1648432611250 218 location=California.SanFrancisco groupid=2",
|
"meters.voltage 1648432611250 218 location=California.SanFrancisco groupid=2",
|
||||||
"meters.voltage 1648432611249 221 location=California.LosAngeles groupid=3",
|
"meters.voltage 1648432611249 221 location=California.LosAngeles groupid=3",
|
||||||
"meters.voltage 1648432611250 217 location=California.LosAngeles groupid=3",
|
"meters.voltage 1648432611250 217 location=California.LosAngeles groupid=3",
|
||||||
};
|
};
|
||||||
IntPtr res = TDengine.SchemalessInsert(conn, lines, lines.Length, (int)TDengineSchemalessProtocol.TSDB_SML_TELNET_PROTOCOL, (int)TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
|
client.SchemalessInsert(lines,
|
||||||
if (TDengine.ErrorNo(res) != 0)
|
TDengineSchemalessProtocol.TSDB_SML_TELNET_PROTOCOL,
|
||||||
{
|
TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_MILLI_SECONDS, 0, ReqId.GetReqId());
|
||||||
throw new Exception("SchemalessInsert failed since " + TDengine.Error(res));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int affectedRows = TDengine.AffectRows(res);
|
|
||||||
Console.WriteLine($"SchemalessInsert success, affected {affectedRows} rows");
|
|
||||||
}
|
|
||||||
TDengine.FreeResult(res);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
TDengine.Close(conn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static IntPtr GetConnection()
|
|
||||||
{
|
|
||||||
string host = "localhost";
|
|
||||||
short port = 6030;
|
|
||||||
string username = "root";
|
|
||||||
string password = "taosdata";
|
|
||||||
string dbname = "";
|
|
||||||
var conn = TDengine.Connect(host, username, password, dbname, port);
|
|
||||||
if (conn == IntPtr.Zero)
|
|
||||||
{
|
|
||||||
throw new Exception("Connect to TDengine failed");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("Connect to TDengine success");
|
|
||||||
}
|
|
||||||
return conn;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void PrepareDatabase(IntPtr conn)
|
|
||||||
{
|
|
||||||
IntPtr res = TDengine.Query(conn, "CREATE DATABASE test WAL_RETENTION_PERIOD 3600");
|
|
||||||
if (TDengine.ErrorNo(res) != 0)
|
|
||||||
{
|
|
||||||
throw new Exception("failed to create database, reason: " + TDengine.Error(res));
|
|
||||||
}
|
|
||||||
res = TDengine.Query(conn, "USE test");
|
|
||||||
if (TDengine.ErrorNo(res) != 0)
|
|
||||||
{
|
|
||||||
throw new Exception("failed to change database, reason: " + TDengine.Error(res));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="TDengine.Connector" Version="3.0.*" />
|
<PackageReference Include="TDengine.Connector" Version="3.1.*" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,80 +1,35 @@
|
||||||
using TDengineDriver;
|
using System.Text;
|
||||||
using TDengineDriver.Impl;
|
using TDengine.Driver;
|
||||||
using System.Runtime.InteropServices;
|
using TDengine.Driver.Client;
|
||||||
|
|
||||||
namespace TDengineExample
|
namespace TDengineExample
|
||||||
{
|
{
|
||||||
internal class QueryExample
|
internal class QueryExample
|
||||||
{
|
{
|
||||||
static void Main()
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
IntPtr conn = GetConnection();
|
var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata");
|
||||||
try
|
using (var client = DbDriver.Open(builder))
|
||||||
{
|
{
|
||||||
// run query
|
try
|
||||||
IntPtr res = TDengine.Query(conn, "SELECT * FROM meters LIMIT 2");
|
|
||||||
if (TDengine.ErrorNo(res) != 0)
|
|
||||||
{
|
{
|
||||||
throw new Exception("Failed to query since: " + TDengine.Error(res));
|
client.Exec("use power");
|
||||||
}
|
string query = "SELECT * FROM meters";
|
||||||
|
using (var rows = client.Query(query))
|
||||||
// get filed count
|
|
||||||
int fieldCount = TDengine.FieldCount(res);
|
|
||||||
Console.WriteLine("fieldCount=" + fieldCount);
|
|
||||||
|
|
||||||
// print column names
|
|
||||||
List<TDengineMeta> metas = LibTaos.GetMeta(res);
|
|
||||||
for (int i = 0; i < metas.Count; i++)
|
|
||||||
{
|
|
||||||
Console.Write(metas[i].name + "\t");
|
|
||||||
}
|
|
||||||
Console.WriteLine();
|
|
||||||
|
|
||||||
// print values
|
|
||||||
List<Object> resData = LibTaos.GetData(res);
|
|
||||||
for (int i = 0; i < resData.Count; i++)
|
|
||||||
{
|
|
||||||
Console.Write($"|{resData[i].ToString()} \t");
|
|
||||||
if (((i + 1) % metas.Count == 0))
|
|
||||||
{
|
{
|
||||||
Console.WriteLine("");
|
while (rows.Read())
|
||||||
|
{
|
||||||
|
Console.WriteLine(
|
||||||
|
$"{((DateTime)rows.GetValue(0)):yyyy-MM-dd HH:mm:ss.fff}, {rows.GetValue(1)}, {rows.GetValue(2)}, {rows.GetValue(3)}, {rows.GetValue(4)}, {Encoding.UTF8.GetString((byte[])rows.GetValue(5))}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Console.WriteLine();
|
catch (Exception e)
|
||||||
|
{
|
||||||
// Free result after use
|
Console.WriteLine(e.ToString());
|
||||||
TDengine.FreeResult(res);
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
TDengine.Close(conn);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
static IntPtr GetConnection()
|
|
||||||
{
|
|
||||||
string host = "localhost";
|
|
||||||
short port = 6030;
|
|
||||||
string username = "root";
|
|
||||||
string password = "taosdata";
|
|
||||||
string dbname = "power";
|
|
||||||
var conn = TDengine.Connect(host, username, password, dbname, port);
|
|
||||||
if (conn == IntPtr.Zero)
|
|
||||||
{
|
|
||||||
throw new Exception("Connect to TDengine failed");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("Connect to TDengine success");
|
|
||||||
}
|
|
||||||
return conn;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// output:
|
|
||||||
// Connect to TDengine success
|
|
||||||
// fieldCount=6
|
|
||||||
// ts current voltage phase location groupid
|
|
||||||
// 1648432611249 10.3 219 0.31 California.SanFrancisco 2
|
|
||||||
// 1648432611749 12.6 218 0.33 California.SanFrancisco 2
|
|
|
@ -9,7 +9,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="TDengine.Connector" Version="3.0.*" />
|
<PackageReference Include="TDengine.Connector" Version="3.1.*" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,69 +1,47 @@
|
||||||
using TDengineDriver;
|
using System.Text;
|
||||||
|
using TDengine.Driver;
|
||||||
|
using TDengine.Driver.Client;
|
||||||
|
|
||||||
namespace TDengineExample
|
namespace TDengineExample
|
||||||
{
|
{
|
||||||
internal class SQLInsertExample
|
internal class SQLInsertExample
|
||||||
{
|
{
|
||||||
|
|
||||||
static void Main()
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
IntPtr conn = GetConnection();
|
var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata");
|
||||||
try
|
using (var client = DbDriver.Open(builder))
|
||||||
{
|
{
|
||||||
IntPtr res = TDengine.Query(conn, "CREATE DATABASE power WAL_RETENTION_PERIOD 3600");
|
try
|
||||||
CheckRes(conn, res, "failed to create database");
|
{
|
||||||
res = TDengine.Query(conn, "USE power");
|
client.Exec("create database power");
|
||||||
CheckRes(conn, res, "failed to change database");
|
client.Exec("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))");
|
||||||
res = TDengine.Query(conn, "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)");
|
string insertQuery =
|
||||||
CheckRes(conn, res, "failed to create stable");
|
"INSERT INTO " +
|
||||||
var sql = "INSERT INTO d1001 USING meters TAGS('California.SanFrancisco', 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000) " +
|
"power.d1001 USING power.meters TAGS(2,'California.SanFrancisco') " +
|
||||||
"d1002 USING power.meters TAGS('California.SanFrancisco', 3) VALUES('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000) " +
|
"VALUES " +
|
||||||
"d1003 USING power.meters TAGS('California.LosAngeles', 2) VALUES('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000)('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000) " +
|
"('2023-10-03 14:38:05.000', 10.30000, 219, 0.31000) " +
|
||||||
"d1004 USING power.meters TAGS('California.LosAngeles', 3) VALUES('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000)('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)";
|
"('2023-10-03 14:38:15.000', 12.60000, 218, 0.33000) " +
|
||||||
res = TDengine.Query(conn, sql);
|
"('2023-10-03 14:38:16.800', 12.30000, 221, 0.31000) " +
|
||||||
CheckRes(conn, res, "failed to insert data");
|
"power.d1002 USING power.meters TAGS(3, 'California.SanFrancisco') " +
|
||||||
int affectedRows = TDengine.AffectRows(res);
|
"VALUES " +
|
||||||
Console.WriteLine("affectedRows " + affectedRows);
|
"('2023-10-03 14:38:16.650', 10.30000, 218, 0.25000) " +
|
||||||
TDengine.FreeResult(res);
|
"power.d1003 USING power.meters TAGS(2,'California.LosAngeles') " +
|
||||||
}
|
"VALUES " +
|
||||||
finally
|
"('2023-10-03 14:38:05.500', 11.80000, 221, 0.28000) " +
|
||||||
{
|
"('2023-10-03 14:38:16.600', 13.40000, 223, 0.29000) " +
|
||||||
TDengine.Close(conn);
|
"power.d1004 USING power.meters TAGS(3,'California.LosAngeles') " +
|
||||||
}
|
"VALUES " +
|
||||||
|
"('2023-10-03 14:38:05.000', 10.80000, 223, 0.29000) " +
|
||||||
}
|
"('2023-10-03 14:38:06.500', 11.50000, 221, 0.35000)";
|
||||||
|
client.Exec(insertQuery);
|
||||||
static IntPtr GetConnection()
|
}
|
||||||
{
|
catch (Exception e)
|
||||||
string host = "localhost";
|
{
|
||||||
short port = 6030;
|
Console.WriteLine(e.ToString());
|
||||||
string username = "root";
|
throw;
|
||||||
string password = "taosdata";
|
}
|
||||||
string dbname = "";
|
|
||||||
var conn = TDengine.Connect(host, username, password, dbname, port);
|
|
||||||
if (conn == IntPtr.Zero)
|
|
||||||
{
|
|
||||||
throw new Exception("Connect to TDengine failed");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("Connect to TDengine success");
|
|
||||||
}
|
|
||||||
return conn;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void CheckRes(IntPtr conn, IntPtr res, String errorMsg)
|
|
||||||
{
|
|
||||||
if (TDengine.ErrorNo(res) != 0)
|
|
||||||
{
|
|
||||||
throw new Exception($"{errorMsg} since: {TDengine.Error(res)}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// output:
|
|
||||||
// Connect to TDengine success
|
|
||||||
// affectedRows 8
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="TDengine.Connector" Version="3.0.*" />
|
<PackageReference Include="TDengine.Connector" Version="3.1.*" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,109 +1,38 @@
|
||||||
using TDengineDriver;
|
using TDengine.Driver;
|
||||||
|
using TDengine.Driver.Client;
|
||||||
|
|
||||||
namespace TDengineExample
|
namespace TDengineExample
|
||||||
{
|
{
|
||||||
internal class StmtInsertExample
|
internal class StmtInsertExample
|
||||||
{
|
{
|
||||||
private static IntPtr conn;
|
public static void Main(string[] args)
|
||||||
private static IntPtr stmt;
|
|
||||||
static void Main()
|
|
||||||
{
|
{
|
||||||
conn = GetConnection();
|
var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata");
|
||||||
try
|
using (var client = DbDriver.Open(builder))
|
||||||
{
|
{
|
||||||
PrepareSTable();
|
try
|
||||||
// 1. init and prepare
|
|
||||||
stmt = TDengine.StmtInit(conn);
|
|
||||||
if (stmt == IntPtr.Zero)
|
|
||||||
{
|
{
|
||||||
throw new Exception("failed to init stmt.");
|
client.Exec($"create database power");
|
||||||
|
client.Exec(
|
||||||
|
"CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))");
|
||||||
|
using (var stmt = client.StmtInit())
|
||||||
|
{
|
||||||
|
stmt.Prepare(
|
||||||
|
"Insert into power.d1001 using power.meters tags(2,'California.SanFrancisco') values(?,?,?,?)");
|
||||||
|
var ts = new DateTime(2023, 10, 03, 14, 38, 05, 000);
|
||||||
|
stmt.BindRow(new object[] { ts, (float)10.30000, (int)219, (float)0.31000 });
|
||||||
|
stmt.AddBatch();
|
||||||
|
stmt.Exec();
|
||||||
|
var affected = stmt.Affected();
|
||||||
|
Console.WriteLine($"affected rows: {affected}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
int res = TDengine.StmtPrepare(stmt, "INSERT INTO ? USING meters TAGS(?, ?) VALUES(?, ?, ?, ?)");
|
catch (Exception e)
|
||||||
CheckStmtRes(res, "failed to prepare stmt");
|
|
||||||
|
|
||||||
// 2. bind table name and tags
|
|
||||||
TAOS_MULTI_BIND[] tags = new TAOS_MULTI_BIND[2] { TaosMultiBind.MultiBindBinary(new string[] { "California.SanFrancisco" }), TaosMultiBind.MultiBindInt(new int?[] { 2 }) };
|
|
||||||
res = TDengine.StmtSetTbnameTags(stmt, "d1001", tags);
|
|
||||||
CheckStmtRes(res, "failed to bind table name and tags");
|
|
||||||
|
|
||||||
// 3. bind values
|
|
||||||
TAOS_MULTI_BIND[] values = new TAOS_MULTI_BIND[4] {
|
|
||||||
TaosMultiBind.MultiBindTimestamp(new long[2] { 1648432611249, 1648432611749}),
|
|
||||||
TaosMultiBind.MultiBindFloat(new float?[2] { 10.3f, 12.6f}),
|
|
||||||
TaosMultiBind.MultiBindInt(new int?[2] { 219, 218}),
|
|
||||||
TaosMultiBind.MultiBindFloat(new float?[2]{ 0.31f, 0.33f})
|
|
||||||
};
|
|
||||||
res = TDengine.StmtBindParamBatch(stmt, values);
|
|
||||||
CheckStmtRes(res, "failed to bind params");
|
|
||||||
|
|
||||||
// 4. add batch
|
|
||||||
res = TDengine.StmtAddBatch(stmt);
|
|
||||||
CheckStmtRes(res, "failed to add batch");
|
|
||||||
|
|
||||||
// 5. execute
|
|
||||||
res = TDengine.StmtExecute(stmt);
|
|
||||||
CheckStmtRes(res, "failed to execute");
|
|
||||||
|
|
||||||
// 6. free
|
|
||||||
TaosMultiBind.FreeTaosBind(tags);
|
|
||||||
TaosMultiBind.FreeTaosBind(values);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
TDengine.Close(conn);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static IntPtr GetConnection()
|
|
||||||
{
|
|
||||||
string host = "localhost";
|
|
||||||
short port = 6030;
|
|
||||||
string username = "root";
|
|
||||||
string password = "taosdata";
|
|
||||||
string dbname = "";
|
|
||||||
var conn = TDengine.Connect(host, username, password, dbname, port);
|
|
||||||
if (conn == IntPtr.Zero)
|
|
||||||
{
|
|
||||||
throw new Exception("Connect to TDengine failed");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("Connect to TDengine success");
|
|
||||||
}
|
|
||||||
return conn;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void PrepareSTable()
|
|
||||||
{
|
|
||||||
IntPtr res = TDengine.Query(conn, "CREATE DATABASE power WAL_RETENTION_PERIOD 3600");
|
|
||||||
CheckResPtr(res, "failed to create database");
|
|
||||||
res = TDengine.Query(conn, "USE power");
|
|
||||||
CheckResPtr(res, "failed to change database");
|
|
||||||
res = TDengine.Query(conn, "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)");
|
|
||||||
CheckResPtr(res, "failed to create stable");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void CheckStmtRes(int res, string errorMsg)
|
|
||||||
{
|
|
||||||
if (res != 0)
|
|
||||||
{
|
|
||||||
Console.WriteLine(errorMsg + ", " + TDengine.StmtErrorStr(stmt));
|
|
||||||
int code = TDengine.StmtClose(stmt);
|
|
||||||
if (code != 0)
|
|
||||||
{
|
{
|
||||||
throw new Exception($"failed to close stmt, {code} reason: {TDengine.StmtErrorStr(stmt)} ");
|
Console.WriteLine(e);
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CheckResPtr(IntPtr res, string errorMsg)
|
|
||||||
{
|
|
||||||
if (TDengine.ErrorNo(res) != 0)
|
|
||||||
{
|
|
||||||
throw new Exception(errorMsg + " since:" + TDengine.Error(res));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,7 +9,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="TDengine.Connector" Version="3.0.*" />
|
<PackageReference Include="TDengine.Connector" Version="3.1.*" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,95 +1,72 @@
|
||||||
using System;
|
|
||||||
using TDengineTMQ;
|
using TDengine.Driver;
|
||||||
using TDengineDriver;
|
using TDengine.Driver.Client;
|
||||||
using System.Runtime.InteropServices;
|
using TDengine.TMQ;
|
||||||
|
|
||||||
namespace TMQExample
|
namespace TMQExample
|
||||||
{
|
{
|
||||||
internal class SubscribeDemo
|
internal class SubscribeDemo
|
||||||
{
|
{
|
||||||
static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
IntPtr conn = GetConnection();
|
var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata");
|
||||||
string topic = "topic_example";
|
using (var client = DbDriver.Open(builder))
|
||||||
//create topic
|
|
||||||
IntPtr res = TDengine.Query(conn, $"create topic if not exists {topic} as select * from meters");
|
|
||||||
|
|
||||||
if (TDengine.ErrorNo(res) != 0 )
|
|
||||||
{
|
{
|
||||||
throw new Exception($"create topic failed, reason:{TDengine.Error(res)}");
|
try
|
||||||
}
|
|
||||||
|
|
||||||
var cfg = new ConsumerConfig
|
|
||||||
{
|
|
||||||
GourpId = "group_1",
|
|
||||||
TDConnectUser = "root",
|
|
||||||
TDConnectPasswd = "taosdata",
|
|
||||||
MsgWithTableName = "true",
|
|
||||||
TDConnectIp = "127.0.0.1",
|
|
||||||
};
|
|
||||||
|
|
||||||
// create consumer
|
|
||||||
var consumer = new ConsumerBuilder(cfg)
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
// subscribe
|
|
||||||
consumer.Subscribe(topic);
|
|
||||||
|
|
||||||
// consume
|
|
||||||
for (int i = 0; i < 5; i++)
|
|
||||||
{
|
|
||||||
var consumeRes = consumer.Consume(300);
|
|
||||||
// print consumeResult
|
|
||||||
foreach (KeyValuePair<TopicPartition, TaosResult> kv in consumeRes.Message)
|
|
||||||
{
|
{
|
||||||
Console.WriteLine("topic partitions:\n{0}", kv.Key.ToString());
|
client.Exec("CREATE DATABASE power");
|
||||||
|
client.Exec("USE power");
|
||||||
kv.Value.Metas.ForEach(meta =>
|
client.Exec(
|
||||||
|
"CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))");
|
||||||
|
client.Exec("CREATE TOPIC topic_meters as SELECT * from power.meters");
|
||||||
|
var cfg = new Dictionary<string, string>()
|
||||||
{
|
{
|
||||||
Console.Write("{0} {1}({2}) \t|", meta.name, meta.TypeName(), meta.size);
|
{ "group.id", "group1" },
|
||||||
});
|
{ "auto.offset.reset", "latest" },
|
||||||
Console.WriteLine("");
|
{ "td.connect.ip", "127.0.0.1" },
|
||||||
kv.Value.Datas.ForEach(data =>
|
{ "td.connect.user", "root" },
|
||||||
|
{ "td.connect.pass", "taosdata" },
|
||||||
|
{ "td.connect.port", "6030" },
|
||||||
|
{ "client.id", "tmq_example" },
|
||||||
|
{ "enable.auto.commit", "true" },
|
||||||
|
{ "msg.with.table.name", "false" },
|
||||||
|
};
|
||||||
|
var consumer = new ConsumerBuilder<Dictionary<string, object>>(cfg).Build();
|
||||||
|
consumer.Subscribe(new List<string>() { "topic_meters" });
|
||||||
|
Task.Run(InsertData);
|
||||||
|
while (true)
|
||||||
{
|
{
|
||||||
Console.WriteLine(data.ToString());
|
using (var cr = consumer.Consume(500))
|
||||||
});
|
{
|
||||||
|
if (cr == null) continue;
|
||||||
|
foreach (var message in cr.Message)
|
||||||
|
{
|
||||||
|
Console.WriteLine(
|
||||||
|
$"message {{{((DateTime)message.Value["ts"]).ToString("yyyy-MM-dd HH:mm:ss.fff")}, " +
|
||||||
|
$"{message.Value["current"]}, {message.Value["voltage"]}, {message.Value["phase"]}}}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
consumer.Commit(consumeRes);
|
|
||||||
Console.WriteLine("\n================ {0} done ", i);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// retrieve topic list
|
|
||||||
List<string> topics = consumer.Subscription();
|
|
||||||
topics.ForEach(t => Console.WriteLine("topic name:{0}", t));
|
|
||||||
|
|
||||||
// unsubscribe
|
|
||||||
consumer.Unsubscribe();
|
|
||||||
|
|
||||||
// close consumer after use.Otherwise will lead memory leak.
|
|
||||||
consumer.Close();
|
|
||||||
TDengine.Close(conn);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static IntPtr GetConnection()
|
static void InsertData()
|
||||||
{
|
{
|
||||||
string host = "localhost";
|
var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata");
|
||||||
short port = 6030;
|
using (var client = DbDriver.Open(builder))
|
||||||
string username = "root";
|
|
||||||
string password = "taosdata";
|
|
||||||
string dbname = "power";
|
|
||||||
var conn = TDengine.Connect(host, username, password, dbname, port);
|
|
||||||
if (conn == IntPtr.Zero)
|
|
||||||
{
|
{
|
||||||
throw new Exception("Connect to TDengine failed");
|
while (true)
|
||||||
|
{
|
||||||
|
client.Exec("INSERT into power.d1001 using power.meters tags(2,'California.SanFrancisco') values(now,11.5,219,0.30)");
|
||||||
|
Task.Delay(1000).Wait();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("Connect to TDengine success");
|
|
||||||
}
|
|
||||||
return conn;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="TDengine.Connector" Version="3.0.*" />
|
<PackageReference Include="TDengine.Connector" Version="3.1.*" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,28 +1,18 @@
|
||||||
using System;
|
using System;
|
||||||
using TDengineWS.Impl;
|
using TDengine.Driver;
|
||||||
|
using TDengine.Driver.Client;
|
||||||
|
|
||||||
namespace Examples
|
namespace Examples
|
||||||
{
|
{
|
||||||
public class WSConnExample
|
public class WSConnExample
|
||||||
{
|
{
|
||||||
static int Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
string DSN = "ws://root:taosdata@127.0.0.1:6041/test";
|
var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata");
|
||||||
IntPtr wsConn = LibTaosWS.WSConnectWithDSN(DSN);
|
using (var client = DbDriver.Open(builder))
|
||||||
|
|
||||||
if (wsConn == IntPtr.Zero)
|
|
||||||
{
|
{
|
||||||
Console.WriteLine("get WS connection failed");
|
Console.WriteLine("connected");
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("Establish connect success.");
|
|
||||||
// close connection.
|
|
||||||
LibTaosWS.WSClose(wsConn);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="TDengine.Connector" Version="3.0.*" GeneratePathProperty="true" />
|
<PackageReference Include="TDengine.Connector" Version="3.1.*" GeneratePathProperty="true" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Target Name="copyDLLDependency" BeforeTargets="BeforeBuild">
|
<Target Name="copyDLLDependency" BeforeTargets="BeforeBuild">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -1,61 +1,46 @@
|
||||||
using System;
|
using System;
|
||||||
using TDengineWS.Impl;
|
using TDengine.Driver;
|
||||||
|
using TDengine.Driver.Client;
|
||||||
|
|
||||||
namespace Examples
|
namespace Examples
|
||||||
{
|
{
|
||||||
public class WSInsertExample
|
public class WSInsertExample
|
||||||
{
|
{
|
||||||
static int Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
string DSN = "ws://root:taosdata@127.0.0.1:6041/test";
|
var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata");
|
||||||
IntPtr wsConn = LibTaosWS.WSConnectWithDSN(DSN);
|
using (var client = DbDriver.Open(builder))
|
||||||
|
|
||||||
// Assert if connection is validate
|
|
||||||
if (wsConn == IntPtr.Zero)
|
|
||||||
{
|
{
|
||||||
Console.WriteLine("get WS connection failed");
|
try
|
||||||
return -1;
|
{
|
||||||
}
|
client.Exec("create database power");
|
||||||
else
|
client.Exec("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))");
|
||||||
{
|
string insertQuery =
|
||||||
Console.WriteLine("Establish connect success.");
|
"INSERT INTO " +
|
||||||
}
|
"power.d1001 USING power.meters TAGS(2,'California.SanFrancisco') " +
|
||||||
|
"VALUES " +
|
||||||
string createTable = "CREATE STABLE test.meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int);";
|
"('2023-10-03 14:38:05.000', 10.30000, 219, 0.31000) " +
|
||||||
string insert = "INSERT INTO test.d1001 USING test.meters TAGS('California.SanFrancisco', 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000)" +
|
"('2023-10-03 14:38:15.000', 12.60000, 218, 0.33000) " +
|
||||||
"test.d1002 USING test.meters TAGS('California.SanFrancisco', 3) VALUES('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000)" +
|
"('2023-10-03 14:38:16.800', 12.30000, 221, 0.31000) " +
|
||||||
"test.d1003 USING test.meters TAGS('California.LosAngeles', 2) VALUES('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000)('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000) " +
|
"power.d1002 USING power.meters TAGS(3, 'California.SanFrancisco') " +
|
||||||
"test.d1004 USING test.meters TAGS('California.LosAngeles', 3) VALUES('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000)('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)";
|
"VALUES " +
|
||||||
|
"('2023-10-03 14:38:16.650', 10.30000, 218, 0.25000) " +
|
||||||
IntPtr wsRes = LibTaosWS.WSQuery(wsConn, createTable);
|
"power.d1003 USING power.meters TAGS(2,'California.LosAngeles') " +
|
||||||
ValidInsert("create table", wsRes);
|
"VALUES " +
|
||||||
LibTaosWS.WSFreeResult(wsRes);
|
"('2023-10-03 14:38:05.500', 11.80000, 221, 0.28000) " +
|
||||||
|
"('2023-10-03 14:38:16.600', 13.40000, 223, 0.29000) " +
|
||||||
wsRes = LibTaosWS.WSQuery(wsConn, insert);
|
"power.d1004 USING power.meters TAGS(3,'California.LosAngeles') " +
|
||||||
ValidInsert("insert data", wsRes);
|
"VALUES " +
|
||||||
LibTaosWS.WSFreeResult(wsRes);
|
"('2023-10-03 14:38:05.000', 10.80000, 223, 0.29000) " +
|
||||||
|
"('2023-10-03 14:38:06.500', 11.50000, 221, 0.35000)";
|
||||||
// close connection.
|
client.Exec(insertQuery);
|
||||||
LibTaosWS.WSClose(wsConn);
|
}
|
||||||
|
catch (Exception e)
|
||||||
return 0;
|
{
|
||||||
}
|
Console.WriteLine(e.ToString());
|
||||||
|
throw;
|
||||||
static void ValidInsert(string desc, IntPtr wsRes)
|
}
|
||||||
{
|
|
||||||
int code = LibTaosWS.WSErrorNo(wsRes);
|
|
||||||
if (code != 0)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"execute SQL failed: reason: {LibTaosWS.WSErrorStr(wsRes)}, code:{code}");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("{0} success affect {2} rows, cost {1} nanoseconds", desc, LibTaosWS.WSTakeTiming(wsRes), LibTaosWS.WSAffectRows(wsRes));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// Establish connect success.
|
|
||||||
// create table success affect 0 rows, cost 3717542 nanoseconds
|
|
||||||
// insert data success affect 8 rows, cost 2613637 nanoseconds
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="TDengine.Connector" Version="3.0.*" GeneratePathProperty="true" />
|
<PackageReference Include="TDengine.Connector" Version="3.1.*" GeneratePathProperty="true" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Target Name="copyDLLDependency" BeforeTargets="BeforeBuild">
|
<Target Name="copyDLLDependency" BeforeTargets="BeforeBuild">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -1,79 +1,36 @@
|
||||||
using System;
|
using System;
|
||||||
using TDengineWS.Impl;
|
using System.Text;
|
||||||
using System.Collections.Generic;
|
using TDengine.Driver;
|
||||||
using TDengineDriver;
|
using TDengine.Driver.Client;
|
||||||
|
|
||||||
namespace Examples
|
namespace Examples
|
||||||
{
|
{
|
||||||
public class WSQueryExample
|
public class WSQueryExample
|
||||||
{
|
{
|
||||||
static int Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
string DSN = "ws://root:taosdata@127.0.0.1:6041/test";
|
var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata");
|
||||||
IntPtr wsConn = LibTaosWS.WSConnectWithDSN(DSN);
|
using (var client = DbDriver.Open(builder))
|
||||||
if (wsConn == IntPtr.Zero)
|
|
||||||
{
|
{
|
||||||
Console.WriteLine("get WS connection failed");
|
try
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("Establish connect success.");
|
|
||||||
}
|
|
||||||
|
|
||||||
string select = "select * from test.meters";
|
|
||||||
|
|
||||||
// optional:wsRes = LibTaosWS.WSQuery(wsConn, select);
|
|
||||||
IntPtr wsRes = LibTaosWS.WSQueryTimeout(wsConn, select, 1);
|
|
||||||
// Assert if query execute success.
|
|
||||||
int code = LibTaosWS.WSErrorNo(wsRes);
|
|
||||||
if (code != 0)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"execute SQL failed: reason: {LibTaosWS.WSErrorStr(wsRes)}, code:{code}");
|
|
||||||
LibTaosWS.WSFreeResult(wsRes);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get meta data
|
|
||||||
List<TDengineMeta> metas = LibTaosWS.WSGetFields(wsRes);
|
|
||||||
// get retrieved data
|
|
||||||
List<object> dataSet = LibTaosWS.WSGetData(wsRes);
|
|
||||||
|
|
||||||
// do something with result.
|
|
||||||
foreach (var meta in metas)
|
|
||||||
{
|
|
||||||
Console.Write("{0} {1}({2}) \t|\t", meta.name, meta.TypeName(), meta.size);
|
|
||||||
}
|
|
||||||
Console.WriteLine("");
|
|
||||||
|
|
||||||
for (int i = 0; i < dataSet.Count;)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < metas.Count; j++)
|
|
||||||
{
|
{
|
||||||
Console.Write("{0}\t|\t", dataSet[i]);
|
client.Exec("use power");
|
||||||
i++;
|
string query = "SELECT * FROM meters";
|
||||||
|
using (var rows = client.Query(query))
|
||||||
|
{
|
||||||
|
while (rows.Read())
|
||||||
|
{
|
||||||
|
Console.WriteLine(
|
||||||
|
$"{((DateTime)rows.GetValue(0)):yyyy-MM-dd HH:mm:ss.fff}, {rows.GetValue(1)}, {rows.GetValue(2)}, {rows.GetValue(3)}, {rows.GetValue(4)}, {Encoding.UTF8.GetString((byte[])rows.GetValue(5))}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
Console.WriteLine("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free result after use.
|
|
||||||
LibTaosWS.WSFreeResult(wsRes);
|
|
||||||
|
|
||||||
// close connection.
|
|
||||||
LibTaosWS.WSClose(wsConn);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establish connect success.
|
|
||||||
// ts TIMESTAMP(8) | current FLOAT(4) | voltage INT(4) | phase FLOAT(4) | location BINARY(64) | groupid INT(4) |
|
|
||||||
// 1538548685000 | 10.8 | 223 | 0.29 | California.LosAngeles | 3 |
|
|
||||||
// 1538548686500 | 11.5 | 221 | 0.35 | California.LosAngeles | 3 |
|
|
||||||
// 1538548685500 | 11.8 | 221 | 0.28 | California.LosAngeles | 2 |
|
|
||||||
// 1538548696600 | 13.4 | 223 | 0.29 | California.LosAngeles | 2 |
|
|
||||||
// 1538548685000 | 10.3 | 219 | 0.31 | California.SanFrancisco | 2 |
|
|
||||||
// 1538548695000 | 12.6 | 218 | 0.33 | California.SanFrancisco | 2 |
|
|
||||||
// 1538548696800 | 12.3 | 221 | 0.31 | California.SanFrancisco | 2 |
|
|
||||||
// 1538548696650 | 10.3 | 218 | 0.25 | California.SanFrancisco | 3 |
|
|
|
@ -7,7 +7,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="TDengine.Connector" Version="3.0.*" GeneratePathProperty="true" />
|
<PackageReference Include="TDengine.Connector" Version="3.1.*" GeneratePathProperty="true" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Target Name="copyDLLDependency" BeforeTargets="BeforeBuild">
|
<Target Name="copyDLLDependency" BeforeTargets="BeforeBuild">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -1,98 +1,41 @@
|
||||||
using System;
|
using System;
|
||||||
using TDengineWS.Impl;
|
using TDengine.Driver;
|
||||||
using TDengineDriver;
|
using TDengine.Driver.Client;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace Examples
|
namespace Examples
|
||||||
{
|
{
|
||||||
public class WSStmtExample
|
public class WSStmtExample
|
||||||
{
|
{
|
||||||
static int Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
const string DSN = "ws://root:taosdata@127.0.0.1:6041/test";
|
var builder =
|
||||||
const string table = "meters";
|
new ConnectionStringBuilder(
|
||||||
const string database = "test";
|
"protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata");
|
||||||
const string childTable = "d1005";
|
using (var client = DbDriver.Open(builder))
|
||||||
string insert = $"insert into ? using {database}.{table} tags(?,?) values(?,?,?,?)";
|
|
||||||
const int numOfTags = 2;
|
|
||||||
const int numOfColumns = 4;
|
|
||||||
|
|
||||||
// Establish connection
|
|
||||||
IntPtr wsConn = LibTaosWS.WSConnectWithDSN(DSN);
|
|
||||||
if (wsConn == IntPtr.Zero)
|
|
||||||
{
|
{
|
||||||
Console.WriteLine($"get WS connection failed");
|
try
|
||||||
return -1;
|
{
|
||||||
}
|
client.Exec($"create database power");
|
||||||
else
|
client.Exec(
|
||||||
{
|
"CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))");
|
||||||
Console.WriteLine("Establish connect success...");
|
using (var stmt = client.StmtInit())
|
||||||
}
|
{
|
||||||
|
stmt.Prepare(
|
||||||
// init stmt
|
"Insert into power.d1001 using power.meters tags(2,'California.SanFrancisco') values(?,?,?,?)");
|
||||||
IntPtr wsStmt = LibTaosWS.WSStmtInit(wsConn);
|
var ts = new DateTime(2023, 10, 03, 14, 38, 05, 000);
|
||||||
if (wsStmt != IntPtr.Zero)
|
stmt.BindRow(new object[] { ts, (float)10.30000, (int)219, (float)0.31000 });
|
||||||
{
|
stmt.AddBatch();
|
||||||
int code = LibTaosWS.WSStmtPrepare(wsStmt, insert);
|
stmt.Exec();
|
||||||
ValidStmtStep(code, wsStmt, "WSStmtPrepare");
|
var affected = stmt.Affected();
|
||||||
|
Console.WriteLine($"affected rows: {affected}");
|
||||||
TAOS_MULTI_BIND[] wsTags = new TAOS_MULTI_BIND[] { WSMultiBind.WSBindNchar(new string[] { "California.SanDiego" }), WSMultiBind.WSBindInt(new int?[] { 4 }) };
|
}
|
||||||
code = LibTaosWS.WSStmtSetTbnameTags(wsStmt, $"{database}.{childTable}", wsTags, numOfTags);
|
}
|
||||||
ValidStmtStep(code, wsStmt, "WSStmtSetTbnameTags");
|
catch (Exception e)
|
||||||
|
{
|
||||||
TAOS_MULTI_BIND[] data = new TAOS_MULTI_BIND[4];
|
Console.WriteLine(e);
|
||||||
data[0] = WSMultiBind.WSBindTimestamp(new long[] { 1538548687000, 1538548688000, 1538548689000, 1538548690000, 1538548691000 });
|
throw;
|
||||||
data[1] = WSMultiBind.WSBindFloat(new float?[] { 10.30F, 10.40F, 10.50F, 10.60F, 10.70F });
|
}
|
||||||
data[2] = WSMultiBind.WSBindInt(new int?[] { 223, 221, 222, 220, 219 });
|
|
||||||
data[3] = WSMultiBind.WSBindFloat(new float?[] { 0.31F, 0.32F, 0.33F, 0.35F, 0.28F });
|
|
||||||
code = LibTaosWS.WSStmtBindParamBatch(wsStmt, data, numOfColumns);
|
|
||||||
ValidStmtStep(code, wsStmt, "WSStmtBindParamBatch");
|
|
||||||
|
|
||||||
code = LibTaosWS.WSStmtAddBatch(wsStmt);
|
|
||||||
ValidStmtStep(code, wsStmt, "WSStmtAddBatch");
|
|
||||||
|
|
||||||
IntPtr stmtAffectRowPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Int32)));
|
|
||||||
code = LibTaosWS.WSStmtExecute(wsStmt, stmtAffectRowPtr);
|
|
||||||
ValidStmtStep(code, wsStmt, "WSStmtExecute");
|
|
||||||
Console.WriteLine("WS STMT insert {0} rows...", Marshal.ReadInt32(stmtAffectRowPtr));
|
|
||||||
Marshal.FreeHGlobal(stmtAffectRowPtr);
|
|
||||||
|
|
||||||
LibTaosWS.WSStmtClose(wsStmt);
|
|
||||||
|
|
||||||
// Free unmanaged memory
|
|
||||||
WSMultiBind.WSFreeTaosBind(wsTags);
|
|
||||||
WSMultiBind.WSFreeTaosBind(data);
|
|
||||||
|
|
||||||
//check result with SQL "SELECT * FROM test.d1005;"
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("Init STMT failed...");
|
|
||||||
}
|
|
||||||
|
|
||||||
// close connection.
|
|
||||||
LibTaosWS.WSClose(wsConn);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ValidStmtStep(int code, IntPtr wsStmt, string desc)
|
|
||||||
{
|
|
||||||
if (code != 0)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"{desc} failed,reason: {LibTaosWS.WSErrorStr(wsStmt)}, code: {code}");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("{0} success...", desc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WSStmtPrepare success...
|
|
||||||
// WSStmtSetTbnameTags success...
|
|
||||||
// WSStmtBindParamBatch success...
|
|
||||||
// WSStmtAddBatch success...
|
|
||||||
// WSStmtExecute success...
|
|
||||||
// WS STMT insert 5 rows...
|
|
|
@ -7,7 +7,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="TDengine.Connector" Version="3.0.*" GeneratePathProperty="true" />
|
<PackageReference Include="TDengine.Connector" Version="3.1.*" GeneratePathProperty="true" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Target Name="copyDLLDependency" BeforeTargets="BeforeBuild">
|
<Target Name="copyDLLDependency" BeforeTargets="BeforeBuild">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -20,7 +20,7 @@ def get_ts(ts: str):
|
||||||
def create_stable():
|
def create_stable():
|
||||||
conn = taos.connect()
|
conn = taos.connect()
|
||||||
try:
|
try:
|
||||||
conn.execute("CREATE DATABASE power")
|
conn.execute("CREATE DATABASE power keep 36500")
|
||||||
conn.execute("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) "
|
conn.execute("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) "
|
||||||
"TAGS (location BINARY(64), groupId INT)")
|
"TAGS (location BINARY(64), groupId INT)")
|
||||||
finally:
|
finally:
|
||||||
|
|
|
@ -4,7 +4,7 @@ import taos
|
||||||
|
|
||||||
taos_conn = taos.connect()
|
taos_conn = taos.connect()
|
||||||
taos_conn.execute('drop database if exists power')
|
taos_conn.execute('drop database if exists power')
|
||||||
taos_conn.execute('create database if not exists power wal_retention_period 3600')
|
taos_conn.execute('create database if not exists power wal_retention_period 3600 keep 36500 ')
|
||||||
taos_conn.execute("use power")
|
taos_conn.execute("use power")
|
||||||
taos_conn.execute(
|
taos_conn.execute(
|
||||||
"CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)")
|
"CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)")
|
||||||
|
|
|
@ -11,7 +11,7 @@ conn = connect(url="http://localhost:6041",
|
||||||
# create STable
|
# create STable
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
cursor.execute("DROP DATABASE IF EXISTS power")
|
cursor.execute("DROP DATABASE IF EXISTS power")
|
||||||
cursor.execute("CREATE DATABASE power")
|
cursor.execute("CREATE DATABASE power keep 36500 ")
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)")
|
"CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)")
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ conn = connect(url="http://localhost:6041",
|
||||||
# create STable
|
# create STable
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
cursor.execute("DROP DATABASE IF EXISTS power", req_id=1)
|
cursor.execute("DROP DATABASE IF EXISTS power", req_id=1)
|
||||||
cursor.execute("CREATE DATABASE power", req_id=2)
|
cursor.execute("CREATE DATABASE power keep 36500", req_id=2)
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)", req_id=3)
|
"CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)", req_id=3)
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,13 @@ conn = taosws.connect("taosws://root:taosdata@localhost:6041")
|
||||||
|
|
||||||
# ANCHOR: basic
|
# ANCHOR: basic
|
||||||
conn.execute("drop database if exists connwspy")
|
conn.execute("drop database if exists connwspy")
|
||||||
conn.execute("create database if not exists connwspy wal_retention_period 3600")
|
conn.execute("create database if not exists connwspy wal_retention_period 3600 keep 36500 ")
|
||||||
conn.execute("use connwspy")
|
conn.execute("use connwspy")
|
||||||
conn.execute("create table if not exists stb (ts timestamp, c1 int) tags (t1 int)")
|
conn.execute("create table if not exists stb (ts timestamp, c1 int) tags (t1 int)")
|
||||||
conn.execute("create table if not exists tb1 using stb tags (1)")
|
conn.execute("create table if not exists tb1 using stb tags (1)")
|
||||||
conn.execute("insert into tb1 values (now, 1)")
|
conn.execute("insert into tb1 values (now, 1)")
|
||||||
conn.execute("insert into tb1 values (now, 2)")
|
conn.execute("insert into tb1 values (now+1s, 2)")
|
||||||
conn.execute("insert into tb1 values (now, 3)")
|
conn.execute("insert into tb1 values (now+2s, 3)")
|
||||||
|
|
||||||
r = conn.execute("select * from stb")
|
r = conn.execute("select * from stb")
|
||||||
result = conn.query("select * from stb")
|
result = conn.query("select * from stb")
|
||||||
|
|
|
@ -6,7 +6,7 @@ conn = taosws.connect("taosws://root:taosdata@localhost:6041")
|
||||||
|
|
||||||
# ANCHOR: basic
|
# ANCHOR: basic
|
||||||
conn.execute("drop database if exists connwspy", req_id=1)
|
conn.execute("drop database if exists connwspy", req_id=1)
|
||||||
conn.execute("create database if not exists connwspy", req_id=2)
|
conn.execute("create database if not exists connwspy keep 36500", req_id=2)
|
||||||
conn.execute("use connwspy", req_id=3)
|
conn.execute("use connwspy", req_id=3)
|
||||||
conn.execute("create table if not exists stb (ts timestamp, c1 int) tags (t1 int)", req_id=4)
|
conn.execute("create table if not exists stb (ts timestamp, c1 int) tags (t1 int)", req_id=4)
|
||||||
conn.execute("create table if not exists tb1 using stb tags (1)", req_id=5)
|
conn.execute("create table if not exists tb1 using stb tags (1)", req_id=5)
|
||||||
|
|
|
@ -4,7 +4,7 @@ import taos
|
||||||
conn = taos.connect()
|
conn = taos.connect()
|
||||||
# Execute a sql, ignore the result set, just get affected rows. It's useful for DDL and DML statement.
|
# Execute a sql, ignore the result set, just get affected rows. It's useful for DDL and DML statement.
|
||||||
conn.execute("DROP DATABASE IF EXISTS test")
|
conn.execute("DROP DATABASE IF EXISTS test")
|
||||||
conn.execute("CREATE DATABASE test")
|
conn.execute("CREATE DATABASE test keep 36500")
|
||||||
# change database. same as execute "USE db"
|
# change database. same as execute "USE db"
|
||||||
conn.select_db("test")
|
conn.select_db("test")
|
||||||
conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)")
|
conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)")
|
||||||
|
|
|
@ -4,7 +4,7 @@ import taos
|
||||||
conn = taos.connect()
|
conn = taos.connect()
|
||||||
# Execute a sql, ignore the result set, just get affected rows. It's useful for DDL and DML statement.
|
# Execute a sql, ignore the result set, just get affected rows. It's useful for DDL and DML statement.
|
||||||
conn.execute("DROP DATABASE IF EXISTS test", req_id=1)
|
conn.execute("DROP DATABASE IF EXISTS test", req_id=1)
|
||||||
conn.execute("CREATE DATABASE test", req_id=2)
|
conn.execute("CREATE DATABASE test keep 36500", req_id=2)
|
||||||
# change database. same as execute "USE db"
|
# change database. same as execute "USE db"
|
||||||
conn.select_db("test")
|
conn.select_db("test")
|
||||||
conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)", req_id=3)
|
conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)", req_id=3)
|
||||||
|
|
|
@ -4,7 +4,7 @@ conn = taos.connect()
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
|
||||||
cursor.execute("DROP DATABASE IF EXISTS test")
|
cursor.execute("DROP DATABASE IF EXISTS test")
|
||||||
cursor.execute("CREATE DATABASE test")
|
cursor.execute("CREATE DATABASE test keep 36500")
|
||||||
cursor.execute("USE test")
|
cursor.execute("USE test")
|
||||||
cursor.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)")
|
cursor.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)")
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ conn = taos.connect()
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
|
||||||
cursor.execute("DROP DATABASE IF EXISTS test", req_id=1)
|
cursor.execute("DROP DATABASE IF EXISTS test", req_id=1)
|
||||||
cursor.execute("CREATE DATABASE test", req_id=2)
|
cursor.execute("CREATE DATABASE test keep 36500", req_id=2)
|
||||||
cursor.execute("USE test", req_id=3)
|
cursor.execute("USE test", req_id=3)
|
||||||
cursor.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)", req_id=4)
|
cursor.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)", req_id=4)
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,7 @@ def main(infinity):
|
||||||
|
|
||||||
conn = get_connection()
|
conn = get_connection()
|
||||||
conn.execute("DROP DATABASE IF EXISTS test")
|
conn.execute("DROP DATABASE IF EXISTS test")
|
||||||
conn.execute("CREATE DATABASE IF NOT EXISTS test")
|
conn.execute("CREATE DATABASE IF NOT EXISTS test keep 36500")
|
||||||
conn.execute("CREATE STABLE IF NOT EXISTS test.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) "
|
conn.execute("CREATE STABLE IF NOT EXISTS test.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) "
|
||||||
"TAGS (location BINARY(64), groupId INT)")
|
"TAGS (location BINARY(64), groupId INT)")
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
|
@ -16,7 +16,7 @@ def get_connection():
|
||||||
|
|
||||||
|
|
||||||
def create_database(conn):
|
def create_database(conn):
|
||||||
conn.execute("CREATE DATABASE test")
|
conn.execute("CREATE DATABASE test keep 36500")
|
||||||
conn.execute("USE test")
|
conn.execute("USE test")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ LOCATIONS = ['California.SanFrancisco', 'California.LosAngles', 'California.SanD
|
||||||
'California.PaloAlto', 'California.Campbell', 'California.MountainView', 'California.Sunnyvale',
|
'California.PaloAlto', 'California.Campbell', 'California.MountainView', 'California.Sunnyvale',
|
||||||
'California.SantaClara', 'California.Cupertino']
|
'California.SantaClara', 'California.Cupertino']
|
||||||
|
|
||||||
CREATE_DATABASE_SQL = 'create database if not exists {} keep 365 duration 10 buffer 16 wal_level 1 wal_retention_period 3600'
|
CREATE_DATABASE_SQL = 'create database if not exists {} keep 36500 duration 10 buffer 16 wal_level 1 wal_retention_period 3600'
|
||||||
USE_DATABASE_SQL = 'use {}'
|
USE_DATABASE_SQL = 'use {}'
|
||||||
DROP_TABLE_SQL = 'drop table if exists meters'
|
DROP_TABLE_SQL = 'drop table if exists meters'
|
||||||
DROP_DATABASE_SQL = 'drop database if exists {}'
|
DROP_DATABASE_SQL = 'drop database if exists {}'
|
||||||
|
|
|
@ -15,7 +15,7 @@ def get_connection():
|
||||||
|
|
||||||
def create_database(conn):
|
def create_database(conn):
|
||||||
# the default precision is ms (microsecond), but we use us(microsecond) here.
|
# the default precision is ms (microsecond), but we use us(microsecond) here.
|
||||||
conn.execute("CREATE DATABASE test precision 'us'")
|
conn.execute("CREATE DATABASE test precision 'us' keep 36500")
|
||||||
conn.execute("USE test")
|
conn.execute("USE test")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ def insert_data():
|
||||||
def create_stable():
|
def create_stable():
|
||||||
conn = taos.connect()
|
conn = taos.connect()
|
||||||
try:
|
try:
|
||||||
conn.execute("CREATE DATABASE power")
|
conn.execute("CREATE DATABASE power keep 36500")
|
||||||
conn.execute("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) "
|
conn.execute("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) "
|
||||||
"TAGS (location BINARY(64), groupId INT)")
|
"TAGS (location BINARY(64), groupId INT)")
|
||||||
finally:
|
finally:
|
||||||
|
|
|
@ -18,7 +18,7 @@ def get_connection() -> taos.TaosConnection:
|
||||||
|
|
||||||
|
|
||||||
def create_stable(conn: taos.TaosConnection):
|
def create_stable(conn: taos.TaosConnection):
|
||||||
conn.execute("CREATE DATABASE power")
|
conn.execute("CREATE DATABASE power keep 36500")
|
||||||
conn.execute("USE power")
|
conn.execute("USE power")
|
||||||
conn.execute("CREATE STABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) "
|
conn.execute("CREATE STABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) "
|
||||||
"TAGS (location BINARY(64), groupId INT)")
|
"TAGS (location BINARY(64), groupId INT)")
|
||||||
|
|
|
@ -2,7 +2,7 @@ import taos
|
||||||
|
|
||||||
conn = taos.connect()
|
conn = taos.connect()
|
||||||
conn.execute("DROP DATABASE IF EXISTS test")
|
conn.execute("DROP DATABASE IF EXISTS test")
|
||||||
conn.execute("CREATE DATABASE test")
|
conn.execute("CREATE DATABASE test keep 36500")
|
||||||
conn.select_db("test")
|
conn.select_db("test")
|
||||||
conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)")
|
conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)")
|
||||||
# prepare data
|
# prepare data
|
||||||
|
|
|
@ -2,7 +2,7 @@ import taos
|
||||||
|
|
||||||
conn = taos.connect()
|
conn = taos.connect()
|
||||||
conn.execute("DROP DATABASE IF EXISTS test", req_id=1)
|
conn.execute("DROP DATABASE IF EXISTS test", req_id=1)
|
||||||
conn.execute("CREATE DATABASE test", req_id=2)
|
conn.execute("CREATE DATABASE test keep 36500", req_id=2)
|
||||||
conn.select_db("test")
|
conn.select_db("test")
|
||||||
conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)", req_id=3)
|
conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)", req_id=3)
|
||||||
# prepare data
|
# prepare data
|
||||||
|
|
|
@ -3,7 +3,7 @@ import taos
|
||||||
conn = taos.connect()
|
conn = taos.connect()
|
||||||
dbname = "pytest_line"
|
dbname = "pytest_line"
|
||||||
conn.execute("drop database if exists %s" % dbname)
|
conn.execute("drop database if exists %s" % dbname)
|
||||||
conn.execute("create database if not exists %s precision 'us'" % dbname)
|
conn.execute("create database if not exists %s precision 'us' keep 36500" % dbname)
|
||||||
conn.select_db(dbname)
|
conn.select_db(dbname)
|
||||||
|
|
||||||
lines = [
|
lines = [
|
||||||
|
|
|
@ -10,9 +10,9 @@ try:
|
||||||
conn.execute("drop database if exists %s" % dbname)
|
conn.execute("drop database if exists %s" % dbname)
|
||||||
|
|
||||||
if taos.IS_V3:
|
if taos.IS_V3:
|
||||||
conn.execute("create database if not exists %s schemaless 1 precision 'ns'" % dbname)
|
conn.execute("create database if not exists %s schemaless 1 precision 'ns' keep 36500" % dbname)
|
||||||
else:
|
else:
|
||||||
conn.execute("create database if not exists %s update 2 precision 'ns'" % dbname)
|
conn.execute("create database if not exists %s update 2 precision 'ns' keep 36500" % dbname)
|
||||||
|
|
||||||
conn.select_db(dbname)
|
conn.select_db(dbname)
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,9 @@ try:
|
||||||
conn.execute("drop database if exists %s" % dbname)
|
conn.execute("drop database if exists %s" % dbname)
|
||||||
|
|
||||||
if taos.IS_V3:
|
if taos.IS_V3:
|
||||||
conn.execute("create database if not exists %s schemaless 1 precision 'ns'" % dbname)
|
conn.execute("create database if not exists %s schemaless 1 precision 'ns' keep 36500" % dbname)
|
||||||
else:
|
else:
|
||||||
conn.execute("create database if not exists %s update 2 precision 'ns'" % dbname)
|
conn.execute("create database if not exists %s update 2 precision 'ns' keep 36500" % dbname)
|
||||||
|
|
||||||
conn.select_db(dbname)
|
conn.select_db(dbname)
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,9 @@ try:
|
||||||
conn.execute("drop database if exists %s" % dbname)
|
conn.execute("drop database if exists %s" % dbname)
|
||||||
|
|
||||||
if taos.IS_V3:
|
if taos.IS_V3:
|
||||||
conn.execute("create database if not exists %s schemaless 1 precision 'ns'" % dbname)
|
conn.execute("create database if not exists %s schemaless 1 precision 'ns' keep 36500" % dbname)
|
||||||
else:
|
else:
|
||||||
conn.execute("create database if not exists %s update 2 precision 'ns'" % dbname)
|
conn.execute("create database if not exists %s update 2 precision 'ns' keep 36500" % dbname)
|
||||||
|
|
||||||
conn.select_db(dbname)
|
conn.select_db(dbname)
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ from taos import SmlProtocol, SmlPrecision
|
||||||
conn = taos.connect()
|
conn = taos.connect()
|
||||||
dbname = "pytest_line"
|
dbname = "pytest_line"
|
||||||
conn.execute("drop database if exists %s" % dbname)
|
conn.execute("drop database if exists %s" % dbname)
|
||||||
conn.execute("create database if not exists %s precision 'us'" % dbname)
|
conn.execute("create database if not exists %s precision 'us' keep 36500" % dbname)
|
||||||
conn.select_db(dbname)
|
conn.select_db(dbname)
|
||||||
|
|
||||||
lines = [
|
lines = [
|
||||||
|
|
|
@ -4,7 +4,7 @@ from taos import SmlProtocol, SmlPrecision
|
||||||
conn = taos.connect()
|
conn = taos.connect()
|
||||||
dbname = "pytest_line"
|
dbname = "pytest_line"
|
||||||
conn.execute("drop database if exists %s" % dbname)
|
conn.execute("drop database if exists %s" % dbname)
|
||||||
conn.execute("create database if not exists %s precision 'us'" % dbname)
|
conn.execute("create database if not exists %s precision 'us' keep 36500" % dbname)
|
||||||
conn.select_db(dbname)
|
conn.select_db(dbname)
|
||||||
|
|
||||||
lines = [
|
lines = [
|
||||||
|
|
|
@ -10,7 +10,7 @@ class SQLWriter:
|
||||||
self._tb_tags = {}
|
self._tb_tags = {}
|
||||||
self._conn = get_connection_func()
|
self._conn = get_connection_func()
|
||||||
self._max_sql_length = self.get_max_sql_length()
|
self._max_sql_length = self.get_max_sql_length()
|
||||||
self._conn.execute("create database if not exists test")
|
self._conn.execute("create database if not exists test keep 36500")
|
||||||
self._conn.execute("USE test")
|
self._conn.execute("USE test")
|
||||||
|
|
||||||
def get_max_sql_length(self):
|
def get_max_sql_length(self):
|
||||||
|
|
|
@ -10,7 +10,7 @@ db_name = 'test_ws_stmt'
|
||||||
def before():
|
def before():
|
||||||
taos_conn = taos.connect()
|
taos_conn = taos.connect()
|
||||||
taos_conn.execute("drop database if exists %s" % db_name)
|
taos_conn.execute("drop database if exists %s" % db_name)
|
||||||
taos_conn.execute("create database %s" % db_name)
|
taos_conn.execute("create database %s keep 36500" % db_name)
|
||||||
taos_conn.select_db(db_name)
|
taos_conn.select_db(db_name)
|
||||||
taos_conn.execute("create table t1 (ts timestamp, a int, b float, c varchar(10))")
|
taos_conn.execute("create table t1 (ts timestamp, a int, b float, c varchar(10))")
|
||||||
taos_conn.execute(
|
taos_conn.execute(
|
||||||
|
|
|
@ -9,7 +9,7 @@ import taos
|
||||||
def before_test(db_name):
|
def before_test(db_name):
|
||||||
taos_conn = taos.connect()
|
taos_conn = taos.connect()
|
||||||
taos_conn.execute("drop database if exists %s" % db_name)
|
taos_conn.execute("drop database if exists %s" % db_name)
|
||||||
taos_conn.execute("create database %s" % db_name)
|
taos_conn.execute("create database %s keep 36500" % db_name)
|
||||||
taos_conn.select_db(db_name)
|
taos_conn.select_db(db_name)
|
||||||
taos_conn.execute("create table t1 (ts timestamp, a int, b float, c varchar(10))")
|
taos_conn.execute("create table t1 (ts timestamp, a int, b float, c varchar(10))")
|
||||||
taos_conn.execute(
|
taos_conn.execute(
|
||||||
|
|
|
@ -19,7 +19,7 @@ def get_connection():
|
||||||
|
|
||||||
|
|
||||||
def create_database(conn):
|
def create_database(conn):
|
||||||
conn.execute("CREATE DATABASE test")
|
conn.execute("CREATE DATABASE test keep 36500")
|
||||||
conn.execute("USE test")
|
conn.execute("USE test")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ def prepare():
|
||||||
conn = taos.connect()
|
conn = taos.connect()
|
||||||
conn.execute("drop topic if exists tmq_assignment_demo_topic")
|
conn.execute("drop topic if exists tmq_assignment_demo_topic")
|
||||||
conn.execute("drop database if exists tmq_assignment_demo_db")
|
conn.execute("drop database if exists tmq_assignment_demo_db")
|
||||||
conn.execute("create database if not exists tmq_assignment_demo_db wal_retention_period 3600")
|
conn.execute("create database if not exists tmq_assignment_demo_db wal_retention_period 3600 keep 36500")
|
||||||
conn.select_db("tmq_assignment_demo_db")
|
conn.select_db("tmq_assignment_demo_db")
|
||||||
conn.execute(
|
conn.execute(
|
||||||
"create table if not exists tmq_assignment_demo_table (ts timestamp, c1 int, c2 float, c3 binary(10)) tags(t1 int)")
|
"create table if not exists tmq_assignment_demo_table (ts timestamp, c1 int, c2 float, c3 binary(10)) tags(t1 int)")
|
||||||
|
|
|
@ -6,7 +6,7 @@ def init_tmq_env(db, topic):
|
||||||
conn = taos.connect()
|
conn = taos.connect()
|
||||||
conn.execute("drop topic if exists {}".format(topic))
|
conn.execute("drop topic if exists {}".format(topic))
|
||||||
conn.execute("drop database if exists {}".format(db))
|
conn.execute("drop database if exists {}".format(db))
|
||||||
conn.execute("create database if not exists {} wal_retention_period 3600".format(db))
|
conn.execute("create database if not exists {} wal_retention_period 3600 keep 36500".format(db))
|
||||||
conn.select_db(db)
|
conn.select_db(db)
|
||||||
conn.execute(
|
conn.execute(
|
||||||
"create stable if not exists stb1 (ts timestamp, c1 int, c2 float, c3 varchar(16)) tags(t1 int, t3 varchar(16))")
|
"create stable if not exists stb1 (ts timestamp, c1 int, c2 float, c3 varchar(16)) tags(t1 int, t3 varchar(16))")
|
||||||
|
|
|
@ -6,7 +6,7 @@ def prepare():
|
||||||
conn = taos.connect()
|
conn = taos.connect()
|
||||||
conn.execute("drop topic if exists tmq_assignment_demo_topic")
|
conn.execute("drop topic if exists tmq_assignment_demo_topic")
|
||||||
conn.execute("drop database if exists tmq_assignment_demo_db")
|
conn.execute("drop database if exists tmq_assignment_demo_db")
|
||||||
conn.execute("create database if not exists tmq_assignment_demo_db wal_retention_period 3600")
|
conn.execute("create database if not exists tmq_assignment_demo_db wal_retention_period 3600 keep 36500")
|
||||||
conn.select_db("tmq_assignment_demo_db")
|
conn.select_db("tmq_assignment_demo_db")
|
||||||
conn.execute(
|
conn.execute(
|
||||||
"create table if not exists tmq_assignment_demo_table (ts timestamp, c1 int, c2 float, c3 binary(10)) tags(t1 int)")
|
"create table if not exists tmq_assignment_demo_table (ts timestamp, c1 int, c2 float, c3 binary(10)) tags(t1 int)")
|
||||||
|
|
|
@ -176,7 +176,7 @@ npm install @tdengine/rest
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="TDengine.Connector" Version="3.0.0" />
|
<PackageReference Include="TDengine.Connector" Version="3.1.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
```csharp
|
|
||||||
{{#include docs/examples/csharp/asyncQuery/Program.cs}}
|
|
||||||
```
|
|
|
@ -16,7 +16,6 @@ import CQuery from "./_c.mdx";
|
||||||
import PhpQuery from "./_php.mdx";
|
import PhpQuery from "./_php.mdx";
|
||||||
import PyAsync from "./_py_async.mdx";
|
import PyAsync from "./_py_async.mdx";
|
||||||
import NodeAsync from "./_js_async.mdx";
|
import NodeAsync from "./_js_async.mdx";
|
||||||
import CsAsync from "./_cs_async.mdx";
|
|
||||||
import CAsync from "./_c_async.mdx";
|
import CAsync from "./_c_async.mdx";
|
||||||
|
|
||||||
## 主要查询功能
|
## 主要查询功能
|
||||||
|
@ -175,9 +174,6 @@ Query OK, 6 rows in database (0.005515s)
|
||||||
<TabItem label="Python" value="python">
|
<TabItem label="Python" value="python">
|
||||||
<PyAsync />
|
<PyAsync />
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem label="C#" value="csharp">
|
|
||||||
<CsAsync />
|
|
||||||
</TabItem>
|
|
||||||
<TabItem label="C" value="c">
|
<TabItem label="C" value="c">
|
||||||
<CAsync />
|
<CAsync />
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
|
@ -248,23 +248,23 @@ function close()
|
||||||
<TabItem value="C#" label="C#">
|
<TabItem value="C#" label="C#">
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
|
class ConsumerBuilder<TValue>
|
||||||
|
|
||||||
ConsumerBuilder(IEnumerable<KeyValuePair<string, string>> config)
|
ConsumerBuilder(IEnumerable<KeyValuePair<string, string>> config)
|
||||||
|
|
||||||
virtual IConsumer Build()
|
public IConsumer<TValue> Build()
|
||||||
|
|
||||||
Consumer(ConsumerBuilder builder)
|
|
||||||
|
|
||||||
void Subscribe(IEnumerable<string> topics)
|
void Subscribe(IEnumerable<string> topics)
|
||||||
|
|
||||||
void Subscribe(string topic)
|
void Subscribe(string topic)
|
||||||
|
|
||||||
ConsumeResult Consume(int millisecondsTimeout)
|
ConsumeResult<TValue> Consume(int millisecondsTimeout)
|
||||||
|
|
||||||
List<string> Subscription()
|
List<string> Subscription()
|
||||||
|
|
||||||
void Unsubscribe()
|
void Unsubscribe()
|
||||||
|
|
||||||
void Commit(ConsumeResult consumerResult)
|
List<TopicPartitionOffset> Commit()
|
||||||
|
|
||||||
void Close()
|
void Close()
|
||||||
```
|
```
|
||||||
|
@ -501,25 +501,19 @@ let consumer = taos.consumer({
|
||||||
<TabItem value="C#" label="C#">
|
<TabItem value="C#" label="C#">
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
using TDengineTMQ;
|
var cfg = new Dictionary<string, string>()
|
||||||
|
{
|
||||||
// 根据需要,设置消费组 (GourpId)、自动提交 (EnableAutoCommit)、
|
{ "group.id", "group1" },
|
||||||
// 自动提交时间间隔 (AutoCommitIntervalMs)、用户名 (TDConnectUser)、密码 (TDConnectPasswd) 等参数
|
{ "auto.offset.reset", "latest" },
|
||||||
var cfg = new ConsumerConfig
|
{ "td.connect.ip", "127.0.0.1" },
|
||||||
{
|
{ "td.connect.user", "root" },
|
||||||
EnableAutoCommit = "true"
|
{ "td.connect.pass", "taosdata" },
|
||||||
AutoCommitIntervalMs = "1000"
|
{ "td.connect.port", "6030" },
|
||||||
GourpId = "TDengine-TMQ-C#",
|
{ "client.id", "tmq_example" },
|
||||||
TDConnectUser = "root",
|
{ "enable.auto.commit", "true" },
|
||||||
TDConnectPasswd = "taosdata",
|
{ "msg.with.table.name", "false" },
|
||||||
AutoOffsetReset = "latest"
|
};
|
||||||
MsgWithTableName = "true",
|
var consumer = new ConsumerBuilder<Dictionary<string, object>>(cfg).Build();
|
||||||
TDConnectIp = "127.0.0.1",
|
|
||||||
TDConnectPort = "6030"
|
|
||||||
};
|
|
||||||
|
|
||||||
var consumer = new ConsumerBuilder(cfg).Build();
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
@ -748,10 +742,12 @@ while(true){
|
||||||
// 消费数据
|
// 消费数据
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
var consumerRes = consumer.Consume(100);
|
using (var result = consumer.Consume(500))
|
||||||
// process ConsumeResult
|
{
|
||||||
ProcessMsg(consumerRes);
|
if (result == null) continue;
|
||||||
consumer.Commit(consumerRes);
|
ProcessMsg(result);
|
||||||
|
consumer.Commit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -257,6 +257,63 @@ curl -L -u username:password -d "<SQL>" <ip>:<PORT>/rest/sql/[db_name][?tz=timez
|
||||||
- "INT UNSIGNED"
|
- "INT UNSIGNED"
|
||||||
- "BIGINT UNSIGNED"
|
- "BIGINT UNSIGNED"
|
||||||
- "JSON"
|
- "JSON"
|
||||||
|
- "VARBINARY"
|
||||||
|
- "GEOMETRY"
|
||||||
|
|
||||||
|
`VARBINARY` 和 `GEOMETRY` 类型返回数据为 Hex 字符串,样例:
|
||||||
|
|
||||||
|
准备数据
|
||||||
|
|
||||||
|
```bash
|
||||||
|
create database demo
|
||||||
|
use demo
|
||||||
|
create table t(ts timestamp,c1 varbinary(20),c2 geometry(100))
|
||||||
|
insert into t values(now,'\x7f8290','point(100 100)')
|
||||||
|
```
|
||||||
|
|
||||||
|
执行查询
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --location 'http://<fqdn>:<port>/rest/sql' \
|
||||||
|
--header 'Content-Type: text/plain' \
|
||||||
|
--header 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' \
|
||||||
|
--data 'select * from demo.t'
|
||||||
|
```
|
||||||
|
|
||||||
|
返回结果
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 0,
|
||||||
|
"column_meta": [
|
||||||
|
[
|
||||||
|
"ts",
|
||||||
|
"TIMESTAMP",
|
||||||
|
8
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"c1",
|
||||||
|
"VARBINARY",
|
||||||
|
20
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"c2",
|
||||||
|
"GEOMETRY",
|
||||||
|
100
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"data": [
|
||||||
|
[
|
||||||
|
"2023-11-01T06:28:15.210Z",
|
||||||
|
"7f8290",
|
||||||
|
"010100000000000000000059400000000000005940"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"rows": 1
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- `010100000000000000000059400000000000005940` 为 `point(100 100)` 的 [Well-Known Binary (WKB)](https://libgeos.org/specifications/wkb/) 格式
|
||||||
|
|
||||||
#### 错误
|
#### 错误
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -34,7 +34,7 @@ extern int32_t tsS3UploadDelaySec;
|
||||||
int32_t s3Init();
|
int32_t s3Init();
|
||||||
void s3CleanUp();
|
void s3CleanUp();
|
||||||
int32_t s3PutObjectFromFile(const char *file, const char *object);
|
int32_t s3PutObjectFromFile(const char *file, const char *object);
|
||||||
int32_t s3PutObjectFromFile2(const char *file, const char *object);
|
int32_t s3PutObjectFromFile2(const char *file, const char *object, int8_t withcp);
|
||||||
void s3DeleteObjectsByPrefix(const char *prefix);
|
void s3DeleteObjectsByPrefix(const char *prefix);
|
||||||
void s3DeleteObjects(const char *object_name[], int nobject);
|
void s3DeleteObjects(const char *object_name[], int nobject);
|
||||||
bool s3Exists(const char *object_name);
|
bool s3Exists(const char *object_name);
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TD_COMMON_COS_CP_H_
|
||||||
|
#define _TD_COMMON_COS_CP_H_
|
||||||
|
|
||||||
|
#include "os.h"
|
||||||
|
#include "tdef.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
COS_CP_TYPE_UPLOAD, // upload
|
||||||
|
COS_CP_TYPE_DOWNLOAD // download
|
||||||
|
} ECpType;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t index; // the index of part, start from 0
|
||||||
|
int64_t offset; // the offset point of part
|
||||||
|
int64_t size; // the size of part
|
||||||
|
int completed; // COS_TRUE completed, COS_FALSE uncompleted
|
||||||
|
char etag[128]; // the etag of part, for upload
|
||||||
|
uint64_t crc64;
|
||||||
|
} SCheckpointPart;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
ECpType cp_type; // 0 upload, 1 download
|
||||||
|
char md5[64]; // the md5 of checkout content
|
||||||
|
TdFilePtr thefile; // the handle of checkpoint file
|
||||||
|
|
||||||
|
char file_path[TSDB_FILENAME_LEN]; // local file path
|
||||||
|
int64_t file_size; // local file size, for upload
|
||||||
|
int32_t file_last_modified; // local file last modified time, for upload
|
||||||
|
char file_md5[64]; // md5 of the local file content, for upload, reserved
|
||||||
|
|
||||||
|
char object_name[128]; // object name
|
||||||
|
int64_t object_size; // object size, for download
|
||||||
|
char object_last_modified[64]; // object last modified time, for download
|
||||||
|
char object_etag[128]; // object etag, for download
|
||||||
|
|
||||||
|
char upload_id[128]; // upload id
|
||||||
|
|
||||||
|
int part_num; // the total number of parts
|
||||||
|
int64_t part_size; // the part size, byte
|
||||||
|
SCheckpointPart* parts; // the parts of local or object, from 0
|
||||||
|
} SCheckpoint;
|
||||||
|
|
||||||
|
int32_t cos_cp_open(char const* cp_path, SCheckpoint* checkpoint);
|
||||||
|
void cos_cp_close(TdFilePtr fd);
|
||||||
|
void cos_cp_remove(char const* filepath);
|
||||||
|
|
||||||
|
int32_t cos_cp_load(char const* filepath, SCheckpoint* checkpoint);
|
||||||
|
int32_t cos_cp_dump(SCheckpoint* checkpoint);
|
||||||
|
void cos_cp_get_undo_parts(SCheckpoint* checkpoint, int* part_num, SCheckpointPart* parts, int64_t* consume_bytes);
|
||||||
|
void cos_cp_update(SCheckpoint* checkpoint, int32_t part_index, char const* etag, uint64_t crc64);
|
||||||
|
void cos_cp_build_upload(SCheckpoint* checkpoint, char const* filepath, int64_t size, int32_t mtime,
|
||||||
|
char const* upload_id, int64_t part_size);
|
||||||
|
bool cos_cp_is_valid_upload(SCheckpoint* checkpoint, int64_t size, int32_t mtime);
|
||||||
|
|
||||||
|
void cos_cp_build_download(SCheckpoint* checkpoint, char const* filepath, char const* object_name, int64_t object_size,
|
||||||
|
char const* object_lmtime, char const* object_etag, int64_t part_size);
|
||||||
|
bool cos_cp_is_valid_download(SCheckpoint* checkpoint, char const* object_name, int64_t object_size,
|
||||||
|
char const* object_lmtime, char const* object_etag);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*_TD_COMMON_COS_CP_H_*/
|
|
@ -50,6 +50,8 @@ extern "C" {
|
||||||
#define TSDB_INS_TABLE_STREAM_TASKS "ins_stream_tasks"
|
#define TSDB_INS_TABLE_STREAM_TASKS "ins_stream_tasks"
|
||||||
#define TSDB_INS_TABLE_USER_PRIVILEGES "ins_user_privileges"
|
#define TSDB_INS_TABLE_USER_PRIVILEGES "ins_user_privileges"
|
||||||
#define TSDB_INS_TABLE_VIEWS "ins_views"
|
#define TSDB_INS_TABLE_VIEWS "ins_views"
|
||||||
|
#define TSDB_INS_TABLE_COMPACTS "ins_compacts"
|
||||||
|
#define TSDB_INS_TABLE_COMPACT_DETAILS "ins_compact_details"
|
||||||
|
|
||||||
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
|
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
|
||||||
#define TSDB_PERFS_TABLE_SMAS "perf_smas"
|
#define TSDB_PERFS_TABLE_SMAS "perf_smas"
|
||||||
|
|
|
@ -253,6 +253,7 @@ typedef struct SQueryTableDataCond {
|
||||||
STimeWindow twindows;
|
STimeWindow twindows;
|
||||||
int64_t startVersion;
|
int64_t startVersion;
|
||||||
int64_t endVersion;
|
int64_t endVersion;
|
||||||
|
bool notLoadData; // response the actual data, not only the rows in the attribute of info.row of ssdatablock
|
||||||
} SQueryTableDataCond;
|
} SQueryTableDataCond;
|
||||||
|
|
||||||
int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock);
|
int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock);
|
||||||
|
|
|
@ -107,8 +107,9 @@ extern int32_t tsMonitorMaxLogs;
|
||||||
extern bool tsMonitorComp;
|
extern bool tsMonitorComp;
|
||||||
|
|
||||||
// audit
|
// audit
|
||||||
extern bool tsEnableAudit;
|
extern bool tsEnableAudit;
|
||||||
extern bool tsEnableAuditCreateTable;
|
extern bool tsEnableAuditCreateTable;
|
||||||
|
extern int32_t tsAuditInterval;
|
||||||
|
|
||||||
// telem
|
// telem
|
||||||
extern bool tsEnableTelem;
|
extern bool tsEnableTelem;
|
||||||
|
@ -195,6 +196,7 @@ extern int64_t tsWalFsyncDataSizeLimit;
|
||||||
|
|
||||||
// internal
|
// internal
|
||||||
extern int32_t tsTransPullupInterval;
|
extern int32_t tsTransPullupInterval;
|
||||||
|
extern int32_t tsCompactPullupInterval;
|
||||||
extern int32_t tsMqRebalanceInterval;
|
extern int32_t tsMqRebalanceInterval;
|
||||||
extern int32_t tsStreamCheckpointInterval;
|
extern int32_t tsStreamCheckpointInterval;
|
||||||
extern float tsSinkDataRate;
|
extern float tsSinkDataRate;
|
||||||
|
@ -213,6 +215,7 @@ extern int32_t tsMaxStreamBackendCache;
|
||||||
extern int32_t tsPQSortMemThreshold;
|
extern int32_t tsPQSortMemThreshold;
|
||||||
extern int32_t tsResolveFQDNRetryTime;
|
extern int32_t tsResolveFQDNRetryTime;
|
||||||
|
|
||||||
|
extern bool tsExperimental;
|
||||||
// #define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
|
// #define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
|
||||||
|
|
||||||
int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd,
|
int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd,
|
||||||
|
|
|
@ -144,6 +144,8 @@ typedef enum _mgmt_table {
|
||||||
TSDB_MGMT_TABLE_STREAM_TASKS,
|
TSDB_MGMT_TABLE_STREAM_TASKS,
|
||||||
TSDB_MGMT_TABLE_PRIVILEGES,
|
TSDB_MGMT_TABLE_PRIVILEGES,
|
||||||
TSDB_MGMT_TABLE_VIEWS,
|
TSDB_MGMT_TABLE_VIEWS,
|
||||||
|
TSDB_MGMT_TABLE_COMPACT,
|
||||||
|
TSDB_MGMT_TABLE_COMPACT_DETAIL,
|
||||||
TSDB_MGMT_TABLE_MAX,
|
TSDB_MGMT_TABLE_MAX,
|
||||||
} EShowType;
|
} EShowType;
|
||||||
|
|
||||||
|
@ -295,7 +297,37 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_SYNCDB_STMT,
|
QUERY_NODE_SYNCDB_STMT,
|
||||||
QUERY_NODE_GRANT_STMT,
|
QUERY_NODE_GRANT_STMT,
|
||||||
QUERY_NODE_REVOKE_STMT,
|
QUERY_NODE_REVOKE_STMT,
|
||||||
QUERY_NODE_SHOW_DNODES_STMT,
|
// placeholder for [152, 180]
|
||||||
|
QUERY_NODE_SHOW_CREATE_VIEW_STMT = 181,
|
||||||
|
QUERY_NODE_SHOW_CREATE_DATABASE_STMT,
|
||||||
|
QUERY_NODE_SHOW_CREATE_TABLE_STMT,
|
||||||
|
QUERY_NODE_SHOW_CREATE_STABLE_STMT,
|
||||||
|
QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT,
|
||||||
|
QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT,
|
||||||
|
QUERY_NODE_SHOW_SCORES_STMT,
|
||||||
|
QUERY_NODE_SHOW_TABLE_TAGS_STMT,
|
||||||
|
QUERY_NODE_KILL_CONNECTION_STMT,
|
||||||
|
QUERY_NODE_KILL_QUERY_STMT,
|
||||||
|
QUERY_NODE_KILL_TRANSACTION_STMT,
|
||||||
|
QUERY_NODE_KILL_COMPACT_STMT,
|
||||||
|
QUERY_NODE_DELETE_STMT,
|
||||||
|
QUERY_NODE_INSERT_STMT,
|
||||||
|
QUERY_NODE_QUERY,
|
||||||
|
QUERY_NODE_SHOW_DB_ALIVE_STMT,
|
||||||
|
QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT,
|
||||||
|
QUERY_NODE_BALANCE_VGROUP_LEADER_STMT,
|
||||||
|
QUERY_NODE_RESTORE_DNODE_STMT,
|
||||||
|
QUERY_NODE_RESTORE_QNODE_STMT,
|
||||||
|
QUERY_NODE_RESTORE_MNODE_STMT,
|
||||||
|
QUERY_NODE_RESTORE_VNODE_STMT,
|
||||||
|
QUERY_NODE_PAUSE_STREAM_STMT,
|
||||||
|
QUERY_NODE_RESUME_STREAM_STMT,
|
||||||
|
QUERY_NODE_CREATE_VIEW_STMT,
|
||||||
|
QUERY_NODE_DROP_VIEW_STMT,
|
||||||
|
|
||||||
|
// show statement nodes
|
||||||
|
// see 'sysTableShowAdapter', 'SYSTABLE_SHOW_TYPE_OFFSET'
|
||||||
|
QUERY_NODE_SHOW_DNODES_STMT = 400,
|
||||||
QUERY_NODE_SHOW_MNODES_STMT,
|
QUERY_NODE_SHOW_MNODES_STMT,
|
||||||
QUERY_NODE_SHOW_MODULES_STMT,
|
QUERY_NODE_SHOW_MODULES_STMT,
|
||||||
QUERY_NODE_SHOW_QNODES_STMT,
|
QUERY_NODE_SHOW_QNODES_STMT,
|
||||||
|
@ -324,31 +356,8 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_SHOW_VNODES_STMT,
|
QUERY_NODE_SHOW_VNODES_STMT,
|
||||||
QUERY_NODE_SHOW_USER_PRIVILEGES_STMT,
|
QUERY_NODE_SHOW_USER_PRIVILEGES_STMT,
|
||||||
QUERY_NODE_SHOW_VIEWS_STMT,
|
QUERY_NODE_SHOW_VIEWS_STMT,
|
||||||
QUERY_NODE_SHOW_CREATE_VIEW_STMT,
|
QUERY_NODE_SHOW_COMPACTS_STMT,
|
||||||
QUERY_NODE_SHOW_CREATE_DATABASE_STMT,
|
QUERY_NODE_SHOW_COMPACT_DETAILS_STMT,
|
||||||
QUERY_NODE_SHOW_CREATE_TABLE_STMT,
|
|
||||||
QUERY_NODE_SHOW_CREATE_STABLE_STMT,
|
|
||||||
QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT,
|
|
||||||
QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT,
|
|
||||||
QUERY_NODE_SHOW_SCORES_STMT,
|
|
||||||
QUERY_NODE_SHOW_TABLE_TAGS_STMT,
|
|
||||||
QUERY_NODE_KILL_CONNECTION_STMT,
|
|
||||||
QUERY_NODE_KILL_QUERY_STMT,
|
|
||||||
QUERY_NODE_KILL_TRANSACTION_STMT,
|
|
||||||
QUERY_NODE_DELETE_STMT,
|
|
||||||
QUERY_NODE_INSERT_STMT,
|
|
||||||
QUERY_NODE_QUERY,
|
|
||||||
QUERY_NODE_SHOW_DB_ALIVE_STMT,
|
|
||||||
QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT,
|
|
||||||
QUERY_NODE_BALANCE_VGROUP_LEADER_STMT,
|
|
||||||
QUERY_NODE_RESTORE_DNODE_STMT,
|
|
||||||
QUERY_NODE_RESTORE_QNODE_STMT,
|
|
||||||
QUERY_NODE_RESTORE_MNODE_STMT,
|
|
||||||
QUERY_NODE_RESTORE_VNODE_STMT,
|
|
||||||
QUERY_NODE_PAUSE_STREAM_STMT,
|
|
||||||
QUERY_NODE_RESUME_STREAM_STMT,
|
|
||||||
QUERY_NODE_CREATE_VIEW_STMT,
|
|
||||||
QUERY_NODE_DROP_VIEW_STMT,
|
|
||||||
|
|
||||||
// logic plan node
|
// logic plan node
|
||||||
QUERY_NODE_LOGIC_PLAN_SCAN = 1000,
|
QUERY_NODE_LOGIC_PLAN_SCAN = 1000,
|
||||||
|
@ -1380,6 +1389,24 @@ int32_t tSerializeSCompactDbReq(void* buf, int32_t bufLen, SCompactDbReq* pReq);
|
||||||
int32_t tDeserializeSCompactDbReq(void* buf, int32_t bufLen, SCompactDbReq* pReq);
|
int32_t tDeserializeSCompactDbReq(void* buf, int32_t bufLen, SCompactDbReq* pReq);
|
||||||
void tFreeSCompactDbReq(SCompactDbReq* pReq);
|
void tFreeSCompactDbReq(SCompactDbReq* pReq);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t compactId;
|
||||||
|
int8_t bAccepted;
|
||||||
|
} SCompactDbRsp;
|
||||||
|
|
||||||
|
int32_t tSerializeSCompactDbRsp(void* buf, int32_t bufLen, SCompactDbRsp* pRsp);
|
||||||
|
int32_t tDeserializeSCompactDbRsp(void* buf, int32_t bufLen, SCompactDbRsp* pRsp);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t compactId;
|
||||||
|
int32_t sqlLen;
|
||||||
|
char* sql;
|
||||||
|
} SKillCompactReq;
|
||||||
|
|
||||||
|
int32_t tSerializeSKillCompactReq(void* buf, int32_t bufLen, SKillCompactReq* pReq);
|
||||||
|
int32_t tDeserializeSKillCompactReq(void* buf, int32_t bufLen, SKillCompactReq* pReq);
|
||||||
|
void tFreeSKillCompactReq(SKillCompactReq *pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_FUNC_NAME_LEN];
|
char name[TSDB_FUNC_NAME_LEN];
|
||||||
int8_t igExists;
|
int8_t igExists;
|
||||||
|
@ -1658,6 +1685,26 @@ int32_t tSerializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pR
|
||||||
int32_t tDeserializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pReq);
|
int32_t tDeserializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pReq);
|
||||||
int32_t tFreeSCreateVnodeReq(SCreateVnodeReq* pReq);
|
int32_t tFreeSCreateVnodeReq(SCreateVnodeReq* pReq);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t compactId;
|
||||||
|
int32_t vgId;
|
||||||
|
int32_t dnodeId;
|
||||||
|
} SQueryCompactProgressReq;
|
||||||
|
|
||||||
|
int32_t tSerializeSQueryCompactProgressReq(void* buf, int32_t bufLen, SQueryCompactProgressReq* pReq);
|
||||||
|
int32_t tDeserializeSQueryCompactProgressReq(void* buf, int32_t bufLen, SQueryCompactProgressReq* pReq);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t compactId;
|
||||||
|
int32_t vgId;
|
||||||
|
int32_t dnodeId;
|
||||||
|
int32_t numberFileset;
|
||||||
|
int32_t finished;
|
||||||
|
} SQueryCompactProgressRsp;
|
||||||
|
|
||||||
|
int32_t tSerializeSQueryCompactProgressRsp(void* buf, int32_t bufLen, SQueryCompactProgressRsp* pReq);
|
||||||
|
int32_t tDeserializeSQueryCompactProgressRsp(void* buf, int32_t bufLen, SQueryCompactProgressRsp* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
|
@ -1685,11 +1732,21 @@ typedef struct {
|
||||||
char db[TSDB_DB_FNAME_LEN];
|
char db[TSDB_DB_FNAME_LEN];
|
||||||
int64_t compactStartTime;
|
int64_t compactStartTime;
|
||||||
STimeWindow tw;
|
STimeWindow tw;
|
||||||
|
int32_t compactId;
|
||||||
} SCompactVnodeReq;
|
} SCompactVnodeReq;
|
||||||
|
|
||||||
int32_t tSerializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq* pReq);
|
int32_t tSerializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq* pReq);
|
||||||
int32_t tDeserializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq* pReq);
|
int32_t tDeserializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq* pReq);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t compactId;
|
||||||
|
int32_t vgId;
|
||||||
|
int32_t dnodeId;
|
||||||
|
} SVKillCompactReq;
|
||||||
|
|
||||||
|
int32_t tSerializeSVKillCompactReq(void* buf, int32_t bufLen, SVKillCompactReq* pReq);
|
||||||
|
int32_t tDeserializeSVKillCompactReq(void* buf, int32_t bufLen, SVKillCompactReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t vgVersion;
|
int32_t vgVersion;
|
||||||
int32_t buffer;
|
int32_t buffer;
|
||||||
|
@ -1885,8 +1942,9 @@ typedef struct {
|
||||||
char db[TSDB_DB_FNAME_LEN];
|
char db[TSDB_DB_FNAME_LEN];
|
||||||
char tb[TSDB_TABLE_NAME_LEN];
|
char tb[TSDB_TABLE_NAME_LEN];
|
||||||
char user[TSDB_USER_LEN];
|
char user[TSDB_USER_LEN];
|
||||||
char filterTb[TSDB_TABLE_NAME_LEN];
|
char filterTb[TSDB_TABLE_NAME_LEN]; // for ins_columns
|
||||||
int64_t showId;
|
int64_t showId;
|
||||||
|
int64_t compactId; // for compact
|
||||||
} SRetrieveTableReq;
|
} SRetrieveTableReq;
|
||||||
|
|
||||||
typedef struct SSysTableSchema {
|
typedef struct SSysTableSchema {
|
||||||
|
|
|
@ -26,10 +26,10 @@
|
||||||
|
|
||||||
#undef TD_NEW_MSG_SEG
|
#undef TD_NEW_MSG_SEG
|
||||||
#undef TD_DEF_MSG_TYPE
|
#undef TD_DEF_MSG_TYPE
|
||||||
#undef TD_CLOSE_MSG_TYPE
|
#undef TD_CLOSE_MSG_SEG
|
||||||
#define TD_NEW_MSG_SEG(TYPE) "null",
|
#define TD_NEW_MSG_SEG(TYPE) "null",
|
||||||
#define TD_DEF_MSG_TYPE(TYPE, MSG, REQ, RSP) MSG, MSG "-rsp",
|
#define TD_DEF_MSG_TYPE(TYPE, MSG, REQ, RSP) MSG, MSG "-rsp",
|
||||||
#define TD_CLOSE_MSG_TYPE(TYPE)
|
#define TD_CLOSE_MSG_SEG(TYPE)
|
||||||
|
|
||||||
char *tMsgInfo[] = {
|
char *tMsgInfo[] = {
|
||||||
|
|
||||||
|
@ -37,20 +37,20 @@
|
||||||
|
|
||||||
#undef TD_NEW_MSG_SEG
|
#undef TD_NEW_MSG_SEG
|
||||||
#undef TD_DEF_MSG_TYPE
|
#undef TD_DEF_MSG_TYPE
|
||||||
#undef TD_CLOSE_MSG_TYPE
|
#undef TD_CLOSE_MSG_SEG
|
||||||
#define TD_NEW_MSG_SEG(TYPE)
|
#define TD_NEW_MSG_SEG(TYPE)
|
||||||
#define TD_DEF_MSG_TYPE(TYPE, MSG, REQ, RSP)
|
#define TD_DEF_MSG_TYPE(TYPE, MSG, REQ, RSP)
|
||||||
#define TD_CLOSE_MSG_TYPE(TYPE) TYPE,
|
#define TD_CLOSE_MSG_SEG(TYPE) TYPE,
|
||||||
int32_t tMsgRangeDict[] = {
|
int32_t tMsgRangeDict[] = {
|
||||||
|
|
||||||
#elif defined(TD_MSG_NUMBER_)
|
#elif defined(TD_MSG_NUMBER_)
|
||||||
|
|
||||||
#undef TD_NEW_MSG_SEG
|
#undef TD_NEW_MSG_SEG
|
||||||
#undef TD_DEF_MSG_TYPE
|
#undef TD_DEF_MSG_TYPE
|
||||||
#undef TD_CLOSE_MSG_TYPE
|
#undef TD_CLOSE_MSG_SEG
|
||||||
#define TD_NEW_MSG_SEG(TYPE) TYPE##_NUM,
|
#define TD_NEW_MSG_SEG(TYPE) TYPE##_NUM,
|
||||||
#define TD_DEF_MSG_TYPE(TYPE, MSG, REQ, RSP) TYPE##_NUM, TYPE##_RSP_NUM,
|
#define TD_DEF_MSG_TYPE(TYPE, MSG, REQ, RSP) TYPE##_NUM, TYPE##_RSP_NUM,
|
||||||
#define TD_CLOSE_MSG_TYPE(TYPE)
|
#define TD_CLOSE_MSG_SEG(TYPE)
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
|
||||||
|
@ -58,10 +58,10 @@
|
||||||
|
|
||||||
#undef TD_NEW_MSG_SEG
|
#undef TD_NEW_MSG_SEG
|
||||||
#undef TD_DEF_MSG_TYPE
|
#undef TD_DEF_MSG_TYPE
|
||||||
#undef TD_CLOSE_MSG_TYPE
|
#undef TD_CLOSE_MSG_SEG
|
||||||
#define TD_NEW_MSG_SEG(TYPE) TYPE##_NUM,
|
#define TD_NEW_MSG_SEG(TYPE) TYPE##_NUM,
|
||||||
#define TD_DEF_MSG_TYPE(TYPE, MSG, REQ, RSP)
|
#define TD_DEF_MSG_TYPE(TYPE, MSG, REQ, RSP)
|
||||||
#define TD_CLOSE_MSG_TYPE(type)
|
#define TD_CLOSE_MSG_SEG(type)
|
||||||
|
|
||||||
int32_t tMsgDict[] = {
|
int32_t tMsgDict[] = {
|
||||||
|
|
||||||
|
@ -70,10 +70,10 @@
|
||||||
|
|
||||||
#undef TD_NEW_MSG_SEG
|
#undef TD_NEW_MSG_SEG
|
||||||
#undef TD_DEF_MSG_TYPE
|
#undef TD_DEF_MSG_TYPE
|
||||||
#undef TD_CLOSE_MSG_TYPE
|
#undef TD_CLOSE_MSG_SEG
|
||||||
#define TD_NEW_MSG_SEG(TYPE) TYPE##_SEG_CODE,
|
#define TD_NEW_MSG_SEG(TYPE) TYPE##_SEG_CODE,
|
||||||
#define TD_DEF_MSG_TYPE(TYPE, MSG, REQ, RSP)
|
#define TD_DEF_MSG_TYPE(TYPE, MSG, REQ, RSP)
|
||||||
#define TD_CLOSE_MSG_TYPE(TYPE)
|
#define TD_CLOSE_MSG_SEG(TYPE)
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
|
||||||
|
@ -82,10 +82,10 @@
|
||||||
|
|
||||||
#undef TD_NEW_MSG_SEG
|
#undef TD_NEW_MSG_SEG
|
||||||
#undef TD_DEF_MSG_TYPE
|
#undef TD_DEF_MSG_TYPE
|
||||||
#undef TD_CLOSE_MSG_TYPE
|
#undef TD_CLOSE_MSG_SEG
|
||||||
#define TD_NEW_MSG_SEG(TYPE) TYPE = ((TYPE##_SEG_CODE) << 8),
|
#define TD_NEW_MSG_SEG(TYPE) TYPE = ((TYPE##_SEG_CODE) << 8),
|
||||||
#define TD_DEF_MSG_TYPE(TYPE, MSG, REQ, RSP) TYPE, TYPE##_RSP,
|
#define TD_DEF_MSG_TYPE(TYPE, MSG, REQ, RSP) TYPE, TYPE##_RSP,
|
||||||
#define TD_CLOSE_MSG_TYPE(TYPE) TYPE,
|
#define TD_CLOSE_MSG_SEG(TYPE) TYPE,
|
||||||
|
|
||||||
enum { // WARN: new msg should be appended to segment tail
|
enum { // WARN: new msg should be appended to segment tail
|
||||||
#endif
|
#endif
|
||||||
|
@ -109,7 +109,7 @@
|
||||||
TD_DEF_MSG_TYPE(TDMT_DND_ALTER_VNODE_TYPE, "dnode-alter-vnode-type", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_DND_ALTER_VNODE_TYPE, "dnode-alter-vnode-type", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_DND_CHECK_VNODE_LEARNER_CATCHUP, "dnode-check-vnode-learner-catchup", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_DND_CHECK_VNODE_LEARNER_CATCHUP, "dnode-check-vnode-learner-catchup", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_DND_MAX_MSG, "dnd-max", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_DND_MAX_MSG, "dnd-max", NULL, NULL)
|
||||||
TD_CLOSE_MSG_TYPE(TDMT_END_DND_MSG)
|
TD_CLOSE_MSG_SEG(TDMT_END_DND_MSG)
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_MND_MSG) // 1<<8
|
TD_NEW_MSG_SEG(TDMT_MND_MSG) // 1<<8
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_CONNECT, "connect", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_CONNECT, "connect", NULL, NULL)
|
||||||
|
@ -217,8 +217,10 @@
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_VIEW, "create-view", SCMCreateViewReq, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_VIEW, "create-view", SCMCreateViewReq, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_DROP_VIEW, "drop-view", SCMDropViewReq, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_DROP_VIEW, "drop-view", SCMDropViewReq, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_VIEW_META, "view-meta", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_VIEW_META, "view-meta", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_MND_KILL_COMPACT, "kill-compact", SKillCompactReq, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_MND_COMPACT_TIMER, "compact-tmr", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_MAX_MSG, "mnd-max", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_MAX_MSG, "mnd-max", NULL, NULL)
|
||||||
TD_CLOSE_MSG_TYPE(TDMT_END_MND_MSG)
|
TD_CLOSE_MSG_SEG(TDMT_END_MND_MSG)
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_VND_MSG) // 2<<8
|
TD_NEW_MSG_SEG(TDMT_VND_MSG) // 2<<8
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT, "submit", SSubmitReq, SSubmitRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT, "submit", SSubmitReq, SSubmitRsp)
|
||||||
|
@ -256,7 +258,7 @@
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_EXEC_RSMA, "vnode-exec-rsma", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_EXEC_RSMA, "vnode-exec-rsma", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_DELETE, "delete-data", SVDeleteReq, SVDeleteRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_DELETE, "delete-data", SVDeleteReq, SVDeleteRsp)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_BATCH_DEL, "batch-delete", SBatchDeleteReq, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_BATCH_DEL, "batch-delete", SBatchDeleteReq, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "alter-config", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "alter-config", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_REPLICA, "alter-replica", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_REPLICA, "alter-replica", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIRM, "alter-confirm", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIRM, "alter-confirm", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_HASHRANGE, "alter-hashrange", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_HASHRANGE, "alter-hashrange", NULL, NULL)
|
||||||
|
@ -267,8 +269,10 @@ TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "alter-config", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_INDEX, "vnode-create-index", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_INDEX, "vnode-create-index", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_DROP_INDEX, "vnode-drop-index", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_DROP_INDEX, "vnode-drop-index", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_DISABLE_WRITE, "vnode-disable-write", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_DISABLE_WRITE, "vnode-disable-write", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_VND_QUERY_COMPACT_PROGRESS, "vnode-query-compact-progress", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_VND_KILL_COMPACT, "kill-compact", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_MAX_MSG, "vnd-max", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_MAX_MSG, "vnd-max", NULL, NULL)
|
||||||
TD_CLOSE_MSG_TYPE(TDMT_END_VND_MSG)
|
TD_CLOSE_MSG_SEG(TDMT_END_VND_MSG)
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_SCH_MSG) // 3<<8
|
TD_NEW_MSG_SEG(TDMT_SCH_MSG) // 3<<8
|
||||||
TD_DEF_MSG_TYPE(TDMT_SCH_QUERY, "query", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SCH_QUERY, "query", NULL, NULL)
|
||||||
|
@ -283,7 +287,7 @@ TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "alter-config", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SCH_LINK_BROKEN, "link-broken", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SCH_LINK_BROKEN, "link-broken", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SCH_TASK_NOTIFY, "task-notify", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SCH_TASK_NOTIFY, "task-notify", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SCH_MAX_MSG, "sch-max", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SCH_MAX_MSG, "sch-max", NULL, NULL)
|
||||||
TD_CLOSE_MSG_TYPE(TDMT_END_SCH_MSG)
|
TD_CLOSE_MSG_SEG(TDMT_END_SCH_MSG)
|
||||||
|
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_STREAM_MSG) //4 << 8
|
TD_NEW_MSG_SEG(TDMT_STREAM_MSG) //4 << 8
|
||||||
|
@ -301,11 +305,11 @@ TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "alter-config", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_STOP, "stream-task-stop", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_STOP, "stream-task-stop", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_STREAM_HTASK_DROP, "stream-htask-drop", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_STREAM_HTASK_DROP, "stream-htask-drop", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_STREAM_MAX_MSG, "stream-max", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_STREAM_MAX_MSG, "stream-max", NULL, NULL)
|
||||||
TD_CLOSE_MSG_TYPE(TDMT_END_STREAM_MSG)
|
TD_CLOSE_MSG_SEG(TDMT_END_STREAM_MSG)
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_MON_MSG) //5 << 8
|
TD_NEW_MSG_SEG(TDMT_MON_MSG) //5 << 8
|
||||||
TD_DEF_MSG_TYPE(TDMT_MON_MAX_MSG, "monitor-max", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MON_MAX_MSG, "monitor-max", NULL, NULL)
|
||||||
TD_CLOSE_MSG_TYPE(TDMT_END_MON_MSG)
|
TD_CLOSE_MSG_SEG(TDMT_END_MON_MSG)
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_SYNC_MSG) //6 << 8
|
TD_NEW_MSG_SEG(TDMT_SYNC_MSG) //6 << 8
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_TIMEOUT, "sync-timer", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_TIMEOUT, "sync-timer", NULL, NULL)
|
||||||
|
@ -337,7 +341,7 @@ TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "alter-config", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_PREP_SNAPSHOT_REPLY, "sync-prep-snapshot-reply", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_PREP_SNAPSHOT_REPLY, "sync-prep-snapshot-reply", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_MAX_MSG, "sync-max", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_MAX_MSG, "sync-max", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_FORCE_FOLLOWER, "sync-force-become-follower", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_FORCE_FOLLOWER, "sync-force-become-follower", NULL, NULL)
|
||||||
TD_CLOSE_MSG_TYPE(TDMT_END_SYNC_MSG)
|
TD_CLOSE_MSG_SEG(TDMT_END_SYNC_MSG)
|
||||||
|
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_VND_STREAM_MSG) //7 << 8
|
TD_NEW_MSG_SEG(TDMT_VND_STREAM_MSG) //7 << 8
|
||||||
|
@ -348,7 +352,7 @@ TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "alter-config", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TASK_RESET, "vnode-stream-reset", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TASK_RESET, "vnode-stream-reset", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TASK_CHECK, "vnode-stream-task-check", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TASK_CHECK, "vnode-stream-task-check", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_MAX_MSG, "vnd-stream-max", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_MAX_MSG, "vnd-stream-max", NULL, NULL)
|
||||||
TD_CLOSE_MSG_TYPE(TDMT_END_VND_STREAM_MSG)
|
TD_CLOSE_MSG_SEG(TDMT_END_VND_STREAM_MSG)
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_VND_TMQ_MSG) //8 << 8
|
TD_NEW_MSG_SEG(TDMT_VND_TMQ_MSG) //8 << 8
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_SUBSCRIBE, "vnode-tmq-subscribe", SMqRebVgReq, SMqRebVgRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_SUBSCRIBE, "vnode-tmq-subscribe", SMqRebVgReq, SMqRebVgRsp)
|
||||||
|
@ -362,10 +366,10 @@ TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "alter-config", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_VG_WALINFO, "vnode-tmq-vg-walinfo", SMqPollReq, SMqDataBlkRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_VG_WALINFO, "vnode-tmq-vg-walinfo", SMqPollReq, SMqDataBlkRsp)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_VG_COMMITTEDINFO, "vnode-tmq-committedinfo", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_VG_COMMITTEDINFO, "vnode-tmq-committedinfo", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_MAX_MSG, "vnd-tmq-max", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_MAX_MSG, "vnd-tmq-max", NULL, NULL)
|
||||||
TD_CLOSE_MSG_TYPE(TDMT_END_TMQ_MSG)
|
TD_CLOSE_MSG_SEG(TDMT_END_TMQ_MSG)
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_MAX_MSG) // msg end mark
|
TD_NEW_MSG_SEG(TDMT_MAX_MSG) // msg end mark
|
||||||
|
TD_CLOSE_MSG_SEG(TDMT_END_MAX_MSG)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -189,184 +189,180 @@
|
||||||
#define TK_ALIVE 170
|
#define TK_ALIVE 170
|
||||||
#define TK_VIEWS 171
|
#define TK_VIEWS 171
|
||||||
#define TK_VIEW 172
|
#define TK_VIEW 172
|
||||||
#define TK_NORMAL 173
|
#define TK_COMPACTS 173
|
||||||
#define TK_CHILD 174
|
#define TK_NORMAL 174
|
||||||
#define TK_LIKE 175
|
#define TK_CHILD 175
|
||||||
#define TK_TBNAME 176
|
#define TK_LIKE 176
|
||||||
#define TK_QTAGS 177
|
#define TK_TBNAME 177
|
||||||
#define TK_AS 178
|
#define TK_QTAGS 178
|
||||||
#define TK_SYSTEM 179
|
#define TK_AS 179
|
||||||
#define TK_INDEX 180
|
#define TK_SYSTEM 180
|
||||||
#define TK_FUNCTION 181
|
#define TK_INDEX 181
|
||||||
#define TK_INTERVAL 182
|
#define TK_FUNCTION 182
|
||||||
#define TK_COUNT 183
|
#define TK_INTERVAL 183
|
||||||
#define TK_LAST_ROW 184
|
#define TK_COUNT 184
|
||||||
#define TK_META 185
|
#define TK_LAST_ROW 185
|
||||||
#define TK_ONLY 186
|
#define TK_META 186
|
||||||
#define TK_TOPIC 187
|
#define TK_ONLY 187
|
||||||
#define TK_CONSUMER 188
|
#define TK_TOPIC 188
|
||||||
#define TK_GROUP 189
|
#define TK_CONSUMER 189
|
||||||
#define TK_DESC 190
|
#define TK_GROUP 190
|
||||||
#define TK_DESCRIBE 191
|
#define TK_DESC 191
|
||||||
#define TK_RESET 192
|
#define TK_DESCRIBE 192
|
||||||
#define TK_QUERY 193
|
#define TK_RESET 193
|
||||||
#define TK_CACHE 194
|
#define TK_QUERY 194
|
||||||
#define TK_EXPLAIN 195
|
#define TK_CACHE 195
|
||||||
#define TK_ANALYZE 196
|
#define TK_EXPLAIN 196
|
||||||
#define TK_VERBOSE 197
|
#define TK_ANALYZE 197
|
||||||
#define TK_NK_BOOL 198
|
#define TK_VERBOSE 198
|
||||||
#define TK_RATIO 199
|
#define TK_NK_BOOL 199
|
||||||
#define TK_NK_FLOAT 200
|
#define TK_RATIO 200
|
||||||
#define TK_OUTPUTTYPE 201
|
#define TK_NK_FLOAT 201
|
||||||
#define TK_AGGREGATE 202
|
#define TK_OUTPUTTYPE 202
|
||||||
#define TK_BUFSIZE 203
|
#define TK_AGGREGATE 203
|
||||||
#define TK_LANGUAGE 204
|
#define TK_BUFSIZE 204
|
||||||
#define TK_REPLACE 205
|
#define TK_LANGUAGE 205
|
||||||
#define TK_STREAM 206
|
#define TK_REPLACE 206
|
||||||
#define TK_INTO 207
|
#define TK_STREAM 207
|
||||||
#define TK_PAUSE 208
|
#define TK_INTO 208
|
||||||
#define TK_RESUME 209
|
#define TK_PAUSE 209
|
||||||
#define TK_TRIGGER 210
|
#define TK_RESUME 210
|
||||||
#define TK_AT_ONCE 211
|
#define TK_TRIGGER 211
|
||||||
#define TK_WINDOW_CLOSE 212
|
#define TK_AT_ONCE 212
|
||||||
#define TK_IGNORE 213
|
#define TK_WINDOW_CLOSE 213
|
||||||
#define TK_EXPIRED 214
|
#define TK_IGNORE 214
|
||||||
#define TK_FILL_HISTORY 215
|
#define TK_EXPIRED 215
|
||||||
#define TK_UPDATE 216
|
#define TK_FILL_HISTORY 216
|
||||||
#define TK_SUBTABLE 217
|
#define TK_UPDATE 217
|
||||||
#define TK_UNTREATED 218
|
#define TK_SUBTABLE 218
|
||||||
#define TK_KILL 219
|
#define TK_UNTREATED 219
|
||||||
#define TK_CONNECTION 220
|
#define TK_KILL 220
|
||||||
#define TK_TRANSACTION 221
|
#define TK_CONNECTION 221
|
||||||
#define TK_BALANCE 222
|
#define TK_TRANSACTION 222
|
||||||
#define TK_VGROUP 223
|
#define TK_BALANCE 223
|
||||||
#define TK_LEADER 224
|
#define TK_VGROUP 224
|
||||||
#define TK_MERGE 225
|
#define TK_LEADER 225
|
||||||
#define TK_REDISTRIBUTE 226
|
#define TK_MERGE 226
|
||||||
#define TK_SPLIT 227
|
#define TK_REDISTRIBUTE 227
|
||||||
#define TK_DELETE 228
|
#define TK_SPLIT 228
|
||||||
#define TK_INSERT 229
|
#define TK_DELETE 229
|
||||||
#define TK_NULL 230
|
#define TK_INSERT 230
|
||||||
#define TK_NK_QUESTION 231
|
#define TK_NULL 231
|
||||||
#define TK_NK_ALIAS 232
|
#define TK_NK_QUESTION 232
|
||||||
#define TK_NK_ARROW 233
|
#define TK_NK_ALIAS 233
|
||||||
#define TK_ROWTS 234
|
#define TK_NK_ARROW 234
|
||||||
#define TK_QSTART 235
|
#define TK_ROWTS 235
|
||||||
#define TK_QEND 236
|
#define TK_QSTART 236
|
||||||
#define TK_QDURATION 237
|
#define TK_QEND 237
|
||||||
#define TK_WSTART 238
|
#define TK_QDURATION 238
|
||||||
#define TK_WEND 239
|
#define TK_WSTART 239
|
||||||
#define TK_WDURATION 240
|
#define TK_WEND 240
|
||||||
#define TK_IROWTS 241
|
#define TK_WDURATION 241
|
||||||
#define TK_ISFILLED 242
|
#define TK_IROWTS 242
|
||||||
#define TK_CAST 243
|
#define TK_ISFILLED 243
|
||||||
#define TK_NOW 244
|
#define TK_CAST 244
|
||||||
#define TK_TODAY 245
|
#define TK_NOW 245
|
||||||
#define TK_TIMEZONE 246
|
#define TK_TODAY 246
|
||||||
#define TK_CLIENT_VERSION 247
|
#define TK_TIMEZONE 247
|
||||||
#define TK_SERVER_VERSION 248
|
#define TK_CLIENT_VERSION 248
|
||||||
#define TK_SERVER_STATUS 249
|
#define TK_SERVER_VERSION 249
|
||||||
#define TK_CURRENT_USER 250
|
#define TK_SERVER_STATUS 250
|
||||||
#define TK_CASE 251
|
#define TK_CURRENT_USER 251
|
||||||
#define TK_WHEN 252
|
#define TK_CASE 252
|
||||||
#define TK_THEN 253
|
#define TK_WHEN 253
|
||||||
#define TK_ELSE 254
|
#define TK_THEN 254
|
||||||
#define TK_BETWEEN 255
|
#define TK_ELSE 255
|
||||||
#define TK_IS 256
|
#define TK_BETWEEN 256
|
||||||
#define TK_NK_LT 257
|
#define TK_IS 257
|
||||||
#define TK_NK_GT 258
|
#define TK_NK_LT 258
|
||||||
#define TK_NK_LE 259
|
#define TK_NK_GT 259
|
||||||
#define TK_NK_GE 260
|
#define TK_NK_LE 260
|
||||||
#define TK_NK_NE 261
|
#define TK_NK_GE 261
|
||||||
#define TK_MATCH 262
|
#define TK_NK_NE 262
|
||||||
#define TK_NMATCH 263
|
#define TK_MATCH 263
|
||||||
#define TK_CONTAINS 264
|
#define TK_NMATCH 264
|
||||||
#define TK_IN 265
|
#define TK_CONTAINS 265
|
||||||
#define TK_JOIN 266
|
#define TK_IN 266
|
||||||
#define TK_INNER 267
|
#define TK_JOIN 267
|
||||||
#define TK_SELECT 268
|
#define TK_INNER 268
|
||||||
#define TK_NK_HINT 269
|
#define TK_SELECT 269
|
||||||
#define TK_DISTINCT 270
|
#define TK_NK_HINT 270
|
||||||
#define TK_WHERE 271
|
#define TK_DISTINCT 271
|
||||||
#define TK_PARTITION 272
|
#define TK_WHERE 272
|
||||||
#define TK_BY 273
|
#define TK_PARTITION 273
|
||||||
#define TK_SESSION 274
|
#define TK_BY 274
|
||||||
#define TK_STATE_WINDOW 275
|
#define TK_SESSION 275
|
||||||
#define TK_EVENT_WINDOW 276
|
#define TK_STATE_WINDOW 276
|
||||||
#define TK_SLIDING 277
|
#define TK_EVENT_WINDOW 277
|
||||||
#define TK_FILL 278
|
#define TK_SLIDING 278
|
||||||
#define TK_VALUE 279
|
#define TK_FILL 279
|
||||||
#define TK_VALUE_F 280
|
#define TK_VALUE 280
|
||||||
#define TK_NONE 281
|
#define TK_VALUE_F 281
|
||||||
#define TK_PREV 282
|
#define TK_NONE 282
|
||||||
#define TK_NULL_F 283
|
#define TK_PREV 283
|
||||||
#define TK_LINEAR 284
|
#define TK_NULL_F 284
|
||||||
#define TK_NEXT 285
|
#define TK_LINEAR 285
|
||||||
#define TK_HAVING 286
|
#define TK_NEXT 286
|
||||||
#define TK_RANGE 287
|
#define TK_HAVING 287
|
||||||
#define TK_EVERY 288
|
#define TK_RANGE 288
|
||||||
#define TK_ORDER 289
|
#define TK_EVERY 289
|
||||||
#define TK_SLIMIT 290
|
#define TK_ORDER 290
|
||||||
#define TK_SOFFSET 291
|
#define TK_SLIMIT 291
|
||||||
#define TK_LIMIT 292
|
#define TK_SOFFSET 292
|
||||||
#define TK_OFFSET 293
|
#define TK_LIMIT 293
|
||||||
#define TK_ASC 294
|
#define TK_OFFSET 294
|
||||||
#define TK_NULLS 295
|
#define TK_ASC 295
|
||||||
#define TK_ABORT 296
|
#define TK_NULLS 296
|
||||||
#define TK_AFTER 297
|
#define TK_ABORT 297
|
||||||
#define TK_ATTACH 298
|
#define TK_AFTER 298
|
||||||
#define TK_BEFORE 299
|
#define TK_ATTACH 299
|
||||||
#define TK_BEGIN 300
|
#define TK_BEFORE 300
|
||||||
#define TK_BITAND 301
|
#define TK_BEGIN 301
|
||||||
#define TK_BITNOT 302
|
#define TK_BITAND 302
|
||||||
#define TK_BITOR 303
|
#define TK_BITNOT 303
|
||||||
#define TK_BLOCKS 304
|
#define TK_BITOR 304
|
||||||
#define TK_CHANGE 305
|
#define TK_BLOCKS 305
|
||||||
#define TK_COMMA 306
|
#define TK_CHANGE 306
|
||||||
#define TK_CONCAT 307
|
#define TK_COMMA 307
|
||||||
#define TK_CONFLICT 308
|
#define TK_CONCAT 308
|
||||||
#define TK_COPY 309
|
#define TK_CONFLICT 309
|
||||||
#define TK_DEFERRED 310
|
#define TK_COPY 310
|
||||||
#define TK_DELIMITERS 311
|
#define TK_DEFERRED 311
|
||||||
#define TK_DETACH 312
|
#define TK_DELIMITERS 312
|
||||||
#define TK_DIVIDE 313
|
#define TK_DETACH 313
|
||||||
#define TK_DOT 314
|
#define TK_DIVIDE 314
|
||||||
#define TK_EACH 315
|
#define TK_DOT 315
|
||||||
#define TK_FAIL 316
|
#define TK_EACH 316
|
||||||
#define TK_FILE 317
|
#define TK_FAIL 317
|
||||||
#define TK_FOR 318
|
#define TK_FILE 318
|
||||||
#define TK_GLOB 319
|
#define TK_FOR 319
|
||||||
#define TK_ID 320
|
#define TK_GLOB 320
|
||||||
#define TK_IMMEDIATE 321
|
#define TK_ID 321
|
||||||
#define TK_IMPORT 322
|
#define TK_IMMEDIATE 322
|
||||||
#define TK_INITIALLY 323
|
#define TK_IMPORT 323
|
||||||
#define TK_INSTEAD 324
|
#define TK_INITIALLY 324
|
||||||
#define TK_ISNULL 325
|
#define TK_INSTEAD 325
|
||||||
#define TK_KEY 326
|
#define TK_ISNULL 326
|
||||||
#define TK_MODULES 327
|
#define TK_KEY 327
|
||||||
#define TK_NK_BITNOT 328
|
#define TK_MODULES 328
|
||||||
#define TK_NK_SEMI 329
|
#define TK_NK_BITNOT 329
|
||||||
#define TK_NOTNULL 330
|
#define TK_NK_SEMI 330
|
||||||
#define TK_OF 331
|
#define TK_NOTNULL 331
|
||||||
#define TK_PLUS 332
|
#define TK_OF 332
|
||||||
#define TK_PRIVILEGE 333
|
#define TK_PLUS 333
|
||||||
#define TK_RAISE 334
|
#define TK_PRIVILEGE 334
|
||||||
#define TK_RESTRICT 335
|
#define TK_RAISE 335
|
||||||
#define TK_ROW 336
|
#define TK_RESTRICT 336
|
||||||
#define TK_SEMI 337
|
#define TK_ROW 337
|
||||||
#define TK_STAR 338
|
#define TK_SEMI 338
|
||||||
#define TK_STATEMENT 339
|
#define TK_STAR 339
|
||||||
#define TK_STRICT 340
|
#define TK_STATEMENT 340
|
||||||
#define TK_STRING 341
|
#define TK_STRICT 341
|
||||||
#define TK_TIMES 342
|
#define TK_STRING 342
|
||||||
#define TK_VALUES 343
|
#define TK_TIMES 343
|
||||||
#define TK_VARIABLE 344
|
#define TK_VALUES 344
|
||||||
#define TK_WAL 345
|
#define TK_VARIABLE 345
|
||||||
|
#define TK_WAL 346
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define TK_NK_SPACE 600
|
#define TK_NK_SPACE 600
|
||||||
#define TK_NK_COMMENT 601
|
#define TK_NK_COMMENT 601
|
||||||
|
|
|
@ -275,9 +275,11 @@ typedef struct {
|
||||||
#define IS_VALID_TINYINT(_t) ((_t) >= INT8_MIN && (_t) <= INT8_MAX)
|
#define IS_VALID_TINYINT(_t) ((_t) >= INT8_MIN && (_t) <= INT8_MAX)
|
||||||
#define IS_VALID_SMALLINT(_t) ((_t) >= INT16_MIN && (_t) <= INT16_MAX)
|
#define IS_VALID_SMALLINT(_t) ((_t) >= INT16_MIN && (_t) <= INT16_MAX)
|
||||||
#define IS_VALID_INT(_t) ((_t) >= INT32_MIN && (_t) <= INT32_MAX)
|
#define IS_VALID_INT(_t) ((_t) >= INT32_MIN && (_t) <= INT32_MAX)
|
||||||
|
#define IS_VALID_INT64(_t) ((_t) >= INT64_MIN && (_t) <= INT64_MAX)
|
||||||
#define IS_VALID_UTINYINT(_t) ((_t) >= 0 && (_t) <= UINT8_MAX)
|
#define IS_VALID_UTINYINT(_t) ((_t) >= 0 && (_t) <= UINT8_MAX)
|
||||||
#define IS_VALID_USMALLINT(_t) ((_t) >= 0 && (_t) <= UINT16_MAX)
|
#define IS_VALID_USMALLINT(_t) ((_t) >= 0 && (_t) <= UINT16_MAX)
|
||||||
#define IS_VALID_UINT(_t) ((_t) >= 0 && (_t) <= UINT32_MAX)
|
#define IS_VALID_UINT(_t) ((_t) >= 0 && (_t) <= UINT32_MAX)
|
||||||
|
#define IS_VALID_UINT64(_t) ((_t) >= 0 && (_t) <= UINT64_MAX)
|
||||||
#define IS_VALID_FLOAT(_t) ((_t) >= -FLT_MAX && (_t) <= FLT_MAX)
|
#define IS_VALID_FLOAT(_t) ((_t) >= -FLT_MAX && (_t) <= FLT_MAX)
|
||||||
#define IS_VALID_DOUBLE(_t) ((_t) >= -DBL_MAX && (_t) <= DBL_MAX)
|
#define IS_VALID_DOUBLE(_t) ((_t) >= -DBL_MAX && (_t) <= DBL_MAX)
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,10 @@ typedef struct SVariant {
|
||||||
};
|
};
|
||||||
} SVariant;
|
} SVariant;
|
||||||
|
|
||||||
|
int32_t toIntegerEx(const char *z, int32_t n, uint32_t type, int64_t *value);
|
||||||
|
int32_t toUIntegerEx(const char *z, int32_t n, uint32_t type, uint64_t *value);
|
||||||
|
int32_t toDoubleEx(const char *z, int32_t n, uint32_t type, double *value);
|
||||||
|
|
||||||
int32_t toInteger(const char *z, int32_t n, int32_t base, int64_t *value);
|
int32_t toInteger(const char *z, int32_t n, int32_t base, int64_t *value);
|
||||||
int32_t toUInteger(const char *z, int32_t n, int32_t base, uint64_t *value);
|
int32_t toUInteger(const char *z, int32_t n, int32_t base, uint64_t *value);
|
||||||
|
|
||||||
|
|
|
@ -23,13 +23,13 @@
|
||||||
#include "tjson.h"
|
#include "tjson.h"
|
||||||
#include "tmsgcb.h"
|
#include "tmsgcb.h"
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
#include "mnode.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define AUDIT_DETAIL_MAX 65472
|
#define AUDIT_DETAIL_MAX 65472
|
||||||
|
#define AUDIT_OPERATION_LEN 20
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *server;
|
const char *server;
|
||||||
|
@ -37,13 +37,28 @@ typedef struct {
|
||||||
bool comp;
|
bool comp;
|
||||||
} SAuditCfg;
|
} SAuditCfg;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int64_t curTime;
|
||||||
|
char strClusterId[TSDB_CLUSTER_ID_LEN];
|
||||||
|
char clientAddress[50];
|
||||||
|
char user[TSDB_USER_LEN];
|
||||||
|
char operation[AUDIT_OPERATION_LEN];
|
||||||
|
char target1[TSDB_DB_NAME_LEN]; //put db name
|
||||||
|
char target2[TSDB_STREAM_NAME_LEN]; //put stb name, table name, topic name, user name, stream name, use max
|
||||||
|
char* detail;
|
||||||
|
} SAuditRecord;
|
||||||
|
|
||||||
int32_t auditInit(const SAuditCfg *pCfg);
|
int32_t auditInit(const SAuditCfg *pCfg);
|
||||||
|
void auditCleanup();
|
||||||
void auditSend(SJson *pJson);
|
void auditSend(SJson *pJson);
|
||||||
void auditRecord(SRpcMsg *pReq, int64_t clusterId, char *operation, char *target1, char *target2,
|
void auditRecord(SRpcMsg *pReq, int64_t clusterId, char *operation, char *target1, char *target2,
|
||||||
char *detail, int32_t len);
|
char *detail, int32_t len);
|
||||||
|
void auditAddRecord(SRpcMsg *pReq, int64_t clusterId, char *operation, char *target1, char *target2,
|
||||||
|
char *detail, int32_t len);
|
||||||
|
void auditSendRecordsInBatch();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_MONITOR_H_*/
|
#endif /*_TD_AUDIT_H_*/
|
||||||
|
|
|
@ -152,10 +152,21 @@ typedef struct {
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
/*-------------------------------------------------new api format---------------------------------------------------*/
|
/*-------------------------------------------------new api format---------------------------------------------------*/
|
||||||
|
typedef enum {
|
||||||
|
TSD_READER_NOTIFY_DURATION_START
|
||||||
|
} ETsdReaderNotifyType;
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
struct {
|
||||||
|
int32_t filesetId;
|
||||||
|
} duration;
|
||||||
|
} STsdReaderNotifyInfo;
|
||||||
|
|
||||||
|
typedef void (*TsdReaderNotifyCbFn)(ETsdReaderNotifyType type, STsdReaderNotifyInfo* info, void* param);
|
||||||
|
|
||||||
typedef struct TsdReader {
|
typedef struct TsdReader {
|
||||||
int32_t (*tsdReaderOpen)(void* pVnode, SQueryTableDataCond* pCond, void* pTableList, int32_t numOfTables,
|
int32_t (*tsdReaderOpen)(void* pVnode, SQueryTableDataCond* pCond, void* pTableList, int32_t numOfTables,
|
||||||
SSDataBlock* pResBlock, void** ppReader, const char* idstr, bool countOnly,
|
SSDataBlock* pResBlock, void** ppReader, const char* idstr, SHashObj** pIgnoreTables);
|
||||||
SHashObj** pIgnoreTables);
|
|
||||||
void (*tsdReaderClose)();
|
void (*tsdReaderClose)();
|
||||||
void (*tsdSetReaderTaskId)(void *pReader, const char *pId);
|
void (*tsdSetReaderTaskId)(void *pReader, const char *pId);
|
||||||
int32_t (*tsdSetQueryTableList)();
|
int32_t (*tsdSetQueryTableList)();
|
||||||
|
@ -170,6 +181,9 @@ typedef struct TsdReader {
|
||||||
int32_t (*tsdReaderGetDataBlockDistInfo)();
|
int32_t (*tsdReaderGetDataBlockDistInfo)();
|
||||||
int64_t (*tsdReaderGetNumOfInMemRows)();
|
int64_t (*tsdReaderGetNumOfInMemRows)();
|
||||||
void (*tsdReaderNotifyClosing)();
|
void (*tsdReaderNotifyClosing)();
|
||||||
|
|
||||||
|
void (*tsdSetFilesetDelimited)(void* pReader);
|
||||||
|
void (*tsdSetSetNotifyCb)(void* pReader, TsdReaderNotifyCbFn notifyFn, void* param);
|
||||||
} TsdReader;
|
} TsdReader;
|
||||||
|
|
||||||
typedef struct SStoreCacheReader {
|
typedef struct SStoreCacheReader {
|
||||||
|
|
|
@ -46,6 +46,10 @@ extern "C" {
|
||||||
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE)
|
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE)
|
||||||
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD3_LEN (TSDB_CONFIG_SCOPE_LEN + VARSTR_HEADER_SIZE)
|
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD3_LEN (TSDB_CONFIG_SCOPE_LEN + VARSTR_HEADER_SIZE)
|
||||||
|
|
||||||
|
#define COMPACT_DB_RESULT_COLS 3
|
||||||
|
#define COMPACT_DB_RESULT_FIELD1_LEN 32
|
||||||
|
#define COMPACT_DB_RESULT_FIELD3_LEN 128
|
||||||
|
|
||||||
#define SHOW_ALIVE_RESULT_COLS 1
|
#define SHOW_ALIVE_RESULT_COLS 1
|
||||||
|
|
||||||
#define BIT_FLAG_MASK(n) (1 << n)
|
#define BIT_FLAG_MASK(n) (1 << n)
|
||||||
|
@ -335,6 +339,15 @@ typedef struct SShowTableTagsStmt {
|
||||||
SNodeList* pTags;
|
SNodeList* pTags;
|
||||||
} SShowTableTagsStmt;
|
} SShowTableTagsStmt;
|
||||||
|
|
||||||
|
typedef struct SShowCompactsStmt {
|
||||||
|
ENodeType type;
|
||||||
|
} SShowCompactsStmt;
|
||||||
|
|
||||||
|
typedef struct SShowCompactDetailsStmt {
|
||||||
|
ENodeType type;
|
||||||
|
SNode* pCompactId;
|
||||||
|
} SShowCompactDetailsStmt;
|
||||||
|
|
||||||
typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT, INDEX_TYPE_NORMAL } EIndexType;
|
typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT, INDEX_TYPE_NORMAL } EIndexType;
|
||||||
|
|
||||||
typedef struct SIndexOptions {
|
typedef struct SIndexOptions {
|
||||||
|
|
|
@ -118,6 +118,7 @@ typedef struct SScanLogicNode {
|
||||||
bool igLastNull;
|
bool igLastNull;
|
||||||
bool groupOrderScan;
|
bool groupOrderScan;
|
||||||
bool onlyMetaCtbIdx; // for tag scan with no tbname
|
bool onlyMetaCtbIdx; // for tag scan with no tbname
|
||||||
|
bool filesetDelimited; // returned blocks delimited by fileset
|
||||||
} SScanLogicNode;
|
} SScanLogicNode;
|
||||||
|
|
||||||
typedef struct SJoinLogicNode {
|
typedef struct SJoinLogicNode {
|
||||||
|
@ -432,6 +433,7 @@ typedef struct STableScanPhysiNode {
|
||||||
int8_t igExpired;
|
int8_t igExpired;
|
||||||
bool assignBlockUid;
|
bool assignBlockUid;
|
||||||
int8_t igCheckUpdate;
|
int8_t igCheckUpdate;
|
||||||
|
bool filesetDelimited;
|
||||||
} STableScanPhysiNode;
|
} STableScanPhysiNode;
|
||||||
|
|
||||||
typedef STableScanPhysiNode STableSeqScanPhysiNode;
|
typedef STableScanPhysiNode STableSeqScanPhysiNode;
|
||||||
|
|
|
@ -509,11 +509,8 @@ typedef struct SStreamMeta {
|
||||||
SArray* chkpSaved;
|
SArray* chkpSaved;
|
||||||
SArray* chkpInUse;
|
SArray* chkpInUse;
|
||||||
SRWLatch chkpDirLock;
|
SRWLatch chkpDirLock;
|
||||||
|
void* qHandle;
|
||||||
void* qHandle;
|
void* bkdChkptMgt;
|
||||||
int32_t pauseTaskNum;
|
|
||||||
|
|
||||||
void* bkdChkptMgt;
|
|
||||||
} SStreamMeta;
|
} SStreamMeta;
|
||||||
|
|
||||||
int32_t tEncodeStreamEpInfo(SEncoder* pEncoder, const SStreamChildEpInfo* pInfo);
|
int32_t tEncodeStreamEpInfo(SEncoder* pEncoder, const SStreamChildEpInfo* pInfo);
|
||||||
|
@ -840,11 +837,10 @@ int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int64_t streamId, int3
|
||||||
int32_t streamMetaGetNumOfTasks(SStreamMeta* pMeta);
|
int32_t streamMetaGetNumOfTasks(SStreamMeta* pMeta);
|
||||||
SStreamTask* streamMetaAcquireTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId);
|
SStreamTask* streamMetaAcquireTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId);
|
||||||
void streamMetaReleaseTask(SStreamMeta* pMeta, SStreamTask* pTask);
|
void streamMetaReleaseTask(SStreamMeta* pMeta, SStreamTask* pTask);
|
||||||
int32_t streamMetaReopen(SStreamMeta* pMeta);
|
void streamMetaClear(SStreamMeta* pMeta);
|
||||||
void streamMetaInitBackend(SStreamMeta* pMeta);
|
void streamMetaInitBackend(SStreamMeta* pMeta);
|
||||||
int32_t streamMetaCommit(SStreamMeta* pMeta);
|
int32_t streamMetaCommit(SStreamMeta* pMeta);
|
||||||
int32_t streamMetaLoadAllTasks(SStreamMeta* pMeta);
|
int32_t streamMetaLoadAllTasks(SStreamMeta* pMeta);
|
||||||
int32_t streamMetaReloadAllTasks(SStreamMeta* pMeta);
|
|
||||||
int64_t streamMetaGetLatestCheckpointId(SStreamMeta* pMeta);
|
int64_t streamMetaGetLatestCheckpointId(SStreamMeta* pMeta);
|
||||||
void streamMetaNotifyClose(SStreamMeta* pMeta);
|
void streamMetaNotifyClose(SStreamMeta* pMeta);
|
||||||
int32_t streamTaskSetDb(SStreamMeta* pMeta, void* pTask, char* key);
|
int32_t streamTaskSetDb(SStreamMeta* pMeta, void* pTask, char* key);
|
||||||
|
|
|
@ -33,11 +33,12 @@ extern "C" {
|
||||||
#define SYNC_MAX_PROGRESS_WAIT_MS 4000
|
#define SYNC_MAX_PROGRESS_WAIT_MS 4000
|
||||||
#define SYNC_MAX_START_TIME_RANGE_MS (1000 * 20)
|
#define SYNC_MAX_START_TIME_RANGE_MS (1000 * 20)
|
||||||
#define SYNC_MAX_RECV_TIME_RANGE_MS 1200
|
#define SYNC_MAX_RECV_TIME_RANGE_MS 1200
|
||||||
#define SYNC_DEL_WAL_MS (1000 * 60)
|
|
||||||
#define SYNC_ADD_QUORUM_COUNT 3
|
#define SYNC_ADD_QUORUM_COUNT 3
|
||||||
#define SYNC_VNODE_LOG_RETENTION (TSDB_SYNC_LOG_BUFFER_RETENTION + 1)
|
#define SYNC_VNODE_LOG_RETENTION (TSDB_SYNC_LOG_BUFFER_RETENTION + 1)
|
||||||
#define SNAPSHOT_WAIT_MS 1000 * 5
|
#define SNAPSHOT_WAIT_MS 1000 * 5
|
||||||
|
|
||||||
|
#define SYNC_WAL_LOG_RETENTION_SIZE (8LL * 1024 * 1024 * 1024)
|
||||||
|
|
||||||
#define SYNC_MAX_RETRY_BACKOFF 5
|
#define SYNC_MAX_RETRY_BACKOFF 5
|
||||||
#define SYNC_LOG_REPL_RETRY_WAIT_MS 100
|
#define SYNC_LOG_REPL_RETRY_WAIT_MS 100
|
||||||
#define SYNC_APPEND_ENTRIES_TIMEOUT_MS 10000
|
#define SYNC_APPEND_ENTRIES_TIMEOUT_MS 10000
|
||||||
|
@ -219,6 +220,7 @@ typedef struct SSyncLogStore {
|
||||||
|
|
||||||
SyncIndex (*syncLogWriteIndex)(struct SSyncLogStore* pLogStore);
|
SyncIndex (*syncLogWriteIndex)(struct SSyncLogStore* pLogStore);
|
||||||
SyncIndex (*syncLogLastIndex)(struct SSyncLogStore* pLogStore);
|
SyncIndex (*syncLogLastIndex)(struct SSyncLogStore* pLogStore);
|
||||||
|
SyncIndex (*syncLogIndexRetention)(struct SSyncLogStore* pLogStore, int64_t bytes);
|
||||||
SyncTerm (*syncLogLastTerm)(struct SSyncLogStore* pLogStore);
|
SyncTerm (*syncLogLastTerm)(struct SSyncLogStore* pLogStore);
|
||||||
|
|
||||||
int32_t (*syncLogAppendEntry)(struct SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry, bool forcSync);
|
int32_t (*syncLogAppendEntry)(struct SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry, bool forcSync);
|
||||||
|
@ -289,6 +291,9 @@ const char* syncStr(ESyncState state);
|
||||||
|
|
||||||
int32_t syncNodeGetConfig(int64_t rid, SSyncCfg *cfg);
|
int32_t syncNodeGetConfig(int64_t rid, SSyncCfg *cfg);
|
||||||
|
|
||||||
|
// util
|
||||||
|
int32_t syncSnapInfoDataRealloc(SSnapshot* pSnap, int32_t size);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -225,6 +225,7 @@ bool walIsEmpty(SWal *);
|
||||||
int64_t walGetFirstVer(SWal *);
|
int64_t walGetFirstVer(SWal *);
|
||||||
int64_t walGetSnapshotVer(SWal *);
|
int64_t walGetSnapshotVer(SWal *);
|
||||||
int64_t walGetLastVer(SWal *);
|
int64_t walGetLastVer(SWal *);
|
||||||
|
int64_t walGetVerRetention(SWal *pWal, int64_t bytes);
|
||||||
int64_t walGetCommittedVer(SWal *);
|
int64_t walGetCommittedVer(SWal *);
|
||||||
int64_t walGetAppliedVer(SWal *);
|
int64_t walGetAppliedVer(SWal *);
|
||||||
|
|
||||||
|
|
|
@ -47,18 +47,13 @@ typedef int32_t TdUcs4;
|
||||||
#define strtof STR_TO_F_FUNC_TAOS_FORBID
|
#define strtof STR_TO_F_FUNC_TAOS_FORBID
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WINDOWS
|
|
||||||
#define tstrdup(str) _strdup(str)
|
|
||||||
#else
|
|
||||||
#define tstrdup(str) strdup(str)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define tstrncpy(dst, src, size) \
|
#define tstrncpy(dst, src, size) \
|
||||||
do { \
|
do { \
|
||||||
strncpy((dst), (src), (size)); \
|
strncpy((dst), (src), (size)); \
|
||||||
(dst)[(size)-1] = 0; \
|
(dst)[(size)-1] = 0; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
char *tstrdup(const char *src);
|
||||||
int32_t taosUcs4len(TdUcs4 *ucs4);
|
int32_t taosUcs4len(TdUcs4 *ucs4);
|
||||||
int64_t taosStr2int64(const char *str);
|
int64_t taosStr2int64(const char *str);
|
||||||
|
|
||||||
|
|
|
@ -288,6 +288,7 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_CONN_ACTIVE_KEY_LEN 255
|
#define TSDB_CONN_ACTIVE_KEY_LEN 255
|
||||||
|
|
||||||
#define TSDB_DEFAULT_PKT_SIZE 65480 // same as RPC_MAX_UDP_SIZE
|
#define TSDB_DEFAULT_PKT_SIZE 65480 // same as RPC_MAX_UDP_SIZE
|
||||||
|
#define TSDB_SNAP_DATA_PAYLOAD_SIZE (1 * 1024 * 1024)
|
||||||
|
|
||||||
#define TSDB_PAYLOAD_SIZE TSDB_DEFAULT_PKT_SIZE
|
#define TSDB_PAYLOAD_SIZE TSDB_DEFAULT_PKT_SIZE
|
||||||
#define TSDB_DEFAULT_PAYLOAD_SIZE 5120 // default payload size, greater than PATH_MAX value
|
#define TSDB_DEFAULT_PAYLOAD_SIZE 5120 // default payload size, greater than PATH_MAX value
|
||||||
|
|
|
@ -205,7 +205,7 @@ typedef struct SRequestSendRecvBody {
|
||||||
__taos_async_fn_t queryFp;
|
__taos_async_fn_t queryFp;
|
||||||
__taos_async_fn_t fetchFp;
|
__taos_async_fn_t fetchFp;
|
||||||
EQueryExecMode execMode;
|
EQueryExecMode execMode;
|
||||||
void* param;
|
void* interParam;
|
||||||
SDataBuf requestMsg;
|
SDataBuf requestMsg;
|
||||||
int64_t queryJob; // query job, created according to sql query DAG.
|
int64_t queryJob; // query job, created according to sql query DAG.
|
||||||
int32_t subplanNum;
|
int32_t subplanNum;
|
||||||
|
@ -287,6 +287,7 @@ typedef struct SRequestObj {
|
||||||
typedef struct SSyncQueryParam {
|
typedef struct SSyncQueryParam {
|
||||||
tsem_t sem;
|
tsem_t sem;
|
||||||
SRequestObj* pRequest;
|
SRequestObj* pRequest;
|
||||||
|
void* userParam;
|
||||||
} SSyncQueryParam;
|
} SSyncQueryParam;
|
||||||
|
|
||||||
void* doAsyncFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4);
|
void* doAsyncFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4);
|
||||||
|
@ -420,6 +421,7 @@ int32_t buildPreviousRequest(SRequestObj *pRequest, const char* sql, SRequestObj
|
||||||
int32_t prepareAndParseSqlSyntax(SSqlCallbackWrapper **ppWrapper, SRequestObj *pRequest, bool updateMetaForce);
|
int32_t prepareAndParseSqlSyntax(SSqlCallbackWrapper **ppWrapper, SRequestObj *pRequest, bool updateMetaForce);
|
||||||
void returnToUser(SRequestObj* pRequest);
|
void returnToUser(SRequestObj* pRequest);
|
||||||
void stopAllQueries(SRequestObj *pRequest);
|
void stopAllQueries(SRequestObj *pRequest);
|
||||||
|
void doRequestCallback(SRequestObj* pRequest, int32_t code);
|
||||||
void freeQueryParam(SSyncQueryParam* param);
|
void freeQueryParam(SSyncQueryParam* param);
|
||||||
|
|
||||||
#ifdef TD_ENTERPRISE
|
#ifdef TD_ENTERPRISE
|
||||||
|
|
|
@ -65,14 +65,32 @@ extern "C" {
|
||||||
#define IS_INVALID_COL_LEN(len) ((len) <= 0 || (len) >= TSDB_COL_NAME_LEN)
|
#define IS_INVALID_COL_LEN(len) ((len) <= 0 || (len) >= TSDB_COL_NAME_LEN)
|
||||||
#define IS_INVALID_TABLE_LEN(len) ((len) <= 0 || (len) >= TSDB_TABLE_NAME_LEN)
|
#define IS_INVALID_TABLE_LEN(len) ((len) <= 0 || (len) >= TSDB_TABLE_NAME_LEN)
|
||||||
|
|
||||||
//#define TS "_ts"
|
|
||||||
//#define TS_LEN 3
|
|
||||||
#define VALUE "_value"
|
#define VALUE "_value"
|
||||||
#define VALUE_LEN 6
|
#define VALUE_LEN (sizeof(VALUE)-1)
|
||||||
|
|
||||||
#define OTD_JSON_FIELDS_NUM 4
|
#define OTD_JSON_FIELDS_NUM 4
|
||||||
#define MAX_RETRY_TIMES 10
|
#define MAX_RETRY_TIMES 10
|
||||||
typedef TSDB_SML_PROTOCOL_TYPE SMLProtocolType;
|
|
||||||
|
#define IS_SAME_CHILD_TABLE (elements->measureTagsLen == info->preLine.measureTagsLen \
|
||||||
|
&& memcmp(elements->measure, info->preLine.measure, elements->measureTagsLen) == 0)
|
||||||
|
|
||||||
|
#define IS_SAME_SUPER_TABLE (elements->measureLen == info->preLine.measureLen \
|
||||||
|
&& memcmp(elements->measure, info->preLine.measure, elements->measureLen) == 0)
|
||||||
|
|
||||||
|
#define IS_SAME_KEY (maxKV->type == kv->type && maxKV->keyLen == kv->keyLen && memcmp(maxKV->key, kv->key, kv->keyLen) == 0)
|
||||||
|
|
||||||
|
#define IS_SLASH_LETTER_IN_MEASUREMENT(sql) \
|
||||||
|
(*((sql)-1) == SLASH && (*(sql) == COMMA || *(sql) == SPACE))
|
||||||
|
|
||||||
|
#define MOVE_FORWARD_ONE(sql, len) (memmove((void *)((sql)-1), (sql), len))
|
||||||
|
|
||||||
|
#define PROCESS_SLASH_IN_MEASUREMENT(key, keyLen) \
|
||||||
|
for (int i = 1; i < keyLen; ++i) { \
|
||||||
|
if (IS_SLASH_LETTER_IN_MEASUREMENT(key + i)) { \
|
||||||
|
MOVE_FORWARD_ONE(key + i, keyLen - i); \
|
||||||
|
keyLen--; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SCHEMA_ACTION_NULL,
|
SCHEMA_ACTION_NULL,
|
||||||
|
@ -83,18 +101,6 @@ typedef enum {
|
||||||
SCHEMA_ACTION_CHANGE_TAG_SIZE,
|
SCHEMA_ACTION_CHANGE_TAG_SIZE,
|
||||||
} ESchemaAction;
|
} ESchemaAction;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
const void *key;
|
|
||||||
int32_t keyLen;
|
|
||||||
void *value;
|
|
||||||
bool used;
|
|
||||||
}Node;
|
|
||||||
|
|
||||||
typedef struct NodeList{
|
|
||||||
Node data;
|
|
||||||
struct NodeList* next;
|
|
||||||
}NodeList;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *measure;
|
char *measure;
|
||||||
char *tags;
|
char *tags;
|
||||||
|
@ -117,7 +123,6 @@ typedef struct {
|
||||||
int32_t sTableNameLen;
|
int32_t sTableNameLen;
|
||||||
char childTableName[TSDB_TABLE_NAME_LEN];
|
char childTableName[TSDB_TABLE_NAME_LEN];
|
||||||
uint64_t uid;
|
uint64_t uid;
|
||||||
// void *key; // for openTsdb
|
|
||||||
|
|
||||||
SArray *tags;
|
SArray *tags;
|
||||||
|
|
||||||
|
@ -161,7 +166,8 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t id;
|
int64_t id;
|
||||||
|
|
||||||
SMLProtocolType protocol;
|
TSDB_SML_PROTOCOL_TYPE protocol;
|
||||||
|
|
||||||
int8_t precision;
|
int8_t precision;
|
||||||
bool reRun;
|
bool reRun;
|
||||||
bool dataFormat; // true means that the name and order of keys in each line are the same(only for influx protocol)
|
bool dataFormat; // true means that the name and order of keys in each line are the same(only for influx protocol)
|
||||||
|
@ -201,29 +207,8 @@ typedef struct {
|
||||||
bool needModifySchema;
|
bool needModifySchema;
|
||||||
} SSmlHandle;
|
} SSmlHandle;
|
||||||
|
|
||||||
#define IS_SAME_CHILD_TABLE (elements->measureTagsLen == info->preLine.measureTagsLen \
|
extern int64_t smlFactorNS[];
|
||||||
&& memcmp(elements->measure, info->preLine.measure, elements->measureTagsLen) == 0)
|
extern int64_t smlFactorS[];
|
||||||
|
|
||||||
#define IS_SAME_SUPER_TABLE (elements->measureLen == info->preLine.measureLen \
|
|
||||||
&& memcmp(elements->measure, info->preLine.measure, elements->measureLen) == 0)
|
|
||||||
|
|
||||||
#define IS_SAME_KEY (maxKV->keyLen == kv.keyLen && memcmp(maxKV->key, kv.key, kv.keyLen) == 0)
|
|
||||||
|
|
||||||
#define IS_SLASH_LETTER_IN_MEASUREMENT(sql) \
|
|
||||||
(*((sql)-1) == SLASH && (*(sql) == COMMA || *(sql) == SPACE))
|
|
||||||
|
|
||||||
#define MOVE_FORWARD_ONE(sql, len) (memmove((void *)((sql)-1), (sql), len))
|
|
||||||
|
|
||||||
#define PROCESS_SLASH_IN_MEASUREMENT(key, keyLen) \
|
|
||||||
for (int i = 1; i < keyLen; ++i) { \
|
|
||||||
if (IS_SLASH_LETTER_IN_MEASUREMENT(key + i)) { \
|
|
||||||
MOVE_FORWARD_ONE(key + i, keyLen - i); \
|
|
||||||
keyLen--; \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
extern int64_t smlFactorNS[3];
|
|
||||||
extern int64_t smlFactorS[3];
|
|
||||||
|
|
||||||
typedef int32_t (*_equal_fn_sml)(const void *, const void *);
|
typedef int32_t (*_equal_fn_sml)(const void *, const void *);
|
||||||
|
|
||||||
|
@ -231,16 +216,10 @@ SSmlHandle *smlBuildSmlInfo(TAOS *taos);
|
||||||
void smlDestroyInfo(SSmlHandle *info);
|
void smlDestroyInfo(SSmlHandle *info);
|
||||||
int smlJsonParseObjFirst(char **start, SSmlLineInfo *element, int8_t *offset);
|
int smlJsonParseObjFirst(char **start, SSmlLineInfo *element, int8_t *offset);
|
||||||
int smlJsonParseObj(char **start, SSmlLineInfo *element, int8_t *offset);
|
int smlJsonParseObj(char **start, SSmlLineInfo *element, int8_t *offset);
|
||||||
//SArray *smlJsonParseTags(char *start, char *end);
|
|
||||||
bool smlParseNumberOld(SSmlKv *kvVal, SSmlMsgBuf *msg);
|
bool smlParseNumberOld(SSmlKv *kvVal, SSmlMsgBuf *msg);
|
||||||
//void* nodeListGet(NodeList* list, const void *key, int32_t len, _equal_fn_sml fn);
|
|
||||||
//int nodeListSet(NodeList** list, const void *key, int32_t len, void* value, _equal_fn_sml fn);
|
|
||||||
//int nodeListSize(NodeList* list);
|
|
||||||
bool smlDoubleToInt64OverFlow(double num);
|
|
||||||
int32_t smlBuildInvalidDataMsg(SSmlMsgBuf *pBuf, const char *msg1, const char *msg2);
|
int32_t smlBuildInvalidDataMsg(SSmlMsgBuf *pBuf, const char *msg1, const char *msg2);
|
||||||
bool smlParseNumber(SSmlKv *kvVal, SSmlMsgBuf *msg);
|
bool smlParseNumber(SSmlKv *kvVal, SSmlMsgBuf *msg);
|
||||||
int64_t smlGetTimeValue(const char *value, int32_t len, uint8_t fromPrecision, uint8_t toPrecision);
|
int64_t smlGetTimeValue(const char *value, int32_t len, uint8_t fromPrecision, uint8_t toPrecision);
|
||||||
int8_t smlGetTsTypeByLen(int32_t len);
|
|
||||||
SSmlTableInfo* smlBuildTableInfo(int numRows, const char* measure, int32_t measureLen);
|
SSmlTableInfo* smlBuildTableInfo(int numRows, const char* measure, int32_t measureLen);
|
||||||
SSmlSTableMeta* smlBuildSTableMeta(bool isDataFormat);
|
SSmlSTableMeta* smlBuildSTableMeta(bool isDataFormat);
|
||||||
int32_t smlSetCTableName(SSmlTableInfo *oneTable);
|
int32_t smlSetCTableName(SSmlTableInfo *oneTable);
|
||||||
|
@ -253,12 +232,45 @@ int32_t smlParseValue(SSmlKv *pVal, SSmlMsgBuf *msg);
|
||||||
uint8_t smlGetTimestampLen(int64_t num);
|
uint8_t smlGetTimestampLen(int64_t num);
|
||||||
void smlDestroyTableInfo(void *para);
|
void smlDestroyTableInfo(void *para);
|
||||||
|
|
||||||
void freeSSmlKv(void* data);
|
void freeSSmlKv(void* data);
|
||||||
int32_t smlParseInfluxString(SSmlHandle *info, char *sql, char *sqlEnd, SSmlLineInfo *elements);
|
int32_t smlParseInfluxString(SSmlHandle *info, char *sql, char *sqlEnd, SSmlLineInfo *elements);
|
||||||
int32_t smlParseTelnetString(SSmlHandle *info, char *sql, char *sqlEnd, SSmlLineInfo *elements);
|
int32_t smlParseTelnetString(SSmlHandle *info, char *sql, char *sqlEnd, SSmlLineInfo *elements);
|
||||||
int32_t smlParseJSON(SSmlHandle *info, char *payload);
|
int32_t smlParseJSON(SSmlHandle *info, char *payload);
|
||||||
|
|
||||||
void smlStrReplace(char* src, int32_t len);
|
SSmlSTableMeta* smlBuildSuperTableInfo(SSmlHandle *info, SSmlLineInfo *currElement);
|
||||||
|
bool isSmlTagAligned(SSmlHandle *info, int cnt, SSmlKv *kv);
|
||||||
|
bool isSmlColAligned(SSmlHandle *info, int cnt, SSmlKv *kv);
|
||||||
|
int32_t smlProcessChildTable(SSmlHandle *info, SSmlLineInfo *elements);
|
||||||
|
int32_t smlProcessSuperTable(SSmlHandle *info, SSmlLineInfo *elements);
|
||||||
|
int32_t smlJoinMeasureTag(SSmlLineInfo *elements);
|
||||||
|
void smlBuildTsKv(SSmlKv *kv, int64_t ts);
|
||||||
|
int32_t smlParseEndTelnetJson(SSmlHandle *info, SSmlLineInfo *elements, SSmlKv *kvTs, SSmlKv *kv);
|
||||||
|
int32_t smlParseEndLine(SSmlHandle *info, SSmlLineInfo *elements, SSmlKv *kvTs);
|
||||||
|
|
||||||
|
static inline bool smlDoubleToInt64OverFlow(double num) {
|
||||||
|
if (num >= (double)INT64_MAX || num <= (double)INT64_MIN) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void smlStrReplace(char* src, int32_t len){
|
||||||
|
if (!tsSmlDot2Underline) return;
|
||||||
|
for(int i = 0; i < len; i++){
|
||||||
|
if(src[i] == '.'){
|
||||||
|
src[i] = '_';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int8_t smlGetTsTypeByLen(int32_t len) {
|
||||||
|
if (len == TSDB_TIME_PRECISION_SEC_DIGITS) {
|
||||||
|
return TSDB_TIME_PRECISION_SECONDS;
|
||||||
|
} else if (len == TSDB_TIME_PRECISION_MILLI_DIGITS) {
|
||||||
|
return TSDB_TIME_PRECISION_MILLI;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -316,6 +316,15 @@ void *createRequest(uint64_t connId, int32_t type, int64_t reqid) {
|
||||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
SSyncQueryParam *interParam = taosMemoryCalloc(1, sizeof(SSyncQueryParam));
|
||||||
|
if (interParam == NULL) {
|
||||||
|
doDestroyRequest(pRequest);
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
tsem_init(&interParam->sem, 0, 0);
|
||||||
|
interParam->pRequest = pRequest;
|
||||||
|
pRequest->body.interParam = interParam;
|
||||||
|
|
||||||
pRequest->resType = RES_TYPE__QUERY;
|
pRequest->resType = RES_TYPE__QUERY;
|
||||||
pRequest->requestId = reqid == 0 ? generateRequestId() : reqid;
|
pRequest->requestId = reqid == 0 ? generateRequestId() : reqid;
|
||||||
|
@ -437,12 +446,10 @@ void doDestroyRequest(void *p) {
|
||||||
deregisterRequest(pRequest);
|
deregisterRequest(pRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pRequest->syncQuery) {
|
if (pRequest->body.interParam) {
|
||||||
if (pRequest->body.param) {
|
tsem_destroy(&((SSyncQueryParam *)pRequest->body.interParam)->sem);
|
||||||
tsem_destroy(&((SSyncQueryParam *)pRequest->body.param)->sem);
|
|
||||||
}
|
|
||||||
taosMemoryFree(pRequest->body.param);
|
|
||||||
}
|
}
|
||||||
|
taosMemoryFree(pRequest->body.interParam);
|
||||||
|
|
||||||
qDestroyQuery(pRequest->pQuery);
|
qDestroyQuery(pRequest->pQuery);
|
||||||
nodesDestroyAllocator(pRequest->allocatorRefId);
|
nodesDestroyAllocator(pRequest->allocatorRefId);
|
||||||
|
@ -732,7 +739,7 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
newstr[0] = '"';
|
newstr[0] = '"';
|
||||||
strncpy(newstr+1, str, len);
|
memcpy(newstr+1, str, len);
|
||||||
newstr[len + 1] = '"';
|
newstr[len + 1] = '"';
|
||||||
newstr[len + 2] = '\0';
|
newstr[len + 2] = '\0';
|
||||||
str = newstr;
|
str = newstr;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue