Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
300098ed
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看板
未验证
提交
300098ed
编写于
1月 26, 2021
作者:
H
haojun Liao
提交者:
GitHub
1月 26, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5027 from taosdata/hotfix/TD-2818-2
[TD-2818]add lock for db field access
上级
34800991
0369b0bf
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
120 addition
and
9 deletion
+120
-9
src/client/src/tscLocal.c
src/client/src/tscLocal.c
+3
-0
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+90
-4
src/client/src/tscServer.c
src/client/src/tscServer.c
+21
-4
src/common/src/tvariant.c
src/common/src/tvariant.c
+1
-1
src/inc/taosdef.h
src/inc/taosdef.h
+5
-0
未找到文件。
src/client/src/tscLocal.c
浏览文件 @
300098ed
...
@@ -749,7 +749,10 @@ static int32_t tscProcessCurrentUser(SSqlObj *pSql) {
...
@@ -749,7 +749,10 @@ static int32_t tscProcessCurrentUser(SSqlObj *pSql) {
static
int32_t
tscProcessCurrentDB
(
SSqlObj
*
pSql
)
{
static
int32_t
tscProcessCurrentDB
(
SSqlObj
*
pSql
)
{
char
db
[
TSDB_DB_NAME_LEN
]
=
{
0
};
char
db
[
TSDB_DB_NAME_LEN
]
=
{
0
};
pthread_mutex_lock
(
&
pSql
->
pTscObj
->
mutex
);
extractDBName
(
pSql
->
pTscObj
->
db
,
db
);
extractDBName
(
pSql
->
pTscObj
->
db
,
db
);
pthread_mutex_unlock
(
&
pSql
->
pTscObj
->
mutex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
pSql
->
cmd
.
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
pSql
->
cmd
.
clauseIndex
);
...
...
src/client/src/tscSQLParser.c
浏览文件 @
300098ed
...
@@ -62,7 +62,7 @@ static int32_t setShowInfo(SSqlObj* pSql, SSqlInfo* pInfo);
...
@@ -62,7 +62,7 @@ static int32_t setShowInfo(SSqlObj* pSql, SSqlInfo* pInfo);
static
char
*
getAccountId
(
SSqlObj
*
pSql
);
static
char
*
getAccountId
(
SSqlObj
*
pSql
);
static
bool
has
(
SArray
*
pFieldList
,
int32_t
startIdx
,
const
char
*
name
);
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
hasSpecifyDB
(
SStrToken
*
pTableName
);
static
bool
validateTableColumnInfo
(
SArray
*
pFieldList
,
SSqlCmd
*
pCmd
);
static
bool
validateTableColumnInfo
(
SArray
*
pFieldList
,
SSqlCmd
*
pCmd
);
static
bool
validateTagParams
(
SArray
*
pTagsList
,
SArray
*
pFieldList
,
SSqlCmd
*
pCmd
);
static
bool
validateTagParams
(
SArray
*
pTagsList
,
SArray
*
pFieldList
,
SSqlCmd
*
pCmd
);
...
@@ -923,16 +923,19 @@ int32_t tscSetTableFullName(STableMetaInfo* pTableMetaInfo, SStrToken* pTableNam
...
@@ -923,16 +923,19 @@ int32_t tscSetTableFullName(STableMetaInfo* pTableMetaInfo, SStrToken* pTableNam
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
}
}
else
{
// get current DB name first, and then set it into path
}
else
{
// get current DB name first, and then set it into path
char
*
t
=
get
CurrentDBName
(
pSql
);
char
*
t
=
clone
CurrentDBName
(
pSql
);
if
(
strlen
(
t
)
==
0
)
{
if
(
strlen
(
t
)
==
0
)
{
return
TSDB_CODE_TSC_DB_NOT_SELECTED
;
return
TSDB_CODE_TSC_DB_NOT_SELECTED
;
}
}
code
=
tNameFromString
(
&
pTableMetaInfo
->
name
,
t
,
T_NAME_ACCT
|
T_NAME_DB
);
code
=
tNameFromString
(
&
pTableMetaInfo
->
name
,
t
,
T_NAME_ACCT
|
T_NAME_DB
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
free
(
t
);
return
TSDB_CODE_TSC_DB_NOT_SELECTED
;
return
TSDB_CODE_TSC_DB_NOT_SELECTED
;
}
}
free
(
t
);
if
(
pTableName
->
n
>=
TSDB_TABLE_NAME_LEN
)
{
if
(
pTableName
->
n
>=
TSDB_TABLE_NAME_LEN
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
}
...
@@ -1246,8 +1249,12 @@ static bool has(SArray* pFieldList, int32_t startIdx, const char* name) {
...
@@ -1246,8 +1249,12 @@ static bool has(SArray* pFieldList, int32_t startIdx, const char* name) {
static
char
*
getAccountId
(
SSqlObj
*
pSql
)
{
return
pSql
->
pTscObj
->
acctId
;
}
static
char
*
getAccountId
(
SSqlObj
*
pSql
)
{
return
pSql
->
pTscObj
->
acctId
;
}
static
char
*
getCurrentDBName
(
SSqlObj
*
pSql
)
{
static
char
*
cloneCurrentDBName
(
SSqlObj
*
pSql
)
{
return
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 */
/* length limitation, strstr cannot be applied */
...
@@ -4302,6 +4309,77 @@ static void doAddJoinTagsColumnsIntoTagList(SSqlCmd* pCmd, SQueryInfo* pQueryInf
...
@@ -4302,6 +4309,77 @@ static void doAddJoinTagsColumnsIntoTagList(SSqlCmd* pCmd, SQueryInfo* pQueryInf
}
}
}
}
static
int32_t
validateTagCondExpr
(
SSqlCmd
*
pCmd
,
tExprNode
*
p
)
{
const
char
*
msg1
=
"invalid tag operator"
;
const
char
*
msg2
=
"not supported filter condition"
;
do
{
if
(
p
->
nodeType
!=
TSQL_NODE_EXPR
)
{
break
;
}
if
(
!
p
->
_node
.
pLeft
||
!
p
->
_node
.
pRight
)
{
break
;
}
if
(
IS_ARITHMETIC_OPTR
(
p
->
_node
.
optr
))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
if
(
!
IS_RELATION_OPTR
(
p
->
_node
.
optr
))
{
break
;
}
tVariant
*
vVariant
=
NULL
;
int32_t
schemaType
=
-
1
;
if
(
p
->
_node
.
pLeft
->
nodeType
==
TSQL_NODE_VALUE
&&
p
->
_node
.
pRight
->
nodeType
==
TSQL_NODE_COL
)
{
if
(
!
p
->
_node
.
pRight
->
pSchema
)
{
break
;
}
vVariant
=
p
->
_node
.
pLeft
->
pVal
;
schemaType
=
p
->
_node
.
pRight
->
pSchema
->
type
;
}
else
if
(
p
->
_node
.
pLeft
->
nodeType
==
TSQL_NODE_COL
&&
p
->
_node
.
pRight
->
nodeType
==
TSQL_NODE_VALUE
)
{
if
(
!
p
->
_node
.
pLeft
->
pSchema
)
{
break
;
}
vVariant
=
p
->
_node
.
pRight
->
pVal
;
schemaType
=
p
->
_node
.
pLeft
->
pSchema
->
type
;
}
else
{
break
;
}
if
(
schemaType
>=
TSDB_DATA_TYPE_TINYINT
&&
schemaType
<=
TSDB_DATA_TYPE_BIGINT
)
{
schemaType
=
TSDB_DATA_TYPE_BIGINT
;
}
else
if
(
schemaType
==
TSDB_DATA_TYPE_FLOAT
||
schemaType
==
TSDB_DATA_TYPE_DOUBLE
)
{
schemaType
=
TSDB_DATA_TYPE_DOUBLE
;
}
int32_t
retVal
=
TSDB_CODE_SUCCESS
;
if
(
schemaType
==
TSDB_DATA_TYPE_BINARY
)
{
char
*
tmp
=
calloc
(
1
,
vVariant
->
nLen
+
TSDB_NCHAR_SIZE
);
retVal
=
tVariantDump
(
vVariant
,
tmp
,
schemaType
,
false
);
free
(
tmp
);
}
else
if
(
schemaType
==
TSDB_DATA_TYPE_NCHAR
)
{
// pRight->val.nLen + 1 is larger than the actual nchar string length
char
*
tmp
=
calloc
(
1
,
(
vVariant
->
nLen
+
1
)
*
TSDB_NCHAR_SIZE
);
retVal
=
tVariantDump
(
vVariant
,
tmp
,
schemaType
,
false
);
free
(
tmp
);
}
else
{
double
tmp
;
retVal
=
tVariantDump
(
vVariant
,
(
char
*
)
&
tmp
,
schemaType
,
false
);
}
if
(
retVal
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
}
while
(
0
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
getTagQueryCondExpr
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
,
SCondExpr
*
pCondExpr
,
tSQLExpr
**
pExpr
)
{
static
int32_t
getTagQueryCondExpr
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
,
SCondExpr
*
pCondExpr
,
tSQLExpr
**
pExpr
)
{
int32_t
ret
=
TSDB_CODE_SUCCESS
;
int32_t
ret
=
TSDB_CODE_SUCCESS
;
...
@@ -4344,6 +4422,10 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
...
@@ -4344,6 +4422,10 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
tsSetSTableQueryCond
(
&
pQueryInfo
->
tagCond
,
uid
,
&
bw
);
tsSetSTableQueryCond
(
&
pQueryInfo
->
tagCond
,
uid
,
&
bw
);
doCompactQueryExpr
(
pExpr
);
doCompactQueryExpr
(
pExpr
);
if
(
ret
==
TSDB_CODE_SUCCESS
)
{
ret
=
validateTagCondExpr
(
pCmd
,
p
);
}
tSqlExprDestroy
(
p1
);
tSqlExprDestroy
(
p1
);
tExprTreeDestroy
(
p
,
NULL
);
tExprTreeDestroy
(
p
,
NULL
);
...
@@ -4351,6 +4433,10 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
...
@@ -4351,6 +4433,10 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
if
(
pQueryInfo
->
tagCond
.
pCond
!=
NULL
&&
taosArrayGetSize
(
pQueryInfo
->
tagCond
.
pCond
)
>
0
&&
!
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
if
(
pQueryInfo
->
tagCond
.
pCond
!=
NULL
&&
taosArrayGetSize
(
pQueryInfo
->
tagCond
.
pCond
)
>
0
&&
!
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
"filter on tag not supported for normal table"
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
"filter on tag not supported for normal table"
);
}
}
if
(
ret
)
{
break
;
}
}
}
pCondExpr
->
pTagCond
=
NULL
;
pCondExpr
->
pTagCond
=
NULL
;
...
...
src/client/src/tscServer.c
浏览文件 @
300098ed
...
@@ -1250,8 +1250,10 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1250,8 +1250,10 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
if
(
tNameIsEmpty
(
&
pTableMetaInfo
->
name
))
{
if
(
tNameIsEmpty
(
&
pTableMetaInfo
->
name
))
{
tstrncpy
(
pShowMsg
->
db
,
pObj
->
db
,
sizeof
(
pShowMsg
->
db
));
pthread_mutex_lock
(
&
pObj
->
mutex
);
tstrncpy
(
pShowMsg
->
db
,
pObj
->
db
,
sizeof
(
pShowMsg
->
db
));
pthread_mutex_unlock
(
&
pObj
->
mutex
);
}
else
{
}
else
{
tNameGetFullDbName
(
&
pTableMetaInfo
->
name
,
pShowMsg
->
db
);
tNameGetFullDbName
(
&
pTableMetaInfo
->
name
,
pShowMsg
->
db
);
}
}
...
@@ -1611,9 +1613,14 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1611,9 +1613,14 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
// TODO refactor full_name
// TODO refactor full_name
char
*
db
;
// ugly code to move the space
char
*
db
;
// ugly code to move the space
pthread_mutex_lock
(
&
pObj
->
mutex
);
db
=
strstr
(
pObj
->
db
,
TS_PATH_DELIMITER
);
db
=
strstr
(
pObj
->
db
,
TS_PATH_DELIMITER
);
db
=
(
db
==
NULL
)
?
pObj
->
db
:
db
+
1
;
db
=
(
db
==
NULL
)
?
pObj
->
db
:
db
+
1
;
tstrncpy
(
pConnect
->
db
,
db
,
sizeof
(
pConnect
->
db
));
tstrncpy
(
pConnect
->
db
,
db
,
sizeof
(
pConnect
->
db
));
pthread_mutex_unlock
(
&
pObj
->
mutex
);
tstrncpy
(
pConnect
->
clientVersion
,
version
,
sizeof
(
pConnect
->
clientVersion
));
tstrncpy
(
pConnect
->
clientVersion
,
version
,
sizeof
(
pConnect
->
clientVersion
));
tstrncpy
(
pConnect
->
msgVersion
,
""
,
sizeof
(
pConnect
->
msgVersion
));
tstrncpy
(
pConnect
->
msgVersion
,
""
,
sizeof
(
pConnect
->
msgVersion
));
...
@@ -2131,10 +2138,13 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
...
@@ -2131,10 +2138,13 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
SConnectRsp
*
pConnect
=
(
SConnectRsp
*
)
pRes
->
pRsp
;
SConnectRsp
*
pConnect
=
(
SConnectRsp
*
)
pRes
->
pRsp
;
tstrncpy
(
pObj
->
acctId
,
pConnect
->
acctId
,
sizeof
(
pObj
->
acctId
));
// copy acctId from response
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
);
int32_t
len
=
sprintf
(
temp
,
"%s%s%s"
,
pObj
->
acctId
,
TS_PATH_DELIMITER
,
pObj
->
db
);
assert
(
len
<=
sizeof
(
pObj
->
db
));
assert
(
len
<=
sizeof
(
pObj
->
db
));
tstrncpy
(
pObj
->
db
,
temp
,
sizeof
(
pObj
->
db
));
tstrncpy
(
pObj
->
db
,
temp
,
sizeof
(
pObj
->
db
));
pthread_mutex_unlock
(
&
pObj
->
mutex
);
if
(
pConnect
->
epSet
.
numOfEps
>
0
)
{
if
(
pConnect
->
epSet
.
numOfEps
>
0
)
{
tscEpSetHtons
(
&
pConnect
->
epSet
);
tscEpSetHtons
(
&
pConnect
->
epSet
);
...
@@ -2161,11 +2171,18 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
...
@@ -2161,11 +2171,18 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
int
tscProcessUseDbRsp
(
SSqlObj
*
pSql
)
{
int
tscProcessUseDbRsp
(
SSqlObj
*
pSql
)
{
STscObj
*
pObj
=
pSql
->
pTscObj
;
STscObj
*
pObj
=
pSql
->
pTscObj
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pSql
->
cmd
,
0
,
0
);
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
)
{
int
tscProcessDropDbRsp
(
SSqlObj
*
pSql
)
{
pSql
->
pTscObj
->
db
[
0
]
=
0
;
//TODO LOCK DB WHEN MODIFY IT
//pSql->pTscObj->db[0] = 0;
taosHashEmpty
(
tscTableMetaInfo
);
taosHashEmpty
(
tscTableMetaInfo
);
return
0
;
return
0
;
}
}
...
...
src/common/src/tvariant.c
浏览文件 @
300098ed
...
@@ -430,7 +430,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result
...
@@ -430,7 +430,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result
}
}
errno
=
0
;
errno
=
0
;
if
(
IS_SIGNED_NUMERIC_TYPE
(
pVariant
->
nType
))
{
if
(
IS_SIGNED_NUMERIC_TYPE
(
pVariant
->
nType
)
||
(
pVariant
->
nType
==
TSDB_DATA_TYPE_BOOL
)
)
{
*
result
=
pVariant
->
i64
;
*
result
=
pVariant
->
i64
;
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
pVariant
->
nType
))
{
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
pVariant
->
nType
))
{
*
result
=
pVariant
->
u64
;
*
result
=
pVariant
->
u64
;
...
...
src/inc/taosdef.h
浏览文件 @
300098ed
...
@@ -163,6 +163,11 @@ do { \
...
@@ -163,6 +163,11 @@ do { \
#define TSDB_BINARY_OP_MULTIPLY 32
#define TSDB_BINARY_OP_MULTIPLY 32
#define TSDB_BINARY_OP_DIVIDE 33
#define TSDB_BINARY_OP_DIVIDE 33
#define TSDB_BINARY_OP_REMAINDER 34
#define TSDB_BINARY_OP_REMAINDER 34
#define IS_RELATION_OPTR(op) (((op) >= TSDB_RELATION_LESS) && ((op) <= TSDB_RELATION_IN))
#define IS_ARITHMETIC_OPTR(op) (((op) >= TSDB_BINARY_OP_ADD) && ((op) <= TSDB_BINARY_OP_REMAINDER))
#define TS_PATH_DELIMITER_LEN 1
#define TS_PATH_DELIMITER_LEN 1
#define TSDB_UNI_LEN 24
#define TSDB_UNI_LEN 24
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录