Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
01001cf0
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
01001cf0
编写于
12月 24, 2021
作者:
W
wenzhouwww
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' of github.com:taosdata/TDengine into develop
上级
d7eb4e9a
c00b9edd
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
406 addition
and
54 deletion
+406
-54
src/client/src/tscServer.c
src/client/src/tscServer.c
+5
-4
src/connector/C#/src/TDengineDriver/TaosBind.cs
src/connector/C#/src/TDengineDriver/TaosBind.cs
+6
-2
src/connector/C#/src/TDengineDriver/TaosMultiBind.cs
src/connector/C#/src/TDengineDriver/TaosMultiBind.cs
+29
-16
src/connector/C#/src/test/Cases/DataSource.cs
src/connector/C#/src/test/Cases/DataSource.cs
+63
-2
src/connector/C#/src/test/Cases/Program.cs
src/connector/C#/src/test/Cases/Program.cs
+27
-4
src/connector/C#/src/test/Cases/StmtNormalTable.cs
src/connector/C#/src/test/Cases/StmtNormalTable.cs
+124
-8
src/connector/C#/src/test/Cases/StmtStable.cs
src/connector/C#/src/test/Cases/StmtStable.cs
+117
-5
src/connector/C#/src/test/Cases/Utils.cs
src/connector/C#/src/test/Cases/Utils.cs
+23
-1
src/connector/C#/src/test/XUnitTest/TestTaosBind.cs
src/connector/C#/src/test/XUnitTest/TestTaosBind.cs
+12
-12
未找到文件。
src/client/src/tscServer.c
浏览文件 @
01001cf0
...
@@ -3124,11 +3124,12 @@ int tscRenewTableMeta(SSqlObj *pSql) {
...
@@ -3124,11 +3124,12 @@ int tscRenewTableMeta(SSqlObj *pSql) {
pSql
->
rootObj
->
retryReason
=
pSql
->
retryReason
;
pSql
->
rootObj
->
retryReason
=
pSql
->
retryReason
;
SSqlObj
*
tmpSql
=
pSql
->
rootObj
;
SSqlObj
*
rootSql
=
pSql
->
rootObj
;
tscFreeSubobj
(
pSql
->
rootObj
);
tscFreeSubobj
(
rootSql
);
tfree
(
tmpSql
->
pSubs
);
tfree
(
rootSql
->
pSubs
);
tscResetSqlCmd
(
&
rootSql
->
cmd
,
true
,
rootSql
->
self
);
code
=
getMultiTableMetaFromMnode
(
tmp
Sql
,
pNameList
,
vgroupList
,
NULL
,
tscTableMetaCallBack
,
true
);
code
=
getMultiTableMetaFromMnode
(
root
Sql
,
pNameList
,
vgroupList
,
NULL
,
tscTableMetaCallBack
,
true
);
taosArrayDestroyEx
(
&
pNameList
,
freeElem
);
taosArrayDestroyEx
(
&
pNameList
,
freeElem
);
taosArrayDestroyEx
(
&
vgroupList
,
freeElem
);
taosArrayDestroyEx
(
&
vgroupList
,
freeElem
);
...
...
src/connector/C#/src/TDengineDriver/TaosBind.cs
浏览文件 @
01001cf0
using
System
;
using
System
;
using
System.Runtime.InteropServices
;
using
System.Runtime.InteropServices
;
using
System.Text
;
namespace
TDengineDriver
namespace
TDengineDriver
...
@@ -249,7 +250,8 @@ namespace TDengineDriver
...
@@ -249,7 +250,8 @@ namespace TDengineDriver
TAOS_BIND
bind
=
new
TAOS_BIND
();
TAOS_BIND
bind
=
new
TAOS_BIND
();
IntPtr
umanageBinary
=
Marshal
.
StringToHGlobalAnsi
(
val
);
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
));
IntPtr
lenPtr
=
Marshal
.
AllocHGlobal
(
sizeof
(
ulong
));
Marshal
.
WriteInt64
(
lenPtr
,
leng
);
Marshal
.
WriteInt64
(
lenPtr
,
leng
);
...
@@ -264,9 +266,11 @@ namespace TDengineDriver
...
@@ -264,9 +266,11 @@ namespace TDengineDriver
public
static
TAOS_BIND
BindNchar
(
String
val
)
public
static
TAOS_BIND
BindNchar
(
String
val
)
{
{
TAOS_BIND
bind
=
new
TAOS_BIND
();
TAOS_BIND
bind
=
new
TAOS_BIND
();
var
strToBytes
=
System
.
Text
.
Encoding
.
Default
.
GetBytes
(
val
);
IntPtr
umanageNchar
=
(
IntPtr
)
Marshal
.
StringToHGlobalAnsi
(
val
);
IntPtr
umanageNchar
=
(
IntPtr
)
Marshal
.
StringToHGlobalAnsi
(
val
);
int
leng
=
val
.
Length
;
int
leng
=
strToBytes
.
Length
;
IntPtr
lenPtr
=
Marshal
.
AllocHGlobal
(
sizeof
(
ulong
));
IntPtr
lenPtr
=
Marshal
.
AllocHGlobal
(
sizeof
(
ulong
));
Marshal
.
WriteInt64
(
lenPtr
,
leng
);
Marshal
.
WriteInt64
(
lenPtr
,
leng
);
...
...
src/connector/C#/src/TDengineDriver/TaosMultiBind.cs
浏览文件 @
01001cf0
...
@@ -449,28 +449,27 @@ namespace TDengineDriver
...
@@ -449,28 +449,27 @@ namespace TDengineDriver
for
(
int
i
=
0
;
i
<
elementCount
;
i
++)
for
(
int
i
=
0
;
i
<
elementCount
;
i
++)
{
{
int
itemLength
=
0
;
int
itemLength
=
0
;
byte
[]
decodeByte
=
GetStringEncodeByte
(
arr
[
i
]);
itemLength
=
decodeByte
.
Length
;
// if element if not null and element length is less then typeSize
// if element if not null and element length is less then typeSize
// fill the memory with default char.Since arr element memory need align.
// 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
==
item
Length
)
{
{
itemLength
=
arr
[
i
].
Length
;
arrStrBuilder
.
Append
(
arr
[
i
]);
arrStrBuilder
.
Append
(
arr
[
i
]);
}
}
else
if
(!
String
.
IsNullOrEmpty
(
arr
[
i
])
&&
typeSize
>
arr
[
i
].
Length
)
else
if
(!
String
.
IsNullOrEmpty
(
arr
[
i
])
&&
typeSize
>
item
Length
)
{
{
itemLength
=
arr
[
i
].
Length
;
arrStrBuilder
.
Append
(
arr
[
i
]);
arrStrBuilder
.
Append
(
arr
[
i
]);
arrStrBuilder
.
Append
(
AlignCharArr
(
typeSize
-
arr
[
i
].
Length
));
arrStrBuilder
.
Append
(
AlignCharArr
(
typeSize
-
item
Length
));
}
}
else
else
{
{
// if is null value,fill the memory with default values.
// if is null value,fill the memory with default values.
itemLength
=
0
;
arrStrBuilder
.
Append
(
AlignCharArr
(
typeSize
));
arrStrBuilder
.
Append
(
AlignCharArr
(
typeSize
));
}
}
//set TAOS_MULTI_BIND.length
//set TAOS_MULTI_BIND.length
Marshal
.
WriteInt32
(
lengthArr
,
intSize
*
i
,
itemLength
);
Marshal
.
WriteInt32
(
lengthArr
,
intSize
*
i
,
typeSize
);
//set TAOS_MULTI_BIND.is_null
//set TAOS_MULTI_BIND.is_null
Marshal
.
WriteByte
(
nullArr
,
byteSize
*
i
,
Convert
.
ToByte
(
String
.
IsNullOrEmpty
(
arr
[
i
])
?
1
:
0
));
Marshal
.
WriteByte
(
nullArr
,
byteSize
*
i
,
Convert
.
ToByte
(
String
.
IsNullOrEmpty
(
arr
[
i
])
?
1
:
0
));
}
}
...
@@ -505,28 +504,27 @@ namespace TDengineDriver
...
@@ -505,28 +504,27 @@ namespace TDengineDriver
for
(
int
i
=
0
;
i
<
elementCount
;
i
++)
for
(
int
i
=
0
;
i
<
elementCount
;
i
++)
{
{
int
itemLength
=
0
;
int
itemLength
=
0
;
byte
[]
decodeByte
=
GetStringEncodeByte
(
arr
[
i
]);
itemLength
=
decodeByte
.
Length
;
// if element if not null and element length is less then typeSize
// if element if not null and element length is less then typeSize
// fill the memory with default char.Since arr element memory need align.
// 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
==
item
Length
)
{
{
itemLength
=
arr
[
i
].
Length
;
arrStrBuilder
.
Append
(
arr
[
i
]);
arrStrBuilder
.
Append
(
arr
[
i
]);
}
}
else
if
(!
String
.
IsNullOrEmpty
(
arr
[
i
])
&&
typeSize
>
arr
[
i
].
Length
)
else
if
(!
String
.
IsNullOrEmpty
(
arr
[
i
])
&&
typeSize
>
item
Length
)
{
{
itemLength
=
arr
[
i
].
Length
;
arrStrBuilder
.
Append
(
arr
[
i
]);
arrStrBuilder
.
Append
(
arr
[
i
]);
arrStrBuilder
.
Append
(
AlignCharArr
(
typeSize
-
arr
[
i
].
Length
));
arrStrBuilder
.
Append
(
AlignCharArr
(
typeSize
-
item
Length
));
}
}
else
else
{
{
// if is null value,fill the memory with default values.
// if is null value,fill the memory with default values.
itemLength
=
0
;
arrStrBuilder
.
Append
(
AlignCharArr
(
typeSize
));
arrStrBuilder
.
Append
(
AlignCharArr
(
typeSize
));
}
}
//set TAOS_MULTI_BIND.length
//set TAOS_MULTI_BIND.length
Marshal
.
WriteInt32
(
lengthArr
,
intSize
*
i
,
itemLength
);
Marshal
.
WriteInt32
(
lengthArr
,
intSize
*
i
,
typeSize
);
//set TAOS_MULTI_BIND.is_null
//set TAOS_MULTI_BIND.is_null
Marshal
.
WriteByte
(
nullArr
,
byteSize
*
i
,
Convert
.
ToByte
(
String
.
IsNullOrEmpty
(
arr
[
i
])
?
1
:
0
));
Marshal
.
WriteByte
(
nullArr
,
byteSize
*
i
,
Convert
.
ToByte
(
String
.
IsNullOrEmpty
(
arr
[
i
])
?
1
:
0
));
}
}
...
@@ -604,13 +602,28 @@ namespace TDengineDriver
...
@@ -604,13 +602,28 @@ namespace TDengineDriver
int
max
=
0
;
int
max
=
0
;
for
(
int
i
=
0
;
i
<
strArr
.
Length
;
i
++)
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
=
tmp
Length
;
}
}
}
}
return
max
;
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
src/connector/C#/src/test/Cases/DataSource.cs
浏览文件 @
01001cf0
...
@@ -21,7 +21,8 @@ namespace Test.UtilsTools.DataSource
...
@@ -21,7 +21,8 @@ namespace Test.UtilsTools.DataSource
public
static
string
[]
binaryArr
=
new
string
[
5
]
{
"1234567890~!@#$%^&*()_+=-`[]{}:,./<>?"
,
String
.
Empty
,
null
,
"qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"
,
"qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890~!@#$%^&*()_+=-`[]{}:,./<>?"
};
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
[]
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
()
public
static
TAOS_BIND
[]
getTags
()
{
{
TAOS_BIND
[]
binds
=
new
TAOS_BIND
[
13
];
TAOS_BIND
[]
binds
=
new
TAOS_BIND
[
13
];
...
@@ -40,6 +41,47 @@ namespace Test.UtilsTools.DataSource
...
@@ -40,6 +41,47 @@ namespace Test.UtilsTools.DataSource
binds
[
12
]
=
TaosBind
.
BindNchar
(
"qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKZXCVBNM`1234567890-=+_)(*&^%$#@!~[];,./<>?:{}"
);
binds
[
12
]
=
TaosBind
.
BindNchar
(
"qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKZXCVBNM`1234567890-=+_)(*&^%$#@!~[];,./<>?:{}"
);
return
binds
;
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
()
public
static
TAOS_BIND
[]
getNtableRow
()
{
{
TAOS_BIND
[]
binds
=
new
TAOS_BIND
[
15
];
TAOS_BIND
[]
binds
=
new
TAOS_BIND
[
15
];
...
@@ -60,7 +102,6 @@ namespace Test.UtilsTools.DataSource
...
@@ -60,7 +102,6 @@ namespace Test.UtilsTools.DataSource
binds
[
14
]
=
TaosBind
.
BindNil
();
binds
[
14
]
=
TaosBind
.
BindNil
();
return
binds
;
return
binds
;
}
}
public
static
TAOS_MULTI_BIND
[]
GetMultiBindArr
()
public
static
TAOS_MULTI_BIND
[]
GetMultiBindArr
()
{
{
TAOS_MULTI_BIND
[]
mBinds
=
new
TAOS_MULTI_BIND
[
14
];
TAOS_MULTI_BIND
[]
mBinds
=
new
TAOS_MULTI_BIND
[
14
];
...
@@ -80,6 +121,26 @@ namespace Test.UtilsTools.DataSource
...
@@ -80,6 +121,26 @@ namespace Test.UtilsTools.DataSource
mBinds
[
13
]
=
TaosMultiBind
.
MultiBindNchar
(
ncharArr
);
mBinds
[
13
]
=
TaosMultiBind
.
MultiBindNchar
(
ncharArr
);
return
mBinds
;
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
()
public
static
TAOS_BIND
[]
GetQueryCondition
()
{
{
TAOS_BIND
[]
queryCondition
=
new
TAOS_BIND
[
2
];
TAOS_BIND
[]
queryCondition
=
new
TAOS_BIND
[
2
];
...
...
src/connector/C#/src/test/Cases/Program.cs
浏览文件 @
01001cf0
using
System
;
using
System
;
using
Test.UtilsTools
;
using
Test.UtilsTools
;
using
Cases
;
using
Cases
;
...
@@ -14,9 +14,9 @@ namespace Cases.EntryPoint
...
@@ -14,9 +14,9 @@ namespace Cases.EntryPoint
IntPtr
res
=
IntPtr
.
Zero
;
IntPtr
res
=
IntPtr
.
Zero
;
conn
=
UtilsTools
.
TDConnection
(
"127.0.0.1"
,
"root"
,
"taosdata"
,
""
,
0
);
conn
=
UtilsTools
.
TDConnection
(
"127.0.0.1"
,
"root"
,
"taosdata"
,
""
,
0
);
UtilsTools
.
Execute
Query
(
conn
,
"drop database if exists csharp"
);
UtilsTools
.
Execute
Update
(
conn
,
"drop database if exists csharp"
);
UtilsTools
.
Execute
Query
(
conn
,
"create database if not exists csharp keep 3650"
);
UtilsTools
.
Execute
Update
(
conn
,
"create database if not exists csharp keep 3650"
);
UtilsTools
.
Execute
Query
(
conn
,
"use csharp"
);
UtilsTools
.
Execute
Update
(
conn
,
"use csharp"
);
Console
.
WriteLine
(
"====================StableColumnByColumn==================="
);
Console
.
WriteLine
(
"====================StableColumnByColumn==================="
);
StableColumnByColumn
columnByColumn
=
new
StableColumnByColumn
();
StableColumnByColumn
columnByColumn
=
new
StableColumnByColumn
();
...
@@ -34,6 +34,8 @@ namespace Cases.EntryPoint
...
@@ -34,6 +34,8 @@ namespace Cases.EntryPoint
Console
.
WriteLine
(
"====================NtableSingleLine==================="
);
Console
.
WriteLine
(
"====================NtableSingleLine==================="
);
NtableSingleLine
ntableSingleLine
=
new
NtableSingleLine
();
NtableSingleLine
ntableSingleLine
=
new
NtableSingleLine
();
ntableSingleLine
.
Test
(
conn
,
"stablesingleline"
);
ntableSingleLine
.
Test
(
conn
,
"stablesingleline"
);
IntPtr
resPtr
=
UtilsTools
.
ExecuteQuery
(
conn
,
"select * from stablesingleline "
);
UtilsTools
.
DisplayRes
(
resPtr
);
Console
.
WriteLine
(
"====================NtableMutipleLine==================="
);
Console
.
WriteLine
(
"====================NtableMutipleLine==================="
);
NtableMutipleLine
ntableMutipleLine
=
new
NtableMutipleLine
();
NtableMutipleLine
ntableMutipleLine
=
new
NtableMutipleLine
();
...
@@ -50,6 +52,27 @@ namespace Cases.EntryPoint
...
@@ -50,6 +52,27 @@ namespace Cases.EntryPoint
FetchFields
fetchFields
=
new
FetchFields
();
FetchFields
fetchFields
=
new
FetchFields
();
fetchFields
.
Test
(
conn
,
"fetchfeilds"
);
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===================="
);
Console
.
WriteLine
(
"===================JsonTagTest===================="
);
JsonTagTest
jsonTagTest
=
new
JsonTagTest
();
JsonTagTest
jsonTagTest
=
new
JsonTagTest
();
jsonTagTest
.
Test
(
conn
);
jsonTagTest
.
Test
(
conn
);
...
...
src/connector/C#/src/test/Cases/StmtNormalTable.cs
浏览文件 @
01001cf0
...
@@ -7,7 +7,11 @@ namespace Cases
...
@@ -7,7 +7,11 @@ namespace Cases
{
{
public
class
NtableSingleLine
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
)
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);"
;
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
...
@@ -23,21 +27,26 @@ namespace Cases
StmtUtilTools
.
StmtExecute
(
stmt
);
StmtUtilTools
.
StmtExecute
(
stmt
);
StmtUtilTools
.
StmtClose
(
stmt
);
StmtUtilTools
.
StmtClose
(
stmt
);
DataSource
.
FreeTaosBind
(
valuesRow
);
DataSource
.
FreeTaosBind
(
valuesRow
);
}
}
}
}
public
class
NtableMutipleLine
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
)
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
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(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
;
String
insertSql
=
"insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
;
UtilsTools
.
Execute
Query
(
conn
,
createTb
);
UtilsTools
.
Execute
Update
(
conn
,
createTb
);
String
[]
loadList
=
{
tableName
};
IntPtr
stmt
=
StmtUtilTools
.
StmtInit
(
conn
);
IntPtr
stmt
=
StmtUtilTools
.
StmtInit
(
conn
);
StmtUtilTools
.
loadTableInfo
(
conn
,
loadList
);
StmtUtilTools
.
StmtPrepare
(
stmt
,
insertSql
);
StmtUtilTools
.
StmtPrepare
(
stmt
,
insertSql
);
StmtUtilTools
.
SetTableName
(
stmt
,
tableName
);
StmtUtilTools
.
SetTableName
(
stmt
,
tableName
);
StmtUtilTools
.
BindParamBatch
(
stmt
,
mbind
);
StmtUtilTools
.
BindParamBatch
(
stmt
,
mbind
);
...
@@ -48,16 +57,93 @@ namespace Cases
...
@@ -48,16 +57,93 @@ namespace Cases
}
}
}
}
public
class
NtableColumnByColumn
public
class
NtableColumnByColumn
{
/// <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
();
DataSource
data
=
new
DataSource
();
TAOS_MULTI_BIND
[]
mbind
=
DataSource
.
GetMultiBindArr
();
TAOS_MULTI_BIND
[]
mbind
=
DataSource
.
GetMultiBindArr
();
public
void
Test
(
IntPtr
conn
,
string
tableName
)
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
);
}
}
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
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(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
;
String
insertSql
=
"insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
;
UtilsTools
.
Execute
Query
(
conn
,
createTb
);
UtilsTools
.
Execute
Update
(
conn
,
createTb
);
IntPtr
stmt
=
StmtUtilTools
.
StmtInit
(
conn
);
IntPtr
stmt
=
StmtUtilTools
.
StmtInit
(
conn
);
StmtUtilTools
.
StmtPrepare
(
stmt
,
insertSql
);
StmtUtilTools
.
StmtPrepare
(
stmt
,
insertSql
);
...
@@ -84,6 +170,36 @@ namespace Cases
...
@@ -84,6 +170,36 @@ namespace Cases
DataSource
.
FreeTaosMBind
(
mbind
);
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
src/connector/C#/src/test/Cases/StmtStable.cs
浏览文件 @
01001cf0
...
@@ -15,10 +15,8 @@ namespace Cases
...
@@ -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
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(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
;
String
insertSql
=
"insert into ? using "
+
tableName
+
" tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
;
UtilsTools
.
ExecuteQuery
(
conn
,
createTb
);
UtilsTools
.
ExecuteUpdate
(
conn
,
createTb
);
String
[]
loadList
=
{
tableName
};
IntPtr
stmt
=
StmtUtilTools
.
StmtInit
(
conn
);
IntPtr
stmt
=
StmtUtilTools
.
StmtInit
(
conn
);
StmtUtilTools
.
loadTableInfo
(
conn
,
loadList
);
StmtUtilTools
.
StmtPrepare
(
stmt
,
insertSql
);
StmtUtilTools
.
StmtPrepare
(
stmt
,
insertSql
);
StmtUtilTools
.
SetTableNameTags
(
stmt
,
tableName
+
"_t1"
,
tags
);
StmtUtilTools
.
SetTableNameTags
(
stmt
,
tableName
+
"_t1"
,
tags
);
...
@@ -43,12 +41,89 @@ namespace Cases
...
@@ -43,12 +41,89 @@ namespace Cases
String
insertSql
=
"insert into ? using "
+
tableName
+
" tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
;
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
);
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
);
}
}
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
);
IntPtr
stmt
=
StmtUtilTools
.
StmtInit
(
conn
);
StmtUtilTools
.
StmtPrepare
(
stmt
,
insertSql
);
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
.
SetTableNameTags
(
stmt
,
tableName
+
"_t1"
,
tags
);
StmtUtilTools
.
BindSingleParamBatch
(
stmt
,
mbind
[
0
],
0
);
StmtUtilTools
.
BindSingleParamBatch
(
stmt
,
mbind
[
0
],
0
);
StmtUtilTools
.
BindSingleParamBatch
(
stmt
,
mbind
[
1
],
1
);
StmtUtilTools
.
BindSingleParamBatch
(
stmt
,
mbind
[
1
],
1
);
StmtUtilTools
.
BindSingleParamBatch
(
stmt
,
mbind
[
2
],
2
);
StmtUtilTools
.
BindSingleParamBatch
(
stmt
,
mbind
[
2
],
2
);
...
@@ -63,6 +138,7 @@ namespace Cases
...
@@ -63,6 +138,7 @@ namespace Cases
StmtUtilTools
.
BindSingleParamBatch
(
stmt
,
mbind
[
11
],
11
);
StmtUtilTools
.
BindSingleParamBatch
(
stmt
,
mbind
[
11
],
11
);
StmtUtilTools
.
BindSingleParamBatch
(
stmt
,
mbind
[
12
],
12
);
StmtUtilTools
.
BindSingleParamBatch
(
stmt
,
mbind
[
12
],
12
);
StmtUtilTools
.
BindSingleParamBatch
(
stmt
,
mbind
[
13
],
13
);
StmtUtilTools
.
BindSingleParamBatch
(
stmt
,
mbind
[
13
],
13
);
StmtUtilTools
.
AddBatch
(
stmt
);
StmtUtilTools
.
AddBatch
(
stmt
);
StmtUtilTools
.
StmtExecute
(
stmt
);
StmtUtilTools
.
StmtExecute
(
stmt
);
StmtUtilTools
.
StmtClose
(
stmt
);
StmtUtilTools
.
StmtClose
(
stmt
);
...
@@ -70,7 +146,43 @@ namespace Cases
...
@@ -70,7 +146,43 @@ namespace Cases
DataSource
.
FreeTaosBind
(
tags
);
DataSource
.
FreeTaosBind
(
tags
);
DataSource
.
FreeTaosMBind
(
mbind
);
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
src/connector/C#/src/test/Cases/Utils.cs
浏览文件 @
01001cf0
...
@@ -8,7 +8,7 @@ namespace Test.UtilsTools
...
@@ -8,7 +8,7 @@ namespace Test.UtilsTools
public
class
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
)
public
static
IntPtr
TDConnection
(
string
ip
,
string
user
,
string
password
,
string
db
,
short
port
)
{
{
...
@@ -60,6 +60,28 @@ namespace Test.UtilsTools
...
@@ -60,6 +60,28 @@ namespace Test.UtilsTools
return
res
;
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
)
public
static
void
DisplayRes
(
IntPtr
res
)
{
{
long
queryRows
=
0
;
long
queryRows
=
0
;
...
...
src/connector/C#/src/test/XUnitTest/TestTaosBind.cs
浏览文件 @
01001cf0
...
@@ -652,8 +652,8 @@ namespace TDengineDriver.Test
...
@@ -652,8 +652,8 @@ namespace TDengineDriver.Test
{
{
int
bufferType
=
8
;
int
bufferType
=
8
;
String
buffer
=
"qwertyuiopasdghjklzxcvbnm<>?:\"{}+_)(*&^%$#@!~QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./`1234567890-="
;
String
buffer
=
"qwertyuiopasdghjklzxcvbnm<>?:\"{}+_)(*&^%$#@!~QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./`1234567890-="
;
int
bufferLength
=
buffer
.
Length
;
int
bufferLength
=
System
.
Text
.
Encoding
.
Default
.
GetBytes
(
buffer
)
.
Length
;
int
length
=
buffer
.
Length
;
int
length
=
System
.
Text
.
Encoding
.
Default
.
GetBytes
(
buffer
)
.
Length
;
TDengineDriver
.
TAOS_BIND
bind
=
TaosBind
.
BindBinary
(
"qwertyuiopasdghjklzxcvbnm<>?:\"{}+_)(*&^%$#@!~QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./`1234567890-="
);
TDengineDriver
.
TAOS_BIND
bind
=
TaosBind
.
BindBinary
(
"qwertyuiopasdghjklzxcvbnm<>?:\"{}+_)(*&^%$#@!~QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./`1234567890-="
);
int
BindLengPtr
=
Marshal
.
ReadInt32
(
bind
.
length
);
int
BindLengPtr
=
Marshal
.
ReadInt32
(
bind
.
length
);
...
@@ -674,8 +674,8 @@ namespace TDengineDriver.Test
...
@@ -674,8 +674,8 @@ namespace TDengineDriver.Test
{
{
int
bufferType
=
8
;
int
bufferType
=
8
;
String
buffer
=
"一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./"
;
String
buffer
=
"一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./"
;
int
bufferLength
=
buffer
.
Length
;
int
bufferLength
=
System
.
Text
.
Encoding
.
Default
.
GetBytes
(
buffer
)
.
Length
;
int
length
=
buffer
.
Length
;
int
length
=
System
.
Text
.
Encoding
.
Default
.
GetBytes
(
buffer
)
.
Length
;
TDengineDriver
.
TAOS_BIND
bind
=
TaosBind
.
BindBinary
(
"一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./"
);
TDengineDriver
.
TAOS_BIND
bind
=
TaosBind
.
BindBinary
(
"一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./"
);
int
BindLengPtr
=
Marshal
.
ReadInt32
(
bind
.
length
);
int
BindLengPtr
=
Marshal
.
ReadInt32
(
bind
.
length
);
...
@@ -696,8 +696,8 @@ namespace TDengineDriver.Test
...
@@ -696,8 +696,8 @@ namespace TDengineDriver.Test
{
{
int
bufferType
=
8
;
int
bufferType
=
8
;
String
buffer
=
"一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"
;
String
buffer
=
"一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"
;
int
bufferLength
=
buffer
.
Length
;
int
bufferLength
=
System
.
Text
.
Encoding
.
Default
.
GetBytes
(
buffer
)
.
Length
;
int
length
=
buffer
.
Length
;
int
length
=
System
.
Text
.
Encoding
.
Default
.
GetBytes
(
buffer
)
.
Length
;
TDengineDriver
.
TAOS_BIND
bind
=
TaosBind
.
BindBinary
(
"一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"
);
TDengineDriver
.
TAOS_BIND
bind
=
TaosBind
.
BindBinary
(
"一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"
);
int
BindLengPtr
=
Marshal
.
ReadInt32
(
bind
.
length
);
int
BindLengPtr
=
Marshal
.
ReadInt32
(
bind
.
length
);
...
@@ -718,8 +718,8 @@ namespace TDengineDriver.Test
...
@@ -718,8 +718,8 @@ namespace TDengineDriver.Test
{
{
int
bufferType
=
10
;
int
bufferType
=
10
;
String
buffer
=
"qwertyuiopasdghjklzxcvbnm<>?:\"{}+_)(*&^%$#@!~QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./`1234567890-="
;
String
buffer
=
"qwertyuiopasdghjklzxcvbnm<>?:\"{}+_)(*&^%$#@!~QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./`1234567890-="
;
int
bufferLength
=
buffer
.
Length
;
int
bufferLength
=
System
.
Text
.
Encoding
.
Default
.
GetBytes
(
buffer
)
.
Length
;
int
length
=
buffer
.
Length
;
int
length
=
System
.
Text
.
Encoding
.
Default
.
GetBytes
(
buffer
)
.
Length
;
TDengineDriver
.
TAOS_BIND
bind
=
TaosBind
.
BindNchar
(
"qwertyuiopasdghjklzxcvbnm<>?:\"{}+_)(*&^%$#@!~QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./`1234567890-="
);
TDengineDriver
.
TAOS_BIND
bind
=
TaosBind
.
BindNchar
(
"qwertyuiopasdghjklzxcvbnm<>?:\"{}+_)(*&^%$#@!~QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./`1234567890-="
);
int
BindLengPtr
=
Marshal
.
ReadInt32
(
bind
.
length
);
int
BindLengPtr
=
Marshal
.
ReadInt32
(
bind
.
length
);
...
@@ -739,8 +739,8 @@ namespace TDengineDriver.Test
...
@@ -739,8 +739,8 @@ namespace TDengineDriver.Test
{
{
int
bufferType
=
10
;
int
bufferType
=
10
;
String
buffer
=
"一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./"
;
String
buffer
=
"一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./"
;
int
bufferLength
=
buffer
.
Length
;
int
bufferLength
=
System
.
Text
.
Encoding
.
Default
.
GetBytes
(
buffer
)
.
Length
;
int
length
=
buffer
.
Length
;
int
length
=
System
.
Text
.
Encoding
.
Default
.
GetBytes
(
buffer
)
.
Length
;
TDengineDriver
.
TAOS_BIND
bind
=
TaosBind
.
BindNchar
(
"一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./"
);
TDengineDriver
.
TAOS_BIND
bind
=
TaosBind
.
BindNchar
(
"一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./"
);
int
BindLengPtr
=
Marshal
.
ReadInt32
(
bind
.
length
);
int
BindLengPtr
=
Marshal
.
ReadInt32
(
bind
.
length
);
...
@@ -760,8 +760,8 @@ namespace TDengineDriver.Test
...
@@ -760,8 +760,8 @@ namespace TDengineDriver.Test
{
{
int
bufferType
=
10
;
int
bufferType
=
10
;
String
buffer
=
"一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"
;
String
buffer
=
"一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"
;
int
bufferLength
=
buffer
.
Length
;
int
bufferLength
=
System
.
Text
.
Encoding
.
Default
.
GetBytes
(
buffer
)
.
Length
;
int
length
=
buffer
.
Length
;
int
length
=
System
.
Text
.
Encoding
.
Default
.
GetBytes
(
buffer
)
.
Length
;
TDengineDriver
.
TAOS_BIND
bind
=
TaosBind
.
BindNchar
(
"一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"
);
TDengineDriver
.
TAOS_BIND
bind
=
TaosBind
.
BindNchar
(
"一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"
);
int
BindLengPtr
=
Marshal
.
ReadInt32
(
bind
.
length
);
int
BindLengPtr
=
Marshal
.
ReadInt32
(
bind
.
length
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录