Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
210e9cdb
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看板
未验证
提交
210e9cdb
编写于
4月 29, 2022
作者:
H
Haojun Liao
提交者:
GitHub
4月 29, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12059 from taosdata/feature/3.0_liaohj
fix(query): avoid to build dummy value column in group by constant value.
上级
27798de8
dda7a598
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
24 addition
and
24 deletion
+24
-24
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+1
-1
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+19
-14
source/dnode/vnode/src/vnd/vnodeQuery.c
source/dnode/vnode/src/vnd/vnodeQuery.c
+0
-5
source/libs/command/inc/commandInt.h
source/libs/command/inc/commandInt.h
+1
-2
source/libs/command/src/explain.c
source/libs/command/src/explain.c
+1
-0
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+1
-1
source/libs/parser/src/parCalcConst.c
source/libs/parser/src/parCalcConst.c
+1
-1
未找到文件。
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
210e9cdb
...
...
@@ -96,7 +96,7 @@ int32_t tsdbUpdateSmaWindow(STsdb* pTsdb, SSubmitReq* pMsg, int64_t version
int32_t
tsdbCreateTSma
(
STsdb
*
pTsdb
,
char
*
pMsg
);
int32_t
tsdbInsertTSmaData
(
STsdb
*
pTsdb
,
int64_t
indexUid
,
const
char
*
msg
);
int
tsdbInsertData
(
STsdb
*
pTsdb
,
int64_t
version
,
SSubmitReq
*
pMsg
,
SSubmitRsp
*
pRsp
);
tsdbReaderT
*
tsdbQueryTables
T
(
STsdb
*
tsdb
,
SQueryTableDataCond
*
pCond
,
STableGroupInfo
*
groupList
,
uint64_t
qId
,
tsdbReaderT
*
tsdbQueryTables
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
STableGroupInfo
*
groupList
,
uint64_t
qId
,
uint64_t
taskId
);
tsdbReaderT
tsdbQueryCacheLastT
(
STsdb
*
tsdb
,
SQueryTableDataCond
*
pCond
,
STableGroupInfo
*
groupList
,
uint64_t
qId
,
void
*
pMemRef
);
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
210e9cdb
...
...
@@ -130,6 +130,7 @@ typedef struct STsdbReadHandle {
SArray
*
prev
;
// previous row which is before than time window
SArray
*
next
;
// next row which is after the query time window
SIOCostSummary
cost
;
STSchema
*
pSchema
;
}
STsdbReadHandle
;
typedef
struct
STableGroupSupporter
{
...
...
@@ -343,14 +344,14 @@ static void setQueryTimewindow(STsdbReadHandle* pTsdbReadHandle, SQueryTableData
}
}
static
STsdbReadHandle
*
tsdbQueryTablesImpl
(
S
Tsdb
*
tsdb
,
SQueryTableDataCond
*
pCond
,
uint64_t
qId
,
uint64_t
taskId
)
{
static
STsdbReadHandle
*
tsdbQueryTablesImpl
(
S
Vnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
uint64_t
qId
,
uint64_t
taskId
)
{
STsdbReadHandle
*
pReadHandle
=
taosMemoryCalloc
(
1
,
sizeof
(
STsdbReadHandle
));
if
(
pReadHandle
==
NULL
)
{
goto
_end
;
}
pReadHandle
->
order
=
pCond
->
order
;
pReadHandle
->
pTsdb
=
t
sdb
;
pReadHandle
->
pTsdb
=
pVnode
->
pT
sdb
;
pReadHandle
->
type
=
TSDB_QUERY_TYPE_ALL
;
pReadHandle
->
cur
.
fid
=
INT32_MIN
;
pReadHandle
->
cur
.
win
=
TSWINDOW_INITIALIZER
;
...
...
@@ -368,7 +369,7 @@ static STsdbReadHandle* tsdbQueryTablesImpl(STsdb* tsdb, SQueryTableDataCond* pC
snprintf
(
buf
,
tListLen
(
buf
),
"TID:0x%"
PRIx64
" QID:0x%"
PRIx64
,
taskId
,
qId
);
pReadHandle
->
idStr
=
strdup
(
buf
);
if
(
tsdbInitReadH
(
&
pReadHandle
->
rhelper
,
(
STsdb
*
)
t
sdb
)
!=
0
)
{
if
(
tsdbInitReadH
(
&
pReadHandle
->
rhelper
,
(
STsdb
*
)
pVnode
->
pT
sdb
)
!=
0
)
{
goto
_end
;
}
...
...
@@ -422,9 +423,10 @@ _end:
return
NULL
;
}
tsdbReaderT
*
tsdbQueryTables
T
(
STsdb
*
tsdb
,
SQueryTableDataCond
*
pCond
,
STableGroupInfo
*
groupList
,
uint64_t
qId
,
tsdbReaderT
*
tsdbQueryTables
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
STableGroupInfo
*
groupList
,
uint64_t
qId
,
uint64_t
taskId
)
{
STsdbReadHandle
*
pTsdbReadHandle
=
tsdbQueryTablesImpl
(
tsdb
,
pCond
,
qId
,
taskId
);
STsdbReadHandle
*
pTsdbReadHandle
=
tsdbQueryTablesImpl
(
pVnode
,
pCond
,
qId
,
taskId
);
if
(
pTsdbReadHandle
==
NULL
)
{
return
NULL
;
}
...
...
@@ -441,6 +443,9 @@ tsdbReaderT* tsdbQueryTablesT(STsdb* tsdb, SQueryTableDataCond* pCond, STableGro
return
NULL
;
}
STableCheckInfo
*
pCheckInfo
=
taosArrayGet
(
pTsdbReadHandle
->
pTableCheckInfo
,
0
);
pTsdbReadHandle
->
pSchema
=
metaGetTbTSchema
(
pVnode
->
pMeta
,
pCheckInfo
->
tableId
,
0
);
tsdbDebug
(
"%p total numOfTable:%"
PRIzu
" in this query, group %"
PRIzu
" %s"
,
pTsdbReadHandle
,
taosArrayGetSize
(
pTsdbReadHandle
->
pTableCheckInfo
),
taosArrayGetSize
(
groupList
->
pGroupList
),
pTsdbReadHandle
->
idStr
);
...
...
@@ -526,7 +531,7 @@ void tsdbResetQueryHandleForNewTable(tsdbReaderT queryHandle, SQueryTableDataCon
// pTsdbReadHandle->next = doFreeColumnInfoData(pTsdbReadHandle->next);
}
tsdbReaderT
tsdbQueryLastRow
(
S
Tsdb
*
tsdb
,
SQueryTableDataCond
*
pCond
,
STableGroupInfo
*
groupList
,
uint64_t
qId
,
tsdbReaderT
tsdbQueryLastRow
(
S
Vnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
STableGroupInfo
*
groupList
,
uint64_t
qId
,
uint64_t
taskId
)
{
pCond
->
twindow
=
updateLastrowForEachGroup
(
groupList
);
...
...
@@ -535,7 +540,7 @@ tsdbReaderT tsdbQueryLastRow(STsdb* tsdb, SQueryTableDataCond* pCond, STableGrou
return
NULL
;
}
STsdbReadHandle
*
pTsdbReadHandle
=
(
STsdbReadHandle
*
)
tsdbQueryTables
T
(
tsdb
,
pCond
,
groupList
,
qId
,
taskId
);
STsdbReadHandle
*
pTsdbReadHandle
=
(
STsdbReadHandle
*
)
tsdbQueryTables
(
pVnode
,
pCond
,
groupList
,
qId
,
taskId
);
if
(
pTsdbReadHandle
==
NULL
)
{
return
NULL
;
}
...
...
@@ -618,7 +623,7 @@ static STableGroupInfo* trimTableGroup(STimeWindow* window, STableGroupInfo* pGr
return
pNew
;
}
tsdbReaderT
tsdbQueryRowsInExternalWindow
(
S
Tsdb
*
tsdb
,
SQueryTableDataCond
*
pCond
,
STableGroupInfo
*
groupList
,
tsdbReaderT
tsdbQueryRowsInExternalWindow
(
S
Vnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
STableGroupInfo
*
groupList
,
uint64_t
qId
,
uint64_t
taskId
)
{
STableGroupInfo
*
pNew
=
trimTableGroup
(
&
pCond
->
twindow
,
groupList
);
...
...
@@ -634,7 +639,7 @@ tsdbReaderT tsdbQueryRowsInExternalWindow(STsdb* tsdb, SQueryTableDataCond* pCon
}
}
STsdbReadHandle
*
pTsdbReadHandle
=
(
STsdbReadHandle
*
)
tsdbQueryTables
T
(
tsdb
,
pCond
,
pNew
,
qId
,
taskId
);
STsdbReadHandle
*
pTsdbReadHandle
=
(
STsdbReadHandle
*
)
tsdbQueryTables
(
pVnode
,
pCond
,
pNew
,
qId
,
taskId
);
pTsdbReadHandle
->
loadExternalRow
=
true
;
pTsdbReadHandle
->
currentLoadExternalRows
=
true
;
...
...
@@ -986,7 +991,7 @@ static int32_t loadBlockInfo(STsdbReadHandle* pTsdbReadHandle, int32_t index, in
pCheckInfo
->
numOfBlocks
=
0
;
STable
table
=
{.
uid
=
pCheckInfo
->
tableId
,
.
tid
=
pCheckInfo
->
tableId
};
table
.
pSchema
=
metaGetTbTSchema
(
REPO_META
(
pTsdbReadHandle
->
pTsdb
),
pCheckInfo
->
tableId
,
0
)
;
table
.
pSchema
=
pTsdbReadHandle
->
pSchema
;
if
(
tsdbSetReadTable
(
&
pTsdbReadHandle
->
rhelper
,
&
table
)
!=
TSDB_CODE_SUCCESS
)
{
code
=
terrno
;
...
...
@@ -1091,22 +1096,21 @@ static int32_t doLoadFileDataBlock(STsdbReadHandle* pTsdbReadHandle, SBlock* pBl
int32_t
slotIndex
)
{
int64_t
st
=
taosGetTimestampUs
();
STSchema
*
pSchema
=
metaGetTbTSchema
(
REPO_META
(
pTsdbReadHandle
->
pTsdb
),
pCheckInfo
->
tableId
,
0
);
int32_t
code
=
tdInitDataCols
(
pTsdbReadHandle
->
pDataCols
,
pSchema
);
int32_t
code
=
tdInitDataCols
(
pTsdbReadHandle
->
pDataCols
,
pTsdbReadHandle
->
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tsdbError
(
"%p failed to malloc buf for pDataCols, %s"
,
pTsdbReadHandle
,
pTsdbReadHandle
->
idStr
);
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
goto
_error
;
}
code
=
tdInitDataCols
(
pTsdbReadHandle
->
rhelper
.
pDCols
[
0
],
pSchema
);
code
=
tdInitDataCols
(
pTsdbReadHandle
->
rhelper
.
pDCols
[
0
],
p
TsdbReadHandle
->
p
Schema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tsdbError
(
"%p failed to malloc buf for rhelper.pDataCols[0], %s"
,
pTsdbReadHandle
,
pTsdbReadHandle
->
idStr
);
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
goto
_error
;
}
code
=
tdInitDataCols
(
pTsdbReadHandle
->
rhelper
.
pDCols
[
1
],
pSchema
);
code
=
tdInitDataCols
(
pTsdbReadHandle
->
rhelper
.
pDCols
[
1
],
p
TsdbReadHandle
->
p
Schema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tsdbError
(
"%p failed to malloc buf for rhelper.pDataCols[1], %s"
,
pTsdbReadHandle
,
pTsdbReadHandle
->
idStr
);
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
...
...
@@ -3292,6 +3296,7 @@ int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT* pTsdbReadHandle, SColumnDat
if
(
pHandle
->
statis
[
i
].
numOfNull
==
-
1
)
{
// set the column data are all NULL
pHandle
->
statis
[
i
].
numOfNull
=
pBlockInfo
->
compBlock
->
numOfRows
;
}
}
int64_t
elapsed
=
taosGetTimestampUs
()
-
stime
;
...
...
source/dnode/vnode/src/vnd/vnodeQuery.c
浏览文件 @
210e9cdb
...
...
@@ -150,11 +150,6 @@ void vnodeGetInfo(SVnode *pVnode, const char **dbname, int32_t *vgId) {
}
// wrapper of tsdb read interface
// TODO: use FORCE_INLINE if possible later
tsdbReaderT
*
tsdbQueryTables
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
STableGroupInfo
*
tableInfoGroup
,
uint64_t
qId
,
uint64_t
taskId
)
{
return
tsdbQueryTablesT
(
pVnode
->
pTsdb
,
pCond
,
tableInfoGroup
,
qId
,
taskId
);
}
tsdbReaderT
tsdbQueryCacheLast
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
STableGroupInfo
*
groupList
,
uint64_t
qId
,
void
*
pMemRef
)
{
#if 0
...
...
source/libs/command/inc/commandInt.h
浏览文件 @
210e9cdb
...
...
@@ -56,10 +56,9 @@ extern "C" {
#define EXPLAIN_ROWS_FORMAT "rows=%" PRIu64
#define EXPLAIN_COLUMNS_FORMAT "columns=%d"
#define EXPLAIN_WIDTH_FORMAT "width=%d"
#define EXPLAIN_TABLE_SCAN_FORMAT "order=[asc|%d desc|%d]"
#define EXPLAIN_GROUPS_FORMAT "groups=%d"
#define EXPLAIN_WIDTH_FORMAT "width=%d"
#define EXPLAIN_LOOPS_FORMAT "loops=%d"
#define EXPLAIN_REVERSE_FORMAT "reverse=%d"
#define EXPLAIN_FUNCTIONS_FORMAT "functions=%d"
#define EXPLAIN_EXECINFO_FORMAT "cost=%" PRIu64 "..%" PRIu64 " rows=%" PRIu64
...
...
source/libs/command/src/explain.c
浏览文件 @
210e9cdb
...
...
@@ -379,6 +379,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
EXPLAIN_ROW_APPEND
(
EXPLAIN_BLANK_FORMAT
);
EXPLAIN_ROW_APPEND
(
EXPLAIN_WIDTH_FORMAT
,
pTblScanNode
->
scan
.
node
.
pOutputDataBlockDesc
->
totalRowSize
);
EXPLAIN_ROW_APPEND
(
EXPLAIN_BLANK_FORMAT
);
EXPLAIN_ROW_APPEND
(
EXPLAIN_TABLE_SCAN_FORMAT
,
pTblScanNode
->
scanSeq
[
0
],
pTblScanNode
->
scanSeq
[
1
]);
EXPLAIN_ROW_APPEND
(
EXPLAIN_RIGHT_PARENTHESIS_FORMAT
);
EXPLAIN_ROW_END
();
QRY_ERR_RET
(
qExplainResAppendRow
(
ctx
,
tbuf
,
tlen
,
level
));
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
210e9cdb
...
...
@@ -6924,7 +6924,7 @@ tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SReadHandle*
code
=
initQueryTableDataCond
(
&
cond
,
pTableScanNode
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
}
#if 0
return tsdbQueryTables(pHandle->reader, &cond, pTableGroupInfo, queryId, taskId);
#endif
...
...
source/libs/parser/src/parCalcConst.c
浏览文件 @
210e9cdb
...
...
@@ -240,7 +240,7 @@ static int32_t calcConstSelect(SCalcConstContext* pCxt, SSelectStmt* pSelect, bo
code
=
calcConstNode
(
&
pSelect
->
pWindow
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
calcConst
List
(
pSelect
->
pGroupByLis
t
);
code
=
calcConst
GroupBy
(
pCxt
,
pSelec
t
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
calcConstSelectCondition
(
pCxt
,
pSelect
,
&
pSelect
->
pHaving
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录