Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6ded6e91
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
6ded6e91
编写于
8月 13, 2021
作者:
D
dapan1121
提交者:
GitHub
8月 13, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7257 from taosdata/hotfix/TD-5863
[TD-5863]fix orderby error msg
上级
23e9739c
a410f288
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
14 deletion
+18
-14
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+18
-14
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
6ded6e91
...
...
@@ -5757,10 +5757,15 @@ static void setDefaultOrderInfo(SQueryInfo* pQueryInfo) {
}
int32_t
validateOrderbyNode
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
,
SSqlNode
*
pSqlNode
,
SSchema
*
pSchema
)
{
const
char
*
msg0
=
"only support order by primary timestamp"
;
const
char
*
msg1
=
"invalid column name"
;
const
char
*
msg2
=
"order by primary timestamp, first tag or groupby column in groupby clause allowed"
;
const
char
*
msg3
=
"invalid column in order by clause, only primary timestamp or first tag in groupby clause allowed"
;
const
char
*
msg0
=
"only one column allowed in orderby"
;
const
char
*
msg1
=
"invalid column name in orderby clause"
;
const
char
*
msg2
=
"too many order by columns"
;
const
char
*
msg3
=
"only primary timestamp/tbname/first tag in groupby clause allowed"
;
const
char
*
msg4
=
"only tag in groupby clause allowed in order by"
;
const
char
*
msg5
=
"only primary timestamp/column in top/bottom function allowed as orderby column"
;
const
char
*
msg6
=
"only primary timestamp allowed as the second orderby column"
;
const
char
*
msg7
=
"only primary timestamp/column in groupby clause allowed as orderby column"
;
const
char
*
msg8
=
"only column in groupby clause allowed as orderby column"
;
setDefaultOrderInfo
(
pQueryInfo
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
...
...
@@ -5790,7 +5795,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
}
}
else
{
if
(
size
>
2
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
3
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
2
);
}
}
...
...
@@ -5819,7 +5824,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
// it is a tag column
if
(
pQueryInfo
->
groupbyExpr
.
columnInfo
==
NULL
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
2
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
4
);
}
SColIndex
*
pColIndex
=
taosArrayGet
(
pQueryInfo
->
groupbyExpr
.
columnInfo
,
0
);
if
(
relTagIndex
==
pColIndex
->
colIndex
)
{
...
...
@@ -5865,7 +5870,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
pExpr
=
tscExprGet
(
pQueryInfo
,
1
);
if
(
pExpr
->
base
.
colInfo
.
colIndex
!=
index
.
columnIndex
&&
index
.
columnIndex
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
2
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
5
);
}
tVariantListItem
*
p1
=
taosArrayGet
(
pSqlNode
->
pSortOrder
,
0
);
...
...
@@ -5906,7 +5911,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
}
if
(
index
.
columnIndex
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
2
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
6
);
}
else
{
tVariantListItem
*
p1
=
taosArrayGet
(
pSortorder
,
1
);
pQueryInfo
->
order
.
order
=
p1
->
sortOrder
;
...
...
@@ -5926,7 +5931,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
validOrder
=
(
pColIndex
->
colIndex
==
index
.
columnIndex
);
}
if
(
!
validOrder
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
2
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
7
);
}
tVariantListItem
*
p1
=
taosArrayGet
(
pSqlNode
->
pSortOrder
,
0
);
pQueryInfo
->
groupbyExpr
.
orderIndex
=
pSchema
[
index
.
columnIndex
].
colId
;
...
...
@@ -5940,6 +5945,9 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
if
(
columnInfo
!=
NULL
&&
taosArrayGetSize
(
columnInfo
)
>
0
)
{
SColIndex
*
pColIndex
=
taosArrayGet
(
columnInfo
,
0
);
validOrder
=
(
pColIndex
->
colIndex
==
index
.
columnIndex
);
if
(
!
validOrder
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg8
);
}
}
else
{
/* order of top/bottom query in interval is not valid */
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
0
);
...
...
@@ -5947,15 +5955,11 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
pExpr
=
tscExprGet
(
pQueryInfo
,
1
);
if
(
pExpr
->
base
.
colInfo
.
colIndex
!=
index
.
columnIndex
&&
index
.
columnIndex
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
2
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
5
);
}
validOrder
=
true
;
}
if
(
!
validOrder
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
tVariantListItem
*
pItem
=
taosArrayGet
(
pSqlNode
->
pSortOrder
,
0
);
pQueryInfo
->
order
.
order
=
pItem
->
sortOrder
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录