Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
51c4b89a
T
TDengine
项目概览
慢慢CG
/
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看板
提交
51c4b89a
编写于
11月 06, 2020
作者:
F
freemine
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
before windows port
上级
77ea55f0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
176 addition
and
51 deletion
+176
-51
src/connector/odbc/src/CMakeLists.txt
src/connector/odbc/src/CMakeLists.txt
+1
-1
src/connector/odbc/src/todbc.c
src/connector/odbc/src/todbc.c
+37
-0
src/connector/odbc/src/todbc.def
src/connector/odbc/src/todbc.def
+3
-0
src/connector/odbc/tests/main.c
src/connector/odbc/tests/main.c
+135
-50
未找到文件。
src/connector/odbc/src/CMakeLists.txt
浏览文件 @
51c4b89a
...
...
@@ -15,7 +15,7 @@ IF (TD_LINUX_64)
ADD_LIBRARY
(
todbc SHARED
${
SRC
}
${
todbc_flex_scanner_src
}
)
SET_TARGET_PROPERTIES
(
todbc PROPERTIES CLEAN_DIRECT_OUTPUT 1
)
SET_TARGET_PROPERTIES
(
todbc PROPERTIES VERSION
${
TD_VER_NUMBER
}
SOVERSION 1
)
TARGET_LINK_LIBRARIES
(
todbc taos
)
TARGET_LINK_LIBRARIES
(
todbc taos
odbcinst
)
target_include_directories
(
todbc PUBLIC .
)
install
(
CODE
"execute_process(COMMAND
${
CMAKE_CURRENT_SOURCE_DIR
}
/install.sh
${
CMAKE_BINARY_DIR
}
)"
)
...
...
src/connector/odbc/src/todbc.c
浏览文件 @
51c4b89a
...
...
@@ -27,8 +27,19 @@
#include "todbc_util.h"
#include "todbc_conv.h"
#include "os.h"
#include <odbcinst.h>
#include <sqlext.h>
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#define UTF8_ENC "UTF-8"
#define UTF16_ENC "UCS-2LE"
#define UNICODE_ENC "UCS-4LE"
...
...
@@ -549,9 +560,20 @@ static SQLRETURN doSQLConnect(SQLHDBC ConnectionHandle,
const
char
*
auth
=
NULL
;
do
{
D
(
"server: %s"
,
serverName
);
D
(
"user: %s"
,
userName
);
D
(
"auth: %s"
,
auth
);
tsdb_conv
(
client_to_server
,
&
buffer
,
(
const
char
*
)
ServerName
,
(
size_t
)
NameLength1
,
&
serverName
,
NULL
);
tsdb_conv
(
client_to_server
,
&
buffer
,
(
const
char
*
)
UserName
,
(
size_t
)
NameLength2
,
&
userName
,
NULL
);
tsdb_conv
(
client_to_server
,
&
buffer
,
(
const
char
*
)
Authentication
,
(
size_t
)
NameLength3
,
&
auth
,
NULL
);
D
(
"server: %s"
,
serverName
);
D
(
"user: %s"
,
userName
);
D
(
"auth: %s"
,
auth
);
char
haha
[
4096
];
haha
[
0
]
=
'\0'
;
int
n
=
SQLGetPrivateProfileString
(
serverName
,
"Server"
,
"null"
,
haha
,
sizeof
(
haha
)
-
1
,
NULL
);
D
(
"n: %d"
,
n
);
D
(
"haha: [%s]"
,
haha
);
if
((
!
serverName
)
||
(
!
userName
)
||
(
!
auth
))
{
SET_ERROR
(
conn
,
"HY001"
,
TSDB_CODE_ODBC_OOM
,
""
);
break
;
...
...
@@ -2847,6 +2869,21 @@ SQLRETURN SQL_API SQLSetStmtAttr(SQLHSTMT StatementHandle,
return
r
;
}
BOOL
INSTAPI
ConfigDSN
(
HWND
hwndParent
,
WORD
fRequest
,
LPCSTR
lpszDriver
,
LPCSTR
lpszAttributes
)
{
return
FALSE
;
}
BOOL
INSTAPI
ConfigTranslator
(
HWND
hwndParent
,
DWORD
*
pvOption
)
{
return
FALSE
;
}
BOOL
INSTAPI
ConfigDriver
(
HWND
hwndParent
,
WORD
fRequest
,
LPCSTR
lpszDriver
,
LPCSTR
lpszArgs
,
LPSTR
lpszMsg
,
WORD
cbMsgMax
,
WORD
*
pcbMsgOut
)
{
return
FALSE
;
}
...
...
src/connector/odbc/src/todbc.def
浏览文件 @
51c4b89a
...
...
@@ -25,4 +25,7 @@ SQLSetConnectAttr
SQLDescribeCol
SQLNumParams
SQLSetStmtAttr
ConfigDSN
ConfigTranslator
ConfigDriver
src/connector/odbc/tests/main.c
浏览文件 @
51c4b89a
...
...
@@ -86,9 +86,9 @@ static int open_connect(const char *dsn, const char *uid, const char *pwd, SQLHE
CHK_RESULT
(
r
,
SQL_HANDLE_ENV
,
env
,
""
);
if
(
r
!=
SQL_SUCCESS
)
break
;
do
{
r
=
SQLConnect
(
conn
,
(
SQLCHAR
*
)
dsn
,
(
SQLSMALLINT
)
strlen
(
dsn
),
(
SQLCHAR
*
)
uid
,
(
SQLSMALLINT
)
strlen
(
uid
),
(
SQLCHAR
*
)
pwd
,
(
SQLSMALLINT
)
strlen
(
pwd
));
r
=
SQLConnect
(
conn
,
(
SQLCHAR
*
)
dsn
,
(
SQLSMALLINT
)
(
dsn
?
strlen
(
dsn
)
:
0
),
(
SQLCHAR
*
)
uid
,
(
SQLSMALLINT
)
(
uid
?
strlen
(
uid
)
:
0
),
(
SQLCHAR
*
)
pwd
,
(
SQLSMALLINT
)
(
pwd
?
strlen
(
pwd
)
:
0
));
CHK_RESULT
(
r
,
SQL_HANDLE_DBC
,
conn
,
""
);
if
(
r
==
SQL_SUCCESS
)
{
*
pEnv
=
env
;
...
...
@@ -119,7 +119,7 @@ static int open_driver_connect(const char *connstr, SQLHENV *pEnv, SQLHDBC *pCon
SQLHDBC
ConnectionHandle
=
conn
;
SQLHWND
WindowHandle
=
NULL
;
SQLCHAR
*
InConnectionString
=
(
SQLCHAR
*
)
connstr
;
SQLSMALLINT
StringLength1
=
(
SQLSMALLINT
)
strlen
(
connstr
);
SQLSMALLINT
StringLength1
=
(
SQLSMALLINT
)
(
connstr
?
strlen
(
connstr
)
:
0
);
SQLCHAR
*
OutConnectionString
=
buf
;
SQLSMALLINT
BufferLength
=
sizeof
(
buf
);
SQLSMALLINT
*
StringLength2Ptr
=
&
blen
;
...
...
@@ -525,64 +525,149 @@ int test_sqls(const char *dsn, const char *uid, const char *pwd, const char *con
}
else
{
CHK_TEST
(
open_driver_connect
(
connstr
,
&
env
,
&
conn
));
}
r
=
test_sqls_in_conn
(
env
,
conn
,
sqls
);
if
(
sqls
)
{
r
=
test_sqls_in_conn
(
env
,
conn
,
sqls
);
}
SQLDisconnect
(
conn
);
SQLFreeConnect
(
conn
);
SQLFreeEnv
(
env
);
return
r
?
1
:
0
;
}
void
usage
(
const
char
*
arg0
)
{
fprintf
(
stdout
,
"%s usage:
\n
"
,
arg0
);
fprintf
(
stdout
,
"%s [--dsn <dsn>] [--uid <uid>] [--pwd <pwd>] [--dcs <dcs>] [--sts <sts>]
\n
"
,
arg0
);
fprintf
(
stdout
,
" --dsn <dsn>: DSN
\n
"
);
fprintf
(
stdout
,
" --uid <uid>: UID
\n
"
);
fprintf
(
stdout
,
" --pwd <pwd>: PWD
\n
"
);
fprintf
(
stdout
,
" --dcs <dcs>: driver connection string
\n
"
);
fprintf
(
stdout
,
" --sts <sts>: file where statements store
\n
"
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
==
1
)
{
CHK_TEST
(
test_env
());
return
0
;
// if (argc==1) {
// CHK_TEST(test_env());
// CHK_TEST(test1("TAOS_DSN", "root", "taoxsdata"));
// D("Done!");
// return 0;
// }
const
char
*
dsn
=
NULL
;
const
char
*
uid
=
NULL
;
const
char
*
pwd
=
NULL
;
const
char
*
dcs
=
NULL
;
// driver connection string
const
char
*
sts
=
NULL
;
// statements file
for
(
size_t
i
=
1
;
i
<
argc
;
++
i
)
{
const
char
*
arg
=
argv
[
i
];
if
(
strcmp
(
arg
,
"-h"
)
==
0
)
{
usage
(
argv
[
0
]);
return
0
;
}
if
(
strcmp
(
arg
,
"--dsn"
)
==
0
)
{
++
i
;
if
(
i
>=
argc
)
{
D
(
"<dsn> expected but got nothing"
);
return
1
;
}
if
(
dcs
)
{
D
(
"--dcs has already been specified"
);
return
1
;
}
dsn
=
argv
[
i
];
continue
;
}
if
(
strcmp
(
arg
,
"--uid"
)
==
0
)
{
++
i
;
if
(
i
>=
argc
)
{
D
(
"<uid> expected but got nothing"
);
return
1
;
}
uid
=
argv
[
i
];
continue
;
}
if
(
strcmp
(
arg
,
"--pwd"
)
==
0
)
{
++
i
;
if
(
i
>=
argc
)
{
D
(
"<pwd> expected but got nothing"
);
return
1
;
}
pwd
=
argv
[
i
];
continue
;
}
if
(
strcmp
(
arg
,
"--dcs"
)
==
0
)
{
++
i
;
if
(
i
>=
argc
)
{
D
(
"<dcs> expected but got nothing"
);
return
1
;
}
if
(
dsn
||
uid
||
pwd
)
{
D
(
"either of --dsn/--uid/--pwd has already been specified"
);
return
1
;
}
dcs
=
argv
[
i
];
continue
;
}
if
(
strcmp
(
arg
,
"--sts"
)
==
0
)
{
++
i
;
if
(
i
>=
argc
)
{
D
(
"<sts> expected but got nothing"
);
return
1
;
}
sts
=
argv
[
i
];
continue
;
}
}
CHK_TEST
(
test_sqls
(
dsn
,
uid
,
pwd
,
dcs
,
sts
));
D
(
"Done!"
);
return
0
;
const
char
*
dsn
=
(
argc
>
1
)
?
argv
[
1
]
:
NULL
;
const
char
*
uid
=
(
argc
>
2
)
?
argv
[
2
]
:
NULL
;
const
char
*
pwd
=
(
argc
>
3
)
?
argv
[
3
]
:
NULL
;
const
char
*
connstr
=
(
argc
>
4
)
?
argv
[
4
]
:
NULL
;
const
char
*
sqls
=
(
argc
>
5
)
?
argv
[
5
]
:
NULL
;
dsn
=
NULL
;
uid
=
NULL
;
pwd
=
NULL
;
connstr
=
argv
[
1
];
sqls
=
argv
[
2
];
if
(
0
)
{
CHK_TEST
(
test_env
());
CHK_TEST
(
test1
(
dsn
,
uid
,
pwd
));
const
char
*
statements
[]
=
{
"drop database if exists m"
,
"create database m"
,
"use m"
,
"drop database m"
,
NULL
};
CHK_TEST
(
test_statements
(
dsn
,
uid
,
pwd
,
statements
));
if
(
connstr
)
CHK_TEST
(
test_driver_connect
(
connstr
));
if
(
connstr
)
{
SQLHENV
env
=
{
0
};
SQLHDBC
conn
=
{
0
};
CHK_TEST
(
open_driver_connect
(
connstr
,
&
env
,
&
conn
));
int
r
=
tests
(
env
,
conn
);
SQLDisconnect
(
conn
);
SQLFreeConnect
(
conn
);
SQLFreeEnv
(
env
);
if
(
r
)
return
1
;
const
char
*
dsn
=
(
argc
>
1
)
?
argv
[
1
]
:
NULL
;
const
char
*
uid
=
(
argc
>
2
)
?
argv
[
2
]
:
NULL
;
const
char
*
pwd
=
(
argc
>
3
)
?
argv
[
3
]
:
NULL
;
const
char
*
connstr
=
(
argc
>
4
)
?
argv
[
4
]
:
NULL
;
const
char
*
sqls
=
(
argc
>
5
)
?
argv
[
5
]
:
NULL
;
dsn
=
NULL
;
uid
=
NULL
;
pwd
=
NULL
;
connstr
=
argv
[
1
];
sqls
=
argv
[
2
];
if
(
0
)
{
CHK_TEST
(
test_env
());
CHK_TEST
(
test1
(
dsn
,
uid
,
pwd
));
const
char
*
statements
[]
=
{
"drop database if exists m"
,
"create database m"
,
"use m"
,
"drop database m"
,
NULL
};
CHK_TEST
(
test_statements
(
dsn
,
uid
,
pwd
,
statements
));
if
(
connstr
)
CHK_TEST
(
test_driver_connect
(
connstr
));
if
(
connstr
)
{
SQLHENV
env
=
{
0
};
SQLHDBC
conn
=
{
0
};
CHK_TEST
(
open_driver_connect
(
connstr
,
&
env
,
&
conn
));
int
r
=
tests
(
env
,
conn
);
SQLDisconnect
(
conn
);
SQLFreeConnect
(
conn
);
SQLFreeEnv
(
env
);
if
(
r
)
return
1
;
}
}
}
if
((
dsn
||
connstr
)
&&
1
)
{
CHK_TEST
(
test_sqls
(
dsn
,
uid
,
pwd
,
connstr
,
sqls
));
}
if
((
dsn
||
connstr
)
&&
1
)
{
CHK_TEST
(
test_sqls
(
dsn
,
uid
,
pwd
,
connstr
,
sqls
));
}
D
(
"Done!"
);
return
0
;
D
(
"Done!"
);
return
0
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录