fix: last(*)/frist(*), etc. do not return the tag column
This commit is contained in:
parent
24d0fc4515
commit
3dbb5554a5
|
@ -558,11 +558,11 @@ static void setColumnInfoByExpr(STempTableNode* pTable, SExprNode* pExpr, SColum
|
||||||
pCol->node.resType = pExpr->resType;
|
pCol->node.resType = pExpr->resType;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* pTable, SNodeList* pList) {
|
static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* pTable, bool igTags, SNodeList* pList) {
|
||||||
if (QUERY_NODE_REAL_TABLE == nodeType(pTable)) {
|
if (QUERY_NODE_REAL_TABLE == nodeType(pTable)) {
|
||||||
const STableMeta* pMeta = ((SRealTableNode*)pTable)->pMeta;
|
const STableMeta* pMeta = ((SRealTableNode*)pTable)->pMeta;
|
||||||
int32_t nums =
|
int32_t nums = pMeta->tableInfo.numOfColumns +
|
||||||
pMeta->tableInfo.numOfColumns + ((TSDB_SUPER_TABLE == pMeta->tableType) ? pMeta->tableInfo.numOfTags : 0);
|
(igTags ? 0 : ((TSDB_SUPER_TABLE == pMeta->tableType) ? pMeta->tableInfo.numOfTags : 0));
|
||||||
for (int32_t i = 0; i < nums; ++i) {
|
for (int32_t i = 0; i < nums; ++i) {
|
||||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||||
if (NULL == pCol) {
|
if (NULL == pCol) {
|
||||||
|
@ -1934,7 +1934,7 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createAllColumns(STranslateContext* pCxt, SNodeList** pCols) {
|
static int32_t createAllColumns(STranslateContext* pCxt, bool igTags, SNodeList** pCols) {
|
||||||
*pCols = nodesMakeList();
|
*pCols = nodesMakeList();
|
||||||
if (NULL == *pCols) {
|
if (NULL == *pCols) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY);
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
@ -1943,7 +1943,7 @@ static int32_t createAllColumns(STranslateContext* pCxt, SNodeList** pCols) {
|
||||||
size_t nums = taosArrayGetSize(pTables);
|
size_t nums = taosArrayGetSize(pTables);
|
||||||
for (size_t i = 0; i < nums; ++i) {
|
for (size_t i = 0; i < nums; ++i) {
|
||||||
STableNode* pTable = taosArrayGetP(pTables, i);
|
STableNode* pTable = taosArrayGetP(pTables, i);
|
||||||
int32_t code = createColumnsByTable(pCxt, pTable, *pCols);
|
int32_t code = createColumnsByTable(pCxt, pTable, igTags, *pCols);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1980,7 +1980,7 @@ static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) {
|
||||||
return (SNode*)pFunc;
|
return (SNode*)pFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createTableAllCols(STranslateContext* pCxt, SColumnNode* pCol, SNodeList** pOutput) {
|
static int32_t createTableAllCols(STranslateContext* pCxt, SColumnNode* pCol, bool igTags, SNodeList** pOutput) {
|
||||||
STableNode* pTable = NULL;
|
STableNode* pTable = NULL;
|
||||||
int32_t code = findTable(pCxt, pCol->tableAlias, &pTable);
|
int32_t code = findTable(pCxt, pCol->tableAlias, &pTable);
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL == *pOutput) {
|
if (TSDB_CODE_SUCCESS == code && NULL == *pOutput) {
|
||||||
|
@ -1990,7 +1990,7 @@ static int32_t createTableAllCols(STranslateContext* pCxt, SColumnNode* pCol, SN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = createColumnsByTable(pCxt, pTable, *pOutput);
|
code = createColumnsByTable(pCxt, pTable, igTags, *pOutput);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2012,11 +2012,9 @@ static int32_t createMultiResFuncsParas(STranslateContext* pCxt, SNodeList* pSrc
|
||||||
SNode* pPara = NULL;
|
SNode* pPara = NULL;
|
||||||
FOREACH(pPara, pSrcParas) {
|
FOREACH(pPara, pSrcParas) {
|
||||||
if (isStar(pPara)) {
|
if (isStar(pPara)) {
|
||||||
code = createAllColumns(pCxt, &pExprs);
|
code = createAllColumns(pCxt, true, &pExprs);
|
||||||
// The syntax definition ensures that * and other parameters do not appear at the same time
|
|
||||||
break;
|
|
||||||
} else if (isTableStar(pPara)) {
|
} else if (isTableStar(pPara)) {
|
||||||
code = createTableAllCols(pCxt, (SColumnNode*)pPara, &pExprs);
|
code = createTableAllCols(pCxt, (SColumnNode*)pPara, true, &pExprs);
|
||||||
} else {
|
} else {
|
||||||
code = nodesListMakeStrictAppend(&pExprs, nodesCloneNode(pPara));
|
code = nodesListMakeStrictAppend(&pExprs, nodesCloneNode(pPara));
|
||||||
}
|
}
|
||||||
|
@ -2075,7 +2073,7 @@ static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if (isStar(pNode)) {
|
if (isStar(pNode)) {
|
||||||
SNodeList* pCols = NULL;
|
SNodeList* pCols = NULL;
|
||||||
code = createAllColumns(pCxt, &pCols);
|
code = createAllColumns(pCxt, false, &pCols);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
INSERT_LIST(pSelect->pProjectionList, pCols);
|
INSERT_LIST(pSelect->pProjectionList, pCols);
|
||||||
ERASE_NODE(pSelect->pProjectionList);
|
ERASE_NODE(pSelect->pProjectionList);
|
||||||
|
@ -2091,7 +2089,7 @@ static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
}
|
}
|
||||||
} else if (isTableStar(pNode)) {
|
} else if (isTableStar(pNode)) {
|
||||||
SNodeList* pCols = NULL;
|
SNodeList* pCols = NULL;
|
||||||
code = createTableAllCols(pCxt, (SColumnNode*)pNode, &pCols);
|
code = createTableAllCols(pCxt, (SColumnNode*)pNode, false, &pCols);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
INSERT_LIST(pSelect->pProjectionList, pCols);
|
INSERT_LIST(pSelect->pProjectionList, pCols);
|
||||||
ERASE_NODE(pSelect->pProjectionList);
|
ERASE_NODE(pSelect->pProjectionList);
|
||||||
|
|
|
@ -14,7 +14,7 @@ sql_error alter table db.stb MODIFY tag ts int
|
||||||
sql_error alter table db.stb MODIFY tag t2 binary(3)
|
sql_error alter table db.stb MODIFY tag t2 binary(3)
|
||||||
sql_error alter table db.stb MODIFY tag t2 int
|
sql_error alter table db.stb MODIFY tag t2 int
|
||||||
sql_error alter table db.stb MODIFY tag t1 int
|
sql_error alter table db.stb MODIFY tag t1 int
|
||||||
sql create table db.ctb using db.stb tags(101, "12345")
|
sql create table db.ctb using db.stb tags(101, "123")
|
||||||
sql insert into db.ctb values(now, 1, "1234")
|
sql insert into db.ctb values(now, 1, "1234")
|
||||||
|
|
||||||
sql select * from db.stb
|
sql select * from db.stb
|
||||||
|
@ -32,7 +32,7 @@ endi
|
||||||
if $data[0][3] != 101 then
|
if $data[0][3] != 101 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data[0][4] != 1234 then
|
if $data[0][4] != 123 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ sql_error alter table db.stb rename tag ts c3
|
||||||
sql_error alter table db.stb rename tag t2 t1
|
sql_error alter table db.stb rename tag t2 t1
|
||||||
sql_error alter table db.stb rename tag t2 t2
|
sql_error alter table db.stb rename tag t2 t2
|
||||||
sql_error alter table db.stb rename tag t1 t2
|
sql_error alter table db.stb rename tag t1 t2
|
||||||
sql create table db.ctb using db.stb tags(101, "12345")
|
sql create table db.ctb using db.stb tags(101, "123")
|
||||||
sql insert into db.ctb values(now, 1, "1234")
|
sql insert into db.ctb values(now, 1, "1234")
|
||||||
|
|
||||||
sql select * from db.stb
|
sql select * from db.stb
|
||||||
|
@ -32,7 +32,7 @@ endi
|
||||||
if $data[0][3] != 101 then
|
if $data[0][3] != 101 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data[0][4] != 1234 then
|
if $data[0][4] != 123 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ endi
|
||||||
if $data[0][3] != 101 then
|
if $data[0][3] != 101 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data[0][4] != 1234 then
|
if $data[0][4] != 123 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue