Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Mz丶苗
TDengine
提交
bd16bb3d
T
TDengine
项目概览
Mz丶苗
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bd16bb3d
编写于
8月 26, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-1214 change csharp driver in win32
上级
8db31201
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
65 addition
and
58 deletion
+65
-58
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+1
-1
src/mnode/src/mnodeDnode.c
src/mnode/src/mnodeDnode.c
+1
-1
tests/examples/C#/TDengineDriver.cs
tests/examples/C#/TDengineDriver.cs
+27
-27
tests/examples/C#/TDengineTest.cs
tests/examples/C#/TDengineTest.cs
+36
-29
未找到文件。
src/mnode/src/mnodeDb.c
浏览文件 @
bd16bb3d
...
...
@@ -354,7 +354,7 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate, SMnodeMsg
mDebug
(
"db:%s, already exist, ignore exist is set"
,
pCreate
->
db
);
return
TSDB_CODE_SUCCESS
;
}
else
{
mError
(
"db:%s,
is
already exist, ignore exist not set"
,
pCreate
->
db
);
mError
(
"db:%s, already exist, ignore exist not set"
,
pCreate
->
db
);
return
TSDB_CODE_MND_DB_ALREADY_EXIST
;
}
}
...
...
src/mnode/src/mnodeDnode.c
浏览文件 @
bd16bb3d
...
...
@@ -518,7 +518,7 @@ static int32_t mnodeCreateDnode(char *ep, SMnodeMsg *pMsg) {
SDnodeObj
*
pDnode
=
mnodeGetDnodeByEp
(
ep
);
if
(
pDnode
!=
NULL
)
{
mnodeDecDnodeRef
(
pDnode
);
mError
(
"dnode:%d
is
already exist, %s:%d"
,
pDnode
->
dnodeId
,
pDnode
->
dnodeFqdn
,
pDnode
->
dnodePort
);
mError
(
"dnode:%d
,
already exist, %s:%d"
,
pDnode
->
dnodeId
,
pDnode
->
dnodeFqdn
,
pDnode
->
dnodePort
);
return
TSDB_CODE_MND_DNODE_ALREADY_EXIST
;
}
...
...
tests/examples/C#/TDengineDriver.cs
浏览文件 @
bd16bb3d
...
...
@@ -80,47 +80,47 @@ namespace TDengineDriver
class
TDengine
{
public
const
int
TSDB_CODE_SUCCESS
=
0
;
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_init"
,
CallingConvention
=
CallingConvention
.
StdCal
l
)]
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_init"
,
CallingConvention
=
CallingConvention
.
Cdec
l
)]
static
extern
public
void
Init
();
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_cleanup"
,
CallingConvention
=
CallingConvention
.
StdCal
l
)]
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_cleanup"
,
CallingConvention
=
CallingConvention
.
Cdec
l
)]
static
extern
public
void
Cleanup
();
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_options"
,
CallingConvention
=
CallingConvention
.
StdCal
l
)]
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_options"
,
CallingConvention
=
CallingConvention
.
Cdec
l
)]
static
extern
public
void
Options
(
int
option
,
string
value
);
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_connect"
,
CallingConvention
=
CallingConvention
.
StdCal
l
)]
static
extern
public
long
Connect
(
string
ip
,
string
user
,
string
password
,
string
db
,
short
port
);
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_connect"
,
CallingConvention
=
CallingConvention
.
Cdec
l
)]
static
extern
public
IntPtr
Connect
(
string
ip
,
string
user
,
string
password
,
string
db
,
short
port
);
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_errstr"
,
CallingConvention
=
CallingConvention
.
StdCal
l
)]
static
extern
private
IntPtr
taos_errstr
(
long
res
);
static
public
string
Error
(
long
res
)
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_errstr"
,
CallingConvention
=
CallingConvention
.
Cdec
l
)]
static
extern
private
IntPtr
taos_errstr
(
IntPtr
res
);
static
public
string
Error
(
IntPtr
res
)
{
IntPtr
errPtr
=
taos_errstr
(
res
);
return
Marshal
.
PtrToStringAnsi
(
errPtr
);
}
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_errno"
,
CallingConvention
=
CallingConvention
.
StdCal
l
)]
static
extern
public
int
ErrorNo
(
long
res
);
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_errno"
,
CallingConvention
=
CallingConvention
.
Cdec
l
)]
static
extern
public
int
ErrorNo
(
IntPtr
res
);
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_query"
,
CallingConvention
=
CallingConvention
.
StdCal
l
)]
static
extern
public
long
Query
(
long
conn
,
string
sqlstr
);
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_query"
,
CallingConvention
=
CallingConvention
.
Cdec
l
)]
static
extern
public
IntPtr
Query
(
IntPtr
conn
,
string
sqlstr
);
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_affected_rows"
,
CallingConvention
=
CallingConvention
.
StdCal
l
)]
static
extern
public
int
AffectRows
(
long
res
);
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_affected_rows"
,
CallingConvention
=
CallingConvention
.
Cdec
l
)]
static
extern
public
int
AffectRows
(
IntPtr
res
);
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_field_count"
,
CallingConvention
=
CallingConvention
.
StdCal
l
)]
static
extern
public
int
FieldCount
(
long
res
);
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_field_count"
,
CallingConvention
=
CallingConvention
.
Cdec
l
)]
static
extern
public
int
FieldCount
(
IntPtr
res
);
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_fetch_fields"
,
CallingConvention
=
CallingConvention
.
StdCal
l
)]
static
extern
private
IntPtr
taos_fetch_fields
(
long
res
);
static
public
List
<
TDengineMeta
>
FetchFields
(
long
res
)
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_fetch_fields"
,
CallingConvention
=
CallingConvention
.
Cdec
l
)]
static
extern
private
IntPtr
taos_fetch_fields
(
IntPtr
res
);
static
public
List
<
TDengineMeta
>
FetchFields
(
IntPtr
res
)
{
const
int
fieldSize
=
68
;
List
<
TDengineMeta
>
metas
=
new
List
<
TDengineMeta
>();
if
(
res
==
0
)
if
(
res
==
IntPtr
.
Zero
)
{
return
metas
;
}
...
...
@@ -142,13 +142,13 @@ namespace TDengineDriver
return
metas
;
}
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_fetch_row"
,
CallingConvention
=
CallingConvention
.
StdCal
l
)]
static
extern
public
IntPtr
FetchRows
(
long
res
);
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_fetch_row"
,
CallingConvention
=
CallingConvention
.
Cdec
l
)]
static
extern
public
IntPtr
FetchRows
(
IntPtr
res
);
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_free_result"
,
CallingConvention
=
CallingConvention
.
StdCal
l
)]
static
extern
public
IntPtr
FreeResult
(
long
res
);
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_free_result"
,
CallingConvention
=
CallingConvention
.
Cdec
l
)]
static
extern
public
IntPtr
FreeResult
(
IntPtr
res
);
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_close"
,
CallingConvention
=
CallingConvention
.
StdCal
l
)]
static
extern
public
int
Close
(
long
taos
);
[
DllImport
(
"taos.dll"
,
EntryPoint
=
"taos_close"
,
CallingConvention
=
CallingConvention
.
Cdec
l
)]
static
extern
public
int
Close
(
IntPtr
taos
);
}
}
\ No newline at end of file
tests/examples/C#/TDengineTest.cs
浏览文件 @
bd16bb3d
...
...
@@ -43,7 +43,7 @@ namespace TDengineDriver
private
long
batchRows
;
private
long
beginTimestamp
=
1551369600000L
;
private
long
conn
=
0
;
private
IntPtr
conn
=
IntPtr
.
Zero
;
private
long
rowsInserted
=
0
;
static
void
Main
(
string
[]
args
)
...
...
@@ -191,7 +191,7 @@ namespace TDengineDriver
{
string
db
=
""
;
this
.
conn
=
TDengine
.
Connect
(
this
.
host
,
this
.
user
,
this
.
password
,
db
,
this
.
port
);
if
(
this
.
conn
==
0
)
if
(
this
.
conn
==
IntPtr
.
Zero
)
{
Console
.
WriteLine
(
"Connect to TDengine failed"
);
ExitProgram
();
...
...
@@ -211,8 +211,8 @@ namespace TDengineDriver
StringBuilder
sql
=
new
StringBuilder
();
sql
.
Append
(
"create database if not exists "
).
Append
(
this
.
dbName
);
long
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
if
(
res
!=
0
)
IntPtr
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
if
(
res
!=
IntPtr
.
Zero
)
{
Console
.
WriteLine
(
sql
.
ToString
()
+
" success"
);
}
...
...
@@ -226,7 +226,7 @@ namespace TDengineDriver
sql
.
Clear
();
sql
.
Append
(
"use "
).
Append
(
this
.
dbName
);
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
if
(
res
!=
0
)
if
(
res
!=
IntPtr
.
Zero
)
{
Console
.
WriteLine
(
sql
.
ToString
()
+
" success"
);
}
...
...
@@ -240,7 +240,7 @@ namespace TDengineDriver
sql
.
Clear
();
sql
.
Append
(
"create table if not exists "
).
Append
(
this
.
stableName
).
Append
(
"(ts timestamp, v1 bool, v2 tinyint, v3 smallint, v4 int, v5 bigint, v6 float, v7 double, v8 binary(10), v9 nchar(10)) tags(t1 int)"
);
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
if
(
res
!=
0
)
if
(
res
!=
IntPtr
.
Zero
)
{
Console
.
WriteLine
(
sql
.
ToString
()
+
" success"
);
}
...
...
@@ -257,7 +257,7 @@ namespace TDengineDriver
sql
=
sql
.
Append
(
"create table if not exists "
).
Append
(
this
.
tablePrefix
).
Append
(
i
)
.
Append
(
" using "
).
Append
(
this
.
stableName
).
Append
(
" tags("
).
Append
(
i
).
Append
(
")"
);
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
if
(
res
!=
0
)
if
(
res
!=
IntPtr
.
Zero
)
{
Console
.
WriteLine
(
sql
.
ToString
()
+
" success"
);
}
...
...
@@ -297,8 +297,8 @@ namespace TDengineDriver
.
Append
(
rows
)
.
Append
(
", 5, 6, 7, 'abc', 'def')"
);
}
long
res
=
TDengine
.
Query
(
conn
,
sql
.
ToString
());
if
(
res
==
0
)
IntPtr
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
if
(
res
==
IntPtr
.
Zero
)
{
Console
.
WriteLine
(
sql
.
ToString
()
+
" failure, reason: "
+
TDengine
.
Error
(
res
));
}
...
...
@@ -326,14 +326,14 @@ namespace TDengineDriver
System
.
DateTime
start
=
new
System
.
DateTime
();
long
queryRows
=
0
;
for
(
int
i
=
0
;
i
<
this
.
tableCount
;
++
i
)
for
(
int
i
=
0
;
i
<
1
/*this.tableCount*/
;
++
i
)
{
String
sql
=
"select * from "
+
this
.
dbName
+
"."
+
tablePrefix
+
i
;
Console
.
WriteLine
(
sql
);
long
res
=
TDengine
.
Query
(
conn
,
sql
);
if
(
res
==
0
)
IntPtr
res
=
TDengine
.
Query
(
conn
,
sql
);
if
(
res
==
IntPtr
.
Zero
)
{
Console
.
WriteLine
(
sql
+
" failure, reason: "
+
TDengine
.
Error
(
res
));
ExitProgram
();
...
...
@@ -350,20 +350,21 @@ namespace TDengineDriver
}
IntPtr
rowdata
;
StringBuilder
builder
=
new
StringBuilder
();
while
((
rowdata
=
TDengine
.
FetchRows
(
res
))
!=
IntPtr
.
Zero
)
{
queryRows
++;
for
(
int
fields
=
0
;
fields
<
fieldCount
;
++
fields
)
{
TDengineMeta
meta
=
metas
[
fields
];
int
offset
=
8
*
fields
;
int
offset
=
IntPtr
.
Size
*
fields
;
IntPtr
data
=
Marshal
.
ReadIntPtr
(
rowdata
,
offset
);
//Console.Write
("---");
builder
.
Append
(
"---"
);
if
(
data
==
IntPtr
.
Zero
)
{
//Console.Write
("NULL");
builder
.
Append
(
"NULL"
);
continue
;
}
...
...
@@ -371,47 +372,53 @@ namespace TDengineDriver
{
case
TDengineDataType
.
TSDB_DATA_TYPE_BOOL
:
bool
v1
=
Marshal
.
ReadByte
(
data
)
==
0
?
false
:
true
;
//Console.Write
(v1);
builder
.
Append
(
v1
);
break
;
case
TDengineDataType
.
TSDB_DATA_TYPE_TINYINT
:
byte
v2
=
Marshal
.
ReadByte
(
data
);
//Console.Write
(v2);
builder
.
Append
(
v2
);
break
;
case
TDengineDataType
.
TSDB_DATA_TYPE_SMALLINT
:
short
v3
=
Marshal
.
ReadInt16
(
data
);
//Console.Write
(v3);
builder
.
Append
(
v3
);
break
;
case
TDengineDataType
.
TSDB_DATA_TYPE_INT
:
int
v4
=
Marshal
.
ReadInt32
(
data
);
//Console.Write
(v4);
builder
.
Append
(
v4
);
break
;
case
TDengineDataType
.
TSDB_DATA_TYPE_BIGINT
:
long
v5
=
Marshal
.
ReadInt64
(
data
);
//Console.Write
(v5);
builder
.
Append
(
v5
);
break
;
case
TDengineDataType
.
TSDB_DATA_TYPE_FLOAT
:
float
v6
=
(
float
)
Marshal
.
PtrToStructure
(
data
,
typeof
(
float
));
//Console.Write
(v6);
builder
.
Append
(
v6
);
break
;
case
TDengineDataType
.
TSDB_DATA_TYPE_DOUBLE
:
double
v7
=
(
double
)
Marshal
.
PtrToStructure
(
data
,
typeof
(
double
));
//Console.Write
(v7);
builder
.
Append
(
v7
);
break
;
case
TDengineDataType
.
TSDB_DATA_TYPE_BINARY
:
string
v8
=
Marshal
.
PtrToStringAnsi
(
data
);
//Console.Write
(v8);
builder
.
Append
(
v8
);
break
;
case
TDengineDataType
.
TSDB_DATA_TYPE_TIMESTAMP
:
long
v9
=
Marshal
.
ReadInt64
(
data
);
//Console.Write
(v9);
builder
.
Append
(
v9
);
break
;
case
TDengineDataType
.
TSDB_DATA_TYPE_NCHAR
:
string
v10
=
Marshal
.
PtrToStringAnsi
(
data
);
//Console.Write
(v10);
builder
.
Append
(
v10
);
break
;
}
}
//Console.WriteLine("---");
builder
.
Append
(
"---"
);
if
(
queryRows
<=
10
)
{
Console
.
WriteLine
(
builder
.
ToString
());
}
builder
.
Clear
();
}
if
(
TDengine
.
ErrorNo
(
res
)
!=
0
)
...
...
@@ -431,9 +438,9 @@ namespace TDengineDriver
public
void
CloseConnection
()
{
if
(
conn
!=
0
)
if
(
this
.
conn
!=
IntPtr
.
Zero
)
{
TDengine
.
Close
(
conn
);
TDengine
.
Close
(
this
.
conn
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录