Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7898e576
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
7898e576
编写于
11月 27, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix index is invalidate in master branch
上级
7d5430b3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
25 addition
and
25 deletion
+25
-25
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+25
-25
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
7898e576
...
...
@@ -5621,7 +5621,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
}
SStrToken
columnName
=
{
pVar
->
nLen
,
pVar
->
nType
,
pVar
->
pz
};
SColumnIndex
index
=
COLUMN_INDEX_INITIALIZER
;
SColumnIndex
index
Column
=
COLUMN_INDEX_INITIALIZER
;
bool
udf
=
false
;
if
(
pQueryInfo
->
pUdfInfo
&&
taosArrayGetSize
(
pQueryInfo
->
pUdfInfo
)
>
0
)
{
...
...
@@ -5637,7 +5637,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
}
if
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
// super table query
if
(
getColumnIndexByName
(
&
columnName
,
pQueryInfo
,
&
index
,
tscGetErrorMsgPayload
(
pCmd
))
!=
TSDB_CODE_SUCCESS
)
{
if
(
getColumnIndexByName
(
&
columnName
,
pQueryInfo
,
&
index
Column
,
tscGetErrorMsgPayload
(
pCmd
))
!=
TSDB_CODE_SUCCESS
)
{
return
invalidOperationMsg
(
pMsgBuf
,
msg1
);
}
...
...
@@ -5645,8 +5645,8 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
bool
orderByTS
=
false
;
bool
orderByGroupbyCol
=
false
;
if
(
index
.
columnIndex
>=
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
))
{
// order by tag1
int32_t
relTagIndex
=
index
.
columnIndex
-
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
if
(
index
Column
.
columnIndex
>=
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
))
{
// order by tag1
int32_t
relTagIndex
=
index
Column
.
columnIndex
-
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
// it is a tag column
if
(
pQueryInfo
->
groupbyExpr
.
columnInfo
==
NULL
)
{
...
...
@@ -5656,7 +5656,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
if
(
relTagIndex
==
pColIndex
->
colIndex
)
{
orderByTags
=
true
;
}
}
else
if
(
index
.
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
// order by tbname
}
else
if
(
index
Column
.
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
// order by tbname
// it is a tag column
if
(
pQueryInfo
->
groupbyExpr
.
columnInfo
==
NULL
)
{
return
invalidOperationMsg
(
pMsgBuf
,
msg4
);
...
...
@@ -5665,13 +5665,13 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
if
(
TSDB_TBNAME_COLUMN_INDEX
==
pColIndex
->
colIndex
)
{
orderByTags
=
true
;
}
}
else
if
(
index
.
columnIndex
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
// order by ts
}
else
if
(
index
Column
.
columnIndex
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
// order by ts
orderByTS
=
true
;
}
else
{
// order by normal column
SArray
*
columnInfo
=
pQueryInfo
->
groupbyExpr
.
columnInfo
;
if
(
columnInfo
!=
NULL
&&
taosArrayGetSize
(
columnInfo
)
>
0
)
{
SColIndex
*
pColIndex
=
taosArrayGet
(
columnInfo
,
0
);
if
(
pColIndex
->
colIndex
==
index
.
columnIndex
)
{
if
(
pColIndex
->
colIndex
==
index
Column
.
columnIndex
)
{
orderByGroupbyCol
=
true
;
}
}
...
...
@@ -5687,7 +5687,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
if
(
tscIsDiffDerivQuery
(
pQueryInfo
))
{
return
invalidOperationMsg
(
pMsgBuf
,
msg12
);
}
pQueryInfo
->
groupbyExpr
.
orderIndex
=
index
.
columnIndex
-
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
pQueryInfo
->
groupbyExpr
.
orderIndex
=
index
Column
.
columnIndex
-
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
tVariantListItem
*
p1
=
taosArrayGet
(
pSqlNode
->
pSortOrder
,
0
);
pQueryInfo
->
groupbyExpr
.
orderType
=
p1
->
sortOrder
;
...
...
@@ -5695,7 +5695,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
tVariantListItem
*
p1
=
taosArrayGet
(
pSqlNode
->
pSortOrder
,
0
);
pQueryInfo
->
groupbyExpr
.
orderType
=
p1
->
sortOrder
;
pQueryInfo
->
order
.
orderColId
=
pSchema
[
index
.
columnIndex
].
colId
;
pQueryInfo
->
order
.
orderColId
=
pSchema
[
index
Column
.
columnIndex
].
colId
;
if
(
udf
)
{
return
invalidOperationMsg
(
pMsgBuf
,
msg11
);
}
...
...
@@ -5709,13 +5709,13 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
pExpr
=
tscExprGet
(
pQueryInfo
,
pos
);
if
(
pExpr
->
base
.
colInfo
.
colIndex
!=
index
.
columnIndex
&&
index
.
columnIndex
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
if
(
pExpr
->
base
.
colInfo
.
colIndex
!=
index
Column
.
columnIndex
&&
indexColumn
.
columnIndex
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
return
invalidOperationMsg
(
pMsgBuf
,
msg5
);
}
tVariantListItem
*
p1
=
taosArrayGet
(
pSqlNode
->
pSortOrder
,
0
);
pQueryInfo
->
order
.
order
=
p1
->
sortOrder
;
pQueryInfo
->
order
.
orderColId
=
pSchema
[
index
.
columnIndex
].
colId
;
pQueryInfo
->
order
.
orderColId
=
pSchema
[
index
Column
.
columnIndex
].
colId
;
return
TSDB_CODE_SUCCESS
;
}
else
{
tVariantListItem
*
p1
=
taosArrayGet
(
pSqlNode
->
pSortOrder
,
0
);
...
...
@@ -5746,11 +5746,11 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
}
else
{
tVariantListItem
*
pItem
=
taosArrayGet
(
pSqlNode
->
pSortOrder
,
0
);
if
(
orderByTags
)
{
pQueryInfo
->
groupbyExpr
.
orderIndex
=
index
.
columnIndex
-
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
pQueryInfo
->
groupbyExpr
.
orderIndex
=
index
Column
.
columnIndex
-
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
pQueryInfo
->
groupbyExpr
.
orderType
=
pItem
->
sortOrder
;
}
else
if
(
orderByGroupbyCol
){
pQueryInfo
->
order
.
order
=
pItem
->
sortOrder
;
pQueryInfo
->
order
.
orderColId
=
index
.
columnIndex
;
pQueryInfo
->
order
.
orderColId
=
index
Column
.
columnIndex
;
if
(
udf
)
{
return
invalidOperationMsg
(
pMsgBuf
,
msg11
);
}
...
...
@@ -5765,11 +5765,11 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
pItem
=
taosArrayGet
(
pSqlNode
->
pSortOrder
,
1
);
tVariant
*
pVar2
=
&
pItem
->
pVar
;
SStrToken
cname
=
{
pVar2
->
nLen
,
pVar2
->
nType
,
pVar2
->
pz
};
if
(
getColumnIndexByName
(
&
cname
,
pQueryInfo
,
&
index
,
tscGetErrorMsgPayload
(
pCmd
))
!=
TSDB_CODE_SUCCESS
)
{
if
(
getColumnIndexByName
(
&
cname
,
pQueryInfo
,
&
index
Column
,
tscGetErrorMsgPayload
(
pCmd
))
!=
TSDB_CODE_SUCCESS
)
{
return
invalidOperationMsg
(
pMsgBuf
,
msg1
);
}
if
(
index
.
columnIndex
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
if
(
index
Column
.
columnIndex
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
return
invalidOperationMsg
(
pMsgBuf
,
msg6
);
}
else
{
tVariantListItem
*
p1
=
taosArrayGet
(
pSortOrder
,
1
);
...
...
@@ -5779,16 +5779,16 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
}
}
else
if
(
UTIL_TABLE_IS_NORMAL_TABLE
(
pTableMetaInfo
)
||
UTIL_TABLE_IS_CHILD_TABLE
(
pTableMetaInfo
))
{
// check order by clause for normal table & temp table
if
(
getColumnIndexByName
(
&
columnName
,
pQueryInfo
,
&
index
,
pMsgBuf
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
getColumnIndexByName
(
&
columnName
,
pQueryInfo
,
&
index
Column
,
pMsgBuf
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidOperationMsg
(
pMsgBuf
,
msg1
);
}
if
(
index
.
columnIndex
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
&&
!
isTopBottomQuery
(
pQueryInfo
))
{
if
(
index
Column
.
columnIndex
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
&&
!
isTopBottomQuery
(
pQueryInfo
))
{
bool
validOrder
=
false
;
SArray
*
columnInfo
=
pQueryInfo
->
groupbyExpr
.
columnInfo
;
if
(
columnInfo
!=
NULL
&&
taosArrayGetSize
(
columnInfo
)
>
0
)
{
SColIndex
*
pColIndex
=
taosArrayGet
(
columnInfo
,
0
);
validOrder
=
(
pColIndex
->
colIndex
==
index
.
columnIndex
);
validOrder
=
(
pColIndex
->
colIndex
==
index
Column
.
columnIndex
);
}
if
(
!
validOrder
)
{
...
...
@@ -5804,7 +5804,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
}
tVariantListItem
*
p1
=
taosArrayGet
(
pSqlNode
->
pSortOrder
,
0
);
pQueryInfo
->
groupbyExpr
.
orderIndex
=
pSchema
[
index
.
columnIndex
].
colId
;
pQueryInfo
->
groupbyExpr
.
orderIndex
=
pSchema
[
index
Column
.
columnIndex
].
colId
;
pQueryInfo
->
groupbyExpr
.
orderType
=
p1
->
sortOrder
;
}
...
...
@@ -5813,7 +5813,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
if
(
columnInfo
!=
NULL
&&
taosArrayGetSize
(
columnInfo
)
>
0
)
{
SColIndex
*
pColIndex
=
taosArrayGet
(
columnInfo
,
0
);
if
(
pColIndex
->
colIndex
!=
index
.
columnIndex
)
{
if
(
pColIndex
->
colIndex
!=
index
Column
.
columnIndex
)
{
return
invalidOperationMsg
(
pMsgBuf
,
msg8
);
}
}
else
{
...
...
@@ -5824,7 +5824,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
pExpr
=
tscExprGet
(
pQueryInfo
,
pos
);
if
(
pExpr
->
base
.
colInfo
.
colIndex
!=
index
.
columnIndex
&&
index
.
columnIndex
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
if
(
pExpr
->
base
.
colInfo
.
colIndex
!=
index
Column
.
columnIndex
&&
indexColumn
.
columnIndex
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
return
invalidOperationMsg
(
pMsgBuf
,
msg5
);
}
}
...
...
@@ -5832,7 +5832,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
tVariantListItem
*
pItem
=
taosArrayGet
(
pSqlNode
->
pSortOrder
,
0
);
pQueryInfo
->
order
.
order
=
pItem
->
sortOrder
;
pQueryInfo
->
order
.
orderColId
=
pSchema
[
index
.
columnIndex
].
colId
;
pQueryInfo
->
order
.
orderColId
=
pSchema
[
index
Column
.
columnIndex
].
colId
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -5842,13 +5842,13 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
tVariantListItem
*
pItem
=
taosArrayGet
(
pSqlNode
->
pSortOrder
,
0
);
pQueryInfo
->
order
.
order
=
pItem
->
sortOrder
;
pQueryInfo
->
order
.
orderColId
=
pSchema
[
index
.
columnIndex
].
colId
;
pQueryInfo
->
order
.
orderColId
=
pSchema
[
index
Column
.
columnIndex
].
colId
;
}
else
{
// handle the temp table order by clause. You can order by any single column in case of the temp table, created by
// inner subquery.
assert
(
UTIL_TABLE_IS_TMP_TABLE
(
pTableMetaInfo
)
&&
taosArrayGetSize
(
pSqlNode
->
pSortOrder
)
==
1
);
if
(
getColumnIndexByName
(
&
columnName
,
pQueryInfo
,
&
index
,
pMsgBuf
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
getColumnIndexByName
(
&
columnName
,
pQueryInfo
,
&
index
Column
,
pMsgBuf
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidOperationMsg
(
pMsgBuf
,
msg1
);
}
...
...
@@ -5858,7 +5858,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
tVariantListItem
*
pItem
=
taosArrayGet
(
pSqlNode
->
pSortOrder
,
0
);
pQueryInfo
->
order
.
order
=
pItem
->
sortOrder
;
pQueryInfo
->
order
.
orderColId
=
pSchema
[
index
.
columnIndex
].
colId
;
pQueryInfo
->
order
.
orderColId
=
pSchema
[
index
Column
.
columnIndex
].
colId
;
}
return
TSDB_CODE_SUCCESS
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录