Merge pull request #18017 from taosdata/fix/3.0_bugfix_wxy
fix: case when type error
This commit is contained in:
commit
16418afb74
|
@ -1252,6 +1252,19 @@ static bool dataTypeEqual(const SDataType* l, const SDataType* r) {
|
|||
return (l->type == r->type && l->bytes == r->bytes && l->precision == r->precision && l->scale == r->scale);
|
||||
}
|
||||
|
||||
// 0 means equal, 1 means the left shall prevail, -1 means the right shall prevail
|
||||
static int32_t dataTypeComp(const SDataType* l, const SDataType* r) {
|
||||
if (l->type != r->type) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (l->bytes != r->bytes) {
|
||||
return l->bytes > r->bytes ? 1 : -1;
|
||||
}
|
||||
|
||||
return (l->precision == r->precision && l->scale == r->scale) ? 0 : 1;
|
||||
}
|
||||
|
||||
static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
|
||||
if (isMultiResFunc(pOp->pLeft)) {
|
||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pLeft))->aliasName);
|
||||
|
@ -1876,10 +1889,15 @@ static EDealRes translateCaseWhen(STranslateContext* pCxt, SCaseWhenNode* pCaseW
|
|||
}
|
||||
pWhenThen->pWhen = pIsTrue;
|
||||
}
|
||||
if (first) {
|
||||
first = false;
|
||||
if (first || dataTypeComp(&pCaseWhen->node.resType, &((SExprNode*)pNode)->resType) < 0) {
|
||||
pCaseWhen->node.resType = ((SExprNode*)pNode)->resType;
|
||||
} else if (!dataTypeEqual(&pCaseWhen->node.resType, &((SExprNode*)pNode)->resType)) {
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
|
||||
FOREACH(pNode, pCaseWhen->pWhenThenList) {
|
||||
SWhenThenNode* pWhenThen = (SWhenThenNode*)pNode;
|
||||
if (!dataTypeEqual(&pCaseWhen->node.resType, &((SExprNode*)pNode)->resType)) {
|
||||
SNode* pCastFunc = NULL;
|
||||
pCxt->errCode = createCastFunc(pCxt, pWhenThen->pThen, pCaseWhen->node.resType, &pCastFunc);
|
||||
if (TSDB_CODE_SUCCESS != pCxt->errCode) {
|
||||
|
@ -1889,6 +1907,7 @@ static EDealRes translateCaseWhen(STranslateContext* pCxt, SCaseWhenNode* pCaseW
|
|||
pWhenThen->node.resType = pCaseWhen->node.resType;
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL != pCaseWhen->pElse && !dataTypeEqual(&pCaseWhen->node.resType, &((SExprNode*)pCaseWhen->pElse)->resType)) {
|
||||
SNode* pCastFunc = NULL;
|
||||
pCxt->errCode = createCastFunc(pCxt, pCaseWhen->pElse, pCaseWhen->node.resType, &pCastFunc);
|
||||
|
@ -3431,19 +3450,6 @@ static SNode* createSetOperProject(const char* pTableAlias, SNode* pNode) {
|
|||
return (SNode*)pCol;
|
||||
}
|
||||
|
||||
// 0 means equal, 1 means the left shall prevail, -1 means the right shall prevail
|
||||
static int32_t dataTypeComp(const SDataType* l, const SDataType* r) {
|
||||
if (l->type != r->type) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (l->bytes != r->bytes) {
|
||||
return l->bytes > r->bytes ? 1 : -1;
|
||||
}
|
||||
|
||||
return (l->precision == r->precision && l->scale == r->scale) ? 0 : 1;
|
||||
}
|
||||
|
||||
static int32_t translateSetOperProject(STranslateContext* pCxt, SSetOperator* pSetOperator) {
|
||||
SNodeList* pLeftProjections = getProjectList(pSetOperator->pLeft);
|
||||
SNodeList* pRightProjections = getProjectList(pSetOperator->pRight);
|
||||
|
@ -4969,7 +4975,8 @@ static int32_t translateUseDatabase(STranslateContext* pCxt, SUseDatabaseStmt* p
|
|||
SName name = {0};
|
||||
tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName));
|
||||
tNameExtractFullName(&name, usedbReq.db);
|
||||
int32_t code = getDBVgVersion(pCxt, usedbReq.db, &usedbReq.vgVersion, &usedbReq.dbId, &usedbReq.numOfTable, &usedbReq.stateTs);
|
||||
int32_t code =
|
||||
getDBVgVersion(pCxt, usedbReq.db, &usedbReq.vgVersion, &usedbReq.dbId, &usedbReq.numOfTable, &usedbReq.stateTs);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = buildCmdMsg(pCxt, TDMT_MND_USE_DB, (FSerializeFunc)tSerializeSUseDbReq, &usedbReq);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue