Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
0369b0bf
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看板
提交
0369b0bf
编写于
1月 25, 2021
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add lock for db access
上级
5d976a26
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
5 deletion
+27
-5
src/client/src/tscLocal.c
src/client/src/tscLocal.c
+3
-0
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+6
-2
src/client/src/tscServer.c
src/client/src/tscServer.c
+18
-3
未找到文件。
src/client/src/tscLocal.c
浏览文件 @
0369b0bf
...
...
@@ -749,7 +749,10 @@ static int32_t tscProcessCurrentUser(SSqlObj *pSql) {
static
int32_t
tscProcessCurrentDB
(
SSqlObj
*
pSql
)
{
char
db
[
TSDB_DB_NAME_LEN
]
=
{
0
};
pthread_mutex_lock
(
&
pSql
->
pTscObj
->
mutex
);
extractDBName
(
pSql
->
pTscObj
->
db
,
db
);
pthread_mutex_unlock
(
&
pSql
->
pTscObj
->
mutex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
pSql
->
cmd
.
clauseIndex
);
...
...
src/client/src/tscSQLParser.c
浏览文件 @
0369b0bf
...
...
@@ -60,7 +60,7 @@ static int32_t setShowInfo(SSqlObj* pSql, SSqlInfo* pInfo);
static
char
*
getAccountId
(
SSqlObj
*
pSql
);
static
bool
has
(
SArray
*
pFieldList
,
int32_t
startIdx
,
const
char
*
name
);
static
char
*
get
CurrentDBName
(
SSqlObj
*
pSql
);
static
char
*
clone
CurrentDBName
(
SSqlObj
*
pSql
);
static
bool
hasSpecifyDB
(
SStrToken
*
pTableName
);
static
bool
validateTableColumnInfo
(
SArray
*
pFieldList
,
SSqlCmd
*
pCmd
);
static
bool
validateTagParams
(
SArray
*
pTagsList
,
SArray
*
pFieldList
,
SSqlCmd
*
pCmd
);
...
...
@@ -1248,7 +1248,11 @@ static bool has(SArray* pFieldList, int32_t startIdx, const char* name) {
static
char
*
getAccountId
(
SSqlObj
*
pSql
)
{
return
pSql
->
pTscObj
->
acctId
;
}
static
char
*
cloneCurrentDBName
(
SSqlObj
*
pSql
)
{
return
strdup
(
pSql
->
pTscObj
->
db
);
pthread_mutex_lock
(
&
pSql
->
pTscObj
->
mutex
);
char
*
p
=
strdup
(
pSql
->
pTscObj
->
db
);
pthread_mutex_unlock
(
&
pSql
->
pTscObj
->
mutex
);
return
p
;
}
/* length limitation, strstr cannot be applied */
...
...
src/client/src/tscServer.c
浏览文件 @
0369b0bf
...
...
@@ -1250,8 +1250,10 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
if
(
tNameIsEmpty
(
&
pTableMetaInfo
->
name
))
{
tstrncpy
(
pShowMsg
->
db
,
pObj
->
db
,
sizeof
(
pShowMsg
->
db
));
if
(
tNameIsEmpty
(
&
pTableMetaInfo
->
name
))
{
pthread_mutex_lock
(
&
pObj
->
mutex
);
tstrncpy
(
pShowMsg
->
db
,
pObj
->
db
,
sizeof
(
pShowMsg
->
db
));
pthread_mutex_unlock
(
&
pObj
->
mutex
);
}
else
{
tNameGetFullDbName
(
&
pTableMetaInfo
->
name
,
pShowMsg
->
db
);
}
...
...
@@ -1611,9 +1613,14 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
// TODO refactor full_name
char
*
db
;
// ugly code to move the space
pthread_mutex_lock
(
&
pObj
->
mutex
);
db
=
strstr
(
pObj
->
db
,
TS_PATH_DELIMITER
);
db
=
(
db
==
NULL
)
?
pObj
->
db
:
db
+
1
;
tstrncpy
(
pConnect
->
db
,
db
,
sizeof
(
pConnect
->
db
));
pthread_mutex_unlock
(
&
pObj
->
mutex
);
tstrncpy
(
pConnect
->
clientVersion
,
version
,
sizeof
(
pConnect
->
clientVersion
));
tstrncpy
(
pConnect
->
msgVersion
,
""
,
sizeof
(
pConnect
->
msgVersion
));
...
...
@@ -2131,10 +2138,13 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
SConnectRsp
*
pConnect
=
(
SConnectRsp
*
)
pRes
->
pRsp
;
tstrncpy
(
pObj
->
acctId
,
pConnect
->
acctId
,
sizeof
(
pObj
->
acctId
));
// copy acctId from response
pthread_mutex_lock
(
&
pObj
->
mutex
);
int32_t
len
=
sprintf
(
temp
,
"%s%s%s"
,
pObj
->
acctId
,
TS_PATH_DELIMITER
,
pObj
->
db
);
assert
(
len
<=
sizeof
(
pObj
->
db
));
tstrncpy
(
pObj
->
db
,
temp
,
sizeof
(
pObj
->
db
));
pthread_mutex_unlock
(
&
pObj
->
mutex
);
if
(
pConnect
->
epSet
.
numOfEps
>
0
)
{
tscEpSetHtons
(
&
pConnect
->
epSet
);
...
...
@@ -2161,7 +2171,12 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
int
tscProcessUseDbRsp
(
SSqlObj
*
pSql
)
{
STscObj
*
pObj
=
pSql
->
pTscObj
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pSql
->
cmd
,
0
,
0
);
return
tNameExtractFullName
(
&
pTableMetaInfo
->
name
,
pObj
->
db
);
pthread_mutex_lock
(
&
pObj
->
mutex
);
int
ret
=
tNameExtractFullName
(
&
pTableMetaInfo
->
name
,
pObj
->
db
);
pthread_mutex_unlock
(
&
pObj
->
mutex
);
return
ret
;
}
int
tscProcessDropDbRsp
(
SSqlObj
*
pSql
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录