Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
9b0b1e24
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看板
提交
9b0b1e24
编写于
6月 02, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] refactor codes
上级
9d492a8d
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
36 addition
and
45 deletion
+36
-45
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+1
-4
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+7
-9
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+12
-14
src/client/src/tscSql.c
src/client/src/tscSql.c
+2
-4
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+5
-8
src/inc/taosdef.h
src/inc/taosdef.h
+1
-1
src/util/inc/tutil.h
src/util/inc/tutil.h
+1
-1
src/util/src/tutil.c
src/util/src/tutil.c
+5
-2
src/util/tests/stringTest.cpp
src/util/tests/stringTest.cpp
+2
-2
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
9b0b1e24
...
...
@@ -132,10 +132,7 @@ bool tscIsSelectivityWithTagQuery(SSqlCmd* pCmd);
void
tscAddSpecialColumnForSelect
(
SQueryInfo
*
pQueryInfo
,
int32_t
outputColIndex
,
int16_t
functionId
,
SColumnIndex
*
pIndex
,
SSchema
*
pColSchema
,
int16_t
isTag
);
//void addRequiredTagColumn(SQueryInfo* pQueryInfo, int32_t tagColIndex, int32_t tableIndex);
void
addRequiredTagColumn
(
STableMetaInfo
*
pTableMetaInfo
,
SColumnIndex
*
index
);
int32_t
tscSetTableId
(
STableMetaInfo
*
pTableMetaInfo
,
SSQLToken
*
pzTableName
,
SSqlObj
*
pSql
);
int32_t
tscSetTableFullName
(
STableMetaInfo
*
pTableMetaInfo
,
SSQLToken
*
pzTableName
,
SSqlObj
*
pSql
);
void
tscClearInterpInfo
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsInsertData
(
char
*
sqlstr
);
...
...
src/client/src/tscParseInsert.c
浏览文件 @
9b0b1e24
...
...
@@ -793,7 +793,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
}
STableMetaInfo
*
pSTableMeterMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
STABLE_INDEX
);
tscSetTable
Id
(
pSTableMeterMetaInfo
,
&
sToken
,
pSql
);
tscSetTable
FullName
(
pSTableMeterMetaInfo
,
&
sToken
,
pSql
);
strncpy
(
pTag
->
name
,
pSTableMeterMetaInfo
->
name
,
TSDB_TABLE_ID_LEN
);
code
=
tscGetTableMeta
(
pSql
,
pSTableMeterMetaInfo
);
...
...
@@ -834,9 +834,8 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
sql
+=
index
;
if
(
TK_STRING
==
sToken
.
type
)
{
sToken
.
n
=
strdequote
(
sToken
.
z
);
strtrim
(
sToken
.
z
);
sToken
.
n
=
(
uint32_t
)
strlen
(
sToken
.
z
);
strdequote
(
sToken
.
z
);
sToken
.
n
=
strtrim
(
sToken
.
z
);
}
if
(
sToken
.
type
==
TK_RP
)
{
...
...
@@ -948,7 +947,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
return
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
"invalid table name"
,
*
sqlstr
);
}
int32_t
ret
=
tscSetTable
Id
(
pTableMetaInfo
,
&
tableToken
,
pSql
);
int32_t
ret
=
tscSetTable
FullName
(
pTableMetaInfo
,
&
tableToken
,
pSql
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
}
...
...
@@ -1091,7 +1090,7 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
goto
_error_clean
;
}
if
((
code
=
tscSetTable
Id
(
pTableMetaInfo
,
&
sToken
,
pSql
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
tscSetTable
FullName
(
pTableMetaInfo
,
&
sToken
,
pSql
))
!=
TSDB_CODE_SUCCESS
)
{
goto
_error_clean
;
}
...
...
@@ -1209,9 +1208,8 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
str
+=
index
;
if
(
TK_STRING
==
sToken
.
type
)
{
sToken
.
n
=
strdequote
(
sToken
.
z
);
strtrim
(
sToken
.
z
);
sToken
.
n
=
(
uint32_t
)
strlen
(
sToken
.
z
);
strdequote
(
sToken
.
z
);
sToken
.
n
=
strtrim
(
sToken
.
z
);
}
if
(
sToken
.
type
==
TK_RP
)
{
...
...
src/client/src/tscSQLParser.c
浏览文件 @
9b0b1e24
...
...
@@ -163,8 +163,7 @@ static int32_t handlePassword(SSqlCmd* pCmd, SSQLToken* pPwd) {
}
strdequote
(
pPwd
->
z
);
strtrim
(
pPwd
->
z
);
// trim space before and after passwords
pPwd
->
n
=
strlen
(
pPwd
->
z
);
pPwd
->
n
=
strtrim
(
pPwd
->
z
);
// trim space before and after passwords
if
(
pPwd
->
n
<=
0
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
...
...
@@ -226,7 +225,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
else
if
(
pInfo
->
type
==
TSDB_SQL_DROP_TABLE
)
{
assert
(
pInfo
->
pDCLInfo
->
nTokens
==
1
);
if
(
tscSetTable
Id
(
pTableMetaInfo
,
pzName
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tscSetTable
FullName
(
pTableMetaInfo
,
pzName
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
}
}
else
if
(
pInfo
->
type
==
TSDB_SQL_DROP_DNODE
)
{
...
...
@@ -353,7 +352,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
if
(
tscSetTable
Id
(
pTableMetaInfo
,
pToken
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tscSetTable
FullName
(
pTableMetaInfo
,
pToken
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
...
...
@@ -686,7 +685,7 @@ int32_t parseSlidingClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
tscSetTable
Id
(
STableMetaInfo
*
pTableMetaInfo
,
SSQLToken
*
pzTableName
,
SSqlObj
*
pSql
)
{
int32_t
tscSetTable
FullName
(
STableMetaInfo
*
pTableMetaInfo
,
SSQLToken
*
pzTableName
,
SSqlObj
*
pSql
)
{
const
char
*
msg
=
"name too long"
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
...
...
@@ -4293,7 +4292,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
}
if
(
tscSetTable
Id
(
pTableMetaInfo
,
&
(
pAlterSQL
->
name
),
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tscSetTable
FullName
(
pTableMetaInfo
,
&
(
pAlterSQL
->
name
),
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg2
);
}
...
...
@@ -4645,8 +4644,7 @@ int32_t validateColumnName(char* name) {
if
(
token
.
type
==
TK_STRING
)
{
strdequote
(
token
.
z
);
strtrim
(
token
.
z
);
token
.
n
=
(
uint32_t
)
strlen
(
token
.
z
);
token
.
n
=
strtrim
(
token
.
z
);
int32_t
k
=
tSQLGetToken
(
token
.
z
,
&
token
.
type
);
if
(
k
!=
token
.
n
)
{
...
...
@@ -5490,7 +5488,7 @@ int32_t doCheckForCreateTable(SSqlObj* pSql, int32_t subClauseIndex, SSqlInfo* p
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
if
(
tscSetTable
Id
(
pTableMetaInfo
,
pzTableName
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tscSetTable
FullName
(
pTableMetaInfo
,
pzTableName
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
...
...
@@ -5545,7 +5543,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
if
(
tscSetTable
Id
(
pStableMeterMetaInfo
,
pToken
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tscSetTable
FullName
(
pStableMeterMetaInfo
,
pToken
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
...
...
@@ -5591,7 +5589,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
}
STableMetaInfo
*
pTableMeterMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
TABLE_INDEX
);
ret
=
tscSetTable
Id
(
pTableMeterMetaInfo
,
&
pInfo
->
pCreateTableInfo
->
name
,
pSql
);
ret
=
tscSetTable
FullName
(
pTableMeterMetaInfo
,
&
pInfo
->
pCreateTableInfo
->
name
,
pSql
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
}
...
...
@@ -5634,7 +5632,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
}
if
(
tscSetTable
Id
(
pTableMetaInfo
,
&
srcToken
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tscSetTable
FullName
(
pTableMetaInfo
,
&
srcToken
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg2
);
}
...
...
@@ -5665,7 +5663,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
}
// set the created table[stream] name
if
(
tscSetTable
Id
(
pTableMetaInfo
,
pzTableName
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tscSetTable
FullName
(
pTableMetaInfo
,
pzTableName
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
}
...
...
@@ -5774,7 +5772,7 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
STableMetaInfo
*
pMeterInfo1
=
tscGetMetaInfo
(
pQueryInfo
,
i
);
SSQLToken
t
=
{.
type
=
TSDB_DATA_TYPE_BINARY
,
.
n
=
pTableItem
->
nLen
,
.
z
=
pTableItem
->
pz
};
if
(
tscSetTable
Id
(
pMeterInfo1
,
&
t
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tscSetTable
FullName
(
pMeterInfo1
,
&
t
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
...
...
src/client/src/tscSql.c
浏览文件 @
9b0b1e24
...
...
@@ -817,9 +817,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
tblName
[
len
]
=
'\0'
;
str
=
nextStr
+
1
;
strtrim
(
tblName
);
len
=
(
uint32_t
)
strlen
(
tblName
);
len
=
strtrim
(
tblName
);
SSQLToken
sToken
=
{.
n
=
len
,
.
type
=
TK_ID
,
.
z
=
tblName
};
tSQLGetToken
(
tblName
,
&
sToken
.
type
);
...
...
@@ -831,7 +829,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
return
code
;
}
if
((
code
=
tscSetTable
Id
(
pTableMetaInfo
,
&
sToken
,
pSql
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
tscSetTable
FullName
(
pTableMetaInfo
,
&
sToken
,
pSql
))
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
src/client/src/tscUtil.c
浏览文件 @
9b0b1e24
...
...
@@ -1231,9 +1231,8 @@ void tscColumnListDestroy(SArray* pColumnList) {
*
*/
static
int32_t
validateQuoteToken
(
SSQLToken
*
pToken
)
{
pToken
->
n
=
strdequote
(
pToken
->
z
);
strtrim
(
pToken
->
z
);
pToken
->
n
=
(
uint32_t
)
strlen
(
pToken
->
z
);
strdequote
(
pToken
->
z
);
pToken
->
n
=
strtrim
(
pToken
->
z
);
int32_t
k
=
tSQLGetToken
(
pToken
->
z
,
&
pToken
->
type
);
...
...
@@ -1255,9 +1254,8 @@ int32_t tscValidateName(SSQLToken* pToken) {
char
*
sep
=
strnchr
(
pToken
->
z
,
TS_PATH_DELIMITER
[
0
],
pToken
->
n
,
true
);
if
(
sep
==
NULL
)
{
// single part
if
(
pToken
->
type
==
TK_STRING
)
{
pToken
->
n
=
strdequote
(
pToken
->
z
);
strtrim
(
pToken
->
z
);
pToken
->
n
=
(
uint32_t
)
strlen
(
pToken
->
z
);
strdequote
(
pToken
->
z
);
pToken
->
n
=
strtrim
(
pToken
->
z
);
int
len
=
tSQLGetToken
(
pToken
->
z
,
&
pToken
->
type
);
...
...
@@ -1282,8 +1280,7 @@ int32_t tscValidateName(SSQLToken* pToken) {
char
*
pStr
=
pToken
->
z
;
if
(
pToken
->
type
==
TK_SPACE
)
{
strtrim
(
pToken
->
z
);
pToken
->
n
=
(
uint32_t
)
strlen
(
pToken
->
z
);
pToken
->
n
=
strtrim
(
pToken
->
z
);
}
pToken
->
n
=
tSQLGetToken
(
pToken
->
z
,
&
pToken
->
type
);
...
...
src/inc/taosdef.h
浏览文件 @
9b0b1e24
...
...
@@ -322,7 +322,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
#define TSDB_QUERY_TYPE_SUBQUERY 0x02u
#define TSDB_QUERY_TYPE_STABLE_SUBQUERY 0x04u // two-stage subquery for super table
#define TSDB_QUERY_TYPE_TABLE_QUERY 0x08u
// query ordinary table; below only apply to client side
#define TSDB_QUERY_TYPE_TABLE_QUERY 0x08u // query ordinary table; below only apply to client side
#define TSDB_QUERY_TYPE_STABLE_QUERY 0x10u // query on super table
#define TSDB_QUERY_TYPE_JOIN_QUERY 0x20u // join query
#define TSDB_QUERY_TYPE_PROJECTION_QUERY 0x40u // select *,columns... query
...
...
src/util/inc/tutil.h
浏览文件 @
9b0b1e24
...
...
@@ -113,7 +113,7 @@ extern "C" {
int32_t
strdequote
(
char
*
src
);
void
strtrim
(
char
*
src
);
size_t
strtrim
(
char
*
src
);
char
*
strnchr
(
char
*
haystack
,
char
needle
,
int32_t
len
,
bool
skipquote
);
...
...
src/util/src/tutil.c
浏览文件 @
9b0b1e24
...
...
@@ -60,7 +60,7 @@ int32_t strdequote(char *z) {
return
j
+
1
;
// only one quote, do nothing
}
void
strtrim
(
char
*
z
)
{
size_t
strtrim
(
char
*
z
)
{
int32_t
i
=
0
;
int32_t
j
=
0
;
...
...
@@ -71,7 +71,7 @@ void strtrim(char *z) {
if
(
z
[
j
]
==
0
)
{
z
[
0
]
=
0
;
return
;
return
0
;
}
delta
=
j
;
...
...
@@ -89,9 +89,12 @@ void strtrim(char *z) {
if
(
stop
>
0
)
{
z
[
stop
-
delta
]
=
0
;
return
(
stop
-
delta
);
}
else
if
(
j
!=
i
)
{
z
[
i
]
=
0
;
}
return
i
;
}
char
**
strsplit
(
char
*
z
,
const
char
*
delim
,
int32_t
*
num
)
{
...
...
src/util/tests/stringTest.cpp
浏览文件 @
9b0b1e24
...
...
@@ -20,10 +20,10 @@ TEST(testCase, string_dequote_test) {
EXPECT_STRCASEEQ
(
t1
,
"abc"
);
char
t21
[]
=
" abc "
;
strtrim
(
t21
);
int32_t
lx
=
strtrim
(
t21
);
EXPECT_STREQ
(
"abc"
,
t21
);
EXPECT_EQ
(
3
,
strlen
(
t21
)
);
EXPECT_EQ
(
3
,
lx
);
}
TEST
(
testCase
,
string_replace_test
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录