Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
417a29af
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看板
提交
417a29af
编写于
8月 30, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: a plan problem of system table complex query
上级
55f8ff35
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
33 addition
and
23 deletion
+33
-23
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+27
-23
source/libs/planner/test/planSysTbTest.cpp
source/libs/planner/test/planSysTbTest.cpp
+6
-0
未找到文件。
source/libs/planner/src/planLogicCreater.c
浏览文件 @
417a29af
...
...
@@ -197,28 +197,21 @@ static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols
return
SCAN_TYPE_TABLE
;
}
static
SNode
*
create
PrimaryKeyCol
(
uint64_t
tableId
)
{
static
SNode
*
create
FirstCol
(
uint64_t
tableId
,
const
SSchema
*
pSchema
)
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
if
(
NULL
==
pCol
)
{
return
NULL
;
}
pCol
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
pCol
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_TIMESTAMP
].
bytes
;
pCol
->
node
.
resType
.
type
=
pSchema
->
type
;
pCol
->
node
.
resType
.
bytes
=
pSchema
->
bytes
;
pCol
->
tableId
=
tableId
;
pCol
->
colId
=
PRIMARYKEY_TIMESTAMP_COL_ID
;
pCol
->
colId
=
pSchema
->
colId
;
pCol
->
colType
=
COLUMN_TYPE_COLUMN
;
strcpy
(
pCol
->
colName
,
"#primarykey"
);
strcpy
(
pCol
->
colName
,
pSchema
->
name
);
return
(
SNode
*
)
pCol
;
}
static
int32_t
addPrimaryKeyCol
(
uint64_t
tableId
,
SNodeList
**
pCols
)
{
if
(
NULL
==
*
pCols
)
{
*
pCols
=
nodesMakeList
();
if
(
NULL
==
*
pCols
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
static
int32_t
addPrimaryKeyCol
(
uint64_t
tableId
,
const
SSchema
*
pSchema
,
SNodeList
**
pCols
)
{
bool
found
=
false
;
SNode
*
pCol
=
NULL
;
FOREACH
(
pCol
,
*
pCols
)
{
...
...
@@ -229,13 +222,25 @@ static int32_t addPrimaryKeyCol(uint64_t tableId, SNodeList** pCols) {
}
if
(
!
found
)
{
if
(
TSDB_CODE_SUCCESS
!=
nodesListStrictAppend
(
*
pCols
,
createPrimaryKeyCol
(
tableId
)))
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
return
nodesListMakeStrictAppend
(
pCols
,
createFirstCol
(
tableId
,
pSchema
));
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
addSystableFirstCol
(
uint64_t
tableId
,
const
SSchema
*
pSchema
,
SNodeList
**
pCols
)
{
if
(
LIST_LENGTH
(
*
pCols
)
>
0
)
{
return
TSDB_CODE_SUCCESS
;
}
return
nodesListMakeStrictAppend
(
pCols
,
createFirstCol
(
tableId
,
pSchema
));
}
static
int32_t
addDefaultScanCol
(
const
STableMeta
*
pMeta
,
SNodeList
**
pCols
)
{
if
(
TSDB_SYSTEM_TABLE
==
pMeta
->
tableType
)
{
return
addSystableFirstCol
(
pMeta
->
uid
,
pMeta
->
schema
,
pCols
);
}
return
addPrimaryKeyCol
(
pMeta
->
uid
,
pMeta
->
schema
,
pCols
);
}
static
int32_t
makeScanLogicNode
(
SLogicPlanContext
*
pCxt
,
SRealTableNode
*
pRealTable
,
bool
hasRepeatScanFuncs
,
SLogicNode
**
pLogicNode
)
{
SScanLogicNode
*
pScan
=
(
SScanLogicNode
*
)
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_SCAN
);
...
...
@@ -299,8 +304,8 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
pScan
->
hasNormalCols
=
true
;
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
SCAN_TYPE_SYSTEM_TABLE
!=
pScan
->
scanType
)
{
code
=
add
PrimaryKeyCol
(
pScan
->
tableId
,
&
pScan
->
pScanCols
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
add
DefaultScanCol
(
pRealTable
->
pMeta
,
&
pScan
->
pScanCols
);
}
// set output
...
...
@@ -787,10 +792,8 @@ static int32_t createWindowLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
static
EDealRes
needFillValueImpl
(
SNode
*
pNode
,
void
*
pContext
)
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
if
(
COLUMN_TYPE_WINDOW_START
!=
pCol
->
colType
&&
COLUMN_TYPE_WINDOW_END
!=
pCol
->
colType
&&
COLUMN_TYPE_WINDOW_DURATION
!=
pCol
->
colType
&&
COLUMN_TYPE_GROUP_KEY
!=
pCol
->
colType
)
{
if
(
COLUMN_TYPE_WINDOW_START
!=
pCol
->
colType
&&
COLUMN_TYPE_WINDOW_END
!=
pCol
->
colType
&&
COLUMN_TYPE_WINDOW_DURATION
!=
pCol
->
colType
&&
COLUMN_TYPE_GROUP_KEY
!=
pCol
->
colType
)
{
*
(
bool
*
)
pContext
=
true
;
return
DEAL_RES_END
;
}
...
...
@@ -1008,7 +1011,8 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS
int32_t
code
=
nodesCollectColumns
(
pSelect
,
SQL_CLAUSE_PARTITION_BY
,
NULL
,
COLLECT_COL_TYPE_ALL
,
&
pPartition
->
node
.
pTargets
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
==
pPartition
->
node
.
pTargets
)
{
code
=
nodesListMakeStrictAppend
(
&
pPartition
->
node
.
pTargets
,
nodesCloneNode
(
nodesListGetNode
(
pCxt
->
pCurrRoot
->
pTargets
,
0
)));
code
=
nodesListMakeStrictAppend
(
&
pPartition
->
node
.
pTargets
,
nodesCloneNode
(
nodesListGetNode
(
pCxt
->
pCurrRoot
->
pTargets
,
0
)));
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
source/libs/planner/test/planSysTbTest.cpp
浏览文件 @
417a29af
...
...
@@ -32,3 +32,9 @@ TEST_F(PlanSysTableTest, informationSchema) {
run
(
"SELECT * FROM information_schema.ins_databases WHERE name = 'information_schema'"
);
}
TEST_F
(
PlanSysTableTest
,
withAgg
)
{
useDb
(
"root"
,
"information_schema"
);
run
(
"SELECT COUNT(1) FROM ins_users"
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录