Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
5501982f
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看板
提交
5501982f
编写于
3月 07, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-2895] refactor.
上级
e313cf3b
变更
6
展开全部
显示空白变更内容
内联
并排
Showing
6 changed file
with
410 addition
and
603 deletion
+410
-603
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+135
-246
src/query/inc/qSqlparser.h
src/query/inc/qSqlparser.h
+20
-17
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+71
-165
src/query/src/qParserImpl.c
src/query/src/qParserImpl.c
+55
-46
src/query/src/qTokenizer.c
src/query/src/qTokenizer.c
+43
-43
tests/script/general/parser/testSuite.sim
tests/script/general/parser/testSuite.sim
+86
-86
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
5501982f
此差异已折叠。
点击以展开。
src/query/inc/qSqlparser.h
浏览文件 @
5501982f
...
@@ -181,19 +181,32 @@ typedef struct SSqlInfo {
...
@@ -181,19 +181,32 @@ typedef struct SSqlInfo {
};
};
}
SSqlInfo
;
}
SSqlInfo
;
#define NON_ARITHMEIC_EXPR 0
#define NORMAL_ARITHMETIC 1
#define AGG_ARIGHTMEIC 2
enum
SQL_NODE_TYPE
{
SQL_NODE_TABLE_COLUMN
=
1
,
SQL_NODE_SQLFUNCTION
=
2
,
SQL_NODE_VALUE
=
3
,
SQL_NODE_EXPR
=
4
,
};
typedef
struct
tSQLExpr
{
typedef
struct
tSQLExpr
{
uint32_t
nSQLOptr
;
// TK_FUNCTION: sql function, TK_LE: less than(binary expr)
uint16_t
type
;
// sql node type
uint32_t
tokenId
;
// TK_FUNCTION: sql function, TK_LE: less than(binary expr)
// the full sql string of function(col, param), which is actually the raw
// the whole string of the function(col, param), while the function name is kept in token
// field name, since the function name is kept in nSQLOptr already
SStrToken
operand
;
SStrToken
operand
;
SStrToken
colInfo
;
// field id
uint32_t
functionId
;
// function id
tVariant
val
;
// value only for string, float, int
SStrToken
colInfo
;
// table column info
tVariant
value
;
// the use input value
SStrToken
token
;
// original sql expr string
SStrToken
token
;
// original sql expr string
struct
tSQLExpr
*
pLeft
;
// left child
struct
tSQLExpr
*
pLeft
;
// left child
struct
tSQLExpr
*
pRight
;
// right child
struct
tSQLExpr
*
pRight
;
// right child
struct
tSQLExprList
*
pParam
;
// function parameters
struct
tSQLExprList
*
pParam
;
// function parameters
list
}
tSQLExpr
;
}
tSQLExpr
;
// used in select clause. select <tSQLExprList> from xxx
// used in select clause. select <tSQLExprList> from xxx
...
@@ -287,16 +300,6 @@ void tSqlSetColumnType(TAOS_FIELD *pField, SStrToken *type);
...
@@ -287,16 +300,6 @@ void tSqlSetColumnType(TAOS_FIELD *pField, SStrToken *type);
void
*
ParseAlloc
(
void
*
(
*
mallocProc
)(
size_t
));
void
*
ParseAlloc
(
void
*
(
*
mallocProc
)(
size_t
));
enum
{
TSQL_NODE_TYPE_EXPR
=
0x1
,
TSQL_NODE_TYPE_ID
=
0x2
,
TSQL_NODE_TYPE_VALUE
=
0x4
,
};
#define NON_ARITHMEIC_EXPR 0
#define NORMAL_ARITHMETIC 1
#define AGG_ARIGHTMEIC 2
SSqlInfo
qSQLParse
(
const
char
*
str
);
SSqlInfo
qSQLParse
(
const
char
*
str
);
#ifdef __cplusplus
#ifdef __cplusplus
...
...
src/query/src/qExecutor.c
浏览文件 @
5501982f
此差异已折叠。
点击以展开。
src/query/src/qParserImpl.c
浏览文件 @
5501982f
...
@@ -126,28 +126,33 @@ tSQLExpr *tSqlExprIdValueCreate(SStrToken *pToken, int32_t optrType) {
...
@@ -126,28 +126,33 @@ tSQLExpr *tSqlExprIdValueCreate(SStrToken *pToken, int32_t optrType) {
if
(
optrType
==
TK_INTEGER
||
optrType
==
TK_STRING
||
optrType
==
TK_FLOAT
||
optrType
==
TK_BOOL
)
{
if
(
optrType
==
TK_INTEGER
||
optrType
==
TK_STRING
||
optrType
==
TK_FLOAT
||
optrType
==
TK_BOOL
)
{
toTSDBType
(
pToken
->
type
);
toTSDBType
(
pToken
->
type
);
tVariantCreate
(
&
pSqlExpr
->
val
,
pToken
);
tVariantCreate
(
&
pSqlExpr
->
value
,
pToken
);
pSqlExpr
->
nSQLOptr
=
optrType
;
pSqlExpr
->
tokenId
=
optrType
;
pSqlExpr
->
type
=
SQL_NODE_VALUE
;
}
else
if
(
optrType
==
TK_NOW
)
{
}
else
if
(
optrType
==
TK_NOW
)
{
// use microsecond by default
// use microsecond by default
pSqlExpr
->
val
.
i64
=
taosGetTimestamp
(
TSDB_TIME_PRECISION_MICRO
);
pSqlExpr
->
value
.
i64
=
taosGetTimestamp
(
TSDB_TIME_PRECISION_MICRO
);
pSqlExpr
->
val
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
pSqlExpr
->
value
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
pSqlExpr
->
nSQLOptr
=
TK_TIMESTAMP
;
// TK_TIMESTAMP used to denote the time value is in microsecond
pSqlExpr
->
tokenId
=
TK_TIMESTAMP
;
// TK_TIMESTAMP used to denote the time value is in microsecond
pSqlExpr
->
type
=
SQL_NODE_VALUE
;
}
else
if
(
optrType
==
TK_VARIABLE
)
{
}
else
if
(
optrType
==
TK_VARIABLE
)
{
int32_t
ret
=
parseAbsoluteDuration
(
pToken
->
z
,
pToken
->
n
,
&
pSqlExpr
->
val
.
i64
);
int32_t
ret
=
parseAbsoluteDuration
(
pToken
->
z
,
pToken
->
n
,
&
pSqlExpr
->
val
ue
.
i64
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
TSDB_CODE_TSC_SQL_SYNTAX_ERROR
;
terrno
=
TSDB_CODE_TSC_SQL_SYNTAX_ERROR
;
}
}
pSqlExpr
->
val
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
pSqlExpr
->
value
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
pSqlExpr
->
nSQLOptr
=
TK_TIMESTAMP
;
pSqlExpr
->
tokenId
=
TK_TIMESTAMP
;
}
else
{
// it must be the column name (tk_id) if it is not the number
pSqlExpr
->
type
=
SQL_NODE_VALUE
;
}
else
{
// Here it must be the column name (tk_id) if it is not a number or string.
assert
(
optrType
==
TK_ID
||
optrType
==
TK_ALL
);
assert
(
optrType
==
TK_ID
||
optrType
==
TK_ALL
);
if
(
pToken
!=
NULL
)
{
if
(
pToken
!=
NULL
)
{
pSqlExpr
->
colInfo
=
*
pToken
;
pSqlExpr
->
colInfo
=
*
pToken
;
}
}
pSqlExpr
->
nSQLOptr
=
optrType
;
pSqlExpr
->
tokenId
=
optrType
;
pSqlExpr
->
type
=
SQL_NODE_TABLE_COLUMN
;
}
}
return
pSqlExpr
;
return
pSqlExpr
;
...
@@ -162,18 +167,18 @@ tSQLExpr *tSqlExprCreateFunction(tSQLExprList *pList, SStrToken *pFuncToken, SSt
...
@@ -162,18 +167,18 @@ tSQLExpr *tSqlExprCreateFunction(tSQLExprList *pList, SStrToken *pFuncToken, SSt
return
NULL
;
return
NULL
;
}
}
assert
(
optType
==
TK_ID
);
tSQLExpr
*
pExpr
=
calloc
(
1
,
sizeof
(
tSQLExpr
));
tSQLExpr
*
pExpr
=
calloc
(
1
,
sizeof
(
tSQLExpr
));
pExpr
->
nSQLOptr
=
TK_FUNCTION
;
pExpr
->
tokenId
=
optType
;
pExpr
->
type
=
SQL_NODE_SQLFUNCTION
;
pExpr
->
pParam
=
pList
;
pExpr
->
pParam
=
pList
;
int32_t
len
=
(
int32_t
)((
endToken
->
z
+
endToken
->
n
)
-
pFuncToken
->
z
);
int32_t
len
=
(
int32_t
)((
endToken
->
z
+
endToken
->
n
)
-
pFuncToken
->
z
);
pExpr
->
operand
.
z
=
pFuncToken
->
z
;
pExpr
->
operand
=
(
*
pFuncToken
);
pExpr
->
operand
.
n
=
len
;
// raw field name
pExpr
->
operand
.
type
=
pFuncToken
->
type
;
pExpr
->
token
.
n
=
len
;
pExpr
->
token
.
z
=
pFuncToken
->
z
;
pExpr
->
token
.
type
=
pFuncToken
->
type
;
pExpr
->
token
=
(
*
pFuncToken
);
return
pExpr
;
return
pExpr
;
}
}
...
@@ -184,6 +189,7 @@ tSQLExpr *tSqlExprCreateFunction(tSQLExprList *pList, SStrToken *pFuncToken, SSt
...
@@ -184,6 +189,7 @@ tSQLExpr *tSqlExprCreateFunction(tSQLExprList *pList, SStrToken *pFuncToken, SSt
tSQLExpr
*
tSqlExprCreate
(
tSQLExpr
*
pLeft
,
tSQLExpr
*
pRight
,
int32_t
optrType
)
{
tSQLExpr
*
tSqlExprCreate
(
tSQLExpr
*
pLeft
,
tSQLExpr
*
pRight
,
int32_t
optrType
)
{
tSQLExpr
*
pExpr
=
calloc
(
1
,
sizeof
(
tSQLExpr
));
tSQLExpr
*
pExpr
=
calloc
(
1
,
sizeof
(
tSQLExpr
));
pExpr
->
type
=
SQL_NODE_EXPR
;
if
(
pLeft
!=
NULL
&&
pRight
!=
NULL
&&
(
optrType
!=
TK_IN
))
{
if
(
pLeft
!=
NULL
&&
pRight
!=
NULL
&&
(
optrType
!=
TK_IN
))
{
char
*
endPos
=
pRight
->
token
.
z
+
pRight
->
token
.
n
;
char
*
endPos
=
pRight
->
token
.
z
+
pRight
->
token
.
n
;
pExpr
->
token
.
z
=
pLeft
->
token
.
z
;
pExpr
->
token
.
z
=
pLeft
->
token
.
z
;
...
@@ -197,32 +203,33 @@ tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
...
@@ -197,32 +203,33 @@ tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
* if a token is noted as the TK_TIMESTAMP, the time precision is microsecond
* if a token is noted as the TK_TIMESTAMP, the time precision is microsecond
* Otherwise, the time precision is adaptive, determined by the time precision from databases.
* Otherwise, the time precision is adaptive, determined by the time precision from databases.
*/
*/
if
((
pLeft
->
nSQLOptr
==
TK_INTEGER
&&
pRight
->
nSQLOptr
==
TK_INTEGER
)
||
if
((
pLeft
->
tokenId
==
TK_INTEGER
&&
pRight
->
tokenId
==
TK_INTEGER
)
||
(
pLeft
->
nSQLOptr
==
TK_TIMESTAMP
&&
pRight
->
nSQLOptr
==
TK_TIMESTAMP
))
{
(
pLeft
->
tokenId
==
TK_TIMESTAMP
&&
pRight
->
tokenId
==
TK_TIMESTAMP
))
{
pExpr
->
val
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
pExpr
->
value
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
pExpr
->
nSQLOptr
=
pLeft
->
nSQLOptr
;
pExpr
->
tokenId
=
pLeft
->
tokenId
;
pExpr
->
type
=
SQL_NODE_VALUE
;
switch
(
optrType
)
{
switch
(
optrType
)
{
case
TK_PLUS
:
{
case
TK_PLUS
:
{
pExpr
->
val
.
i64
=
pLeft
->
val
.
i64
+
pRight
->
val
.
i64
;
pExpr
->
val
ue
.
i64
=
pLeft
->
value
.
i64
+
pRight
->
value
.
i64
;
break
;
break
;
}
}
case
TK_MINUS
:
{
case
TK_MINUS
:
{
pExpr
->
val
.
i64
=
pLeft
->
val
.
i64
-
pRight
->
val
.
i64
;
pExpr
->
val
ue
.
i64
=
pLeft
->
value
.
i64
-
pRight
->
value
.
i64
;
break
;
break
;
}
}
case
TK_STAR
:
{
case
TK_STAR
:
{
pExpr
->
val
.
i64
=
pLeft
->
val
.
i64
*
pRight
->
val
.
i64
;
pExpr
->
val
ue
.
i64
=
pLeft
->
value
.
i64
*
pRight
->
value
.
i64
;
break
;
break
;
}
}
case
TK_DIVIDE
:
{
case
TK_DIVIDE
:
{
pExpr
->
nSQLOptr
=
TK_FLOAT
;
pExpr
->
tokenId
=
TK_FLOAT
;
pExpr
->
val
.
nType
=
TSDB_DATA_TYPE_DOUBLE
;
pExpr
->
val
ue
.
nType
=
TSDB_DATA_TYPE_DOUBLE
;
pExpr
->
val
.
dKey
=
(
double
)
pLeft
->
val
.
i64
/
pRight
->
val
.
i64
;
pExpr
->
val
ue
.
dKey
=
(
double
)
pLeft
->
value
.
i64
/
pRight
->
value
.
i64
;
break
;
break
;
}
}
case
TK_REM
:
{
case
TK_REM
:
{
pExpr
->
val
.
i64
=
pLeft
->
val
.
i64
%
pRight
->
val
.
i64
;
pExpr
->
val
ue
.
i64
=
pLeft
->
value
.
i64
%
pRight
->
value
.
i64
;
break
;
break
;
}
}
}
}
...
@@ -230,33 +237,35 @@ tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
...
@@ -230,33 +237,35 @@ tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
tSqlExprDestroy
(
pLeft
);
tSqlExprDestroy
(
pLeft
);
tSqlExprDestroy
(
pRight
);
tSqlExprDestroy
(
pRight
);
}
else
if
((
pLeft
->
nSQLOptr
==
TK_FLOAT
&&
pRight
->
nSQLOptr
==
TK_INTEGER
)
||
(
pLeft
->
nSQLOptr
==
TK_INTEGER
&&
pRight
->
nSQLOptr
==
TK_FLOAT
)
||
}
else
if
((
pLeft
->
tokenId
==
TK_FLOAT
&&
pRight
->
tokenId
==
TK_INTEGER
)
||
(
pLeft
->
nSQLOptr
==
TK_FLOAT
&&
pRight
->
nSQLOptr
==
TK_FLOAT
))
{
(
pLeft
->
tokenId
==
TK_INTEGER
&&
pRight
->
tokenId
==
TK_FLOAT
)
||
pExpr
->
val
.
nType
=
TSDB_DATA_TYPE_DOUBLE
;
(
pLeft
->
tokenId
==
TK_FLOAT
&&
pRight
->
tokenId
==
TK_FLOAT
))
{
pExpr
->
nSQLOptr
=
TK_FLOAT
;
pExpr
->
value
.
nType
=
TSDB_DATA_TYPE_DOUBLE
;
pExpr
->
tokenId
=
TK_FLOAT
;
pExpr
->
type
=
SQL_NODE_VALUE
;
double
left
=
(
pLeft
->
val
.
nType
==
TSDB_DATA_TYPE_DOUBLE
)
?
pLeft
->
val
.
dKey
:
pLeft
->
val
.
i64
;
double
left
=
(
pLeft
->
val
ue
.
nType
==
TSDB_DATA_TYPE_DOUBLE
)
?
pLeft
->
value
.
dKey
:
pLeft
->
value
.
i64
;
double
right
=
(
pRight
->
val
.
nType
==
TSDB_DATA_TYPE_DOUBLE
)
?
pRight
->
val
.
dKey
:
pRight
->
val
.
i64
;
double
right
=
(
pRight
->
val
ue
.
nType
==
TSDB_DATA_TYPE_DOUBLE
)
?
pRight
->
value
.
dKey
:
pRight
->
value
.
i64
;
switch
(
optrType
)
{
switch
(
optrType
)
{
case
TK_PLUS
:
{
case
TK_PLUS
:
{
pExpr
->
val
.
dKey
=
left
+
right
;
pExpr
->
val
ue
.
dKey
=
left
+
right
;
break
;
break
;
}
}
case
TK_MINUS
:
{
case
TK_MINUS
:
{
pExpr
->
val
.
dKey
=
left
-
right
;
pExpr
->
val
ue
.
dKey
=
left
-
right
;
break
;
break
;
}
}
case
TK_STAR
:
{
case
TK_STAR
:
{
pExpr
->
val
.
dKey
=
left
*
right
;
pExpr
->
val
ue
.
dKey
=
left
*
right
;
break
;
break
;
}
}
case
TK_DIVIDE
:
{
case
TK_DIVIDE
:
{
pExpr
->
val
.
dKey
=
left
/
right
;
pExpr
->
val
ue
.
dKey
=
left
/
right
;
break
;
break
;
}
}
case
TK_REM
:
{
case
TK_REM
:
{
pExpr
->
val
.
dKey
=
left
-
((
int64_t
)(
left
/
right
))
*
right
;
pExpr
->
val
ue
.
dKey
=
left
-
((
int64_t
)(
left
/
right
))
*
right
;
break
;
break
;
}
}
}
}
...
@@ -265,21 +274,21 @@ tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
...
@@ -265,21 +274,21 @@ tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
tSqlExprDestroy
(
pRight
);
tSqlExprDestroy
(
pRight
);
}
else
{
}
else
{
pExpr
->
nSQLOptr
=
optrType
;
pExpr
->
tokenId
=
optrType
;
pExpr
->
pLeft
=
pLeft
;
pExpr
->
pLeft
=
pLeft
;
pExpr
->
pRight
=
pRight
;
pExpr
->
pRight
=
pRight
;
}
}
}
else
if
(
optrType
==
TK_IN
)
{
}
else
if
(
optrType
==
TK_IN
)
{
pExpr
->
nSQLOptr
=
optrType
;
pExpr
->
tokenId
=
optrType
;
pExpr
->
pLeft
=
pLeft
;
pExpr
->
pLeft
=
pLeft
;
tSQLExpr
*
pRSub
=
calloc
(
1
,
sizeof
(
tSQLExpr
));
tSQLExpr
*
pRSub
=
calloc
(
1
,
sizeof
(
tSQLExpr
));
pRSub
->
nSQLOptr
=
TK_SET
;
// TODO refactor .....
pRSub
->
tokenId
=
TK_SET
;
// TODO refactor .....
pRSub
->
pParam
=
(
tSQLExprList
*
)
pRight
;
pRSub
->
pParam
=
(
tSQLExprList
*
)
pRight
;
pExpr
->
pRight
=
pRSub
;
pExpr
->
pRight
=
pRSub
;
}
else
{
}
else
{
pExpr
->
nSQLOptr
=
optrType
;
pExpr
->
tokenId
=
optrType
;
pExpr
->
pLeft
=
pLeft
;
pExpr
->
pLeft
=
pLeft
;
if
(
pLeft
!=
NULL
&&
pRight
==
NULL
)
{
if
(
pLeft
!=
NULL
&&
pRight
==
NULL
)
{
...
@@ -297,8 +306,8 @@ void tSqlExprNodeDestroy(tSQLExpr *pExpr) {
...
@@ -297,8 +306,8 @@ void tSqlExprNodeDestroy(tSQLExpr *pExpr) {
return
;
return
;
}
}
if
(
pExpr
->
nSQLOptr
==
TK_STRING
)
{
if
(
pExpr
->
tokenId
==
TK_STRING
)
{
tVariantDestroy
(
&
pExpr
->
val
);
tVariantDestroy
(
&
pExpr
->
val
ue
);
}
}
tSqlExprListDestroy
(
pExpr
->
pParam
);
tSqlExprListDestroy
(
pExpr
->
pParam
);
...
...
src/query/src/qTokenizer.c
浏览文件 @
5501982f
...
@@ -268,7 +268,7 @@ int tSQLKeywordCode(const char* z, int n) {
...
@@ -268,7 +268,7 @@ int tSQLKeywordCode(const char* z, int n) {
* Return the length of the token that begins at z[0].
* Return the length of the token that begins at z[0].
* Store the token type in *type before returning.
* Store the token type in *type before returning.
*/
*/
uint32_t
tSQLGetToken
(
char
*
z
,
uint32_t
*
token
Type
)
{
uint32_t
tSQLGetToken
(
char
*
z
,
uint32_t
*
token
Id
)
{
uint32_t
i
;
uint32_t
i
;
switch
(
*
z
)
{
switch
(
*
z
)
{
case
' '
:
case
' '
:
...
@@ -278,121 +278,121 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
...
@@ -278,121 +278,121 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
case
'\r'
:
{
case
'\r'
:
{
for
(
i
=
1
;
isspace
(
z
[
i
]);
i
++
)
{
for
(
i
=
1
;
isspace
(
z
[
i
]);
i
++
)
{
}
}
*
token
Type
=
TK_SPACE
;
*
token
Id
=
TK_SPACE
;
return
i
;
return
i
;
}
}
case
':'
:
{
case
':'
:
{
*
token
Type
=
TK_COLON
;
*
token
Id
=
TK_COLON
;
return
1
;
return
1
;
}
}
case
'-'
:
{
case
'-'
:
{
if
(
z
[
1
]
==
'-'
)
{
if
(
z
[
1
]
==
'-'
)
{
for
(
i
=
2
;
z
[
i
]
&&
z
[
i
]
!=
'\n'
;
i
++
)
{
for
(
i
=
2
;
z
[
i
]
&&
z
[
i
]
!=
'\n'
;
i
++
)
{
}
}
*
token
Type
=
TK_COMMENT
;
*
token
Id
=
TK_COMMENT
;
return
i
;
return
i
;
}
}
*
token
Type
=
TK_MINUS
;
*
token
Id
=
TK_MINUS
;
return
1
;
return
1
;
}
}
case
'('
:
{
case
'('
:
{
*
token
Type
=
TK_LP
;
*
token
Id
=
TK_LP
;
return
1
;
return
1
;
}
}
case
')'
:
{
case
')'
:
{
*
token
Type
=
TK_RP
;
*
token
Id
=
TK_RP
;
return
1
;
return
1
;
}
}
case
';'
:
{
case
';'
:
{
*
token
Type
=
TK_SEMI
;
*
token
Id
=
TK_SEMI
;
return
1
;
return
1
;
}
}
case
'+'
:
{
case
'+'
:
{
*
token
Type
=
TK_PLUS
;
*
token
Id
=
TK_PLUS
;
return
1
;
return
1
;
}
}
case
'*'
:
{
case
'*'
:
{
*
token
Type
=
TK_STAR
;
*
token
Id
=
TK_STAR
;
return
1
;
return
1
;
}
}
case
'/'
:
{
case
'/'
:
{
if
(
z
[
1
]
!=
'*'
||
z
[
2
]
==
0
)
{
if
(
z
[
1
]
!=
'*'
||
z
[
2
]
==
0
)
{
*
token
Type
=
TK_SLASH
;
*
token
Id
=
TK_SLASH
;
return
1
;
return
1
;
}
}
for
(
i
=
3
;
z
[
i
]
&&
(
z
[
i
]
!=
'/'
||
z
[
i
-
1
]
!=
'*'
);
i
++
)
{
for
(
i
=
3
;
z
[
i
]
&&
(
z
[
i
]
!=
'/'
||
z
[
i
-
1
]
!=
'*'
);
i
++
)
{
}
}
if
(
z
[
i
])
i
++
;
if
(
z
[
i
])
i
++
;
*
token
Type
=
TK_COMMENT
;
*
token
Id
=
TK_COMMENT
;
return
i
;
return
i
;
}
}
case
'%'
:
{
case
'%'
:
{
*
token
Type
=
TK_REM
;
*
token
Id
=
TK_REM
;
return
1
;
return
1
;
}
}
case
'='
:
{
case
'='
:
{
*
token
Type
=
TK_EQ
;
*
token
Id
=
TK_EQ
;
return
1
+
(
z
[
1
]
==
'='
);
return
1
+
(
z
[
1
]
==
'='
);
}
}
case
'<'
:
{
case
'<'
:
{
if
(
z
[
1
]
==
'='
)
{
if
(
z
[
1
]
==
'='
)
{
*
token
Type
=
TK_LE
;
*
token
Id
=
TK_LE
;
return
2
;
return
2
;
}
else
if
(
z
[
1
]
==
'>'
)
{
}
else
if
(
z
[
1
]
==
'>'
)
{
*
token
Type
=
TK_NE
;
*
token
Id
=
TK_NE
;
return
2
;
return
2
;
}
else
if
(
z
[
1
]
==
'<'
)
{
}
else
if
(
z
[
1
]
==
'<'
)
{
*
token
Type
=
TK_LSHIFT
;
*
token
Id
=
TK_LSHIFT
;
return
2
;
return
2
;
}
else
{
}
else
{
*
token
Type
=
TK_LT
;
*
token
Id
=
TK_LT
;
return
1
;
return
1
;
}
}
}
}
case
'>'
:
{
case
'>'
:
{
if
(
z
[
1
]
==
'='
)
{
if
(
z
[
1
]
==
'='
)
{
*
token
Type
=
TK_GE
;
*
token
Id
=
TK_GE
;
return
2
;
return
2
;
}
else
if
(
z
[
1
]
==
'>'
)
{
}
else
if
(
z
[
1
]
==
'>'
)
{
*
token
Type
=
TK_RSHIFT
;
*
token
Id
=
TK_RSHIFT
;
return
2
;
return
2
;
}
else
{
}
else
{
*
token
Type
=
TK_GT
;
*
token
Id
=
TK_GT
;
return
1
;
return
1
;
}
}
}
}
case
'!'
:
{
case
'!'
:
{
if
(
z
[
1
]
!=
'='
)
{
if
(
z
[
1
]
!=
'='
)
{
*
token
Type
=
TK_ILLEGAL
;
*
token
Id
=
TK_ILLEGAL
;
return
2
;
return
2
;
}
else
{
}
else
{
*
token
Type
=
TK_NE
;
*
token
Id
=
TK_NE
;
return
2
;
return
2
;
}
}
}
}
case
'|'
:
{
case
'|'
:
{
if
(
z
[
1
]
!=
'|'
)
{
if
(
z
[
1
]
!=
'|'
)
{
*
token
Type
=
TK_BITOR
;
*
token
Id
=
TK_BITOR
;
return
1
;
return
1
;
}
else
{
}
else
{
*
token
Type
=
TK_CONCAT
;
*
token
Id
=
TK_CONCAT
;
return
2
;
return
2
;
}
}
}
}
case
','
:
{
case
','
:
{
*
token
Type
=
TK_COMMA
;
*
token
Id
=
TK_COMMA
;
return
1
;
return
1
;
}
}
case
'&'
:
{
case
'&'
:
{
*
token
Type
=
TK_BITAND
;
*
token
Id
=
TK_BITAND
;
return
1
;
return
1
;
}
}
case
'~'
:
{
case
'~'
:
{
*
token
Type
=
TK_BITNOT
;
*
token
Id
=
TK_BITNOT
;
return
1
;
return
1
;
}
}
case
'?'
:
{
case
'?'
:
{
*
token
Type
=
TK_QUESTION
;
*
token
Id
=
TK_QUESTION
;
return
1
;
return
1
;
}
}
case
'\''
:
case
'\''
:
...
@@ -418,7 +418,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
...
@@ -418,7 +418,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
if
(
z
[
i
])
i
++
;
if
(
z
[
i
])
i
++
;
if
(
strEnd
)
{
if
(
strEnd
)
{
*
token
Type
=
TK_STRING
;
*
token
Id
=
TK_STRING
;
return
i
;
return
i
;
}
}
...
@@ -442,10 +442,10 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
...
@@ -442,10 +442,10 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
}
}
}
}
*
token
Type
=
TK_FLOAT
;
*
token
Id
=
TK_FLOAT
;
return
i
;
return
i
;
}
else
{
}
else
{
*
token
Type
=
TK_DOT
;
*
token
Id
=
TK_DOT
;
return
1
;
return
1
;
}
}
}
}
...
@@ -454,7 +454,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
...
@@ -454,7 +454,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
char
next
=
z
[
1
];
char
next
=
z
[
1
];
if
(
next
==
'b'
)
{
// bin number
if
(
next
==
'b'
)
{
// bin number
*
token
Type
=
TK_BIN
;
*
token
Id
=
TK_BIN
;
for
(
i
=
2
;
(
z
[
i
]
==
'0'
||
z
[
i
]
==
'1'
);
++
i
)
{
for
(
i
=
2
;
(
z
[
i
]
==
'0'
||
z
[
i
]
==
'1'
);
++
i
)
{
}
}
...
@@ -464,7 +464,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
...
@@ -464,7 +464,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
return
i
;
return
i
;
}
else
if
(
next
==
'x'
)
{
//hex number
}
else
if
(
next
==
'x'
)
{
//hex number
*
token
Type
=
TK_HEX
;
*
token
Id
=
TK_HEX
;
for
(
i
=
2
;
isdigit
(
z
[
i
])
||
(
z
[
i
]
>=
'a'
&&
z
[
i
]
<=
'f'
)
||
(
z
[
i
]
>=
'A'
&&
z
[
i
]
<=
'F'
);
++
i
)
{
for
(
i
=
2
;
isdigit
(
z
[
i
])
||
(
z
[
i
]
>=
'a'
&&
z
[
i
]
<=
'f'
)
||
(
z
[
i
]
>=
'A'
&&
z
[
i
]
<=
'F'
);
++
i
)
{
}
}
...
@@ -484,7 +484,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
...
@@ -484,7 +484,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
case
'7'
:
case
'7'
:
case
'8'
:
case
'8'
:
case
'9'
:
{
case
'9'
:
{
*
token
Type
=
TK_INTEGER
;
*
token
Id
=
TK_INTEGER
;
for
(
i
=
1
;
isdigit
(
z
[
i
]);
i
++
)
{
for
(
i
=
1
;
isdigit
(
z
[
i
]);
i
++
)
{
}
}
...
@@ -494,7 +494,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
...
@@ -494,7 +494,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
z
[
i
]
==
'U'
||
z
[
i
]
==
'A'
||
z
[
i
]
==
'S'
||
z
[
i
]
==
'M'
||
z
[
i
]
==
'H'
||
z
[
i
]
==
'D'
||
z
[
i
]
==
'N'
||
z
[
i
]
==
'U'
||
z
[
i
]
==
'A'
||
z
[
i
]
==
'S'
||
z
[
i
]
==
'M'
||
z
[
i
]
==
'H'
||
z
[
i
]
==
'D'
||
z
[
i
]
==
'N'
||
z
[
i
]
==
'Y'
||
z
[
i
]
==
'W'
)
&&
z
[
i
]
==
'Y'
||
z
[
i
]
==
'W'
)
&&
(
isIdChar
[(
uint8_t
)
z
[
i
+
1
]]
==
0
))
{
(
isIdChar
[(
uint8_t
)
z
[
i
+
1
]]
==
0
))
{
*
token
Type
=
TK_VARIABLE
;
*
token
Id
=
TK_VARIABLE
;
i
+=
1
;
i
+=
1
;
return
i
;
return
i
;
}
}
...
@@ -505,12 +505,12 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
...
@@ -505,12 +505,12 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
while
(
isdigit
(
z
[
i
]))
{
while
(
isdigit
(
z
[
i
]))
{
i
++
;
i
++
;
}
}
*
token
Type
=
TK_FLOAT
;
*
token
Id
=
TK_FLOAT
;
seg
++
;
seg
++
;
}
}
if
(
seg
==
4
)
{
// ip address
if
(
seg
==
4
)
{
// ip address
*
token
Type
=
TK_IPTOKEN
;
*
token
Id
=
TK_IPTOKEN
;
return
i
;
return
i
;
}
}
...
@@ -520,14 +520,14 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
...
@@ -520,14 +520,14 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
while
(
isdigit
(
z
[
i
]))
{
while
(
isdigit
(
z
[
i
]))
{
i
++
;
i
++
;
}
}
*
token
Type
=
TK_FLOAT
;
*
token
Id
=
TK_FLOAT
;
}
}
return
i
;
return
i
;
}
}
case
'['
:
{
case
'['
:
{
for
(
i
=
1
;
z
[
i
]
&&
z
[
i
-
1
]
!=
']'
;
i
++
)
{
for
(
i
=
1
;
z
[
i
]
&&
z
[
i
-
1
]
!=
']'
;
i
++
)
{
}
}
*
token
Type
=
TK_ID
;
*
token
Id
=
TK_ID
;
return
i
;
return
i
;
}
}
case
'T'
:
case
'T'
:
...
@@ -538,7 +538,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
...
@@ -538,7 +538,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
}
}
if
((
i
==
4
&&
strncasecmp
(
z
,
"true"
,
4
)
==
0
)
||
(
i
==
5
&&
strncasecmp
(
z
,
"false"
,
5
)
==
0
))
{
if
((
i
==
4
&&
strncasecmp
(
z
,
"true"
,
4
)
==
0
)
||
(
i
==
5
&&
strncasecmp
(
z
,
"false"
,
5
)
==
0
))
{
*
token
Type
=
TK_BOOL
;
*
token
Id
=
TK_BOOL
;
return
i
;
return
i
;
}
}
}
}
...
@@ -548,12 +548,12 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
...
@@ -548,12 +548,12 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
}
}
for
(
i
=
1
;
((
z
[
i
]
&
0x80
)
==
0
)
&&
isIdChar
[(
uint8_t
)
z
[
i
]];
i
++
)
{
for
(
i
=
1
;
((
z
[
i
]
&
0x80
)
==
0
)
&&
isIdChar
[(
uint8_t
)
z
[
i
]];
i
++
)
{
}
}
*
token
Type
=
tSQLKeywordCode
(
z
,
i
);
*
token
Id
=
tSQLKeywordCode
(
z
,
i
);
return
i
;
return
i
;
}
}
}
}
*
token
Type
=
TK_ILLEGAL
;
*
token
Id
=
TK_ILLEGAL
;
return
0
;
return
0
;
}
}
...
...
tests/script/general/parser/testSuite.sim
浏览文件 @
5501982f
run general/parser/alter.sim
#
run general/parser/alter.sim
sleep 100
#
sleep 100
run general/parser/alter1.sim
#
run general/parser/alter1.sim
sleep 100
#
sleep 100
run general/parser/alter_stable.sim
#
run general/parser/alter_stable.sim
sleep 100
#
sleep 100
run general/parser/auto_create_tb.sim
#
run general/parser/auto_create_tb.sim
sleep 100
#
sleep 100
run general/parser/auto_create_tb_drop_tb.sim
#
run general/parser/auto_create_tb_drop_tb.sim
sleep 100
#
sleep 100
run general/parser/col_arithmetic_operation.sim
#
run general/parser/col_arithmetic_operation.sim
sleep 100
#
sleep 100
run general/parser/columnValue.sim
#
run general/parser/columnValue.sim
sleep 100
#
sleep 100
run general/parser/commit.sim
#
run general/parser/commit.sim
sleep 100
#
sleep 100
run general/parser/create_db.sim
#
run general/parser/create_db.sim
sleep 100
#
sleep 100
run general/parser/create_mt.sim
#
run general/parser/create_mt.sim
sleep 100
#
sleep 100
run general/parser/create_tb.sim
#
run general/parser/create_tb.sim
sleep 100
#
sleep 100
run general/parser/dbtbnameValidate.sim
#
run general/parser/dbtbnameValidate.sim
sleep 100
#
sleep 100
run general/parser/fill.sim
#
run general/parser/fill.sim
sleep 100
#
sleep 100
run general/parser/fill_stb.sim
#
run general/parser/fill_stb.sim
sleep 100
#
sleep 100
#run general/parser/fill_us.sim #
#
#
run general/parser/fill_us.sim #
sleep 100
#
sleep 100
run general/parser/first_last.sim
#
run general/parser/first_last.sim
sleep 100
#
sleep 100
run general/parser/import_commit1.sim
#
run general/parser/import_commit1.sim
sleep 100
#
sleep 100
run general/parser/import_commit2.sim
#
run general/parser/import_commit2.sim
sleep 100
#
sleep 100
run general/parser/import_commit3.sim
#
run general/parser/import_commit3.sim
sleep 100
#
sleep 100
#run general/parser/import_file.sim
#
#
run general/parser/import_file.sim
sleep 100
#
sleep 100
run general/parser/insert_tb.sim
#
run general/parser/insert_tb.sim
sleep 100
#
sleep 100
run general/parser/tags_dynamically_specifiy.sim
#
run general/parser/tags_dynamically_specifiy.sim
sleep 100
#
sleep 100
run general/parser/interp.sim
#
run general/parser/interp.sim
sleep 100
#
sleep 100
run general/parser/lastrow.sim
#
run general/parser/lastrow.sim
sleep 100
#
sleep 100
run general/parser/limit.sim
#
run general/parser/limit.sim
sleep 100
#
sleep 100
run general/parser/limit1.sim
#
run general/parser/limit1.sim
sleep 100
#
sleep 100
run general/parser/limit1_tblocks100.sim
#
run general/parser/limit1_tblocks100.sim
sleep 100
#
sleep 100
run general/parser/limit2.sim
#
run general/parser/limit2.sim
sleep 100
#
sleep 100
run general/parser/mixed_blocks.sim
#
run general/parser/mixed_blocks.sim
sleep 100
#
sleep 100
run general/parser/nchar.sim
#
run general/parser/nchar.sim
sleep 100
#
sleep 100
run general/parser/null_char.sim
#
run general/parser/null_char.sim
sleep 100
#
sleep 100
run general/parser/selectResNum.sim
#
run general/parser/selectResNum.sim
sleep 100
#
sleep 100
run general/parser/select_across_vnodes.sim
#
run general/parser/select_across_vnodes.sim
sleep 100
#
sleep 100
run general/parser/select_from_cache_disk.sim
#
run general/parser/select_from_cache_disk.sim
sleep 100
#
sleep 100
run general/parser/set_tag_vals.sim
#
run general/parser/set_tag_vals.sim
sleep 100
#
sleep 100
run general/parser/single_row_in_tb.sim
#
run general/parser/single_row_in_tb.sim
sleep 100
#
sleep 100
run general/parser/slimit.sim
#
run general/parser/slimit.sim
sleep 100
#
sleep 100
run general/parser/slimit1.sim
#
run general/parser/slimit1.sim
sleep 100
#
sleep 100
run general/parser/slimit_alter_tags.sim
#
run general/parser/slimit_alter_tags.sim
sleep 100
#
sleep 100
run general/parser/tbnameIn.sim
#
run general/parser/tbnameIn.sim
sleep 100
#
sleep 100
run general/parser/slimit_alter_tags.sim # persistent failed
#
run general/parser/slimit_alter_tags.sim # persistent failed
sleep 100
#
sleep 100
run general/parser/join.sim
#
run general/parser/join.sim
sleep 100
#
sleep 100
run general/parser/join_multivnode.sim
#
run general/parser/join_multivnode.sim
sleep 100
#
sleep 100
run general/parser/projection_limit_offset.sim
run general/parser/projection_limit_offset.sim
sleep 100
sleep 100
run general/parser/select_with_tags.sim
run general/parser/select_with_tags.sim
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录