Merge pull request #21754 from taosdata/fix/TD-24832

fix: invalid system table primary key and distinct order by column issue
This commit is contained in:
dapan1121 2023-06-19 13:24:48 +08:00 committed by GitHub
commit 3bd5fbad0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -884,6 +884,10 @@ static int32_t findAndSetColumn(STranslateContext* pCxt, SColumnNode** pColRef,
if (QUERY_NODE_REAL_TABLE == nodeType(pTable)) {
const STableMeta* pMeta = ((SRealTableNode*)pTable)->pMeta;
if (isInternalPrimaryKey(pCol)) {
if (TSDB_SYSTEM_TABLE == pMeta->tableType) {
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMN, pCol->colName);
}
setColumnInfoBySchema((SRealTableNode*)pTable, pMeta->schema, -1, pCol);
*pFound = true;
return TSDB_CODE_SUCCESS;
@ -2255,7 +2259,7 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
}
}
if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) {
if (pSelect->selectFuncNum > 1 || pSelect->hasOtherVectorFunc || !pSelect->hasSelectFunc) {
if (pSelect->selectFuncNum > 1 || pSelect->hasOtherVectorFunc || !pSelect->hasSelectFunc || (isDistinctOrderBy(pCxt) && pCxt->currClause == SQL_CLAUSE_ORDER_BY)) {
return generateDealNodeErrMsg(pCxt, getGroupByErrorCode(pCxt), ((SExprNode*)(*pNode))->userAlias);
} else {
return rewriteColToSelectValFunc(pCxt, pNode);

View File

@ -31,10 +31,10 @@ class TDTestCase:
tdSql.query(f"select histogram(`columns`, 'user_input', '[1, 3, 5]', 0) from `information_schema`.`ins_tables`;")
tdSql.query(f"select hyperloglog(`columns`) from `information_schema`.`ins_tables`;")
tdSql.query(f"select sample(`columns`, 3) from `information_schema`.`ins_tables`;")
tdSql.query(f"select tail(`columns`, 3) from `information_schema`.`ins_tables`;")
tdSql.query(f"select unique(`columns`) from `information_schema`.`ins_tables`;")
tdSql.query(f"select mode(`columns`) from `information_schema`.`ins_tables`;")
tdSql.error(f"select unique(`columns`) from `information_schema`.`ins_tables`;")
tdSql.error(f"select tail(`columns`, 3) from `information_schema`.`ins_tables`;")
tdSql.error(f"select leastsquares(`columns`, 1, 1) from `information_schema`.`ins_tables`;")
tdSql.error(f"select elapsed(`columns`) from `information_schema`.`ins_tables`;")
tdSql.error(f"select interp(`columns`) from `information_schema`.`ins_tables` range(0, 1) every(1s) fill(null);")