Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
04517568
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看板
提交
04517568
编写于
10月 08, 2020
作者:
F
freemine
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1. typo correction in CMakeLists.txt
2. fprint error message when SQLxxx failed in tcodbc
上级
75786385
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
43 addition
and
20 deletion
+43
-20
src/connector/odbc/CMakeLists.txt
src/connector/odbc/CMakeLists.txt
+1
-1
src/connector/odbc/src/odbc_install.sh
src/connector/odbc/src/odbc_install.sh
+0
-7
src/connector/odbc/src/todbc.c
src/connector/odbc/src/todbc.c
+12
-12
src/connector/odbc/tests/main.c
src/connector/odbc/tests/main.c
+30
-0
未找到文件。
src/connector/odbc/CMakeLists.txt
浏览文件 @
04517568
...
@@ -27,7 +27,7 @@ IF (TD_LINUX_64)
...
@@ -27,7 +27,7 @@ IF (TD_LINUX_64)
ADD_SUBDIRECTORY
(
tests
)
ADD_SUBDIRECTORY
(
tests
)
endif
()
endif
()
ELSE
()
ELSE
()
message
(
WARNING
"unixodbc is not installed yet, you may install it under ubuntu by typing: sudo apt install unixodbc
-dev
"
)
message
(
WARNING
"unixodbc is not installed yet, you may install it under ubuntu by typing: sudo apt install unixodbc"
)
ENDIF
()
ENDIF
()
ENDIF
()
ENDIF
()
src/connector/odbc/src/odbc_install.sh
已删除
100644 → 0
浏览文件 @
75786385
#!/bin/bash
odbcinst
-u
-d
-n
TAOS
&&
odbcinst
-i
-d
-f
"
$(
dirname
"
$0
"
)
/template.ini"
&&
odbcinst
-i
-s
-f
"
$(
dirname
"
$0
"
)
/template.dsn"
&&
echo yes
src/connector/odbc/src/todbc.c
浏览文件 @
04517568
...
@@ -52,12 +52,12 @@ do {
...
@@ -52,12 +52,12 @@ do {
obj->err.err_no = eno; \
obj->err.err_no = eno; \
const char* estr = tstrerror(eno); \
const char* estr = tstrerror(eno); \
if (!estr) estr = "Unknown error"; \
if (!estr) estr = "Unknown error"; \
int n = snprintf(NULL, 0, "
@[%d][%x]%s: " err_fmt "", __LINE__, eno, estr, ##__VA_ARGS__);
\
int n = snprintf(NULL, 0, "
%s: @[%d][TSDB:%x]" err_fmt "", estr, __LINE__, eno, ##__VA_ARGS__);
\
if (n<0) break; \
if (n<0) break; \
char *err_str = (char*)realloc(obj->err.err_str, n+1); \
char *err_str = (char*)realloc(obj->err.err_str, n+1); \
if (!err_str) break; \
if (!err_str) break; \
obj->err.err_str = err_str; \
obj->err.err_str = err_str; \
snprintf(obj->err.err_str, n+1, "
@[%d][%x]%s: " err_fmt "", __LINE__, eno, estr, ##__VA_ARGS__);
\
snprintf(obj->err.err_str, n+1, "
%s: @[%d][TSDB:%x]" err_fmt "", estr, __LINE__, eno, ##__VA_ARGS__);
\
snprintf((char*)obj->err.sql_state, sizeof(obj->err.sql_state), "%s", sqlstate); \
snprintf((char*)obj->err.sql_state, sizeof(obj->err.sql_state), "%s", sqlstate); \
} while (0)
} while (0)
...
...
src/connector/odbc/tests/main.c
浏览文件 @
04517568
...
@@ -37,14 +37,30 @@ static const char *pro_stmts[] = {
...
@@ -37,14 +37,30 @@ static const char *pro_stmts[] = {
// "drop database db"
// "drop database db"
};
};
#define CHK_RESULT(r, ht, h) \
do { \
if (r==0) break; \
SQLCHAR ss[10]; \
SQLINTEGER ne = 0; \
SQLCHAR es[4096]; \
SQLSMALLINT n = 0; \
ss[0] = '\0'; \
es[0] = '\0'; \
SQLRETURN ret = SQLGetDiagRec(ht, h, 1, ss, &ne, es, sizeof(es), &n); \
if (ret) break; \
fprintf(stderr, "%s%s\n", ss, es); \
} while (0)
static
int
do_statement
(
SQLHSTMT
stmt
,
const
char
*
statement
)
{
static
int
do_statement
(
SQLHSTMT
stmt
,
const
char
*
statement
)
{
SQLRETURN
r
=
0
;
SQLRETURN
r
=
0
;
do
{
do
{
fprintf
(
stderr
,
"prepare [%s]
\n
"
,
statement
);
fprintf
(
stderr
,
"prepare [%s]
\n
"
,
statement
);
r
=
SQLPrepare
(
stmt
,
(
SQLCHAR
*
)
statement
,
strlen
(
statement
));
r
=
SQLPrepare
(
stmt
,
(
SQLCHAR
*
)
statement
,
strlen
(
statement
));
CHK_RESULT
(
r
,
SQL_HANDLE_STMT
,
stmt
);
if
(
r
)
break
;
if
(
r
)
break
;
fprintf
(
stderr
,
"execute [%s]
\n
"
,
statement
);
fprintf
(
stderr
,
"execute [%s]
\n
"
,
statement
);
r
=
SQLExecute
(
stmt
);
r
=
SQLExecute
(
stmt
);
CHK_RESULT
(
r
,
SQL_HANDLE_STMT
,
stmt
);
if
(
r
)
break
;
if
(
r
)
break
;
fprintf
(
stderr
,
"done
\n
"
);
fprintf
(
stderr
,
"done
\n
"
);
}
while
(
0
);
}
while
(
0
);
...
@@ -63,53 +79,65 @@ static int do_insert(SQLHSTMT stmt, data_t data) {
...
@@ -63,53 +79,65 @@ static int do_insert(SQLHSTMT stmt, data_t data) {
do
{
do
{
fprintf
(
stderr
,
"prepare [%s]
\n
"
,
statement
);
fprintf
(
stderr
,
"prepare [%s]
\n
"
,
statement
);
r
=
SQLPrepare
(
stmt
,
(
SQLCHAR
*
)
statement
,
strlen
(
statement
));
r
=
SQLPrepare
(
stmt
,
(
SQLCHAR
*
)
statement
,
strlen
(
statement
));
CHK_RESULT
(
r
,
SQL_HANDLE_STMT
,
stmt
);
if
(
r
)
break
;
if
(
r
)
break
;
fprintf
(
stderr
,
"bind 1 [%s]
\n
"
,
statement
);
fprintf
(
stderr
,
"bind 1 [%s]
\n
"
,
statement
);
r
=
SQLBindParameter
(
stmt
,
1
,
SQL_PARAM_INPUT
,
SQL_C_SBIGINT
,
SQL_TIMESTAMP
,
ignored
,
ignored
,
&
data
.
ts
,
ignored
,
NULL
);
r
=
SQLBindParameter
(
stmt
,
1
,
SQL_PARAM_INPUT
,
SQL_C_SBIGINT
,
SQL_TIMESTAMP
,
ignored
,
ignored
,
&
data
.
ts
,
ignored
,
NULL
);
CHK_RESULT
(
r
,
SQL_HANDLE_STMT
,
stmt
);
if
(
r
)
break
;
if
(
r
)
break
;
fprintf
(
stderr
,
"bind 2 [%s]
\n
"
,
statement
);
fprintf
(
stderr
,
"bind 2 [%s]
\n
"
,
statement
);
r
=
SQLBindParameter
(
stmt
,
2
,
SQL_PARAM_INPUT
,
SQL_C_BIT
,
SQL_BIT
,
ignored
,
ignored
,
&
data
.
b
,
ignored
,
NULL
);
r
=
SQLBindParameter
(
stmt
,
2
,
SQL_PARAM_INPUT
,
SQL_C_BIT
,
SQL_BIT
,
ignored
,
ignored
,
&
data
.
b
,
ignored
,
NULL
);
CHK_RESULT
(
r
,
SQL_HANDLE_STMT
,
stmt
);
if
(
r
)
break
;
if
(
r
)
break
;
fprintf
(
stderr
,
"bind 3 [%s]
\n
"
,
statement
);
fprintf
(
stderr
,
"bind 3 [%s]
\n
"
,
statement
);
r
=
SQLBindParameter
(
stmt
,
3
,
SQL_PARAM_INPUT
,
SQL_C_TINYINT
,
SQL_TINYINT
,
ignored
,
ignored
,
&
data
.
v1
,
ignored
,
NULL
);
r
=
SQLBindParameter
(
stmt
,
3
,
SQL_PARAM_INPUT
,
SQL_C_TINYINT
,
SQL_TINYINT
,
ignored
,
ignored
,
&
data
.
v1
,
ignored
,
NULL
);
CHK_RESULT
(
r
,
SQL_HANDLE_STMT
,
stmt
);
if
(
r
)
break
;
if
(
r
)
break
;
fprintf
(
stderr
,
"bind 4 [%s]
\n
"
,
statement
);
fprintf
(
stderr
,
"bind 4 [%s]
\n
"
,
statement
);
r
=
SQLBindParameter
(
stmt
,
4
,
SQL_PARAM_INPUT
,
SQL_C_SHORT
,
SQL_SMALLINT
,
ignored
,
ignored
,
&
data
.
v2
,
ignored
,
NULL
);
r
=
SQLBindParameter
(
stmt
,
4
,
SQL_PARAM_INPUT
,
SQL_C_SHORT
,
SQL_SMALLINT
,
ignored
,
ignored
,
&
data
.
v2
,
ignored
,
NULL
);
CHK_RESULT
(
r
,
SQL_HANDLE_STMT
,
stmt
);
if
(
r
)
break
;
if
(
r
)
break
;
fprintf
(
stderr
,
"bind 5 [%s]
\n
"
,
statement
);
fprintf
(
stderr
,
"bind 5 [%s]
\n
"
,
statement
);
r
=
SQLBindParameter
(
stmt
,
5
,
SQL_PARAM_INPUT
,
SQL_C_LONG
,
SQL_INTEGER
,
ignored
,
ignored
,
&
data
.
v4
,
ignored
,
NULL
);
r
=
SQLBindParameter
(
stmt
,
5
,
SQL_PARAM_INPUT
,
SQL_C_LONG
,
SQL_INTEGER
,
ignored
,
ignored
,
&
data
.
v4
,
ignored
,
NULL
);
CHK_RESULT
(
r
,
SQL_HANDLE_STMT
,
stmt
);
if
(
r
)
break
;
if
(
r
)
break
;
fprintf
(
stderr
,
"bind 6 [%s]
\n
"
,
statement
);
fprintf
(
stderr
,
"bind 6 [%s]
\n
"
,
statement
);
r
=
SQLBindParameter
(
stmt
,
6
,
SQL_PARAM_INPUT
,
SQL_C_SBIGINT
,
SQL_BIGINT
,
ignored
,
ignored
,
&
data
.
v8
,
ignored
,
NULL
);
r
=
SQLBindParameter
(
stmt
,
6
,
SQL_PARAM_INPUT
,
SQL_C_SBIGINT
,
SQL_BIGINT
,
ignored
,
ignored
,
&
data
.
v8
,
ignored
,
NULL
);
CHK_RESULT
(
r
,
SQL_HANDLE_STMT
,
stmt
);
if
(
r
)
break
;
if
(
r
)
break
;
fprintf
(
stderr
,
"bind 7 [%s]
\n
"
,
statement
);
fprintf
(
stderr
,
"bind 7 [%s]
\n
"
,
statement
);
r
=
SQLBindParameter
(
stmt
,
7
,
SQL_PARAM_INPUT
,
SQL_C_FLOAT
,
SQL_FLOAT
,
ignored
,
ignored
,
&
data
.
f4
,
ignored
,
NULL
);
r
=
SQLBindParameter
(
stmt
,
7
,
SQL_PARAM_INPUT
,
SQL_C_FLOAT
,
SQL_FLOAT
,
ignored
,
ignored
,
&
data
.
f4
,
ignored
,
NULL
);
CHK_RESULT
(
r
,
SQL_HANDLE_STMT
,
stmt
);
if
(
r
)
break
;
if
(
r
)
break
;
fprintf
(
stderr
,
"bind 8 [%s]
\n
"
,
statement
);
fprintf
(
stderr
,
"bind 8 [%s]
\n
"
,
statement
);
SQLLEN
l8
=
SQL_NULL_DATA
;
SQLLEN
l8
=
SQL_NULL_DATA
;
r
=
SQLBindParameter
(
stmt
,
8
,
SQL_PARAM_INPUT
,
SQL_C_DOUBLE
,
SQL_DOUBLE
,
ignored
,
ignored
,
&
data
.
f8
,
ignored
,
&
l8
);
r
=
SQLBindParameter
(
stmt
,
8
,
SQL_PARAM_INPUT
,
SQL_C_DOUBLE
,
SQL_DOUBLE
,
ignored
,
ignored
,
&
data
.
f8
,
ignored
,
&
l8
);
CHK_RESULT
(
r
,
SQL_HANDLE_STMT
,
stmt
);
if
(
r
)
break
;
if
(
r
)
break
;
fprintf
(
stderr
,
"bind 9 [%s]
\n
"
,
statement
);
fprintf
(
stderr
,
"bind 9 [%s]
\n
"
,
statement
);
lbin
=
SQL_NTS
;
lbin
=
SQL_NTS
;
r
=
SQLBindParameter
(
stmt
,
9
,
SQL_PARAM_INPUT
,
SQL_C_BINARY
,
SQL_VARBINARY
,
sizeof
(
data
.
bin
)
-
1
,
ignored
,
&
data
.
bin
,
ignored
,
&
lbin
);
r
=
SQLBindParameter
(
stmt
,
9
,
SQL_PARAM_INPUT
,
SQL_C_BINARY
,
SQL_VARBINARY
,
sizeof
(
data
.
bin
)
-
1
,
ignored
,
&
data
.
bin
,
ignored
,
&
lbin
);
CHK_RESULT
(
r
,
SQL_HANDLE_STMT
,
stmt
);
if
(
r
)
break
;
if
(
r
)
break
;
fprintf
(
stderr
,
"bind 10 [%s]
\n
"
,
statement
);
fprintf
(
stderr
,
"bind 10 [%s]
\n
"
,
statement
);
lblob
=
SQL_NTS
;
lblob
=
SQL_NTS
;
r
=
SQLBindParameter
(
stmt
,
10
,
SQL_PARAM_INPUT
,
SQL_C_CHAR
,
SQL_VARCHAR
,
sizeof
(
data
.
blob
)
-
1
,
ignored
,
&
data
.
blob
,
ignored
,
&
lblob
);
r
=
SQLBindParameter
(
stmt
,
10
,
SQL_PARAM_INPUT
,
SQL_C_CHAR
,
SQL_VARCHAR
,
sizeof
(
data
.
blob
)
-
1
,
ignored
,
&
data
.
blob
,
ignored
,
&
lblob
);
CHK_RESULT
(
r
,
SQL_HANDLE_STMT
,
stmt
);
if
(
r
)
break
;
if
(
r
)
break
;
fprintf
(
stderr
,
"execute [%s]
\n
"
,
statement
);
fprintf
(
stderr
,
"execute [%s]
\n
"
,
statement
);
r
=
SQLExecute
(
stmt
);
r
=
SQLExecute
(
stmt
);
CHK_RESULT
(
r
,
SQL_HANDLE_STMT
,
stmt
);
if
(
r
)
break
;
if
(
r
)
break
;
// ts += 1;
// ts += 1;
...
@@ -136,11 +164,13 @@ int main(int argc, char *argv[]) {
...
@@ -136,11 +164,13 @@ int main(int argc, char *argv[]) {
if
(
r
!=
SQL_SUCCESS
)
return
1
;
if
(
r
!=
SQL_SUCCESS
)
return
1
;
do
{
do
{
r
=
SQLAllocConnect
(
env
,
&
conn
);
r
=
SQLAllocConnect
(
env
,
&
conn
);
CHK_RESULT
(
r
,
SQL_HANDLE_ENV
,
env
);
if
(
r
!=
SQL_SUCCESS
)
break
;
if
(
r
!=
SQL_SUCCESS
)
break
;
do
{
do
{
r
=
SQLConnect
(
conn
,
(
SQLCHAR
*
)
dsn
,
strlen
(
dsn
),
r
=
SQLConnect
(
conn
,
(
SQLCHAR
*
)
dsn
,
strlen
(
dsn
),
(
SQLCHAR
*
)
uid
,
strlen
(
uid
),
(
SQLCHAR
*
)
uid
,
strlen
(
uid
),
(
SQLCHAR
*
)
pwd
,
strlen
(
pwd
));
(
SQLCHAR
*
)
pwd
,
strlen
(
pwd
));
CHK_RESULT
(
r
,
SQL_HANDLE_DBC
,
conn
);
if
(
r
!=
SQL_SUCCESS
)
break
;
if
(
r
!=
SQL_SUCCESS
)
break
;
do
{
do
{
SQLHSTMT
stmt
=
{
0
};
SQLHSTMT
stmt
=
{
0
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录