Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
dd2940b8
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看板
未验证
提交
dd2940b8
编写于
3月 15, 2023
作者:
S
Shengliang Guan
提交者:
GitHub
3月 15, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #20463 from taosdata/fix/TS-2883
fix: fix table count operator groupId issue
上级
09ca41b3
397bead0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
134 addition
and
6 deletion
+134
-6
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+26
-6
tests/parallel_test/cases.task
tests/parallel_test/cases.task
+1
-0
tests/script/tsim/query/tableCount.sim
tests/script/tsim/query/tableCount.sim
+107
-0
未找到文件。
source/libs/executor/src/scanoperator.c
浏览文件 @
dd2940b8
...
@@ -3189,7 +3189,7 @@ static SSDataBlock* buildSysDbTableCount(SOperatorInfo* pOperator, STableCountSc
...
@@ -3189,7 +3189,7 @@ static SSDataBlock* buildSysDbTableCount(SOperatorInfo* pOperator, STableCountSc
size_t
perfdbTableNum
;
size_t
perfdbTableNum
;
getPerfDbMeta
(
NULL
,
&
perfdbTableNum
);
getPerfDbMeta
(
NULL
,
&
perfdbTableNum
);
if
(
pSupp
->
groupByDbName
)
{
if
(
pSupp
->
groupByDbName
||
pSupp
->
groupByStbName
)
{
buildSysDbGroupedTableCount
(
pOperator
,
pInfo
,
pSupp
,
pRes
,
infodbTableNum
,
perfdbTableNum
);
buildSysDbGroupedTableCount
(
pOperator
,
pInfo
,
pSupp
,
pRes
,
infodbTableNum
,
perfdbTableNum
);
return
(
pRes
->
info
.
rows
>
0
)
?
pRes
:
NULL
;
return
(
pRes
->
info
.
rows
>
0
)
?
pRes
:
NULL
;
}
else
{
}
else
{
...
@@ -3214,11 +3214,23 @@ static void buildSysDbGroupedTableCount(SOperatorInfo* pOperator, STableCountSca
...
@@ -3214,11 +3214,23 @@ static void buildSysDbGroupedTableCount(SOperatorInfo* pOperator, STableCountSca
STableCountScanSupp
*
pSupp
,
SSDataBlock
*
pRes
,
size_t
infodbTableNum
,
STableCountScanSupp
*
pSupp
,
SSDataBlock
*
pRes
,
size_t
infodbTableNum
,
size_t
perfdbTableNum
)
{
size_t
perfdbTableNum
)
{
if
(
pInfo
->
currGrpIdx
==
0
)
{
if
(
pInfo
->
currGrpIdx
==
0
)
{
uint64_t
groupId
=
calcGroupId
(
TSDB_INFORMATION_SCHEMA_DB
,
strlen
(
TSDB_INFORMATION_SCHEMA_DB
));
uint64_t
groupId
=
0
;
if
(
pSupp
->
groupByDbName
)
{
groupId
=
calcGroupId
(
TSDB_INFORMATION_SCHEMA_DB
,
strlen
(
TSDB_INFORMATION_SCHEMA_DB
));
}
else
{
groupId
=
calcGroupId
(
""
,
0
);
}
pRes
->
info
.
id
.
groupId
=
groupId
;
pRes
->
info
.
id
.
groupId
=
groupId
;
fillTableCountScanDataBlock
(
pSupp
,
TSDB_INFORMATION_SCHEMA_DB
,
""
,
infodbTableNum
,
pRes
);
fillTableCountScanDataBlock
(
pSupp
,
TSDB_INFORMATION_SCHEMA_DB
,
""
,
infodbTableNum
,
pRes
);
}
else
if
(
pInfo
->
currGrpIdx
==
1
)
{
}
else
if
(
pInfo
->
currGrpIdx
==
1
)
{
uint64_t
groupId
=
calcGroupId
(
TSDB_PERFORMANCE_SCHEMA_DB
,
strlen
(
TSDB_PERFORMANCE_SCHEMA_DB
));
uint64_t
groupId
=
0
;
if
(
pSupp
->
groupByDbName
)
{
groupId
=
calcGroupId
(
TSDB_PERFORMANCE_SCHEMA_DB
,
strlen
(
TSDB_PERFORMANCE_SCHEMA_DB
));
}
else
{
groupId
=
calcGroupId
(
""
,
0
);
}
pRes
->
info
.
id
.
groupId
=
groupId
;
pRes
->
info
.
id
.
groupId
=
groupId
;
fillTableCountScanDataBlock
(
pSupp
,
TSDB_PERFORMANCE_SCHEMA_DB
,
""
,
perfdbTableNum
,
pRes
);
fillTableCountScanDataBlock
(
pSupp
,
TSDB_PERFORMANCE_SCHEMA_DB
,
""
,
perfdbTableNum
,
pRes
);
}
else
{
}
else
{
...
@@ -3256,7 +3268,7 @@ static SSDataBlock* buildVnodeDbTableCount(SOperatorInfo* pOperator, STableCount
...
@@ -3256,7 +3268,7 @@ static SSDataBlock* buildVnodeDbTableCount(SOperatorInfo* pOperator, STableCount
tNameFromString
(
&
sn
,
db
,
T_NAME_ACCT
|
T_NAME_DB
);
tNameFromString
(
&
sn
,
db
,
T_NAME_ACCT
|
T_NAME_DB
);
tNameGetDbName
(
&
sn
,
dbName
);
tNameGetDbName
(
&
sn
,
dbName
);
if
(
pSupp
->
groupByDbName
)
{
if
(
pSupp
->
groupByDbName
||
pSupp
->
groupByStbName
)
{
buildVnodeGroupedTableCount
(
pOperator
,
pInfo
,
pSupp
,
pRes
,
vgId
,
dbName
);
buildVnodeGroupedTableCount
(
pOperator
,
pInfo
,
pSupp
,
pRes
,
vgId
,
dbName
);
}
else
{
}
else
{
buildVnodeFilteredTbCount
(
pOperator
,
pInfo
,
pSupp
,
pRes
,
dbName
);
buildVnodeFilteredTbCount
(
pOperator
,
pInfo
,
pSupp
,
pRes
,
dbName
);
...
@@ -3317,7 +3329,10 @@ static void buildVnodeFilteredTbCount(SOperatorInfo* pOperator, STableCountScanO
...
@@ -3317,7 +3329,10 @@ static void buildVnodeFilteredTbCount(SOperatorInfo* pOperator, STableCountScanO
static
void
buildVnodeGroupedNtbTableCount
(
STableCountScanOperatorInfo
*
pInfo
,
STableCountScanSupp
*
pSupp
,
static
void
buildVnodeGroupedNtbTableCount
(
STableCountScanOperatorInfo
*
pInfo
,
STableCountScanSupp
*
pSupp
,
SSDataBlock
*
pRes
,
char
*
dbName
)
{
SSDataBlock
*
pRes
,
char
*
dbName
)
{
char
fullStbName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
char
fullStbName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
snprintf
(
fullStbName
,
TSDB_TABLE_FNAME_LEN
,
"%s.%s"
,
dbName
,
""
);
if
(
pSupp
->
groupByDbName
)
{
snprintf
(
fullStbName
,
TSDB_TABLE_FNAME_LEN
,
"%s.%s"
,
dbName
,
""
);
}
uint64_t
groupId
=
calcGroupId
(
fullStbName
,
strlen
(
fullStbName
));
uint64_t
groupId
=
calcGroupId
(
fullStbName
,
strlen
(
fullStbName
));
pRes
->
info
.
id
.
groupId
=
groupId
;
pRes
->
info
.
id
.
groupId
=
groupId
;
int64_t
ntbNum
=
metaGetNtbNum
(
pInfo
->
readHandle
.
meta
);
int64_t
ntbNum
=
metaGetNtbNum
(
pInfo
->
readHandle
.
meta
);
...
@@ -3332,7 +3347,12 @@ static void buildVnodeGroupedStbTableCount(STableCountScanOperatorInfo* pInfo, S
...
@@ -3332,7 +3347,12 @@ static void buildVnodeGroupedStbTableCount(STableCountScanOperatorInfo* pInfo, S
metaGetTableSzNameByUid
(
pInfo
->
readHandle
.
meta
,
stbUid
,
stbName
);
metaGetTableSzNameByUid
(
pInfo
->
readHandle
.
meta
,
stbUid
,
stbName
);
char
fullStbName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
char
fullStbName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
snprintf
(
fullStbName
,
TSDB_TABLE_FNAME_LEN
,
"%s.%s"
,
dbName
,
stbName
);
if
(
pSupp
->
groupByDbName
)
{
snprintf
(
fullStbName
,
TSDB_TABLE_FNAME_LEN
,
"%s.%s"
,
dbName
,
stbName
);
}
else
{
snprintf
(
fullStbName
,
TSDB_TABLE_FNAME_LEN
,
"%s"
,
stbName
);
}
uint64_t
groupId
=
calcGroupId
(
fullStbName
,
strlen
(
fullStbName
));
uint64_t
groupId
=
calcGroupId
(
fullStbName
,
strlen
(
fullStbName
));
pRes
->
info
.
id
.
groupId
=
groupId
;
pRes
->
info
.
id
.
groupId
=
groupId
;
...
...
tests/parallel_test/cases.task
浏览文件 @
dd2940b8
...
@@ -864,6 +864,7 @@
...
@@ -864,6 +864,7 @@
,,y,script,./test.sh -f tsim/query/forceFill.sim
,,y,script,./test.sh -f tsim/query/forceFill.sim
,,y,script,./test.sh -f tsim/query/emptyTsRange.sim
,,y,script,./test.sh -f tsim/query/emptyTsRange.sim
,,y,script,./test.sh -f tsim/query/partitionby.sim
,,y,script,./test.sh -f tsim/query/partitionby.sim
,,y,script,./test.sh -f tsim/query/tableCount.sim
,,y,script,./test.sh -f tsim/qnode/basic1.sim
,,y,script,./test.sh -f tsim/qnode/basic1.sim
,,y,script,./test.sh -f tsim/snode/basic1.sim
,,y,script,./test.sh -f tsim/snode/basic1.sim
,,y,script,./test.sh -f tsim/mnode/basic1.sim
,,y,script,./test.sh -f tsim/mnode/basic1.sim
...
...
tests/script/tsim/query/tableCount.sim
0 → 100644
浏览文件 @
dd2940b8
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
sql drop database if exists db1;
sql create database db1 vgroups 3;
sql create database db1;
sql use db1;
sql create stable sta (ts timestamp, f1 int, f2 binary(200)) tags(t1 int, t2 int, t3 int);
sql create stable stb (ts timestamp, f1 int, f2 binary(200)) tags(t1 int, t2 int, t3 int);
sql create table tba1 using sta tags(1, 1, 1);
sql create table tba2 using sta tags(2, 2, 2);
sql create table tba3 using sta tags(3, 3, 3);
sql create table tba4 using sta tags(3, 3, 3);
sql create table tba5 using sta tags(3, 3, 3);
sql create table tba6 using sta tags(3, 3, 3);
sql create table tba7 using sta tags(3, 3, 3);
sql create table tba8 using sta tags(3, 3, 3);
sql create table tbb1 using stb tags(4, 4, 4);
sql create table tbb2 using stb tags(5, 5, 5);
sql create table tbb3 using stb tags(6, 6, 6);
sql create table tbb4 using stb tags(4, 4, 4);
sql create table tbb5 using stb tags(5, 5, 5);
sql create table tbb6 using stb tags(6, 6, 6);
sql create table tbb7 using stb tags(7, 7, 7);
sql create table tbb8 using stb tags(8, 8, 8);
sql create table tbn1 (ts timestamp, f1 int);
sql create database db2 vgroups 3;
sql create database db2;
sql use db2;
sql create stable sta (ts timestamp, f1 int, f2 binary(200)) tags(t1 int, t2 int, t3 int);
sql create stable stb (ts timestamp, f1 int, f2 binary(200)) tags(t1 int, t2 int, t3 int);
sql create table tba1 using sta tags(1, 1, 1);
sql create table tba2 using sta tags(2, 2, 2);
sql create table tbb1 using stb tags(4, 4, 4);
sql create table tbb2 using stb tags(5, 5, 5);
sql create table tbb3 using stb tags(6, 6, 6);
sql select count(table_name) from information_schema.ins_tables group by stable_name;
if $rows != 3 then
return -1
endi
sql select count(table_name) from information_schema.ins_tables group by db_name;
if $rows != 4 then
return -1
endi
sql select count(table_name) from information_schema.ins_tables group by db_name, stable_name;
if $rows != 7 then
return -1
endi
sql select stable_name,count(table_name) from information_schema.ins_tables group by stable_name order by stable_name;
if $rows != 3 then
return -1
endi
if $data01 != 30 then
return -1
endi
if $data11 != 10 then
return -1
endi
if $data21 != 11 then
return -1
endi
sql select db_name,count(table_name) from information_schema.ins_tables group by db_name order by db_name;
if $rows != 4 then
return -1
endi
if $data01 != 17 then
return -1
endi
if $data11 != 5 then
return -1
endi
if $data21 != 24 then
return -1
endi
if $data31 != 5 then
return -1
endi
sql select db_name,stable_name,count(table_name) from information_schema.ins_tables group by db_name, stable_name order by db_name, stable_name;
if $rows != 7 then
return -1
endi
if $data02 != 1 then
return -1
endi
if $data12 != 8 then
return -1
endi
if $data22 != 8 then
return -1
endi
if $data32 != 2 then
return -1
endi
if $data42 != 3 then
return -1
endi
if $data52 != 24 then
return -1
endi
if $data62 != 5 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录