fix:fix json error
This commit is contained in:
parent
e7194116e7
commit
aca3da385b
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* 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) {
|
||||||
return (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsScanPseudoColumnFunc(((SFunctionNode*)pNode)->funcId));
|
return (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsScanPseudoColumnFunc(((SFunctionNode*)pNode)->funcId));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isNonstandardSQLFunc(const SNode* pNode) {
|
static bool isIndefiniteRowsFunc(const SNode* pNode) {
|
||||||
return (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsNonstandardSQLFunc(((SFunctionNode*)pNode)->funcId));
|
return (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsIndefiniteRowsFunc(((SFunctionNode*)pNode)->funcId));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isDistinctOrderBy(STranslateContext* pCxt) {
|
static bool isDistinctOrderBy(STranslateContext* pCxt) {
|
||||||
|
@ -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 (isNonstandardSQLFunc(pNode)) {
|
} else if (isIndefiniteRowsFunc(pNode)) {
|
||||||
*((bool*)pContext) = true;
|
*((bool*)pContext) = true;
|
||||||
return DEAL_RES_END;
|
return DEAL_RES_END;
|
||||||
}
|
}
|
||||||
|
@ -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(¶m, 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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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(¶m, 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)
|
||||||
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->hasNonstdSQLFunc) {
|
if (pCxt->pCurrStmt->hasIndefiniteRowsFunc) {
|
||||||
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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->hasNonstdSQLFunc = true;
|
pCxt->pCurrStmt->hasIndefiniteRowsFunc = 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
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
static EDealRes rewriteColsToSelectValFuncImpl(SNode** pNode, void* pContext) {
|
static EDealRes rewriteColsToSelectValFuncImpl(SNode** pNode, void* pContext) {
|
||||||
if (isAggFunc(*pNode)) {
|
if (isAggFunc(*pNode) || isIndefiniteRowsFunc(*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) {
|
||||||
pCxt->existAggFunc = true;
|
pCxt->existAggFunc = true;
|
||||||
return DEAL_RES_IGNORE_CHILD;
|
return DEAL_RES_IGNORE_CHILD;
|
||||||
}
|
}
|
||||||
if (isNonstandardSQLFunc(pNode)) {
|
if (isIndefiniteRowsFunc(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
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
|
Loading…
Reference in New Issue