未验证 提交 5259aa13 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #18508 from taosdata/fix/3.0_bugfix_wxy

fix: select null error
......@@ -270,10 +270,10 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbFName, S
"CREATE DATABASE `%s` BUFFER %d CACHESIZE %d CACHEMODEL '%s' COMP %d DURATION %dm "
"WAL_FSYNC_PERIOD %d MAXROWS %d MINROWS %d KEEP %dm,%dm,%dm PAGES %d PAGESIZE %d PRECISION '%s' REPLICA %d "
"STRICT '%s' WAL_LEVEL %d VGROUPS %d SINGLE_STABLE %d",
dbFName, pCfg->buffer, pCfg->cacheSize, cacheModelStr(pCfg->cacheLast), pCfg->compression, pCfg->daysPerFile, pCfg->walFsyncPeriod,
pCfg->maxRows, pCfg->minRows, pCfg->daysToKeep0, pCfg->daysToKeep1, pCfg->daysToKeep2, pCfg->pages,
pCfg->pageSize, prec, pCfg->replications, strictStr(pCfg->strict), pCfg->walLevel, pCfg->numOfVgroups,
1 == pCfg->numOfStables);
dbFName, pCfg->buffer, pCfg->cacheSize, cacheModelStr(pCfg->cacheLast), pCfg->compression, pCfg->daysPerFile,
pCfg->walFsyncPeriod, pCfg->maxRows, pCfg->minRows, pCfg->daysToKeep0, pCfg->daysToKeep1, pCfg->daysToKeep2,
pCfg->pages, pCfg->pageSize, prec, pCfg->replications, strictStr(pCfg->strict), pCfg->walLevel,
pCfg->numOfVgroups, 1 == pCfg->numOfStables);
if (retentions) {
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, " RETENTIONS %s", retentions);
......@@ -500,8 +500,8 @@ static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, SDbCfgInfo* p
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
return terrno;
}
int32_t len = 0;
int32_t len = 0;
if (TSDB_SUPER_TABLE == pCfg->tableType) {
len += sprintf(buf2 + VARSTR_HEADER_SIZE, "CREATE STABLE `%s` (", tbName);
......@@ -533,7 +533,7 @@ static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, SDbCfgInfo* p
colDataAppend(pCol2, 0, buf2, false);
taosMemoryFree(buf2);
return TSDB_CODE_SUCCESS;
}
......@@ -691,9 +691,15 @@ static int32_t createSelectResultDataBlock(SNodeList* pProjects, SSDataBlock** p
SNode* pProj = NULL;
FOREACH(pProj, pProjects) {
SExprNode* pExpr = (SExprNode*)pProj;
SColumnInfoData infoData = {0};
infoData.info.type = ((SExprNode*)pProj)->resType.type;
infoData.info.bytes = ((SExprNode*)pProj)->resType.bytes;
if (TSDB_DATA_TYPE_NULL == pExpr->resType.type) {
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
infoData.info.bytes = 0;
} else {
infoData.info.type = pExpr->resType.type;
infoData.info.bytes = pExpr->resType.bytes;
}
blockDataAppendColInfo(pBlock, &infoData);
}
*pOutput = pBlock;
......
......@@ -654,7 +654,7 @@ cgroup_name(A) ::= NK_ID(B).
/************************************************ expression **********************************************************/
expr_or_subquery(A) ::= expression(B). { A = B; }
expr_or_subquery(A) ::= subquery(B). { A = B; }
//expr_or_subquery(A) ::= subquery(B). { A = createTempTableNode(pCxt, releaseRawExprNode(pCxt, B), NULL); }
expression(A) ::= literal(B). { A = B; }
expression(A) ::= pseudo_column(B). { A = B; }
......
......@@ -372,14 +372,42 @@ static bool isEmptyResultQuery(SNode* pStmt) {
return isEmptyResult;
}
static void resetProjectNullTypeImpl(SNodeList* pProjects) {
SNode* pProj = NULL;
FOREACH(pProj, pProjects) {
SExprNode* pExpr = (SExprNode*)pProj;
if (TSDB_DATA_TYPE_NULL == pExpr->resType.type) {
pExpr->resType.type = TSDB_DATA_TYPE_VARCHAR;
pExpr->resType.bytes = 0;
}
}
}
static void resetProjectNullType(SNode* pStmt) {
switch (nodeType(pStmt)) {
case QUERY_NODE_SELECT_STMT:
resetProjectNullTypeImpl(((SSelectStmt*)pStmt)->pProjectionList);
break;
case QUERY_NODE_SET_OPERATOR: {
resetProjectNullTypeImpl(((SSetOperator*)pStmt)->pProjectionList);
break;
}
default:
break;
}
}
int32_t calculateConstant(SParseContext* pParseCxt, SQuery* pQuery) {
SCalcConstContext cxt = {.pParseCxt = pParseCxt,
.msgBuf.buf = pParseCxt->pMsg,
.msgBuf.len = pParseCxt->msgLen,
.code = TSDB_CODE_SUCCESS};
int32_t code = calcConstQuery(&cxt, pQuery->pRoot, false);
if (TSDB_CODE_SUCCESS == code && isEmptyResultQuery(pQuery->pRoot)) {
pQuery->execMode = QUERY_EXEC_MODE_EMPTY_RESULT;
if (TSDB_CODE_SUCCESS == code) {
resetProjectNullType(pQuery->pRoot);
if (isEmptyResultQuery(pQuery->pRoot)) {
pQuery->execMode = QUERY_EXEC_MODE_EMPTY_RESULT;
}
}
return code;
}
因为 它太大了无法显示 source diff 。你可以改为 查看blob
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册