Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5d123801
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看板
提交
5d123801
编写于
1月 13, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-11818] fix bug in select * from super_table.
上级
23b39814
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
631 addition
and
568 deletion
+631
-568
include/libs/planner/planner.h
include/libs/planner/planner.h
+1
-0
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+541
-513
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+1
-1
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+62
-36
source/libs/parser/src/astValidate.c
source/libs/parser/src/astValidate.c
+2
-0
source/libs/planner/src/physicalPlan.c
source/libs/planner/src/physicalPlan.c
+2
-2
source/libs/planner/src/physicalPlanJson.c
source/libs/planner/src/physicalPlanJson.c
+19
-13
source/libs/planner/src/planner.c
source/libs/planner/src/planner.c
+3
-3
未找到文件。
include/libs/planner/planner.h
浏览文件 @
5d123801
...
...
@@ -95,6 +95,7 @@ typedef struct SScanPhyNode {
int8_t
tableType
;
int32_t
order
;
// scan order: TSDB_ORDER_ASC|TSDB_ORDER_DESC
int32_t
count
;
// repeat count
int32_t
reverse
;
// reverse scan count
}
SScanPhyNode
;
typedef
SScanPhyNode
SSystemTableScanPhyNode
;
...
...
source/client/test/clientTests.cpp
浏览文件 @
5d123801
此差异已折叠。
点击以展开。
source/libs/executor/inc/executorimpl.h
浏览文件 @
5d123801
...
...
@@ -542,7 +542,7 @@ typedef struct SOrderOperatorInfo {
void
appendUpstream
(
SOperatorInfo
*
p
,
SOperatorInfo
*
pUpstream
);
SOperatorInfo
*
createDataBlocksOptScanInfo
(
void
*
pTsdbQueryHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
,
int32_t
repeatTime
,
int32_t
reverseTime
);
SOperatorInfo
*
createDataBlocksOptScanInfo
(
void
*
pTsdbQueryHandle
,
int32_t
order
,
int32_t
numOfOutput
,
int32_t
repeatTime
,
int32_t
reverseTime
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createTableScanOperator
(
void
*
pTsdbQueryHandle
,
int32_t
order
,
int32_t
numOfOutput
,
int32_t
repeatTime
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createTableSeqScanOperator
(
void
*
pTsdbQueryHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
);
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
5d123801
...
...
@@ -4844,7 +4844,16 @@ static SSDataBlock* doBlockInfoScan(void* param, bool* newgroup) {
SOperatorInfo
*
createTableScanOperator
(
void
*
pTsdbQueryHandle
,
int32_t
order
,
int32_t
numOfOutput
,
int32_t
repeatTime
,
SExecTaskInfo
*
pTaskInfo
)
{
assert
(
repeatTime
>
0
&&
numOfOutput
>
0
);
STableScanInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
STableScanInfo
));
STableScanInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
STableScanInfo
));
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
tfree
(
pInfo
);
tfree
(
pOperator
);
terrno
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
return
NULL
;
}
pInfo
->
pTsdbReadHandle
=
pTsdbQueryHandle
;
pInfo
->
times
=
repeatTime
;
pInfo
->
reverseTimes
=
0
;
...
...
@@ -4852,7 +4861,6 @@ SOperatorInfo* createTableScanOperator(void* pTsdbQueryHandle, int32_t order, in
pInfo
->
current
=
0
;
pInfo
->
scanFlag
=
MAIN_SCAN
;
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
pOperator
->
name
=
"TableScanOperator"
;
pOperator
->
operatorType
=
OP_TableScan
;
pOperator
->
blockingOptr
=
false
;
...
...
@@ -4866,6 +4874,39 @@ SOperatorInfo* createTableScanOperator(void* pTsdbQueryHandle, int32_t order, in
return
pOperator
;
}
SOperatorInfo
*
createDataBlocksOptScanInfo
(
void
*
pTsdbQueryHandle
,
int32_t
order
,
int32_t
numOfOutput
,
int32_t
repeatTime
,
int32_t
reverseTime
,
SExecTaskInfo
*
pTaskInfo
)
{
assert
(
repeatTime
>
0
);
STableScanInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
STableScanInfo
));
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
tfree
(
pInfo
);
tfree
(
pOperator
);
terrno
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
return
NULL
;
}
pInfo
->
pTsdbReadHandle
=
pTsdbQueryHandle
;
pInfo
->
times
=
repeatTime
;
pInfo
->
reverseTimes
=
reverseTime
;
pInfo
->
order
=
order
;
pInfo
->
current
=
0
;
pInfo
->
scanFlag
=
MAIN_SCAN
;
pOperator
->
name
=
"DataBlocksOptimizedScanOperator"
;
pOperator
->
operatorType
=
OP_DataBlocksOptScan
;
pOperator
->
blockingOptr
=
false
;
pOperator
->
status
=
OP_IN_EXECUTING
;
pOperator
->
info
=
pInfo
;
pOperator
->
numOfOutput
=
numOfOutput
;
pOperator
->
pRuntimeEnv
=
NULL
;
pOperator
->
exec
=
doTableScan
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
return
pOperator
;
}
SOperatorInfo
*
createTableSeqScanOperator
(
void
*
pTsdbQueryHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
)
{
STableScanInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
STableScanInfo
));
...
...
@@ -4973,27 +5014,6 @@ void setTableScanFilterOperatorInfo(STableScanInfo* pTableScanInfo, SOperatorInf
}
SOperatorInfo
*
createDataBlocksOptScanInfo
(
void
*
pTsdbQueryHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
,
int32_t
repeatTime
,
int32_t
reverseTime
)
{
assert
(
repeatTime
>
0
);
STableScanInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
STableScanInfo
));
pInfo
->
pTsdbReadHandle
=
pTsdbQueryHandle
;
pInfo
->
times
=
repeatTime
;
pInfo
->
reverseTimes
=
reverseTime
;
pInfo
->
current
=
0
;
pInfo
->
order
=
pRuntimeEnv
->
pQueryAttr
->
order
.
order
;
SOperatorInfo
*
pOptr
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
pOptr
->
name
=
"DataBlocksOptimizedScanOperator"
;
// pOptr->operatorType = OP_DataBlocksOptScan;
pOptr
->
pRuntimeEnv
=
pRuntimeEnv
;
pOptr
->
blockingOptr
=
false
;
pOptr
->
info
=
pInfo
;
pOptr
->
exec
=
doTableScan
;
return
pOptr
;
}
SArray
*
getOrderCheckColumns
(
STaskAttr
*
pQuery
)
{
int32_t
numOfCols
=
(
pQuery
->
pGroupbyExpr
==
NULL
)
?
0
:
taosArrayGetSize
(
pQuery
->
pGroupbyExpr
->
columnInfo
);
...
...
@@ -7187,10 +7207,13 @@ static SExecTaskInfo* createExecTaskInfo(uint64_t queryId) {
SOperatorInfo
*
doCreateOperatorTreeNode
(
SPhyNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
,
void
*
param
)
{
if
(
pPhyNode
->
pChildren
==
NULL
||
taosArrayGetSize
(
pPhyNode
->
pChildren
)
==
0
)
{
if
(
pPhyNode
->
info
.
type
==
OP_TableScan
)
{
SScanPhyNode
*
pScanPhyNode
=
(
SScanPhyNode
*
)
pPhyNode
;
size_t
numOfCols
=
taosArrayGetSize
(
pPhyNode
->
pTargets
);
SOperatorInfo
*
pOperatorInfo
=
createTableScanOperator
(
param
,
pScanPhyNode
->
order
,
numOfCols
,
pScanPhyNode
->
count
,
pTaskInfo
);
pTaskInfo
->
pRoot
=
pOperatorInfo
;
SScanPhyNode
*
pScanPhyNode
=
(
SScanPhyNode
*
)
pPhyNode
;
size_t
numOfCols
=
taosArrayGetSize
(
pPhyNode
->
pTargets
);
return
createTableScanOperator
(
param
,
pScanPhyNode
->
order
,
numOfCols
,
pScanPhyNode
->
count
,
pTaskInfo
);
}
else
if
(
pPhyNode
->
info
.
type
==
OP_DataBlocksOptScan
)
{
SScanPhyNode
*
pScanPhyNode
=
(
SScanPhyNode
*
)
pPhyNode
;
size_t
numOfCols
=
taosArrayGetSize
(
pPhyNode
->
pTargets
);
return
createDataBlocksOptScanInfo
(
param
,
pScanPhyNode
->
order
,
numOfCols
,
pScanPhyNode
->
count
,
pScanPhyNode
->
reverse
,
pTaskInfo
);
}
else
{
assert
(
0
);
}
...
...
@@ -7199,21 +7222,20 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhyNode* pPhyNode, SExecTaskInfo* pTask
int32_t
doCreateExecTaskInfo
(
SSubplan
*
pPlan
,
SExecTaskInfo
**
pTaskInfo
,
void
*
readerHandle
)
{
STsdbQueryCond
cond
=
{.
loadExternalRows
=
false
};
cond
.
twindow
.
skey
=
INT64_MIN
;
cond
.
twindow
.
ekey
=
INT64_MAX
;
uint64_t
uid
=
0
;
SPhyNode
*
pPhyNode
=
pPlan
->
pNode
;
if
(
pPhyNode
->
info
.
type
==
OP_TableScan
)
{
if
(
pPhyNode
->
info
.
type
==
OP_TableScan
||
pPhyNode
->
info
.
type
==
OP_DataBlocksOptScan
)
{
S
ScanPhyNode
*
pScanNode
=
(
S
ScanPhyNode
*
)
pPhyNode
;
uid
=
p
ScanNode
->
uid
;
cond
.
order
=
p
ScanNode
->
order
;
cond
.
numOfCols
=
taosArrayGetSize
(
p
ScanNode
->
node
.
pTargets
);
S
TableScanPhyNode
*
pTableScanNode
=
(
STable
ScanPhyNode
*
)
pPhyNode
;
uid
=
p
TableScanNode
->
scan
.
uid
;
cond
.
order
=
p
TableScanNode
->
scan
.
order
;
cond
.
numOfCols
=
taosArrayGetSize
(
p
TableScanNode
->
scan
.
node
.
pTargets
);
cond
.
colList
=
calloc
(
cond
.
numOfCols
,
sizeof
(
SColumnInfo
));
cond
.
twindow
=
pTableScanNode
->
window
;
for
(
int32_t
i
=
0
;
i
<
cond
.
numOfCols
;
++
i
)
{
SExprInfo
*
pExprInfo
=
taosArrayGetP
(
p
ScanNode
->
node
.
pTargets
,
i
);
SExprInfo
*
pExprInfo
=
taosArrayGetP
(
p
TableScanNode
->
scan
.
node
.
pTargets
,
i
);
assert
(
pExprInfo
->
pExpr
->
nodeType
==
TEXPR_COL_NODE
);
SSchema
*
pSchema
=
pExprInfo
->
pExpr
->
pSchema
;
...
...
@@ -7235,7 +7257,11 @@ int32_t doCreateExecTaskInfo(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, void* r
*
pTaskInfo
=
createExecTaskInfo
((
uint64_t
)
pPlan
->
id
.
queryId
);
tsdbReadHandleT
tsdbReadHandle
=
tsdbQueryTables
(
readerHandle
,
&
cond
,
&
group
,
(
*
pTaskInfo
)
->
id
.
queryId
,
NULL
);
doCreateOperatorTreeNode
(
pPlan
->
pNode
,
*
pTaskInfo
,
tsdbReadHandle
);
(
*
pTaskInfo
)
->
pRoot
=
doCreateOperatorTreeNode
(
pPlan
->
pNode
,
*
pTaskInfo
,
tsdbReadHandle
);
if
((
*
pTaskInfo
)
->
pRoot
==
NULL
)
{
return
terrno
;
}
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/parser/src/astValidate.c
浏览文件 @
5d123801
...
...
@@ -917,6 +917,8 @@ int32_t validateLimitNode(SQueryStmtInfo *pQueryInfo, SSqlNode* pSqlNode, SMsgBu
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg1
);
}
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
validateOrderbyNode
(
SQueryStmtInfo
*
pQueryInfo
,
SSqlNode
*
pSqlNode
,
SMsgBuf
*
pMsgBuf
)
{
...
...
source/libs/planner/src/physicalPlan.c
浏览文件 @
5d123801
...
...
@@ -262,8 +262,8 @@ static void vgroupMsgToEpSet(const SVgroupMsg* vg, SQueryNodeAddr* execNode) {
}
static
uint64_t
splitSubplanByTable
(
SPlanContext
*
pCxt
,
SQueryPlanNode
*
pPlanNode
,
SQueryTableInfo
*
pTable
)
{
SVgroupsInfo
*
v
groupList
=
pTable
->
pMeta
->
vgroupList
;
for
(
int32_t
i
=
0
;
i
<
p
Table
->
pMeta
->
v
groupList
->
numOfVgroups
;
++
i
)
{
SVgroupsInfo
*
pV
groupList
=
pTable
->
pMeta
->
vgroupList
;
for
(
int32_t
i
=
0
;
i
<
p
V
groupList
->
numOfVgroups
;
++
i
)
{
STORE_CURRENT_SUBPLAN
(
pCxt
);
SSubplan
*
subplan
=
initSubplan
(
pCxt
,
QUERY_TYPE_SCAN
);
subplan
->
msgType
=
TDMT_VND_QUERY
;
...
...
source/libs/planner/src/physicalPlanJson.c
浏览文件 @
5d123801
...
...
@@ -530,32 +530,38 @@ static const char* jkScanNodeTableId = "TableId";
static
const
char
*
jkScanNodeTableType
=
"TableType"
;
static
const
char
*
jkScanNodeTableOrder
=
"Order"
;
static
const
char
*
jkScanNodeTableCount
=
"Count"
;
static
const
char
*
jkScanNodeTableRevCount
=
"Reverse"
;
static
bool
scanNodeToJson
(
const
void
*
obj
,
cJSON
*
json
)
{
const
SScanPhyNode
*
scan
=
(
const
SScanPhyNode
*
)
obj
;
bool
res
=
cJSON_AddNumberToObject
(
json
,
jkScanNodeTableId
,
scan
->
uid
);
const
SScanPhyNode
*
pNode
=
(
const
SScanPhyNode
*
)
obj
;
bool
res
=
cJSON_AddNumberToObject
(
json
,
jkScanNodeTableId
,
pNode
->
uid
);
if
(
res
)
{
res
=
cJSON_AddNumberToObject
(
json
,
jkScanNodeTableType
,
scan
->
tableType
);
res
=
cJSON_AddNumberToObject
(
json
,
jkScanNodeTableType
,
pNode
->
tableType
);
}
if
(
res
)
{
res
=
cJSON_AddNumberToObject
(
json
,
jkScanNodeTableOrder
,
scan
->
order
);
res
=
cJSON_AddNumberToObject
(
json
,
jkScanNodeTableOrder
,
pNode
->
order
);
}
if
(
res
)
{
res
=
cJSON_AddNumberToObject
(
json
,
jkScanNodeTableCount
,
scan
->
count
);
res
=
cJSON_AddNumberToObject
(
json
,
jkScanNodeTableCount
,
pNode
->
count
);
}
if
(
res
)
{
res
=
cJSON_AddNumberToObject
(
json
,
jkScanNodeTableRevCount
,
pNode
->
reverse
);
}
return
res
;
}
static
bool
scanNodeFromJson
(
const
cJSON
*
json
,
void
*
obj
)
{
SScanPhyNode
*
scan
=
(
SScanPhyNode
*
)
obj
;
scan
->
uid
=
getNumber
(
json
,
jkScanNodeTableId
);
scan
->
tableType
=
getNumber
(
json
,
jkScanNodeTableType
);
scan
->
count
=
getNumber
(
json
,
jkScanNodeTableCount
);
scan
->
order
=
getNumber
(
json
,
jkScanNodeTableOrder
);
SScanPhyNode
*
pNode
=
(
SScanPhyNode
*
)
obj
;
pNode
->
uid
=
getNumber
(
json
,
jkScanNodeTableId
);
pNode
->
tableType
=
getNumber
(
json
,
jkScanNodeTableType
);
pNode
->
count
=
getNumber
(
json
,
jkScanNodeTableCount
);
pNode
->
order
=
getNumber
(
json
,
jkScanNodeTableOrder
);
pNode
->
reverse
=
getNumber
(
json
,
jkScanNodeTableRevCount
);
return
true
;
}
...
...
@@ -910,7 +916,7 @@ static SSubplan* subplanFromJson(const cJSON* json) {
}
bool
res
=
fromObject
(
json
,
jkSubplanId
,
subplanIdFromJson
,
&
subplan
->
id
,
true
);
if
(
res
)
{
size_t
size
=
MAX
(
sizeof
(
SPhyNode
),
sizeof
(
SScanPhyNode
));
size_t
size
=
MAX
(
sizeof
(
SPhyNode
),
sizeof
(
S
Table
ScanPhyNode
));
res
=
fromObjectWithAlloc
(
json
,
jkSubplanNode
,
phyNodeFromJson
,
(
void
**
)
&
subplan
->
pNode
,
size
,
false
);
}
if
(
res
)
{
...
...
@@ -940,8 +946,8 @@ int32_t subPlanToString(const SSubplan* subplan, char** str, int32_t* len) {
}
*
str
=
cJSON_Print
(
json
);
// printf("====Physical plan:====\n")
//
printf("%s\n", *str);
printf
(
"====Physical plan:====
\n
"
);
printf
(
"%s
\n
"
,
*
str
);
*
len
=
strlen
(
*
str
)
+
1
;
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/planner/src/planner.c
浏览文件 @
5d123801
...
...
@@ -65,9 +65,9 @@ int32_t qCreateQueryDag(const struct SQueryNode* pNode, struct SQueryDag** pDag,
}
if
(
pLogicPlan
->
info
.
type
!=
QNODE_MODIFY
)
{
//
char* str = NULL;
//
queryPlanToString(pLogicPlan, &str);
//
printf("%s\n", str);
char
*
str
=
NULL
;
queryPlanToString
(
pLogicPlan
,
&
str
);
printf
(
"%s
\n
"
,
str
);
}
code
=
optimizeQueryPlan
(
pLogicPlan
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录