Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6c3ea16c
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看板
提交
6c3ea16c
编写于
3月 15, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] refactor
上级
c35c114f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
105 addition
and
233 deletion
+105
-233
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+11
-208
src/query/inc/qSqlparser.h
src/query/inc/qSqlparser.h
+5
-1
src/query/src/qSqlParser.c
src/query/src/qSqlParser.c
+89
-24
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
6c3ea16c
...
...
@@ -114,7 +114,6 @@ static int32_t parseLimitClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t i
static
int32_t
parseCreateDBOptions
(
SSqlCmd
*
pCmd
,
SCreateDbInfo
*
pCreateDbSql
);
static
int32_t
getColumnIndexByName
(
SSqlCmd
*
pCmd
,
const
SStrToken
*
pToken
,
SQueryInfo
*
pQueryInfo
,
SColumnIndex
*
pIndex
);
static
int32_t
getTableIndexByName
(
SStrToken
*
pToken
,
SQueryInfo
*
pQueryInfo
,
SColumnIndex
*
pIndex
);
static
int32_t
optrToString
(
tSqlExpr
*
pExpr
,
char
**
exprString
);
static
int32_t
getTableIndexImpl
(
SStrToken
*
pTableToken
,
SQueryInfo
*
pQueryInfo
,
SColumnIndex
*
pIndex
);
static
int32_t
doFunctionsCompatibleCheck
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
);
...
...
@@ -3169,127 +3168,6 @@ typedef struct SCondExpr {
static
int32_t
getTimeRange
(
STimeWindow
*
win
,
tSqlExpr
*
pRight
,
int32_t
optr
,
int16_t
timePrecision
);
static
int32_t
tSQLExprNodeToString
(
tSqlExpr
*
pExpr
,
char
**
str
)
{
if
(
pExpr
->
tokenId
==
TK_ID
)
{
// column name
strncpy
(
*
str
,
pExpr
->
colInfo
.
z
,
pExpr
->
colInfo
.
n
);
*
str
+=
pExpr
->
colInfo
.
n
;
}
else
if
(
pExpr
->
tokenId
>=
TK_BOOL
&&
pExpr
->
tokenId
<=
TK_STRING
)
{
// value
*
str
+=
tVariantToString
(
&
pExpr
->
value
,
*
str
);
}
else
if
(
pExpr
->
tokenId
>=
TSDB_FUNC_COUNT
&&
pExpr
->
tokenId
<=
TSDB_FUNC_BLKINFO
)
{
/*
* arithmetic expression of aggregation, such as count(ts) + count(ts) *2
*/
strncpy
(
*
str
,
pExpr
->
operand
.
z
,
pExpr
->
operand
.
n
);
*
str
+=
pExpr
->
operand
.
n
;
}
else
{
// not supported operation
assert
(
false
);
}
return
TSDB_CODE_SUCCESS
;
}
// pExpr->tokenId == 0 while handling "is null" query
static
bool
isExprLeafNode
(
tSqlExpr
*
pExpr
)
{
return
(
pExpr
->
pRight
==
NULL
&&
pExpr
->
pLeft
==
NULL
)
&&
(
pExpr
->
tokenId
==
0
||
pExpr
->
tokenId
==
TK_ID
||
(
pExpr
->
tokenId
>=
TK_BOOL
&&
pExpr
->
tokenId
<=
TK_NCHAR
)
||
pExpr
->
tokenId
==
TK_SET
);
}
static
bool
isExprDirectParentOfLeafNode
(
tSqlExpr
*
pExpr
)
{
return
(
pExpr
->
pLeft
!=
NULL
&&
pExpr
->
pRight
!=
NULL
)
&&
(
isExprLeafNode
(
pExpr
->
pLeft
)
&&
isExprLeafNode
(
pExpr
->
pRight
));
}
static
int32_t
tSQLExprLeafToString
(
tSqlExpr
*
pExpr
,
bool
addParentheses
,
char
**
output
)
{
if
(
!
isExprDirectParentOfLeafNode
(
pExpr
))
{
return
TSDB_CODE_TSC_INVALID_SQL
;
}
tSqlExpr
*
pLeft
=
pExpr
->
pLeft
;
tSqlExpr
*
pRight
=
pExpr
->
pRight
;
if
(
addParentheses
)
{
*
(
*
output
)
=
'('
;
*
output
+=
1
;
}
tSQLExprNodeToString
(
pLeft
,
output
);
if
(
optrToString
(
pExpr
,
output
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_TSC_INVALID_SQL
;
}
tSQLExprNodeToString
(
pRight
,
output
);
if
(
addParentheses
)
{
*
(
*
output
)
=
')'
;
*
output
+=
1
;
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
optrToString
(
tSqlExpr
*
pExpr
,
char
**
exprString
)
{
const
char
*
le
=
"<="
;
const
char
*
ge
=
">="
;
const
char
*
ne
=
"<>"
;
const
char
*
likeOptr
=
"LIKE"
;
switch
(
pExpr
->
tokenId
)
{
case
TK_LE
:
{
*
(
int16_t
*
)(
*
exprString
)
=
*
(
int16_t
*
)
le
;
*
exprString
+=
1
;
break
;
}
case
TK_GE
:
{
*
(
int16_t
*
)(
*
exprString
)
=
*
(
int16_t
*
)
ge
;
*
exprString
+=
1
;
break
;
}
case
TK_NE
:
{
*
(
int16_t
*
)(
*
exprString
)
=
*
(
int16_t
*
)
ne
;
*
exprString
+=
1
;
break
;
}
case
TK_LT
:
*
(
*
exprString
)
=
'<'
;
break
;
case
TK_GT
:
*
(
*
exprString
)
=
'>'
;
break
;
case
TK_EQ
:
*
(
*
exprString
)
=
'='
;
break
;
case
TK_PLUS
:
*
(
*
exprString
)
=
'+'
;
break
;
case
TK_MINUS
:
*
(
*
exprString
)
=
'-'
;
break
;
case
TK_STAR
:
*
(
*
exprString
)
=
'*'
;
break
;
case
TK_DIVIDE
:
*
(
*
exprString
)
=
'/'
;
break
;
case
TK_REM
:
*
(
*
exprString
)
=
'%'
;
break
;
case
TK_LIKE
:
{
int32_t
len
=
sprintf
(
*
exprString
,
" %s "
,
likeOptr
);
*
exprString
+=
(
len
-
1
);
break
;
}
default:
return
TSDB_CODE_TSC_INVALID_SQL
;
}
*
exprString
+=
1
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
tablenameListToString
(
tSqlExpr
*
pExpr
,
SStringBuilder
*
sb
)
{
SArray
*
pList
=
pExpr
->
pParam
;
...
...
@@ -3400,50 +3278,6 @@ static int32_t extractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SC
return
doExtractColumnFilterInfo
(
pCmd
,
pQueryInfo
,
pColFilter
,
pIndex
,
pExpr
);
}
static
void
relToString
(
tSqlExpr
*
pExpr
,
char
**
str
)
{
assert
(
pExpr
->
tokenId
==
TK_AND
||
pExpr
->
tokenId
==
TK_OR
);
const
char
*
or
=
"OR"
;
const
char
*
and
=
"AND"
;
// if (pQueryInfo->tagCond.relType == TSQL_STABLE_QTYPE_COND) {
if
(
pExpr
->
tokenId
==
TK_AND
)
{
strcpy
(
*
str
,
and
);
*
str
+=
strlen
(
and
);
}
else
{
strcpy
(
*
str
,
or
);
*
str
+=
strlen
(
or
);
}
}
UNUSED_FUNC
static
int32_t
getTagCondString
(
tSqlExpr
*
pExpr
,
char
**
str
)
{
if
(
pExpr
==
NULL
)
{
return
TSDB_CODE_SUCCESS
;
}
if
(
!
isExprDirectParentOfLeafNode
(
pExpr
))
{
*
(
*
str
)
=
'('
;
*
str
+=
1
;
int32_t
ret
=
getTagCondString
(
pExpr
->
pLeft
,
str
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
}
relToString
(
pExpr
,
str
);
ret
=
getTagCondString
(
pExpr
->
pRight
,
str
);
*
(
*
str
)
=
')'
;
*
str
+=
1
;
return
ret
;
}
return
tSQLExprLeafToString
(
pExpr
,
true
,
str
);
}
static
int32_t
getTablenameCond
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
,
tSqlExpr
*
pTableCond
,
SStringBuilder
*
sb
)
{
const
char
*
msg0
=
"invalid table name list"
;
const
char
*
msg1
=
"not string following like"
;
...
...
@@ -3483,7 +3317,7 @@ static int32_t getColumnQueryCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSq
return
TSDB_CODE_SUCCESS
;
}
if
(
!
isExprDirectParentOfLeafNode
(
pExpr
))
{
// internal node
if
(
!
tSqlExprIsParentOfLeaf
(
pExpr
))
{
// internal node
int32_t
ret
=
getColumnQueryCondInfo
(
pCmd
,
pQueryInfo
,
pExpr
->
pLeft
,
pExpr
->
tokenId
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
...
...
@@ -3510,7 +3344,7 @@ static int32_t getJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr*
return
TSDB_CODE_SUCCESS
;
}
if
(
!
isExprDirectParentOfLeafNode
(
pExpr
))
{
if
(
!
tSqlExprIsParentOfLeaf
(
pExpr
))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
...
...
@@ -3705,7 +3539,7 @@ static bool isValidExpr(tSqlExpr* pLeft, tSqlExpr* pRight, int32_t optr) {
}
static
void
exchangeExpr
(
tSqlExpr
*
pExpr
)
{
tSqlExpr
*
pLeft
=
pExpr
->
pLeft
;
tSqlExpr
*
pLeft
=
pExpr
->
pLeft
;
tSqlExpr
*
pRight
=
pExpr
->
pRight
;
if
(
pRight
->
tokenId
==
TK_ID
&&
(
pLeft
->
tokenId
==
TK_INTEGER
||
pLeft
->
tokenId
==
TK_FLOAT
||
...
...
@@ -3827,7 +3661,7 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql
const
char
*
msg7
=
"only in/like allowed in filter table name"
;
const
char
*
msg8
=
"wildcard string should be less than 20 characters"
;
tSqlExpr
*
pLeft
=
(
*
pExpr
)
->
pLeft
;
tSqlExpr
*
pLeft
=
(
*
pExpr
)
->
pLeft
;
tSqlExpr
*
pRight
=
(
*
pExpr
)
->
pRight
;
int32_t
ret
=
TSDB_CODE_SUCCESS
;
...
...
@@ -3837,7 +3671,7 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
assert
(
isExprDirectParentOfLeafNode
(
*
pExpr
));
assert
(
tSqlExprIsParentOfLeaf
(
*
pExpr
));
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
index
.
tableIndex
);
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
...
...
@@ -3957,7 +3791,7 @@ int32_t getQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr
int32_t
leftType
=
-
1
;
int32_t
rightType
=
-
1
;
if
(
!
isExprDirectParentOfLeafNode
(
*
pExpr
))
{
if
(
!
tSqlExprIsParentOfLeaf
(
*
pExpr
))
{
int32_t
ret
=
getQueryCondExpr
(
pCmd
,
pQueryInfo
,
&
(
*
pExpr
)
->
pLeft
,
pCondExpr
,
&
leftType
,
(
*
pExpr
)
->
tokenId
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
...
...
@@ -3987,39 +3821,8 @@ int32_t getQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr
return
handleExprInQueryCond
(
pCmd
,
pQueryInfo
,
pExpr
,
pCondExpr
,
type
,
parentOptr
);
}
static
void
doCompactQueryExpr
(
tSqlExpr
**
pExpr
)
{
if
(
*
pExpr
==
NULL
||
isExprDirectParentOfLeafNode
(
*
pExpr
))
{
return
;
}
if
((
*
pExpr
)
->
pLeft
)
{
doCompactQueryExpr
(
&
(
*
pExpr
)
->
pLeft
);
}
if
((
*
pExpr
)
->
pRight
)
{
doCompactQueryExpr
(
&
(
*
pExpr
)
->
pRight
);
}
if
((
*
pExpr
)
->
pLeft
==
NULL
&&
(
*
pExpr
)
->
pRight
==
NULL
&&
((
*
pExpr
)
->
tokenId
==
TK_OR
||
(
*
pExpr
)
->
tokenId
==
TK_AND
))
{
tSqlExprDestroy
(
*
pExpr
);
*
pExpr
=
NULL
;
}
else
if
((
*
pExpr
)
->
pLeft
==
NULL
&&
(
*
pExpr
)
->
pRight
!=
NULL
)
{
tSqlExpr
*
tmpPtr
=
(
*
pExpr
)
->
pRight
;
tSqlExprDestroy
(
*
pExpr
);
(
*
pExpr
)
=
tmpPtr
;
}
else
if
((
*
pExpr
)
->
pRight
==
NULL
&&
(
*
pExpr
)
->
pLeft
!=
NULL
)
{
tSqlExpr
*
tmpPtr
=
(
*
pExpr
)
->
pLeft
;
tSqlExprDestroy
(
*
pExpr
);
(
*
pExpr
)
=
tmpPtr
;
}
}
static
void
doExtractExprForSTable
(
SSqlCmd
*
pCmd
,
tSqlExpr
**
pExpr
,
SQueryInfo
*
pQueryInfo
,
tSqlExpr
**
pOut
,
int32_t
tableIndex
)
{
if
(
isExprDirectParentOfLeafNode
(
*
pExpr
))
{
if
(
tSqlExprIsParentOfLeaf
(
*
pExpr
))
{
tSqlExpr
*
pLeft
=
(
*
pExpr
)
->
pLeft
;
SColumnIndex
index
=
COLUMN_INDEX_INITIALIZER
;
...
...
@@ -4047,7 +3850,7 @@ static tSqlExpr* extractExprForSTable(SSqlCmd* pCmd, tSqlExpr** pExpr, SQueryInf
if
(
*
pExpr
!=
NULL
)
{
doExtractExprForSTable
(
pCmd
,
pExpr
,
pQueryInfo
,
&
pResExpr
,
tableIndex
);
doCompactQueryExpr
(
&
pResExpr
);
tSqlExprCompact
(
&
pResExpr
);
}
return
pResExpr
;
...
...
@@ -4176,7 +3979,7 @@ static int32_t getTimeRangeFromExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlE
return
TSDB_CODE_SUCCESS
;
}
if
(
!
isExprDirectParentOfLeafNode
(
pExpr
))
{
if
(
!
tSqlExprIsParentOfLeaf
(
pExpr
))
{
if
(
pExpr
->
tokenId
==
TK_OR
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
...
...
@@ -4397,7 +4200,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
}
tsSetSTableQueryCond
(
&
pQueryInfo
->
tagCond
,
uid
,
&
bw
);
doCompactQueryExpr
(
pExpr
);
tSqlExprCompact
(
pExpr
);
if
(
ret
==
TSDB_CODE_SUCCESS
)
{
ret
=
validateTagCondExpr
(
pCmd
,
p
);
...
...
@@ -4443,7 +4246,7 @@ int32_t parseWhereClause(SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SSqlObj* pSql
return
ret
;
}
doCompactQueryExpr
(
pExpr
);
tSqlExprCompact
(
pExpr
);
// after expression compact, the expression tree is only include tag query condition
condExpr
.
pTagCond
=
(
*
pExpr
);
...
...
src/query/inc/qSqlparser.h
浏览文件 @
6c3ea16c
...
...
@@ -50,7 +50,8 @@ extern char tTokenTypeSwitcher[13];
} \
} while (0)
#define TPARSER_HAS_TOKEN(_t) ((_t).n > 0)
#define TPARSER_HAS_TOKEN(_t) ((_t).n > 0)
#define TPARSER_SET_NONE_TOKEN(_t) ((_t).n = 0)
typedef
struct
SLimitVal
{
int64_t
limit
;
...
...
@@ -238,6 +239,9 @@ tSqlExpr *tSqlExprCreateFunction(SArray *pParam, SStrToken *pFuncToken, SStrToke
tSqlExpr
*
tSqlExprCreate
(
tSqlExpr
*
pLeft
,
tSqlExpr
*
pRight
,
int32_t
optrType
);
tSqlExpr
*
tSqlExprClone
(
tSqlExpr
*
pSrc
);
void
tSqlExprCompact
(
tSqlExpr
**
pExpr
);
bool
tSqlExprIsLeaf
(
tSqlExpr
*
pExpr
);
bool
tSqlExprIsParentOfLeaf
(
tSqlExpr
*
pExpr
);
void
tSqlExprDestroy
(
tSqlExpr
*
pExpr
);
SArray
*
tSqlExprListAppend
(
SArray
*
pList
,
tSqlExpr
*
pNode
,
SStrToken
*
pDistinct
,
SStrToken
*
pToken
);
void
tSqlExprListDestroy
(
SArray
*
pList
);
...
...
src/query/src/qSqlParser.c
浏览文件 @
6c3ea16c
...
...
@@ -195,7 +195,7 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) {
pExpr
->
type
=
SQL_NODE_EXPR
;
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
.
n
=
(
uint32_t
)(
endPos
-
pExpr
->
token
.
z
);
pExpr
->
token
.
type
=
pLeft
->
token
.
type
;
...
...
@@ -305,8 +305,6 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) {
return
pExpr
;
}
tSqlExpr
*
tSqlExprClone
(
tSqlExpr
*
pSrc
)
{
tSqlExpr
*
pExpr
=
calloc
(
1
,
sizeof
(
tSqlExpr
));
...
...
@@ -322,12 +320,51 @@ tSqlExpr *tSqlExprClone(tSqlExpr *pSrc) {
//we don't clone pParam now because clone is only used for between/and
assert
(
pSrc
->
pParam
==
NULL
);
return
pExpr
;
}
void
tSqlExprCompact
(
tSqlExpr
**
pExpr
)
{
if
(
*
pExpr
==
NULL
||
tSqlExprIsParentOfLeaf
(
*
pExpr
))
{
return
;
}
if
((
*
pExpr
)
->
pLeft
)
{
tSqlExprCompact
(
&
(
*
pExpr
)
->
pLeft
);
}
if
((
*
pExpr
)
->
pRight
)
{
tSqlExprCompact
(
&
(
*
pExpr
)
->
pRight
);
}
void
doDestroySqlExprNode
(
tSqlExpr
*
pExpr
)
{
if
((
*
pExpr
)
->
pLeft
==
NULL
&&
(
*
pExpr
)
->
pRight
==
NULL
&&
((
*
pExpr
)
->
tokenId
==
TK_OR
||
(
*
pExpr
)
->
tokenId
==
TK_AND
))
{
tSqlExprDestroy
(
*
pExpr
);
*
pExpr
=
NULL
;
}
else
if
((
*
pExpr
)
->
pLeft
==
NULL
&&
(
*
pExpr
)
->
pRight
!=
NULL
)
{
tSqlExpr
*
tmpPtr
=
(
*
pExpr
)
->
pRight
;
(
*
pExpr
)
->
pRight
=
NULL
;
tSqlExprDestroy
(
*
pExpr
);
(
*
pExpr
)
=
tmpPtr
;
}
else
if
((
*
pExpr
)
->
pRight
==
NULL
&&
(
*
pExpr
)
->
pLeft
!=
NULL
)
{
tSqlExpr
*
tmpPtr
=
(
*
pExpr
)
->
pLeft
;
(
*
pExpr
)
->
pLeft
=
NULL
;
tSqlExprDestroy
(
*
pExpr
);
(
*
pExpr
)
=
tmpPtr
;
}
}
bool
tSqlExprIsLeaf
(
tSqlExpr
*
pExpr
)
{
return
(
pExpr
->
pRight
==
NULL
&&
pExpr
->
pLeft
==
NULL
)
&&
(
pExpr
->
tokenId
==
0
||
pExpr
->
tokenId
==
TK_ID
||
(
pExpr
->
tokenId
>=
TK_BOOL
&&
pExpr
->
tokenId
<=
TK_NCHAR
)
||
pExpr
->
tokenId
==
TK_SET
);
}
bool
tSqlExprIsParentOfLeaf
(
tSqlExpr
*
pExpr
)
{
return
(
pExpr
->
pLeft
!=
NULL
&&
pExpr
->
pRight
!=
NULL
)
&&
(
tSqlExprIsLeaf
(
pExpr
->
pLeft
)
&&
tSqlExprIsLeaf
(
pExpr
->
pRight
));
}
static
void
doDestroySqlExprNode
(
tSqlExpr
*
pExpr
)
{
if
(
pExpr
==
NULL
)
{
return
;
}
...
...
@@ -548,28 +585,56 @@ void tSetColumnType(TAOS_FIELD *pField, SStrToken *type) {
SQuerySqlNode
*
tSetQuerySqlNode
(
SStrToken
*
pSelectToken
,
SArray
*
pSelectList
,
SArray
*
pFrom
,
tSqlExpr
*
pWhere
,
SArray
*
pGroupby
,
SArray
*
pSortOrder
,
SIntervalVal
*
pInterval
,
SSessionWindowVal
*
pSession
,
SStrToken
*
pSliding
,
SArray
*
pFill
,
SLimitVal
*
pLimit
,
SLimitVal
*
psLimit
)
{
assert
(
pSelectList
!=
NULL
&&
pLimit
!=
NULL
&&
psLimit
!=
NULL
&&
pInterval
!=
NULL
&&
pSliding
!=
NULL
&&
pSession
!=
NULL
);
assert
(
pSelectList
!=
NULL
);
SQuerySqlNode
*
p
Query
=
calloc
(
1
,
sizeof
(
SQuerySqlNode
));
SQuerySqlNode
*
p
SqlNode
=
calloc
(
1
,
sizeof
(
SQuerySqlNode
));
// all later sql string are belonged to the stream sql
pQuery
->
sqlstr
=
*
pSelectToken
;
pQuery
->
sqlstr
.
n
=
(
uint32_t
)
strlen
(
pQuery
->
sqlstr
.
z
);
pQuery
->
pSelectList
=
pSelectList
;
pQuery
->
from
=
pFrom
;
pQuery
->
pGroupby
=
pGroupby
;
pQuery
->
pSortOrder
=
pSortOrder
;
pQuery
->
pWhere
=
pWhere
;
pQuery
->
limit
=
*
pLimit
;
pQuery
->
slimit
=
*
psLimit
;
pQuery
->
interval
=
*
pInterval
;
pQuery
->
sliding
=
*
pSliding
;
pQuery
->
sessionVal
=
*
pSession
;
pQuery
->
fillType
=
pFill
;
return
pQuery
;
pSqlNode
->
sqlstr
=
*
pSelectToken
;
pSqlNode
->
sqlstr
.
n
=
(
uint32_t
)
strlen
(
pSqlNode
->
sqlstr
.
z
);
pSqlNode
->
pSelectList
=
pSelectList
;
pSqlNode
->
from
=
pFrom
;
pSqlNode
->
pGroupby
=
pGroupby
;
pSqlNode
->
pSortOrder
=
pSortOrder
;
pSqlNode
->
pWhere
=
pWhere
;
pSqlNode
->
fillType
=
pFill
;
if
(
pLimit
!=
NULL
)
{
pSqlNode
->
limit
=
*
pLimit
;
}
else
{
pSqlNode
->
limit
.
limit
=
-
1
;
pSqlNode
->
limit
.
offset
=
0
;
}
if
(
psLimit
!=
NULL
)
{
pSqlNode
->
slimit
=
*
psLimit
;
}
else
{
pSqlNode
->
slimit
.
limit
=
-
1
;
pSqlNode
->
slimit
.
offset
=
0
;
}
if
(
pInterval
!=
NULL
)
{
pSqlNode
->
interval
=
*
pInterval
;
}
else
{
TPARSER_SET_NONE_TOKEN
(
pSqlNode
->
interval
.
interval
);
TPARSER_SET_NONE_TOKEN
(
pSqlNode
->
interval
.
offset
);
}
if
(
pSliding
!=
NULL
)
{
pSqlNode
->
sliding
=
*
pSliding
;
}
else
{
TPARSER_SET_NONE_TOKEN
(
pSqlNode
->
sliding
);
}
if
(
pSession
!=
NULL
)
{
pSqlNode
->
sessionVal
=
*
pSession
;
}
else
{
TPARSER_SET_NONE_TOKEN
(
pSqlNode
->
sessionVal
.
gap
);
TPARSER_SET_NONE_TOKEN
(
pSqlNode
->
sessionVal
.
col
);
}
return
pSqlNode
;
}
static
void
freeVariant
(
void
*
pItem
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录