提交 8c34232b 编写于 作者: J jiacy-jcy

[test/TD-10790]<test>(connector):update test.sh

上级 9b5866ee
......@@ -35,7 +35,8 @@ namespace TDengineDriver
TSDB_DATA_TYPE_UTINYINT = 11,// 1 byte
TSDB_DATA_TYPE_USMALLINT = 12,// 2 bytes
TSDB_DATA_TYPE_UINT = 13, // 4 bytes
TSDB_DATA_TYPE_UBIGINT = 14 // 8 bytes
TSDB_DATA_TYPE_UBIGINT = 14, // 8 bytes
TSDB_DATA_TYPE_JSONTAG = 15 //4096 bytes
}
public enum TDengineInitOption
......@@ -46,7 +47,6 @@ namespace TDengineDriver
TDDB_OPTION_CONFIGDIR = 3,
TDDB_OPTION_SHELL_ACTIVITY_TIMER = 4
}
enum TaosField
{
STRUCT_SIZE = 68,
......@@ -92,6 +92,8 @@ namespace TDengineDriver
return "TIMESTAMP";
case TDengineDataType.TSDB_DATA_TYPE_NCHAR:
return "NCHAR";
case TDengineDataType.TSDB_DATA_TYPE_JSONTAG:
return "JSON";
default:
return "undefine";
}
......@@ -204,6 +206,7 @@ namespace TDengineDriver
metas.Add(meta);
}
return metas;
}
......@@ -395,5 +398,8 @@ namespace TDengineDriver
IntPtr stmtErrPrt = StmtErrPtr(stmt);
return Marshal.PtrToStringAnsi(stmtErrPrt);
}
[DllImport("taos", EntryPoint = "taos_fetch_lengths", CallingConvention = CallingConvention.Cdecl)]
static extern public IntPtr FetchLengths(IntPtr taos);
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
......
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
......@@ -30,3 +30,6 @@ cd ${WKC}/tests/examples/C#/taosdemo
dotnet build -c Release
tree | true
./bin/Release/net5.0/taosdemo -c /etc/taos -y
cd ${WKC}/tests/system-test/3-connectors/c#/stmtfunction
dotnet run
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册