未验证 提交 eed39fef 编写于 作者: W wenzhouwww 提交者: GitHub

Merge branch 'develop' into testcase_TD_12228

......@@ -367,6 +367,7 @@ pipeline {
else{
sh'''
cd ${WKC}
git reset --hard HEAD~10
git fetch
git checkout ${CHANGE_BRANCH}
git pull
......
......@@ -136,7 +136,6 @@ IF (TD_ALPINE)
MESSAGE(STATUS "aplhine is defined")
ENDIF ()
IF ("${BUILD_HTTP}" STREQUAL "")
IF (TD_LINUX)
IF (TD_ARM_32)
......@@ -153,6 +152,9 @@ ELSEIF (${BUILD_HTTP} MATCHES "false")
SET(TD_BUILD_HTTP FALSE)
ELSEIF (${BUILD_HTTP} MATCHES "true")
SET(TD_BUILD_HTTP TRUE)
ELSEIF (${BUILD_HTTP} MATCHES "internal")
SET(TD_BUILD_HTTP FALSE)
SET(TD_BUILD_TAOSA_INTERNAL TRUE)
ELSE ()
SET(TD_BUILD_HTTP TRUE)
ENDIF ()
......
......@@ -4,7 +4,7 @@ PROJECT(TDengine)
IF (DEFINED VERNUMBER)
SET(TD_VER_NUMBER ${VERNUMBER})
ELSE ()
SET(TD_VER_NUMBER "2.3.2.0")
SET(TD_VER_NUMBER "2.4.0.0")
ENDIF ()
IF (DEFINED VERCOMPATIBLE)
......
Subproject commit 9015e129bd7de389afa4196495451669700904d0
Subproject commit ea6b3e973b477b8061e0076bb257dbd7f3faa756
......@@ -83,6 +83,7 @@ TDengine 目前支持时间戳、数字、字符、布尔类型,与 Java 对
| BINARY | java.lang.String | byte array |
| NCHAR | java.lang.String | java.lang.String |
| JSON | - | java.lang.String |
注意:JSON类型仅在tag中支持。
## 安装Java Connector
......@@ -804,17 +805,16 @@ Query OK, 1 row(s) in set (0.000141s)
请参考:[JDBC example](https://github.com/taosdata/TDengine/tree/develop/tests/examples/JDBC)
## 常见问题
* 使用Statement的addBatch和executeBatch来执行“批量写入/更行”,为什么没有带来性能上的提升?
**原因**:TDengine的JDBC实现中,通过addBatch方法提交的sql语句,会按照添加的顺序,依次执行,这种方式没有减少与服务端的交互次数,不会带来性能上的提升。
**解决方法**:1. 在一条insert语句中拼接多个values值;2. 使用多线程的方式并发插入;3. 使用参数绑定的写入方式
* java.lang.UnsatisfiedLinkError: no taos in java.library.path
**原因**:程序没有找到依赖的本地函数库 taos。
**解决方法**:Windows 下可以将 C:\TDengine\driver\taos.dll 拷贝到 C:\Windows\System32\ 目录下,Linux 下将建立如下软链 `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` 即可。
* java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on a IA 32-bit platform
**原因**:目前 TDengine 只支持 64 位 JDK。
**解决方法**:重新安装 64 位 JDK。
* 其它问题请参考 [Issues](https://github.com/taosdata/TDengine/issues)
......
# 常见问题
## 0. 怎么报告问题?
# 常见问题及反馈
## 问题反馈
如果 FAQ 中的信息不能够帮到您,需要 TDengine 技术团队的技术支持与协助,请将以下两个目录中内容打包:
1. /var/log/taos (如果没有修改过默认路径)
2. /etc/taos
......@@ -14,7 +13,9 @@
```
但系统正常运行时,请一定将debugFlag设置为131,否则会产生大量的日志信息,降低系统效率。
## 1. TDengine2.0之前的版本升级到2.0及以上的版本应该注意什么?☆☆☆
## 常见问题列表
**1. TDengine2.0之前的版本升级到2.0及以上的版本应该注意什么?☆☆☆**
2.0版在之前版本的基础上,进行了完全的重构,配置文件和数据文件是不兼容的。在升级之前务必进行如下操作:
......@@ -24,19 +25,19 @@
4. 安装最新稳定版本的 TDengine
5. 如果需要迁移数据或者数据文件损坏,请联系涛思数据官方技术支持团队,进行协助解决
## 2. Windows平台下JDBCDriver找不到动态链接库,怎么办?
**2. Windows平台下JDBCDriver找不到动态链接库,怎么办?**
请看为此问题撰写的[技术博客](https://www.taosdata.com/blog/2019/12/03/950.html)
## 3. 创建数据表时提示more dnodes are needed
**3. 创建数据表时提示more dnodes are needed**
请看为此问题撰写的[技术博客](https://www.taosdata.com/blog/2019/12/03/965.html)
## 4. 如何让TDengine crash时生成core文件?
**4. 如何让TDengine crash时生成core文件?**
请看为此问题撰写的[技术博客](https://www.taosdata.com/blog/2019/12/06/974.html)
## 5. 遇到错误“Unable to establish connection”, 我怎么办?
**5. 遇到错误“Unable to establish connection”, 我怎么办?**
客户端遇到连接故障,请按照下面的步骤进行检查:
......@@ -70,7 +71,7 @@
10. 也可以使用taos程序内嵌的网络连通检测功能,来验证服务器和客户端之间指定的端口连接是否通畅(包括TCP和UDP):[TDengine 内嵌网络检测工具使用指南](https://www.taosdata.com/blog/2020/09/08/1816.html)
## 6. 遇到错误“Unexpected generic error in RPC”或者“Unable to resolve FQDN”,我怎么办?
**6. 遇到错误“Unexpected generic error in RPC”或者“Unable to resolve FQDN”,我怎么办?**
产生这个错误,是由于客户端或数据节点无法解析FQDN(Fully Qualified Domain Name)导致。对于TAOS Shell或客户端应用,请做如下检查:
......@@ -79,16 +80,17 @@
3. 如果网络没有配置DNS server,请检查客户端所在机器的hosts文件,查看该FQDN是否配置,并是否有正确的IP地址
4. 如果网络配置OK,从客户端所在机器,你需要能Ping该连接的FQDN,否则客户端是无法连接服务器的
## 7. 虽然语法正确,为什么我还是得到 "Invalid SQL" 错误
**7. 虽然语法正确,为什么我还是得到 "Invalid SQL" 错误**
如果你确认语法正确,2.0之前版本,请检查SQL语句长度是否超过64K。如果超过,也会返回这个错误。
## 8. 是否支持validation queries?
**8. 是否支持validation queries?**
TDengine还没有一组专用的validation queries。然而建议你使用系统监测的数据库”log"来做。
<a class="anchor" id="update"></a>
## 9. 我可以删除或更新一条记录吗?
**9. 我可以删除或更新一条记录吗?**
TDengine 目前尚不支持删除功能,未来根据用户需求可能会支持。
......@@ -98,15 +100,15 @@ TDengine 目前尚不支持删除功能,未来根据用户需求可能会支
此外,从 2.1.7.0 版本开始,支持将 UPDATE 参数设为 2,表示“支持部分列更新”。也即,当 UPDATE 设为 1 时,如果更新一个数据行,其中某些列没有提供取值,那么这些列会被设为 NULL;而当 UPDATE 设为 2 时,如果更新一个数据行,其中某些列没有提供取值,那么这些列会保持原有数据行中的对应值。
## 10. 我怎么创建超过1024列的表?
**10. 我怎么创建超过1024列的表?**
使用 2.0 及其以上版本,默认支持 1024 列;2.0 之前的版本,TDengine 最大允许创建 250 列的表。但是如果确实超过限值,建议按照数据特性,逻辑地将这个宽表分解成几个小表。(从 2.1.7.0 版本开始,表的最大列数增加到了 4096 列。)
## 11. 最有效的写入数据的方法是什么?
**11. 最有效的写入数据的方法是什么?**
批量插入。每条写入语句可以一张表同时插入多条记录,也可以同时插入多张表的多条记录。
## 12. Windows系统下插入的nchar类数据中的汉字被解析成了乱码如何解决?
**12. Windows系统下插入的nchar类数据中的汉字被解析成了乱码如何解决?**
Windows下插入nchar类的数据中如果有中文,请先确认系统的地区设置成了中国(在Control Panel里可以设置),这时cmd中的`taos`客户端应该已经可以正常工作了;如果是在IDE里开发Java应用,比如Eclipse, Intellij,请确认IDE里的文件编码为GBK(这是Java默认的编码类型),然后在生成Connection时,初始化客户端的配置,具体语句如下:
```JAVA
......@@ -116,7 +118,7 @@ properties.setProperty(TSDBDriver.LOCALE_KEY, "UTF-8");
Connection = DriverManager.getConnection(url, properties);
```
## 13.JDBC报错: the excuted SQL is not a DML or a DDL?
**13.JDBC报错: the excuted SQL is not a DML or a DDL?**
请更新至最新的JDBC驱动
```xml
......@@ -127,15 +129,15 @@ Connection = DriverManager.getConnection(url, properties);
</dependency>
```
## 14. taos connect failed, reason&#58; invalid timestamp
**14. taos connect failed, reason&#58; invalid timestamp**
常见原因是服务器和客户端时间没有校准,可以通过和时间服务器同步的方式(Linux 下使用 ntpdate 命令,Windows 在系统时间设置中选择自动同步)校准。
## 15. 表名显示不全
**15. 表名显示不全**
由于 taos shell 在终端中显示宽度有限,有可能比较长的表名显示不全,如果按照显示的不全的表名进行相关操作会发生 Table does not exist 错误。解决方法可以是通过修改 taos.cfg 文件中的设置项 maxBinaryDisplayWidth, 或者直接输入命令 set max_binary_display_width 100。或者在命令结尾使用 \G 参数来调整结果的显示方式。
## 16. 如何进行数据迁移?
**16. 如何进行数据迁移?**
TDengine是根据hostname唯一标志一台机器的,在数据文件从机器A移动机器B时,注意如下两件事:
......@@ -143,7 +145,7 @@ TDengine是根据hostname唯一标志一台机器的,在数据文件从机器A
- 2.0.7.0 及以后的版本,到/var/lib/taos/dnode下,修复dnodeEps.json的dnodeId对应的FQDN,重启。确保机器内所有机器的此文件是完全相同的。
- 1.x 和 2.x 版本的存储结构不兼容,需要使用迁移工具或者自己开发应用导出导入数据。
## 17. 如何在命令行程序 taos 中临时调整日志级别
**17. 如何在命令行程序 taos 中临时调整日志级别**
为了调试方便,从 2.0.16 版本开始,命令行程序 taos 新增了与日志记录相关的两条指令:
......@@ -162,7 +164,8 @@ ALTER LOCAL RESETLOG;
其含义是,清空本机所有由客户端生成的日志文件。
<a class="anchor" id="timezone"></a>
## 18. 时间戳的时区信息是怎样处理的?
**18. 时间戳的时区信息是怎样处理的?**
TDengine 中时间戳的时区总是由客户端进行处理,而与服务端无关。具体来说,客户端会对 SQL 语句中的时间戳进行时区转换,转为 UTC 时区(即 Unix 时间戳——Unix Timestamp)再交由服务端进行写入和查询;在读取数据时,服务端也是采用 UTC 时区提供原始数据,客户端收到后再根据本地设置,把时间戳转换为本地系统所要求的时区进行显示。
......@@ -173,7 +176,8 @@ TDengine 中时间戳的时区总是由客户端进行处理,而与服务端
4. 在书写 SQL 语句时,也可以直接使用 Unix 时间戳(例如 `1554984068000`)或带有时区的时间戳字符串,也即以 RFC 3339 格式(例如 `2013-04-12T15:52:01.123+08:00`)或 ISO-8601 格式(例如 `2013-04-12T15:52:01.123+0800`)来书写时间戳,此时这些时间戳的取值将不再受其他时区设置的影响。
<a class="anchor" id="port"></a>
## 19. TDengine 都会用到哪些网络端口?
**19. TDengine 都会用到哪些网络端口?**
在 TDengine 2.0 版本中,会用到以下这些网络端口(以默认端口 6030 为前提进行说明,如果修改了配置文件中的设置,那么这里列举的端口都会出现变化),管理员可以参考这里的信息调整防火墙设置:
......@@ -191,7 +195,7 @@ TDengine 中时间戳的时区总是由客户端进行处理,而与服务端
| UDP | 6030-6034 | 客户端与服务端之间通讯。 | 随 serverPort 端口变化。 |
| UDP | 6035-6039 | 多节点集群的节点间通讯。 | 随 serverPort 端口变化。 |
## 20. go 语言编写组件编译失败怎样解决?
**20. go 语言编写组件编译失败怎样解决?**
新版本 TDengine 2.3.0.0 包含一个使用 go 语言开发的 taosAdapter 组件,取代之前内置的 httpd ,提供包含原 httpd 功能以及支持多种其他软件(Prometheus、Telegraf、collectd、StatsD等)的数据接入功能。
使用最新 develop 分支代码编译需要先 `git submodule update --init --recursive` 下载 taosAdapter 仓库代码后再编译。
......@@ -205,3 +209,5 @@ go env -w GOPROXY=https://goproxy.cn,direct
如果希望继续使用之前的内置 httpd,可以关闭 taosAdapter 编译,使用
`cmake .. -DBUILD_HTTP=true` 使用原来内置的 httpd。
......@@ -761,17 +761,16 @@ Query OK, 1 row(s) in set (0.000141s)
you see sample code here: [JDBC example](https://github.com/taosdata/TDengine/tree/develop/tests/examples/JDBC)
## FAQ
- Why does not addBatch and executeBatch provide a performance benefit for executing "batch writes/updates"?
**Cause**:In TDengine's JDBC implementation, SQL statements submitted through the addBatch method are executed in the order in which they are added. This method does not reduce the number of interactions with the server and does not improve performance.
**Answer**:1. Concatenate multiple values in an INSERT statement; 2. Use multi-threaded concurrent insertion; 3. Use the parameter-binding to write
- java.lang.UnsatisfiedLinkError: no taos in java.library.path
**Cause**:The application program cannot find Library function *taos*
**Answer**:Copy `C:\TDengine\driver\taos.dll` to `C:\Windows\System32\` on Windows and make a soft link through `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` on Linux.
- java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on a IA 32-bit platform
**Cause**:Currently TDengine only support 64bit JDK
**Answer**:re-install 64bit JDK.
- For other questions, please refer to [Issues](https://github.com/taosdata/TDengine/issues)
......
......@@ -418,6 +418,10 @@ else
BUILD_HTTP=false
fi
if [[ "$verMode" == "cluster" ]]; then
BUILD_HTTP=internal
fi
if [[ "$pagMode" == "full" ]]; then
BUILD_TOOLS=true
else
......
name: tdengine
base: core20
version: '2.3.2.0'
version: '2.4.0.0'
icon: snap/gui/t-dengine.svg
summary: an open-source big data platform designed and optimized for IoT.
description: |
......
......@@ -6090,7 +6090,7 @@ int32_t getTimeRange(STimeWindow* win, tSqlExpr* pRight, int32_t optr, int16_t t
// todo error !!!!
int32_t tsRewriteFieldNameIfNecessary(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) {
const char rep[] = {'(', ')', '*', ',', '.', '/', '\\', '+', '-', '%', ' '};
const char rep[] = {'(', ')', '*', ',', '.', '/', '\\', '+', '-', '%', ' ', '`'};
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
char* fieldName = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i)->name;
......
......@@ -3124,11 +3124,12 @@ int tscRenewTableMeta(SSqlObj *pSql) {
pSql->rootObj->retryReason = pSql->retryReason;
SSqlObj *tmpSql = pSql->rootObj;
tscFreeSubobj(pSql->rootObj);
tfree(tmpSql->pSubs);
SSqlObj *rootSql = pSql->rootObj;
tscFreeSubobj(rootSql);
tfree(rootSql->pSubs);
tscResetSqlCmd(&rootSql->cmd, true, rootSql->self);
code = getMultiTableMetaFromMnode(tmpSql, pNameList, vgroupList, NULL, tscTableMetaCallBack, true);
code = getMultiTableMetaFromMnode(rootSql, pNameList, vgroupList, NULL, tscTableMetaCallBack, true);
taosArrayDestroyEx(&pNameList, freeElem);
taosArrayDestroyEx(&vgroupList, freeElem);
......
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace TDengineDriver
......@@ -249,7 +250,8 @@ namespace TDengineDriver
TAOS_BIND bind = new TAOS_BIND();
IntPtr umanageBinary = Marshal.StringToHGlobalAnsi(val);
int leng = val.Length;
var strToBytes = System.Text.Encoding.Default.GetBytes(val);
int leng = strToBytes.Length;
IntPtr lenPtr = Marshal.AllocHGlobal(sizeof(ulong));
Marshal.WriteInt64(lenPtr, leng);
......@@ -264,9 +266,11 @@ namespace TDengineDriver
public static TAOS_BIND BindNchar(String val)
{
TAOS_BIND bind = new TAOS_BIND();
var strToBytes = System.Text.Encoding.Default.GetBytes(val);
IntPtr umanageNchar = (IntPtr)Marshal.StringToHGlobalAnsi(val);
int leng = val.Length;
int leng = strToBytes.Length;
IntPtr lenPtr = Marshal.AllocHGlobal(sizeof(ulong));
Marshal.WriteInt64(lenPtr, leng);
......
......@@ -449,28 +449,27 @@ namespace TDengineDriver
for (int i = 0; i < elementCount; i++)
{
int itemLength = 0;
byte[] decodeByte = GetStringEncodeByte(arr[i]);
itemLength = decodeByte.Length;
// if element if not null and element length is less then typeSize
// fill the memory with default char.Since arr element memory need align.
if (!String.IsNullOrEmpty(arr[i]) && typeSize <= arr[i].Length)
if (!String.IsNullOrEmpty(arr[i]) && typeSize == itemLength)
{
itemLength = arr[i].Length;
arrStrBuilder.Append(arr[i]);
}
else if (!String.IsNullOrEmpty(arr[i]) && typeSize > arr[i].Length)
else if (!String.IsNullOrEmpty(arr[i]) && typeSize > itemLength)
{
itemLength = arr[i].Length;
arrStrBuilder.Append(arr[i]);
arrStrBuilder.Append(AlignCharArr(typeSize - arr[i].Length));
arrStrBuilder.Append(AlignCharArr(typeSize - itemLength));
}
else
{
// if is null value,fill the memory with default values.
itemLength = 0;
arrStrBuilder.Append(AlignCharArr(typeSize));
}
//set TAOS_MULTI_BIND.length
Marshal.WriteInt32(lengthArr, intSize * i, itemLength);
Marshal.WriteInt32(lengthArr, intSize * i, typeSize);
//set TAOS_MULTI_BIND.is_null
Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(String.IsNullOrEmpty(arr[i]) ? 1 : 0));
}
......@@ -505,28 +504,27 @@ namespace TDengineDriver
for (int i = 0; i < elementCount; i++)
{
int itemLength = 0;
byte[] decodeByte = GetStringEncodeByte(arr[i]);
itemLength = decodeByte.Length;
// if element if not null and element length is less then typeSize
// fill the memory with default char.Since arr element memory need align.
if (!String.IsNullOrEmpty(arr[i]) && typeSize <= arr[i].Length)
if (!String.IsNullOrEmpty(arr[i]) && typeSize == itemLength)
{
itemLength = arr[i].Length;
arrStrBuilder.Append(arr[i]);
}
else if (!String.IsNullOrEmpty(arr[i]) && typeSize > arr[i].Length)
else if (!String.IsNullOrEmpty(arr[i]) && typeSize > itemLength)
{
itemLength = arr[i].Length;
arrStrBuilder.Append(arr[i]);
arrStrBuilder.Append(AlignCharArr(typeSize - arr[i].Length));
arrStrBuilder.Append(AlignCharArr(typeSize - itemLength));
}
else
{
// if is null value,fill the memory with default values.
itemLength = 0;
arrStrBuilder.Append(AlignCharArr(typeSize));
}
//set TAOS_MULTI_BIND.length
Marshal.WriteInt32(lengthArr, intSize * i, itemLength);
Marshal.WriteInt32(lengthArr, intSize * i, typeSize);
//set TAOS_MULTI_BIND.is_null
Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(String.IsNullOrEmpty(arr[i]) ? 1 : 0));
}
......@@ -604,13 +602,28 @@ namespace TDengineDriver
int max = 0;
for (int i = 0; i < strArr.Length; i++)
{
if (!String.IsNullOrEmpty(strArr[i]) && max < strArr[i].Length)
int tmpLength = GetStringEncodeByte(strArr[i]).Length;
if (!String.IsNullOrEmpty(strArr[i]) && max < tmpLength)
{
max = strArr[i].Length;
max = tmpLength;
}
}
return max;
}
private static Byte[] GetStringEncodeByte(string str)
{
Byte[] strToBytes = null;
if(String.IsNullOrEmpty(str))
{
strToBytes = System.Text.Encoding.Default.GetBytes(String.Empty);
}
else
{
strToBytes = System.Text.Encoding.Default.GetBytes(str);
}
return strToBytes;
}
}
}
\ No newline at end of file
......@@ -21,7 +21,8 @@ namespace Test.UtilsTools.DataSource
public static string[] binaryArr = new string[5] { "1234567890~!@#$%^&*()_+=-`[]{}:,./<>?", String.Empty, null, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890~!@#$%^&*()_+=-`[]{}:,./<>?" };
public static string[] ncharArr = new string[5] { "1234567890~!@#$%^&*()_+=-`[]{}:,./<>?", null, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890~!@#$%^&*()_+=-`[]{}:,./<>?", string.Empty };
public static string[] binaryArrCn = new string[5] { "涛思数据", String.Empty, null, "taosdata涛思数据", "涛思数据TDengine" };
public static string[] NcharArrCn = new string[5] { "涛思数据", null, "taosdata涛思数据", "涛思数据TDengine", String.Empty };
public static TAOS_BIND[] getTags()
{
TAOS_BIND[] binds = new TAOS_BIND[13];
......@@ -40,6 +41,47 @@ namespace Test.UtilsTools.DataSource
binds[12] = TaosBind.BindNchar("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKZXCVBNM`1234567890-=+_)(*&^%$#@!~[];,./<>?:{}");
return binds;
}
public static TAOS_BIND[] getCNTags()
{
TAOS_BIND[] binds = new TAOS_BIND[13];
binds[0] = TaosBind.BindBool(true);
binds[1] = TaosBind.BindTinyInt(-2);
binds[2] = TaosBind.BindSmallInt(short.MaxValue - 1);
binds[3] = TaosBind.BindInt(int.MaxValue - 1);
binds[4] = TaosBind.BindBigInt(Int64.MaxValue - 1);
binds[5] = TaosBind.BindUTinyInt(byte.MaxValue - 1);
binds[6] = TaosBind.BindUSmallInt(UInt16.MaxValue - 1);
binds[7] = TaosBind.BindUInt(uint.MinValue + 1);
binds[8] = TaosBind.BindUBigInt(UInt64.MinValue + 1);
binds[9] = TaosBind.BindFloat(11.11F);
binds[10] = TaosBind.BindDouble(22.22D);
binds[11] = TaosBind.BindBinary("TDengine涛思数据");
binds[12] = TaosBind.BindNchar("涛思");
return binds;
}
public static TAOS_BIND[] getNtableCNRow()
{
TAOS_BIND[] binds = new TAOS_BIND[15];
binds[0] = TaosBind.BindTimestamp(1637064040000);
binds[1] = TaosBind.BindTinyInt(-2);
binds[2] = TaosBind.BindSmallInt(short.MaxValue);
binds[3] = TaosBind.BindInt(int.MaxValue);
binds[4] = TaosBind.BindBigInt(Int64.MaxValue);
binds[5] = TaosBind.BindUTinyInt(byte.MaxValue - 1);
binds[6] = TaosBind.BindUSmallInt(UInt16.MaxValue - 1);
binds[7] = TaosBind.BindUInt(uint.MinValue + 1);
binds[8] = TaosBind.BindUBigInt(UInt64.MinValue + 1);
binds[9] = TaosBind.BindFloat(11.11F);
binds[10] = TaosBind.BindDouble(22.22D);
binds[11] = TaosBind.BindBinary("TDengine数据");
binds[12] = TaosBind.BindNchar("taosdata涛思数据");
binds[13] = TaosBind.BindBool(true);
binds[14] = TaosBind.BindNil();
return binds;
}
public static TAOS_BIND[] getNtableRow()
{
TAOS_BIND[] binds = new TAOS_BIND[15];
......@@ -60,7 +102,6 @@ namespace Test.UtilsTools.DataSource
binds[14] = TaosBind.BindNil();
return binds;
}
public static TAOS_MULTI_BIND[] GetMultiBindArr()
{
TAOS_MULTI_BIND[] mBinds = new TAOS_MULTI_BIND[14];
......@@ -80,6 +121,26 @@ namespace Test.UtilsTools.DataSource
mBinds[13] = TaosMultiBind.MultiBindNchar(ncharArr);
return mBinds;
}
public static TAOS_MULTI_BIND[] GetMultiBindCNArr()
{
TAOS_MULTI_BIND[] mBinds = new TAOS_MULTI_BIND[14];
mBinds[0] = TaosMultiBind.MultiBindTimestamp(tsArr);
mBinds[1] = TaosMultiBind.MultiBindBool(boolArr);
mBinds[2] = TaosMultiBind.MultiBindTinyInt(tinyIntArr);
mBinds[3] = TaosMultiBind.MultiBindSmallInt(shortArr);
mBinds[4] = TaosMultiBind.MultiBindInt(intArr);
mBinds[5] = TaosMultiBind.MultiBindBigint(longArr);
mBinds[6] = TaosMultiBind.MultiBindFloat(floatArr);
mBinds[7] = TaosMultiBind.MultiBindDouble(doubleArr);
mBinds[8] = TaosMultiBind.MultiBindUTinyInt(uTinyIntArr);
mBinds[9] = TaosMultiBind.MultiBindUSmallInt(uShortArr);
mBinds[10] = TaosMultiBind.MultiBindUInt(uIntArr);
mBinds[11] = TaosMultiBind.MultiBindUBigInt(uLongArr);
mBinds[12] = TaosMultiBind.MultiBindBinary(binaryArrCn);
mBinds[13] = TaosMultiBind.MultiBindNchar(NcharArrCn);
return mBinds;
}
public static TAOS_BIND[] GetQueryCondition()
{
TAOS_BIND[] queryCondition = new TAOS_BIND[2];
......
using System;
using System;
using Test.UtilsTools;
using Cases;
......@@ -14,9 +14,9 @@ namespace Cases.EntryPoint
IntPtr res = IntPtr.Zero;
conn = UtilsTools.TDConnection("127.0.0.1", "root", "taosdata", "", 0);
UtilsTools.ExecuteQuery(conn, "drop database if exists csharp");
UtilsTools.ExecuteQuery(conn, "create database if not exists csharp keep 3650");
UtilsTools.ExecuteQuery(conn, "use csharp");
UtilsTools.ExecuteUpdate(conn, "drop database if exists csharp");
UtilsTools.ExecuteUpdate(conn, "create database if not exists csharp keep 3650");
UtilsTools.ExecuteUpdate(conn, "use csharp");
Console.WriteLine("====================StableColumnByColumn===================");
StableColumnByColumn columnByColumn = new StableColumnByColumn();
......@@ -34,6 +34,8 @@ namespace Cases.EntryPoint
Console.WriteLine("====================NtableSingleLine===================");
NtableSingleLine ntableSingleLine = new NtableSingleLine();
ntableSingleLine.Test(conn, "stablesingleline");
IntPtr resPtr = UtilsTools.ExecuteQuery(conn, "select * from stablesingleline ");
UtilsTools.DisplayRes(resPtr);
Console.WriteLine("====================NtableMutipleLine===================");
NtableMutipleLine ntableMutipleLine = new NtableMutipleLine();
......@@ -50,6 +52,27 @@ namespace Cases.EntryPoint
FetchFields fetchFields = new FetchFields();
fetchFields.Test(conn, "fetchfeilds");
StableStmtCases stableStmtCases = new StableStmtCases();
Console.WriteLine("====================stableStmtCases.TestBindSingleLineCn===================");
stableStmtCases.TestBindSingleLineCn(conn, "stablestmtcasestestbindsinglelinecn");
Console.WriteLine("====================stableStmtCases.TestBindColumnCn===================");
stableStmtCases.TestBindColumnCn(conn, " stablestmtcasestestbindcolumncn");
Console.WriteLine("====================stableStmtCases.TestBindMultiLineCn===================");
stableStmtCases.TestBindMultiLineCn(conn, "stablestmtcasestestbindmultilinecn");
NormalTableStmtCases normalTableStmtCases = new NormalTableStmtCases();
Console.WriteLine("====================normalTableStmtCases.TestBindSingleLineCn===================");
normalTableStmtCases.TestBindSingleLineCn(conn, "normaltablestmtcasestestbindsinglelinecn");
Console.WriteLine("====================normalTableStmtCases.TestBindColumnCn===================");
normalTableStmtCases.TestBindColumnCn(conn, "normaltablestmtcasestestbindcolumncn");
Console.WriteLine("====================normalTableStmtCases.TestBindMultiLineCn===================");
normalTableStmtCases.TestBindMultiLineCn(conn, "normaltablestmtcasestestbindmultilinecn");
Console.WriteLine("===================JsonTagTest====================");
JsonTagTest jsonTagTest = new JsonTagTest();
jsonTagTest.Test(conn);
......
......@@ -7,7 +7,11 @@ namespace Cases
{
public class NtableSingleLine
{
/// <author>xiaolei</author>
/// <Name>NtableSingleLine.Test</Name>
/// <describe>Test stmt insert sinle line data into normal table</describe>
/// <filename>StmtNormalTable.cs</filename>
/// <result>pass or failed </result>
public void Test(IntPtr conn, string tableName)
{
String createTb = "create table " + tableName + "(ts timestamp,tt tinyint,si smallint,ii int,bi bigint,tu tinyint unsigned,su smallint unsigned,iu int unsigned,bu bigint unsigned,ff float ,dd double ,bb binary(200),nc nchar(200),bo bool,nullVal int);";
......@@ -23,21 +27,26 @@ namespace Cases
StmtUtilTools.StmtExecute(stmt);
StmtUtilTools.StmtClose(stmt);
DataSource.FreeTaosBind(valuesRow);
}
}
public class NtableMutipleLine
{
TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindArr();
/// <author>xiaolei</author>
/// <Name>NtableMutipleLine.Test</Name>
/// <describe>Test stmt insert multiple rows of data into normal table</describe>
/// <filename>StmtNormalTable.cs</filename>
/// <result>pass or failed </result>
public void Test(IntPtr conn, string tableName)
{
TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindArr();
String createTb = "create table " + tableName + " (ts timestamp ,b bool,v1 tinyint,v2 smallint,v4 int,v8 bigint,f4 float,f8 double,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,bin binary(200),blob nchar(200));";
String insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
UtilsTools.ExecuteQuery(conn, createTb);
String[] loadList = { tableName };
UtilsTools.ExecuteUpdate(conn, createTb);
IntPtr stmt = StmtUtilTools.StmtInit(conn);
StmtUtilTools.loadTableInfo(conn, loadList);
StmtUtilTools.StmtPrepare(stmt, insertSql);
StmtUtilTools.SetTableName(stmt, tableName);
StmtUtilTools.BindParamBatch(stmt, mbind);
......@@ -49,15 +58,20 @@ namespace Cases
}
public class NtableColumnByColumn
{
DataSource data = new DataSource();
TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindArr();
/// <author>xiaolei</author>
/// <Name>NtableColumnByColumn.Test</Name>
/// <describe>Test stmt insert multiple rows of data into normal table by column after column </describe>
/// <filename>StmtNormalTable.cs</filename>
/// <result>pass or failed </result>
public void Test(IntPtr conn, string tableName)
{
DataSource data = new DataSource();
TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindArr();
String createTb = "create table " + tableName + " (ts timestamp ,b bool,v1 tinyint,v2 smallint,v4 int,v8 bigint,f4 float,f8 double,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,bin binary(200),blob nchar(200));";
String insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
UtilsTools.ExecuteQuery(conn, createTb);
UtilsTools.ExecuteUpdate(conn, createTb);
IntPtr stmt = StmtUtilTools.StmtInit(conn);
StmtUtilTools.StmtPrepare(stmt, insertSql);
......@@ -86,4 +100,106 @@ namespace Cases
}
}
public class NormalTableStmtCases
{
/// <author>xiaolei</author>
/// <Name>NormalTableStmtCases.TestBindSingleLineCn</Name>
/// <describe>Test stmt insert single line of chinese character into normal table by column after column </describe>
/// <filename>StmtNormalTable.cs</filename>
/// <result>pass or failed </result>
public void TestBindSingleLineCn(IntPtr conn, string tableName)
{
String createTb = "create table " + tableName + "(ts timestamp,tt tinyint,si smallint,ii int,bi bigint,tu tinyint unsigned,su smallint unsigned,iu int unsigned,bu bigint unsigned,ff float ,dd double ,bb binary(200),nc nchar(200),bo bool,nullVal int);";
String insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
TAOS_BIND[] valuesRow = DataSource.getNtableCNRow();
UtilsTools.ExecuteUpdate(conn, createTb);
IntPtr stmt = StmtUtilTools.StmtInit(conn);
StmtUtilTools.StmtPrepare(stmt, insertSql);
StmtUtilTools.SetTableName(stmt, tableName);
StmtUtilTools.BindParam(stmt, valuesRow);
StmtUtilTools.AddBatch(stmt);
StmtUtilTools.StmtExecute(stmt);
StmtUtilTools.StmtClose(stmt);
DataSource.FreeTaosBind(valuesRow);
string querySql = "select * from " + tableName;
IntPtr res = UtilsTools.ExecuteQuery(conn, querySql);
UtilsTools.DisplayRes(res);
}
/// <author>xiaolei</author>
/// <Name>NormalTableStmtCases.TestBindColumnCn</Name>
/// <describe>Test stmt insert single line of chinese character into normal table by column after column </describe>
/// <filename>StmtNormalTable.cs</filename>
/// <result>pass or failed </result>
public void TestBindColumnCn(IntPtr conn,string tableName)
{
DataSource data = new DataSource();
TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindCNArr();
String createTb = "create table " + tableName + " (ts timestamp ,b bool,v1 tinyint,v2 smallint,v4 int,v8 bigint,f4 float,f8 double,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,bin binary(200),blob nchar(200));";
String insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
UtilsTools.ExecuteUpdate(conn, createTb);
IntPtr stmt = StmtUtilTools.StmtInit(conn);
StmtUtilTools.StmtPrepare(stmt, insertSql);
StmtUtilTools.SetTableName(stmt, tableName);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[0], 0);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[1], 1);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[2], 2);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[3], 3);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[4], 4);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[5], 5);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[6], 6);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[7], 7);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[8], 8);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[9], 9);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[10], 10);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[11], 11);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[12], 12);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[13], 13);
StmtUtilTools.AddBatch(stmt);
StmtUtilTools.StmtExecute(stmt);
StmtUtilTools.StmtClose(stmt);
DataSource.FreeTaosMBind(mbind);
string querySql = "select * from " + tableName;
IntPtr res = UtilsTools.ExecuteQuery(conn, querySql);
UtilsTools.DisplayRes(res);
}
/// <author>xiaolei</author>
/// <Name>NormalTableStmtCases.TestBindMultiLineCn</Name>
/// <describe>Test stmt insert single line of chinese character into normal table by column after column </describe>
/// <filename>StmtNormalTable.cs</filename>
/// <result>pass or failed </result>
public void TestBindMultiLineCn(IntPtr conn, string tableName)
{
TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindCNArr();
String createTb = "create table " + tableName + " (ts timestamp ,b bool,v1 tinyint,v2 smallint,v4 int,v8 bigint,f4 float,f8 double,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,bin binary(200),blob nchar(200));";
String insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
UtilsTools.ExecuteUpdate(conn, createTb);
IntPtr stmt = StmtUtilTools.StmtInit(conn);
StmtUtilTools.StmtPrepare(stmt, insertSql);
StmtUtilTools.SetTableName(stmt, tableName);
StmtUtilTools.BindParamBatch(stmt, mbind);
StmtUtilTools.AddBatch(stmt);
StmtUtilTools.StmtExecute(stmt);
StmtUtilTools.StmtClose(stmt);
DataSource.FreeTaosMBind(mbind);
string querySql = "select * from " + tableName;
IntPtr res = UtilsTools.ExecuteQuery(conn, querySql);
UtilsTools.DisplayRes(res);
}
}
}
\ No newline at end of file
......@@ -15,10 +15,8 @@ namespace Cases
String createTb = "create stable " + tableName + " (ts timestamp ,b bool,v1 tinyint,v2 smallint,v4 int,v8 bigint,f4 float,f8 double,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,bin binary(200),blob nchar(200))tags(bo bool,tt tinyint,si smallint,ii int,bi bigint,tu tinyint unsigned,su smallint unsigned,iu int unsigned,bu bigint unsigned,ff float ,dd double ,bb binary(200),nc nchar(200));";
String insertSql = "insert into ? using " + tableName + " tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
UtilsTools.ExecuteQuery(conn, createTb);
String[] loadList = { tableName };
UtilsTools.ExecuteUpdate(conn, createTb);
IntPtr stmt = StmtUtilTools.StmtInit(conn);
StmtUtilTools.loadTableInfo(conn, loadList);
StmtUtilTools.StmtPrepare(stmt, insertSql);
StmtUtilTools.SetTableNameTags(stmt, tableName + "_t1", tags);
......@@ -43,9 +41,8 @@ namespace Cases
String insertSql = "insert into ? using " + tableName + " tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
UtilsTools.ExecuteQuery(conn, createTb);
UtilsTools.ExecuteUpdate(conn, createTb);
IntPtr stmt = StmtUtilTools.StmtInit(conn);
StmtUtilTools.StmtPrepare(stmt, insertSql);
StmtUtilTools.SetTableNameTags(stmt, tableName + "_t1", tags);
......@@ -73,4 +70,119 @@ namespace Cases
}
}
public class StableStmtCases
{
/// <author>xiaolei</author>
/// <Name>StableStmtCases.TestBindSingleLineCn</Name>
/// <describe>Test stmt insert single line of chinese character into stable by column after column </describe>
/// <filename>StmtSTable.cs</filename>
/// <result>pass or failed </result>
public void TestBindSingleLineCn(IntPtr conn, string tableName)
{
TAOS_BIND[] tags = DataSource.getCNTags();
TAOS_BIND[] binds = DataSource.getNtableCNRow();
String createTb = "create stable " + tableName + " (ts timestamp,v1 tinyint,v2 smallint,v4 int,v8 bigint,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,f4 float,f8 double,bin binary(200),blob nchar(200),b bool,nilcol int)tags(bo bool,tt tinyint,si smallint,ii int,bi bigint,tu tinyint unsigned,su smallint unsigned,iu int unsigned,bu bigint unsigned,ff float ,dd double ,bb binary(200),nc nchar(200));";
String insertSql = "insert into ? using " + tableName + " tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
UtilsTools.ExecuteUpdate(conn, createTb);
IntPtr stmt = StmtUtilTools.StmtInit(conn);
StmtUtilTools.StmtPrepare(stmt, insertSql);
StmtUtilTools.SetTableNameTags(stmt, tableName + "_t1", tags);
StmtUtilTools.BindParam(stmt, binds);
StmtUtilTools.AddBatch(stmt);
StmtUtilTools.StmtExecute(stmt);
StmtUtilTools.StmtClose(stmt);
DataSource.FreeTaosBind(tags);
DataSource.FreeTaosBind(binds);
string querySql = "select * from " + tableName;
IntPtr res = UtilsTools.ExecuteQuery(conn, querySql);
UtilsTools.DisplayRes(res);
}
/// <author>xiaolei</author>
/// <Name>StableStmtCases.TestBindColumnCn</Name>
/// <describe>Test stmt insert single line of chinese character into stable by column after column </describe>
/// <filename>StmtSTable.cs</filename>
/// <result>pass or failed </result>
public void TestBindColumnCn(IntPtr conn, string tableName)
{
DataSource data = new DataSource();
TAOS_BIND[] tags = DataSource.getCNTags();
TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindCNArr();
String createTb = "create stable " + tableName + " (ts timestamp ,b bool,v1 tinyint,v2 smallint,v4 int,v8 bigint,f4 float,f8 double,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,bin binary(200),blob nchar(200))tags(bo bool,tt tinyint,si smallint,ii int,bi bigint,tu tinyint unsigned,su smallint unsigned,iu int unsigned,bu bigint unsigned,ff float ,dd double ,bb binary(200),nc nchar(200));";
String insertSql = "insert into ? using " + tableName + " tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
UtilsTools.ExecuteUpdate(conn, createTb);
IntPtr stmt = StmtUtilTools.StmtInit(conn);
StmtUtilTools.StmtPrepare(stmt, insertSql);
StmtUtilTools.SetTableNameTags(stmt, tableName + "_t1", tags);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[0], 0);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[1], 1);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[2], 2);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[3], 3);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[4], 4);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[5], 5);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[6], 6);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[7], 7);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[8], 8);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[9], 9);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[10], 10);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[11], 11);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[12], 12);
StmtUtilTools.BindSingleParamBatch(stmt, mbind[13], 13);
StmtUtilTools.AddBatch(stmt);
StmtUtilTools.StmtExecute(stmt);
StmtUtilTools.StmtClose(stmt);
DataSource.FreeTaosBind(tags);
DataSource.FreeTaosMBind(mbind);
string querySql = "select * from " + tableName;
IntPtr res = UtilsTools.ExecuteQuery(conn, querySql);
UtilsTools.DisplayRes(res);
}
/// <author>xiaolei</author>
/// <Name>StableStmtCases.TestBindMultiLineCn</Name>
/// <describe>Test stmt insert single line of chinese character into stable by column after column </describe>
/// <filename>StmtSTable.cs</filename>
/// <result>pass or failed </result>
public void TestBindMultiLineCn(IntPtr conn, string tableName)
{
TAOS_BIND[] tags = DataSource.getCNTags();
TAOS_MULTI_BIND[] mbind = DataSource.GetMultiBindCNArr();
String createTb = "create stable " + tableName + " (ts timestamp ,b bool,v1 tinyint,v2 smallint,v4 int,v8 bigint,f4 float,f8 double,u1 tinyint unsigned,u2 smallint unsigned,u4 int unsigned,u8 bigint unsigned,bin binary(200),blob nchar(200))tags(bo bool,tt tinyint,si smallint,ii int,bi bigint,tu tinyint unsigned,su smallint unsigned,iu int unsigned,bu bigint unsigned,ff float ,dd double ,bb binary(200),nc nchar(200));";
String insertSql = "insert into ? using " + tableName + " tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
UtilsTools.ExecuteUpdate(conn, createTb);
IntPtr stmt = StmtUtilTools.StmtInit(conn);
StmtUtilTools.StmtPrepare(stmt, insertSql);
StmtUtilTools.SetTableNameTags(stmt, tableName + "_t1", tags);
StmtUtilTools.BindParamBatch(stmt, mbind);
StmtUtilTools.AddBatch(stmt);
StmtUtilTools.StmtExecute(stmt);
StmtUtilTools.StmtClose(stmt);
DataSource.FreeTaosBind(tags);
DataSource.FreeTaosMBind(mbind);
string querySql = "select * from " + tableName;
IntPtr res = UtilsTools.ExecuteQuery(conn, querySql);
UtilsTools.DisplayRes(res);
}
}
}
\ No newline at end of file
......@@ -8,7 +8,7 @@ namespace Test.UtilsTools
public class UtilsTools
{
static string configDir = "C:/TDengine/cfg";
static string configDir = "/etc/taos";//"C:/TDengine/cfg";
public static IntPtr TDConnection(string ip, string user, string password, string db, short port)
{
......@@ -60,6 +60,28 @@ namespace Test.UtilsTools
return res;
}
public static void ExecuteUpdate(IntPtr conn, String sql)
{
IntPtr res = TDengine.Query(conn, sql);
if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
{
Console.Write(sql.ToString() + " failure, ");
if (res != IntPtr.Zero)
{
Console.Write("reason: " + TDengine.Error(res));
}
Console.WriteLine("");
ExitProgram();
}
else
{
Console.WriteLine(sql.ToString() + " success");
}
TDengine.FreeResult(res);
}
public static void DisplayRes(IntPtr res)
{
long queryRows = 0;
......
......@@ -652,8 +652,8 @@ namespace TDengineDriver.Test
{
int bufferType = 8;
String buffer = "qwertyuiopasdghjklzxcvbnm<>?:\"{}+_)(*&^%$#@!~QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./`1234567890-=";
int bufferLength = buffer.Length;
int length = buffer.Length;
int bufferLength = System.Text.Encoding.Default.GetBytes(buffer).Length;
int length = System.Text.Encoding.Default.GetBytes(buffer).Length;
TDengineDriver.TAOS_BIND bind = TaosBind.BindBinary("qwertyuiopasdghjklzxcvbnm<>?:\"{}+_)(*&^%$#@!~QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./`1234567890-=");
int BindLengPtr = Marshal.ReadInt32(bind.length);
......@@ -674,8 +674,8 @@ namespace TDengineDriver.Test
{
int bufferType = 8;
String buffer = "一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./";
int bufferLength = buffer.Length;
int length = buffer.Length;
int bufferLength = System.Text.Encoding.Default.GetBytes(buffer).Length;
int length = System.Text.Encoding.Default.GetBytes(buffer).Length;
TDengineDriver.TAOS_BIND bind = TaosBind.BindBinary("一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./");
int BindLengPtr = Marshal.ReadInt32(bind.length);
......@@ -696,8 +696,8 @@ namespace TDengineDriver.Test
{
int bufferType = 8;
String buffer = "一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
int bufferLength = buffer.Length;
int length = buffer.Length;
int bufferLength = System.Text.Encoding.Default.GetBytes(buffer).Length;
int length = System.Text.Encoding.Default.GetBytes(buffer).Length;
TDengineDriver.TAOS_BIND bind = TaosBind.BindBinary("一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM");
int BindLengPtr = Marshal.ReadInt32(bind.length);
......@@ -718,8 +718,8 @@ namespace TDengineDriver.Test
{
int bufferType = 10;
String buffer = "qwertyuiopasdghjklzxcvbnm<>?:\"{}+_)(*&^%$#@!~QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./`1234567890-=";
int bufferLength = buffer.Length;
int length = buffer.Length;
int bufferLength = System.Text.Encoding.Default.GetBytes(buffer).Length;
int length = System.Text.Encoding.Default.GetBytes(buffer).Length;
TDengineDriver.TAOS_BIND bind = TaosBind.BindNchar("qwertyuiopasdghjklzxcvbnm<>?:\"{}+_)(*&^%$#@!~QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./`1234567890-=");
int BindLengPtr = Marshal.ReadInt32(bind.length);
......@@ -739,8 +739,8 @@ namespace TDengineDriver.Test
{
int bufferType = 10;
String buffer = "一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./";
int bufferLength = buffer.Length;
int length = buffer.Length;
int bufferLength = System.Text.Encoding.Default.GetBytes(buffer).Length;
int length = System.Text.Encoding.Default.GetBytes(buffer).Length;
TDengineDriver.TAOS_BIND bind = TaosBind.BindNchar("一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./");
int BindLengPtr = Marshal.ReadInt32(bind.length);
......@@ -760,8 +760,8 @@ namespace TDengineDriver.Test
{
int bufferType = 10;
String buffer = "一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
int bufferLength = buffer.Length;
int length = buffer.Length;
int bufferLength = System.Text.Encoding.Default.GetBytes(buffer).Length;
int length = System.Text.Encoding.Default.GetBytes(buffer).Length;
TDengineDriver.TAOS_BIND bind = TaosBind.BindNchar("一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM");
int BindLengPtr = Marshal.ReadInt32(bind.length);
......
package com.taosdata.jdbc.confprops;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import java.sql.Connection;
......@@ -13,6 +14,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
@Ignore
public class HttpKeepAliveTest {
private static final String host = "127.0.0.1";
......
node_modules
\ No newline at end of file
This repositry create a custom Node-Red node for configing TDEngine server connection and execute SQL from preview node msg.payload
## Design
Use Taos data restful API to commit SQL, API call like
```
curl -H 'Authorization: Basic <TOKEN>' -d '<SQL>' <ip>:<PORT>/rest/sql/[db_name]
```
Input options:
* DB Server: Setup server connection or select a exist server
* DB Name: Database to execute SQL
Use [axios](https://axios-http.com/) to call http request
## Usage
1. Start Node-Red
2. Install TDEngine node
3. Add "taos query" node to workspace from palette
4. Setup a TDEngine server and database name
5. Add function or other node to create SQL, put SQL into msg.payload
6. Link to "taos query" node
### Demo
1. Start Node-Red by docker
```
docker run -it -p 1880:1880 -v node_red_data:/data --name mynodered nodered/node-red
```
2. Import sample flow "demo/flow.json"
![import-flow](demo/ImportFlow.png)
3. Install TDEngine node by name "node-red-contrib-tdengine", current version is 0.0.2
![alt](demo/InstallTDEngineNode.png)
4. Modify your TDEngine server config
![alt](demo/ModifyServerConfig.png)
5. Edit test SQL
![alt](demo/EditTestSQL.png)
6. Start flow by click Inject node
[
{
"id": "01ad89bea2c249f6",
"type": "tab",
"label": "流程 1",
"disabled": false,
"info": "",
"env": [
{
"name": "test",
"value": "abc",
"type": "str"
},
{
"name": "path",
"value": "{\"codes\":\"/usr/local/processing/codes\",\"parameters\":\"/usr/local/processing/parameters\"}",
"type": "json"
}
]
},
{
"id": "0ab8aa0c7f1b7522",
"type": "taos-query",
"z": "01ad89bea2c249f6",
"server": "e385222cd91994dc",
"database": "demo",
"x": 780,
"y": 400,
"wires": [
[
"f9c4f70dc2d79548"
]
]
},
{
"id": "ba09b80a40b65780",
"type": "inject",
"z": "01ad89bea2c249f6",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "INSERT INTO t VALUES (NOW, 23)",
"payloadType": "str",
"x": 490,
"y": 400,
"wires": [
[
"0ab8aa0c7f1b7522"
]
]
},
{
"id": "f9c4f70dc2d79548",
"type": "debug",
"z": "01ad89bea2c249f6",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1050,
"y": 400,
"wires": []
},
{
"id": "e385222cd91994dc",
"type": "taos-config",
"host": "localhost",
"port": "6030",
"username": "root",
"password": "taosdata"
}
]
\ No newline at end of file
{
"name": "node-red-contrib-tdengine",
"version": "0.0.2",
"description": "",
"main": "tdengine.js",
"repository": {
"type": "git",
"url": "git+https://github.com/kevinpan45/node-red-contrib-tdengine.git"
},
"author": "kevinpan45@163.com",
"license": "ISC",
"dependencies": {
"axios": "^0.24.0",
"mocha": "^9.1.3"
},
"node-red": {
"nodes": {
"tdengine": "tdengine.js"
}
},
"keywords": [
"node-red",
"tdengine"
],
"devDependencies": {
"node-red": "^2.1.4",
"node-red-node-test-helper": "^0.2.7"
}
}
<script type="text/javascript">
"use strict";
/*global RED*/
RED.nodes.registerType('taos-config', {
category: 'config',
defaults: {
host: {
value: "localhost",
required: true
},
port: {
value: "6030",
required: true
},
username: {
value: "",
required: false
},
password: {
value: "",
required: false
}
},
label: function () {
return this.host || "TDEngine host";
}
});
</script>
<script type="text/x-red" data-template-name="taos-config">
<div class="form-row">
<label for="node-config-input-host"><i class="fa fa-server"></i> Host</label>
<input type="text" id="node-config-input-host">
</div>
<div class="form-row">
<label for="node-config-input-port"><i class="fa fa-server"></i> Port</label>
<input type="text" id="node-config-input-port">
</div>
<div class="form-row">
<label for="node-config-input-username"><i class="fa fa-server"></i> User Name</label>
<input type="text" id="node-config-input-username">
</div>
<div class="form-row">
<label for="node-config-input-password"><i class="fa fa-server"></i> Password</label>
<input type="text" id="node-config-input-password">
</div>
</script>
<script type="text/javascript">
/*global RED*/
RED.nodes.registerType('taos-query', {
category: 'TDEngine',
inputs: 1,
outputs: 1,
color: "#ffffff",
paletteLabel: "taos query",
defaults: {
server: {
value: "",
type: "taos-config"
},
database: {
value: ""
},
sql: {
value: ""
}
},
label: function () {
return this.name || "taos " + this.database;
}
});
</script>
<script type="text/x-red" data-template-name="taos-query">
<div class="form-row">
<label for="node-input-server"><i class="fa fa-globe"></i> Server</label>
<input type="text" id="node-input-server" placeholder="Server">
</div>
<div class="form-row">
<label for="node-input-database"><i class="fa fa-tag"></i> Database</label>
<input type="text" id="node-input-database" placeholder="Database">
</div>
</script>
<script type="text/x-red" data-help-name="taos-query">
<p>TDEngine Query</p>
<p>Execute SQL on remote TDEngine server by restful API</p>
</script>
\ No newline at end of file
module.exports = function (RED) {
"use strict";
const axios = require('axios');
function TaosConfig(n) {
RED.nodes.createNode(this, n);
this.host = n.host;
this.port = n.port;
this.username = n.username;
this.password = n.password;
}
RED.nodes.registerType("taos-config", TaosConfig);
function TaosQuery(n) {
RED.nodes.createNode(this, n);
this.server = RED.nodes.getNode(n.server);
this.database = n.database;
var node = this;
node.on("close", function (done) {
node.status({});
client = null;
done();
});
node.on("input", async function (msg, send, done) {
send = send || function () { node.send.apply(node, arguments) }
done = done || function (err) { if (err) node.error(err, msg); }
let sql = msg.payload;
if (!msg.payload || msg.payload == "") {
throw new Error("Execute SQL must be set.");
}
try {
msg.payload = await query(this.server, sql);
send(msg);
done();
} catch (error) {
done(error);
}
});
}
RED.nodes.registerType("taos-query", TaosQuery);
function query(server, sql) {
console.log("Start to execute SQL : " + sql);
let url = generateUrl(server);
return axios.post(url, sql, {
headers: { 'Authorization': token(server) }
}).then(function (response) {
console.log('Get http response from taos : ' + response.data.data);
return response.data.data;
}).catch(function (error) {
console.error("Request Failed " + e);
throw new Error(response.desc);
});
}
function generateUrl(server) {
return "http://" + server.host + ":" + server.port + '/rest/sql';
}
function token(server) {
return 'Basic ' + Buffer.from(server.username + ":" + server.password).toString('base64')
}
};
......@@ -448,9 +448,29 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
tt = 0;
}
*/
#ifdef WINDOWS
if (tt < 0) tt = 0;
if (tt < 0) {
SYSTEMTIME a={1970,1,5,1,0,0,0,0}; // SYSTEMTIME struct support 1601-01-01. set 1970 to compatible with Epoch time.
FILETIME b; // unit is 100ns
ULARGE_INTEGER c;
SystemTimeToFileTime(&a,&b);
c.LowPart = b.dwLowDateTime;
c.HighPart = b.dwHighDateTime;
c.QuadPart+=tt*10000000;
b.dwLowDateTime=c.LowPart;
b.dwHighDateTime=c.HighPart;
FileTimeToLocalFileTime(&b,&b);
FileTimeToSystemTime(&b,&a);
int pos = sprintf(buf,"%02d-%02d-%02d %02d:%02d:%02d", a.wYear, a.wMonth,a.wDay, a.wHour, a.wMinute, a.wSecond);
if (precision == TSDB_TIME_PRECISION_NANO) {
sprintf(buf + pos, ".%09d", ms);
} else if (precision == TSDB_TIME_PRECISION_MICRO) {
sprintf(buf + pos, ".%06d", ms);
} else {
sprintf(buf + pos, ".%03d", ms);
}
return buf;
}
#endif
if (tt <= 0 && ms < 0) {
tt--;
......
Subproject commit 14a23779d24a9571cdb7165bea2b0208d54c53ad
Subproject commit 27751ba9ca17407425fb50a52cd68295794dedc3
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册