Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3ab55496
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1181
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
3ab55496
编写于
3月 21, 2023
作者:
D
dapan1121
提交者:
GitHub
3月 21, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #20561 from taosdata/fix/TS-2891-M
fix: select ins_columns from stb/tb
上级
1056c987
aa4c1cb5
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
96 addition
and
23 deletion
+96
-23
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+1
-0
source/dnode/mnode/impl/src/mndShow.c
source/dnode/mnode/impl/src/mndShow.c
+1
-1
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+22
-2
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+1
-1
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+2
-2
source/libs/executor/src/sysscanoperator.c
source/libs/executor/src/sysscanoperator.c
+40
-17
tests/system-test/0-others/information_schema.py
tests/system-test/0-others/information_schema.py
+29
-0
未找到文件。
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
3ab55496
...
...
@@ -457,6 +457,7 @@ typedef struct {
void
*
pIter
;
SMnode
*
pMnode
;
STableMetaRsp
*
pMeta
;
bool
restore
;
bool
sysDbRsp
;
char
db
[
TSDB_DB_FNAME_LEN
];
char
filterTb
[
TSDB_TABLE_NAME_LEN
];
...
...
source/dnode/mnode/impl/src/mndShow.c
浏览文件 @
3ab55496
...
...
@@ -324,7 +324,7 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) {
pReq
->
info
.
rsp
=
pRsp
;
pReq
->
info
.
rspLen
=
size
;
if
(
rowsRead
==
0
||
rowsRead
<
rowsToRead
)
{
if
(
rowsRead
==
0
||
((
rowsRead
<
rowsToRead
)
&&
!
pShow
->
restore
)
)
{
pRsp
->
completed
=
1
;
mDebug
(
"show:0x%"
PRIx64
", retrieve completed"
,
pShow
->
id
);
mndReleaseShowObj
(
pShow
,
true
);
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
3ab55496
...
...
@@ -3113,9 +3113,18 @@ static int32_t mndRetrieveStbCol(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
char
typeName
[
TSDB_TABLE_FNAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_TO_VARSTR
(
typeName
,
"SUPER_TABLE"
);
bool
fetch
=
pShow
->
restore
?
false
:
true
;
pShow
->
restore
=
false
;
while
(
numOfRows
<
rows
)
{
pShow
->
pIter
=
sdbFetch
(
pSdb
,
SDB_STB
,
pShow
->
pIter
,
(
void
**
)
&
pStb
);
if
(
pShow
->
pIter
==
NULL
)
break
;
if
(
fetch
)
{
pShow
->
pIter
=
sdbFetch
(
pSdb
,
SDB_STB
,
pShow
->
pIter
,
(
void
**
)
&
pStb
);
if
(
pShow
->
pIter
==
NULL
)
break
;
}
else
{
fetch
=
true
;
void
*
pKey
=
taosHashGetKey
(
pShow
->
pIter
,
NULL
);
pStb
=
sdbAcquire
(
pSdb
,
SDB_STB
,
pKey
);
if
(
!
pStb
)
continue
;
}
if
(
pDb
!=
NULL
&&
pStb
->
dbUid
!=
pDb
->
uid
)
{
sdbRelease
(
pSdb
,
pStb
);
...
...
@@ -3129,6 +3138,17 @@ static int32_t mndRetrieveStbCol(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
sdbRelease
(
pSdb
,
pStb
);
continue
;
}
if
((
numOfRows
+
pStb
->
numOfColumns
)
>
rows
)
{
pShow
->
restore
=
true
;
if
(
numOfRows
==
0
)
{
mError
(
"mndRetrieveStbCol failed to get stable cols since buf:%d less than result:%d, stable name:%s, db:%s"
,
rows
,
pStb
->
numOfColumns
,
pStb
->
name
,
pStb
->
db
);
}
sdbRelease
(
pSdb
,
pStb
);
break
;
}
varDataSetLen
(
stbName
,
strlen
(
&
stbName
[
VARSTR_HEADER_SIZE
]));
mDebug
(
"mndRetrieveStbCol get stable cols, stable name:%s, db:%s"
,
pStb
->
name
,
pStb
->
db
);
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
3ab55496
...
...
@@ -157,7 +157,7 @@ typedef struct SMTbCursor SMTbCursor;
SMTbCursor
*
metaOpenTbCursor
(
SMeta
*
pMeta
);
void
metaCloseTbCursor
(
SMTbCursor
*
pTbCur
);
int32_t
metaTbCursorNext
(
SMTbCursor
*
pTbCur
,
ETableType
jumpTableType
);
int32_t
metaTbCursorPrev
(
SMTbCursor
*
pTbCur
);
int32_t
metaTbCursorPrev
(
SMTbCursor
*
pTbCur
,
ETableType
jumpTableType
);
#endif
...
...
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
3ab55496
...
...
@@ -336,7 +336,7 @@ int32_t metaTbCursorNext(SMTbCursor *pTbCur, ETableType jumpTableType) {
return
0
;
}
int32_t
metaTbCursorPrev
(
SMTbCursor
*
pTbCur
)
{
int32_t
metaTbCursorPrev
(
SMTbCursor
*
pTbCur
,
ETableType
jumpTableType
)
{
int
ret
;
void
*
pBuf
;
STbCfg
tbCfg
;
...
...
@@ -350,7 +350,7 @@ int32_t metaTbCursorPrev(SMTbCursor *pTbCur) {
tDecoderClear
(
&
pTbCur
->
mr
.
coder
);
metaGetTableEntryByVersion
(
&
pTbCur
->
mr
,
((
SUidIdxVal
*
)
pTbCur
->
pVal
)[
0
].
version
,
*
(
tb_uid_t
*
)
pTbCur
->
pKey
);
if
(
pTbCur
->
mr
.
me
.
type
==
TSDB_SUPER_TABLE
)
{
if
(
pTbCur
->
mr
.
me
.
type
==
jumpTableType
)
{
continue
;
}
...
...
source/libs/executor/src/sysscanoperator.c
浏览文件 @
3ab55496
...
...
@@ -57,9 +57,11 @@ typedef struct SSysTableScanInfo {
const
char
*
pUser
;
bool
sysInfo
;
bool
showRewrite
;
bool
restore
;
SNode
*
pCondition
;
// db_name filter condition, to discard data that are not in current database
SMTbCursor
*
pCur
;
// cursor for iterate the local table meta store.
SSysTableIndex
*
pIdx
;
// idx for local table meta
SHashObj
*
pSchema
;
SColMatchInfo
matchInfo
;
SName
name
;
SSDataBlock
*
pRes
;
...
...
@@ -514,9 +516,23 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) {
pInfo
->
pCur
=
metaOpenTbCursor
(
pInfo
->
readHandle
.
meta
);
}
SHashObj
*
stableSchema
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
taosHashSetFreeFp
(
stableSchema
,
tDeleteSSchemaWrapperForHash
);
while
((
ret
=
metaTbCursorNext
(
pInfo
->
pCur
,
TSDB_TABLE_MAX
))
==
0
)
{
if
(
pInfo
->
pSchema
==
NULL
)
{
pInfo
->
pSchema
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
HASH_NO_LOCK
);
taosHashSetFreeFp
(
pInfo
->
pSchema
,
tDeleteSSchemaWrapperForHash
);
}
if
(
!
pInfo
->
pCur
||
!
pInfo
->
pSchema
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
qError
(
"sysTableScanUserCols failed since %s"
,
terrstr
(
terrno
));
blockDataDestroy
(
dataBlock
);
pInfo
->
loadInfo
.
totalRows
=
0
;
return
NULL
;
}
int32_t
restore
=
pInfo
->
restore
;
pInfo
->
restore
=
false
;
while
(
restore
||
((
ret
=
metaTbCursorNext
(
pInfo
->
pCur
,
TSDB_TABLE_MAX
))
==
0
))
{
if
(
restore
)
restore
=
false
;
char
typeName
[
TSDB_TABLE_FNAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
char
tableName
[
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
...
...
@@ -524,33 +540,36 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) {
if
(
pInfo
->
pCur
->
mr
.
me
.
type
==
TSDB_SUPER_TABLE
)
{
qDebug
(
"sysTableScanUserCols cursor get super table"
);
void
*
schema
=
taosHashGet
(
stable
Schema
,
&
pInfo
->
pCur
->
mr
.
me
.
uid
,
sizeof
(
int64_t
));
void
*
schema
=
taosHashGet
(
pInfo
->
p
Schema
,
&
pInfo
->
pCur
->
mr
.
me
.
uid
,
sizeof
(
int64_t
));
if
(
schema
==
NULL
)
{
SSchemaWrapper
*
schemaWrapper
=
tCloneSSchemaWrapper
(
&
pInfo
->
pCur
->
mr
.
me
.
stbEntry
.
schemaRow
);
taosHashPut
(
stable
Schema
,
&
pInfo
->
pCur
->
mr
.
me
.
uid
,
sizeof
(
int64_t
),
&
schemaWrapper
,
POINTER_BYTES
);
taosHashPut
(
pInfo
->
p
Schema
,
&
pInfo
->
pCur
->
mr
.
me
.
uid
,
sizeof
(
int64_t
),
&
schemaWrapper
,
POINTER_BYTES
);
}
continue
;
}
else
if
(
pInfo
->
pCur
->
mr
.
me
.
type
==
TSDB_CHILD_TABLE
)
{
qDebug
(
"sysTableScanUserCols cursor get child table"
);
STR_TO_VARSTR
(
typeName
,
"CHILD_TABLE"
);
STR_TO_VARSTR
(
tableName
,
pInfo
->
pCur
->
mr
.
me
.
name
);
int64_t
suid
=
pInfo
->
pCur
->
mr
.
me
.
ctbEntry
.
suid
;
void
*
schema
=
taosHashGet
(
stable
Schema
,
&
pInfo
->
pCur
->
mr
.
me
.
ctbEntry
.
suid
,
sizeof
(
int64_t
));
void
*
schema
=
taosHashGet
(
pInfo
->
p
Schema
,
&
pInfo
->
pCur
->
mr
.
me
.
ctbEntry
.
suid
,
sizeof
(
int64_t
));
if
(
schema
!=
NULL
)
{
schemaRow
=
*
(
SSchemaWrapper
**
)
schema
;
}
else
{
tDecoderClear
(
&
pInfo
->
pCur
->
mr
.
coder
);
int
code
=
metaGetTableEntryByUid
(
&
pInfo
->
pCur
->
mr
,
suid
);
SMetaReader
smrSuperTable
=
{
0
};
metaReaderInit
(
&
smrSuperTable
,
pInfo
->
readHandle
.
meta
,
0
);
int
code
=
metaGetTableEntryByUid
(
&
smrSuperTable
,
suid
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
// terrno has been set by metaGetTableEntryByName, therefore, return directly
qError
(
"sysTableScanUserCols get meta by suid:%"
PRId64
" error, code:%d"
,
suid
,
code
);
metaReaderClear
(
&
smrSuperTable
);
blockDataDestroy
(
dataBlock
);
pInfo
->
loadInfo
.
totalRows
=
0
;
taosHashCleanup
(
stableSchema
);
return
NULL
;
}
schemaRow
=
&
pInfo
->
pCur
->
mr
.
me
.
stbEntry
.
schemaRow
;
SSchemaWrapper
*
schemaWrapper
=
tCloneSSchemaWrapper
(
&
smrSuperTable
.
me
.
stbEntry
.
schemaRow
);
taosHashPut
(
pInfo
->
pSchema
,
&
suid
,
sizeof
(
int64_t
),
&
schemaWrapper
,
POINTER_BYTES
);
schemaRow
=
schemaWrapper
;
metaReaderClear
(
&
smrSuperTable
);
}
}
else
if
(
pInfo
->
pCur
->
mr
.
me
.
type
==
TSDB_NORMAL_TABLE
)
{
qDebug
(
"sysTableScanUserCols cursor get normal table"
);
...
...
@@ -562,20 +581,19 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) {
continue
;
}
sysTableUserColsFillOneTableCols
(
pInfo
,
dbname
,
&
numOfRows
,
dataBlock
,
tableName
,
schemaRow
,
typeName
);
if
(
numOfRows
>=
pOperator
->
resultInfo
.
capacity
)
{
if
((
numOfRows
+
schemaRow
->
nCols
)
>
pOperator
->
resultInfo
.
capacity
)
{
relocateAndFilterSysTagsScanResult
(
pInfo
,
numOfRows
,
dataBlock
,
pOperator
->
exprSupp
.
pFilterInfo
);
numOfRows
=
0
;
pInfo
->
restore
=
true
;
if
(
pInfo
->
pRes
->
info
.
rows
>
0
)
{
break
;
}
}
else
{
sysTableUserColsFillOneTableCols
(
pInfo
,
dbname
,
&
numOfRows
,
dataBlock
,
tableName
,
schemaRow
,
typeName
);
}
}
taosHashCleanup
(
stableSchema
);
if
(
numOfRows
>
0
)
{
relocateAndFilterSysTagsScanResult
(
pInfo
,
numOfRows
,
dataBlock
,
pOperator
->
exprSupp
.
pFilterInfo
);
numOfRows
=
0
;
...
...
@@ -695,7 +713,7 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) {
}
if
((
smrSuperTable
.
me
.
stbEntry
.
schemaTag
.
nCols
+
numOfRows
)
>
pOperator
->
resultInfo
.
capacity
)
{
metaTbCursorPrev
(
pInfo
->
pCur
);
metaTbCursorPrev
(
pInfo
->
pCur
,
TSDB_TABLE_MAX
);
blockFull
=
true
;
}
else
{
sysTableUserTagsFillOneTableTags
(
pInfo
,
&
smrSuperTable
,
&
pInfo
->
pCur
->
mr
,
dbname
,
tableName
,
&
numOfRows
,
...
...
@@ -1789,6 +1807,11 @@ void destroySysScanOperator(void* param) {
pInfo
->
pIdx
=
NULL
;
}
if
(
pInfo
->
pSchema
)
{
taosHashCleanup
(
pInfo
->
pSchema
);
pInfo
->
pSchema
=
NULL
;
}
taosArrayDestroy
(
pInfo
->
matchInfo
.
pList
);
taosMemoryFreeClear
(
pInfo
->
pUser
);
...
...
tests/system-test/0-others/information_schema.py
浏览文件 @
3ab55496
...
...
@@ -101,9 +101,38 @@ class TDTestCase:
tdSql
.
checkEqual
(
i
[
1
],
len
(
self
.
perf_list
))
elif
i
[
0
].
lower
()
==
self
.
dbname
:
tdSql
.
checkEqual
(
i
[
1
],
self
.
tbnum
+
1
)
def
ins_columns_check
(
self
):
tdSql
.
execute
(
'drop database if exists db2'
)
tdSql
.
execute
(
'create database if not exists db2 vgroups 1 replica 1'
)
for
i
in
range
(
5
):
self
.
stb4096
=
'create table db2.stb%d (ts timestamp'
%
(
i
)
for
j
in
range
(
4094
-
i
):
self
.
stb4096
+=
', c%d int'
%
(
j
)
self
.
stb4096
+=
') tags (t1 int)'
tdSql
.
execute
(
self
.
stb4096
)
for
k
in
range
(
10
):
tdSql
.
execute
(
"create table db2.ctb_%d_%dc using db2.stb%d tags(%d)"
%
(
i
,
k
,
i
,
k
))
for
t
in
range
(
2
):
tdSql
.
query
(
f
'select * from information_schema.ins_columns where db_name="db2" and table_type=="SUPER_TABLE"'
)
tdSql
.
checkEqual
(
20465
,
len
(
tdSql
.
queryResult
))
for
t
in
range
(
2
):
tdSql
.
query
(
f
'select * from information_schema.ins_columns where db_name="db2" and table_type=="CHILD_TABLE"'
)
tdSql
.
checkEqual
(
204650
,
len
(
tdSql
.
queryResult
))
for
i
in
range
(
5
):
self
.
ntb4096
=
'create table db2.ntb%d (ts timestamp'
%
(
i
)
for
j
in
range
(
4095
-
i
):
self
.
ntb4096
+=
', c%d binary(10)'
%
(
j
)
self
.
ntb4096
+=
')'
tdSql
.
execute
(
self
.
ntb4096
)
for
t
in
range
(
2
):
tdSql
.
query
(
f
'select * from information_schema.ins_columns where db_name="db2" and table_type=="NORMAL_TABLE"'
)
tdSql
.
checkEqual
(
20470
,
len
(
tdSql
.
queryResult
))
def
run
(
self
):
self
.
prepare_data
()
self
.
count_check
()
self
.
ins_columns_check
()
def
stop
(
self
):
tdSql
.
close
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录