Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d8cb54ff
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看板
提交
d8cb54ff
编写于
10月 30, 2020
作者:
F
freemine
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add predefined environment locale support
上级
81029157
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
40 addition
and
7 deletion
+40
-7
src/connector/odbc/src/todbc.c
src/connector/odbc/src/todbc.c
+40
-7
未找到文件。
src/connector/odbc/src/todbc.c
浏览文件 @
d8cb54ff
...
...
@@ -229,6 +229,8 @@ struct env_s {
uint64_t
refcount
;
unsigned
int
destroying
:
1
;
char
env_locale
[
64
];
taos_error_t
err
;
};
...
...
@@ -245,6 +247,8 @@ struct conn_s {
tsdb_conv_t
*
utf16_to_utf8
;
tsdb_conv_t
*
utf16_to_server
;
tsdb_conv_t
*
client_to_utf8
;
tsdb_conv_t
*
env_to_client
;
tsdb_conv_t
*
client_to_env
;
TAOS
*
taos
;
...
...
@@ -339,6 +343,20 @@ static tsdb_conv_t* tsdb_conn_client_to_utf8(conn_t *conn) {
return
conn
->
client_to_utf8
;
}
static
tsdb_conv_t
*
tsdb_conn_env_to_client
(
conn_t
*
conn
)
{
if
(
!
conn
->
env_to_client
)
{
conn
->
env_to_client
=
tsdb_conv_open
(
conn
->
env
->
env_locale
,
conn
->
client_enc
);
}
return
conn
->
env_to_client
;
}
static
tsdb_conv_t
*
tsdb_conn_client_to_env
(
conn_t
*
conn
)
{
if
(
!
conn
->
client_to_env
)
{
conn
->
client_to_env
=
tsdb_conv_open
(
conn
->
client_enc
,
conn
->
env
->
env_locale
);
}
return
conn
->
client_to_env
;
}
static
void
tsdb_conn_close_convs
(
conn_t
*
conn
)
{
if
(
0
)
{
tsdb_conn_server_to_client
(
NULL
);
...
...
@@ -367,6 +385,14 @@ static void tsdb_conn_close_convs(conn_t *conn) {
tsdb_conv_close
(
conn
->
client_to_utf8
);
conn
->
client_to_utf8
=
NULL
;
}
if
(
conn
->
env_to_client
)
{
tsdb_conv_close
(
conn
->
env_to_client
);
conn
->
env_to_client
=
NULL
;
}
if
(
conn
->
client_to_env
)
{
tsdb_conv_close
(
conn
->
client_to_env
);
conn
->
client_to_env
=
NULL
;
}
}
#define SFREE(buffer, v, src) \
...
...
@@ -403,6 +429,12 @@ static SQLRETURN doSQLAllocEnv(SQLHENV *EnvironmentHandle)
DASSERT
(
INC_REF
(
env
)
>
0
);
#ifdef _MSC_VER
snprintf
(
env
->
env_locale
,
sizeof
(
env
->
env_locale
),
GB18030_ENC
);
#else
snprintf
(
env
->
env_locale
,
sizeof
(
env
->
env_locale
),
UTF8_ENC
);
#endif
*
EnvironmentHandle
=
env
;
CLR_ERROR
(
env
);
...
...
@@ -464,10 +496,11 @@ static SQLRETURN doSQLAllocConnect(SQLHENV EnvironmentHandle,
break
;
}
snprintf
(
conn
->
client_enc
,
sizeof
(
conn
->
client_enc
),
UTF8_ENC
);
snprintf
(
conn
->
server_enc
,
sizeof
(
conn
->
server_enc
),
UTF8_ENC
);
conn
->
env
=
env
;
snprintf
(
conn
->
client_enc
,
sizeof
(
conn
->
client_enc
),
"%s"
,
conn
->
env
->
env_locale
);
snprintf
(
conn
->
server_enc
,
sizeof
(
conn
->
server_enc
),
"%s"
,
conn
->
env
->
env_locale
);
*
ConnectionHandle
=
conn
;
DASSERT
(
INC_REF
(
conn
)
>
0
);
...
...
@@ -1219,10 +1252,10 @@ static SQLRETURN doSQLGetData(SQLHSTMT StatementHandle,
field_bytes
-=
VARSTR_HEADER_SIZE
;
switch
(
target
.
ct
)
{
case
SQL_C_CHAR
:
{
tsdb_conv_t
*
server_to_client
=
tsdb_conn_server
_to_client
(
conn
);
tsdb_conv_t
*
env_to_client
=
tsdb_conn_env
_to_client
(
conn
);
size_t
slen
=
strnlen
((
const
char
*
)
row
,
field_bytes
);
size_t
len
=
(
size_t
)
BufferLength
;
TSDB_CONV_CODE
code
=
tsdb_conv_write
(
server
_to_client
,
TSDB_CONV_CODE
code
=
tsdb_conv_write
(
env
_to_client
,
(
const
char
*
)
row
,
&
slen
,
(
char
*
)
TargetValue
,
&
len
);
if
(
StrLen_or_Ind
)
*
StrLen_or_Ind
=
(
SQLLEN
)((
size_t
)
BufferLength
-
len
);
...
...
@@ -2067,12 +2100,12 @@ static SQLRETURN do_bind_param_value(sql_t *sql, int idx_row, int idx, param_bin
CHK_CONV
(
1
,
code
);
}
break
;
case
SQL_C_CHAR
:
{
tsdb_conv_t
*
client_to_
server
=
tsdb_conn_client_to_server
(
conn
);
tsdb_conv_t
*
client_to_
env
=
tsdb_conn_client_to_env
(
conn
);
size_t
slen
=
(
size_t
)
*
soi
;
if
(
slen
==
SQL_NTS
)
slen
=
strlen
((
const
char
*
)
paramValue
);
const
char
*
buf
=
NULL
;
size_t
blen
=
0
;
TSDB_CONV_CODE
code
=
tsdb_conv
(
client_to_
server
,
NULL
,
(
const
char
*
)
paramValue
,
slen
,
&
buf
,
&
blen
);
TSDB_CONV_CODE
code
=
tsdb_conv
(
client_to_
env
,
NULL
,
(
const
char
*
)
paramValue
,
slen
,
&
buf
,
&
blen
);
if
(
code
==
TSDB_CONV_OK
)
{
if
(
buf
!=
(
const
char
*
)
paramValue
)
{
bind
->
allocated
=
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录