Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
aca3da38
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
aca3da38
编写于
5月 23, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:fix json error
上级
e7194116
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
3792 addition
and
3786 deletion
+3792
-3786
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+3792
-3786
未找到文件。
source/libs/parser/src/parTranslater.c
浏览文件 @
aca3da38
/*
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
*
* This program is free software: you can use, redistribute, and/or modify
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
* or later ("AGPL"), as published by the Free Software Foundation.
*
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
* FITNESS FOR A PARTICULAR PURPOSE.
*
*
* You should have received a copy of the GNU Affero General Public License
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "parInt.h"
#include "parInt.h"
...
@@ -292,8 +292,8 @@ static bool isScanPseudoColumnFunc(const SNode* pNode) {
...
@@ -292,8 +292,8 @@ static bool isScanPseudoColumnFunc(const SNode* pNode) {
return
(
QUERY_NODE_FUNCTION
==
nodeType
(
pNode
)
&&
fmIsScanPseudoColumnFunc
(((
SFunctionNode
*
)
pNode
)
->
funcId
));
return
(
QUERY_NODE_FUNCTION
==
nodeType
(
pNode
)
&&
fmIsScanPseudoColumnFunc
(((
SFunctionNode
*
)
pNode
)
->
funcId
));
}
}
static
bool
is
NonstandardSQL
Func
(
const
SNode
*
pNode
)
{
static
bool
is
IndefiniteRows
Func
(
const
SNode
*
pNode
)
{
return
(
QUERY_NODE_FUNCTION
==
nodeType
(
pNode
)
&&
fmIsNonstandardSQL
Func
(((
SFunctionNode
*
)
pNode
)
->
funcId
));
return
(
QUERY_NODE_FUNCTION
==
nodeType
(
pNode
)
&&
fmIsIndefiniteRows
Func
(((
SFunctionNode
*
)
pNode
)
->
funcId
));
}
}
static
bool
isDistinctOrderBy
(
STranslateContext
*
pCxt
)
{
static
bool
isDistinctOrderBy
(
STranslateContext
*
pCxt
)
{
...
@@ -816,7 +816,7 @@ static EDealRes haveAggOrNonstdFunction(SNode* pNode, void* pContext) {
...
@@ -816,7 +816,7 @@ static EDealRes haveAggOrNonstdFunction(SNode* pNode, void* pContext) {
if
(
isAggFunc
(
pNode
))
{
if
(
isAggFunc
(
pNode
))
{
*
((
bool
*
)
pContext
)
=
true
;
*
((
bool
*
)
pContext
)
=
true
;
return
DEAL_RES_END
;
return
DEAL_RES_END
;
}
else
if
(
isNonstandardSQL
Func
(
pNode
))
{
}
else
if
(
isIndefiniteRows
Func
(
pNode
))
{
*
((
bool
*
)
pContext
)
=
true
;
*
((
bool
*
)
pContext
)
=
true
;
return
DEAL_RES_END
;
return
DEAL_RES_END
;
}
}
...
@@ -861,6 +861,15 @@ static bool hasInvalidFuncNesting(SNodeList* pParameterList) {
...
@@ -861,6 +861,15 @@ static bool hasInvalidFuncNesting(SNodeList* pParameterList) {
return
hasInvalidFunc
;
return
hasInvalidFunc
;
}
}
static
int32_t
getFuncInfo
(
STranslateContext
*
pCxt
,
SFunctionNode
*
pFunc
)
{
SFmGetFuncInfoParam
param
=
{.
pCtg
=
pCxt
->
pParseCxt
->
pCatalog
,
.
pRpc
=
pCxt
->
pParseCxt
->
pTransporter
,
.
pMgmtEps
=
&
pCxt
->
pParseCxt
->
mgmtEpSet
,
.
pErrBuf
=
pCxt
->
msgBuf
.
buf
,
.
errBufLen
=
pCxt
->
msgBuf
.
len
};
return
fmGetFuncInfo
(
&
param
,
pFunc
);
}
static
EDealRes
translateFunction
(
STranslateContext
*
pCxt
,
SFunctionNode
*
pFunc
)
{
static
EDealRes
translateFunction
(
STranslateContext
*
pCxt
,
SFunctionNode
*
pFunc
)
{
SNode
*
pParam
=
NULL
;
SNode
*
pParam
=
NULL
;
FOREACH
(
pParam
,
pFunc
->
pParameterList
)
{
FOREACH
(
pParam
,
pFunc
->
pParameterList
)
{
...
@@ -869,12 +878,7 @@ static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc)
...
@@ -869,12 +878,7 @@ static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc)
}
}
}
}
SFmGetFuncInfoParam
param
=
{.
pCtg
=
pCxt
->
pParseCxt
->
pCatalog
,
pCxt
->
errCode
=
getFuncInfo
(
pCxt
,
pFunc
);
.
pRpc
=
pCxt
->
pParseCxt
->
pTransporter
,
.
pMgmtEps
=
&
pCxt
->
pParseCxt
->
mgmtEpSet
,
.
pErrBuf
=
pCxt
->
msgBuf
.
buf
,
.
errBufLen
=
pCxt
->
msgBuf
.
len
};
pCxt
->
errCode
=
fmGetFuncInfo
(
&
param
,
pFunc
);
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
&&
fmIsAggFunc
(
pFunc
->
funcId
))
{
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
&&
fmIsAggFunc
(
pFunc
->
funcId
))
{
if
(
beforeHaving
(
pCxt
->
currClause
))
{
if
(
beforeHaving
(
pCxt
->
currClause
))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION
);
...
@@ -882,7 +886,7 @@ static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc)
...
@@ -882,7 +886,7 @@ static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc)
if
(
hasInvalidFuncNesting
(
pFunc
->
pParameterList
))
{
if
(
hasInvalidFuncNesting
(
pFunc
->
pParameterList
))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_AGG_FUNC_NESTING
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_AGG_FUNC_NESTING
);
}
}
if
(
pCxt
->
pCurrStmt
->
hasNonstdSQL
Func
)
{
if
(
pCxt
->
pCurrStmt
->
hasIndefiniteRows
Func
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_NOT_ALLOWED_FUNC
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_NOT_ALLOWED_FUNC
);
}
}
...
@@ -909,14 +913,15 @@ static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc)
...
@@ -909,14 +913,15 @@ static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc)
}
}
}
}
}
}
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
&&
fmIsNonstandardSQLFunc
(
pFunc
->
funcId
))
{
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
&&
fmIsIndefiniteRowsFunc
(
pFunc
->
funcId
))
{
if
(
SQL_CLAUSE_SELECT
!=
pCxt
->
currClause
||
pCxt
->
pCurrStmt
->
hasNonstdSQLFunc
||
pCxt
->
pCurrStmt
->
hasAggFuncs
)
{
if
(
SQL_CLAUSE_SELECT
!=
pCxt
->
currClause
||
pCxt
->
pCurrStmt
->
hasIndefiniteRowsFunc
||
pCxt
->
pCurrStmt
->
hasAggFuncs
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_NOT_ALLOWED_FUNC
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_NOT_ALLOWED_FUNC
);
}
}
if
(
hasInvalidFuncNesting
(
pFunc
->
pParameterList
))
{
if
(
hasInvalidFuncNesting
(
pFunc
->
pParameterList
))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_AGG_FUNC_NESTING
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_AGG_FUNC_NESTING
);
}
}
pCxt
->
pCurrStmt
->
hasNonstdSQL
Func
=
true
;
pCxt
->
pCurrStmt
->
hasIndefiniteRows
Func
=
true
;
}
}
return
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
?
DEAL_RES_CONTINUE
:
DEAL_RES_ERROR
;
return
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
?
DEAL_RES_CONTINUE
:
DEAL_RES_ERROR
;
}
}
...
@@ -1000,7 +1005,7 @@ static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode
...
@@ -1000,7 +1005,7 @@ static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode
strcpy
(
pFunc
->
node
.
aliasName
,
((
SExprNode
*
)
*
pNode
)
->
aliasName
);
strcpy
(
pFunc
->
node
.
aliasName
,
((
SExprNode
*
)
*
pNode
)
->
aliasName
);
pCxt
->
errCode
=
nodesListMakeAppend
(
&
pFunc
->
pParameterList
,
*
pNode
);
pCxt
->
errCode
=
nodesListMakeAppend
(
&
pFunc
->
pParameterList
,
*
pNode
);
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
)
{
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
)
{
translateFunction
(
pCxt
,
pFunc
);
pCxt
->
errCode
==
getFuncInfo
(
pCxt
,
pFunc
);
}
}
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
)
{
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
)
{
*
pNode
=
(
SNode
*
)
pFunc
;
*
pNode
=
(
SNode
*
)
pFunc
;
...
@@ -1070,7 +1075,7 @@ static int32_t checkExprListForGroupBy(STranslateContext* pCxt, SNodeList* pList
...
@@ -1070,7 +1075,7 @@ static int32_t checkExprListForGroupBy(STranslateContext* pCxt, SNodeList* pList
}
}
static
EDealRes
rewriteColsToSelectValFuncImpl
(
SNode
**
pNode
,
void
*
pContext
)
{
static
EDealRes
rewriteColsToSelectValFuncImpl
(
SNode
**
pNode
,
void
*
pContext
)
{
if
(
isAgg
Func
(
*
pNode
))
{
if
(
isAggFunc
(
*
pNode
)
||
isIndefiniteRows
Func
(
*
pNode
))
{
return
DEAL_RES_IGNORE_CHILD
;
return
DEAL_RES_IGNORE_CHILD
;
}
}
if
(
isScanPseudoColumnFunc
(
*
pNode
)
||
QUERY_NODE_COLUMN
==
nodeType
(
*
pNode
))
{
if
(
isScanPseudoColumnFunc
(
*
pNode
)
||
QUERY_NODE_COLUMN
==
nodeType
(
*
pNode
))
{
...
@@ -1107,7 +1112,7 @@ static EDealRes doCheckAggColCoexist(SNode* pNode, void* pContext) {
...
@@ -1107,7 +1112,7 @@ static EDealRes doCheckAggColCoexist(SNode* pNode, void* pContext) {
pCxt
->
existAggFunc
=
true
;
pCxt
->
existAggFunc
=
true
;
return
DEAL_RES_IGNORE_CHILD
;
return
DEAL_RES_IGNORE_CHILD
;
}
}
if
(
isNonstandardSQL
Func
(
pNode
))
{
if
(
isIndefiniteRows
Func
(
pNode
))
{
pCxt
->
existNonstdFunc
=
true
;
pCxt
->
existNonstdFunc
=
true
;
return
DEAL_RES_IGNORE_CHILD
;
return
DEAL_RES_IGNORE_CHILD
;
}
}
...
@@ -1949,7 +1954,7 @@ static int32_t createCastFunc(STranslateContext* pCxt, SNode* pExpr, SDataType d
...
@@ -1949,7 +1954,7 @@ static int32_t createCastFunc(STranslateContext* pCxt, SNode* pExpr, SDataType d
nodesDestroyNode
(
pFunc
);
nodesDestroyNode
(
pFunc
);
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
DEAL_RES_ERROR
==
translateFunction
(
pCxt
,
pFunc
))
{
if
(
TSDB_CODE_SUCCESS
!=
getFuncInfo
(
pCxt
,
pFunc
))
{
nodesClearList
(
pFunc
->
pParameterList
);
nodesClearList
(
pFunc
->
pParameterList
);
pFunc
->
pParameterList
=
NULL
;
pFunc
->
pParameterList
=
NULL
;
nodesDestroyNode
(
pFunc
);
nodesDestroyNode
(
pFunc
);
...
@@ -4085,10 +4090,11 @@ static int32_t addValToKVRow(STranslateContext* pCxt, SValueNode* pVal, const SS
...
@@ -4085,10 +4090,11 @@ static int32_t addValToKVRow(STranslateContext* pCxt, SValueNode* pVal, const SS
}
}
static
int32_t
createValueFromFunction
(
STranslateContext
*
pCxt
,
SFunctionNode
*
pFunc
,
SValueNode
**
pVal
)
{
static
int32_t
createValueFromFunction
(
STranslateContext
*
pCxt
,
SFunctionNode
*
pFunc
,
SValueNode
**
pVal
)
{
if
(
DEAL_RES_ERROR
==
translateFunction
(
pCxt
,
pFunc
))
{
int32_t
code
=
getFuncInfo
(
pCxt
,
pFunc
);
return
pCxt
->
errCode
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
scalarCalculateConstants
((
SNode
*
)
pFunc
,
(
SNode
**
)
pVal
);
}
}
return
scalarCalculateConstants
((
SNode
*
)
pFunc
,
(
SNode
**
)
pVal
)
;
return
code
;
}
}
static
SDataType
schemaToDataType
(
SSchema
*
pSchema
)
{
static
SDataType
schemaToDataType
(
SSchema
*
pSchema
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录