fix:avoid put tag to select if where condition is always true or false

This commit is contained in:
wangmm0220 2023-05-30 16:50:20 +08:00
parent 689ee05527
commit b8a4df4146
1 changed files with 5 additions and 5 deletions

View File

@ -5899,15 +5899,15 @@ static int32_t checkCollectTopicTags(STranslateContext* pCxt, SCreateTopicStmt*
nodesDestroyList(colCxt.pTags); nodesDestroyList(colCxt.pTags);
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, "Columns are forbidden in where clause"); return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, "Columns are forbidden in where clause");
} }
if (NULL == colCxt.pTags) { if (NULL == colCxt.pTags) { // put one column to select
for (int32_t i = 0; i < pMeta->tableInfo.numOfTags; ++i) { // for (int32_t i = 0; i < pMeta->tableInfo.numOfColumns; ++i) {
SSchema* tag = &pMeta->schema[pMeta->tableInfo.numOfColumns + i]; SSchema* column = &pMeta->schema[0];
SColumnNode* col = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); SColumnNode* col = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
strcpy(col->colName, tag->name); strcpy(col->colName, column->name);
strcpy(col->node.aliasName, col->colName); strcpy(col->node.aliasName, col->colName);
strcpy(col->node.userAlias, col->colName); strcpy(col->node.userAlias, col->colName);
addTagList(&colCxt.pTags, (SNode*)col); addTagList(&colCxt.pTags, (SNode*)col);
} // }
} }
*ppProjection = colCxt.pTags; *ppProjection = colCxt.pTags;