Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
164a80e9
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看板
未验证
提交
164a80e9
编写于
12月 30, 2021
作者:
H
Haojun Liao
提交者:
GitHub
12月 30, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #9511 from taosdata/feature/3.0_liaohj
[td-11818] show tables;
上级
d94f2c32
0e8676ab
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
115 addition
and
39 deletion
+115
-39
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+25
-2
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+36
-36
source/dnode/vnode/impl/src/vnodeQuery.c
source/dnode/vnode/impl/src/vnodeQuery.c
+54
-1
未找到文件。
source/client/src/clientImpl.c
浏览文件 @
164a80e9
...
...
@@ -502,8 +502,31 @@ void* doFetchRow(SRequestObj* pRequest) {
pRequest
->
type
=
TDMT_MND_SHOW_RETRIEVE
;
}
else
if
(
pRequest
->
type
==
TDMT_VND_SHOW_TABLES
)
{
pRequest
->
type
=
TDMT_VND_SHOW_TABLES_FETCH
;
}
else
{
// do nothing
}
else
if
(
pRequest
->
type
==
TDMT_VND_SHOW_TABLES_FETCH
)
{
pRequest
->
type
=
TDMT_VND_SHOW_TABLES
;
SShowReqInfo
*
pShowReqInfo
=
&
pRequest
->
body
.
showInfo
;
pShowReqInfo
->
currentIndex
+=
1
;
if
(
pShowReqInfo
->
currentIndex
>=
taosArrayGetSize
(
pShowReqInfo
->
pArray
))
{
return
NULL
;
}
SVgroupInfo
*
pVgroupInfo
=
taosArrayGet
(
pShowReqInfo
->
pArray
,
pShowReqInfo
->
currentIndex
);
SVShowTablesReq
*
pShowReq
=
calloc
(
1
,
sizeof
(
SVShowTablesReq
));
pShowReq
->
head
.
vgId
=
htonl
(
pVgroupInfo
->
vgId
);
pRequest
->
body
.
requestMsg
.
len
=
sizeof
(
SVShowTablesReq
);
pRequest
->
body
.
requestMsg
.
pData
=
pShowReq
;
SMsgSendInfo
*
body
=
buildMsgInfoImpl
(
pRequest
);
int64_t
transporterId
=
0
;
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
asyncSendMsgToServer
(
pTscObj
->
pTransporter
,
&
pTscObj
->
pAppInfo
->
mgmtEp
.
epSet
,
&
transporterId
,
body
);
tsem_wait
(
&
pRequest
->
body
.
rspSem
);
destroySendMsgInfo
(
body
);
pRequest
->
type
=
TDMT_VND_SHOW_TABLES_FETCH
;
}
SMsgSendInfo
*
body
=
buildMsgInfoImpl
(
pRequest
);
...
...
source/client/test/clientTests.cpp
浏览文件 @
164a80e9
...
...
@@ -96,24 +96,24 @@ TEST(testCase, connect_Test) {
// taos_close(pConn);
//}
TEST
(
testCase
,
show_user_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"show users"
);
TAOS_ROW
pRow
=
NULL
;
TAOS_FIELD
*
pFields
=
taos_fetch_fields
(
pRes
);
int32_t
numOfFields
=
taos_num_fields
(
pRes
);
char
str
[
512
]
=
{
0
};
while
((
pRow
=
taos_fetch_row
(
pRes
))
!=
NULL
)
{
int32_t
code
=
taos_print_row
(
str
,
pRow
,
pFields
,
numOfFields
);
printf
(
"%s
\n
"
,
str
);
}
taos_close
(
pConn
);
}
//
TEST(testCase, show_user_Test) {
//
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
//
assert(pConn != NULL);
//
//
TAOS_RES* pRes = taos_query(pConn, "show users");
//
TAOS_ROW pRow = NULL;
//
//
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
//
int32_t numOfFields = taos_num_fields(pRes);
//
//
char str[512] = {0};
//
while((pRow = taos_fetch_row(pRes)) != NULL) {
//
int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
//
printf("%s\n", str);
//
}
//
//
taos_close(pConn);
//
}
//TEST(testCase, drop_user_Test) {
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
...
...
@@ -128,24 +128,24 @@ TEST(testCase, show_user_Test) {
// taos_close(pConn);
//}
TEST
(
testCase
,
show_db_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
// assert(pConn != NULL);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"show databases"
);
TAOS_ROW
pRow
=
NULL
;
TAOS_FIELD
*
pFields
=
taos_fetch_fields
(
pRes
);
int32_t
numOfFields
=
taos_num_fields
(
pRes
);
char
str
[
512
]
=
{
0
};
while
((
pRow
=
taos_fetch_row
(
pRes
))
!=
NULL
)
{
int32_t
code
=
taos_print_row
(
str
,
pRow
,
pFields
,
numOfFields
);
printf
(
"%s
\n
"
,
str
);
}
taos_close
(
pConn
);
}
//
TEST(testCase, show_db_Test) {
//
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
//
//
assert(pConn != NULL);
//
//
TAOS_RES* pRes = taos_query(pConn, "show databases");
//
TAOS_ROW pRow = NULL;
//
//
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
//
int32_t numOfFields = taos_num_fields(pRes);
//
//
char str[512] = {0};
//
while((pRow = taos_fetch_row(pRes)) != NULL) {
//
int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
//
printf("%s\n", str);
//
}
//
//
taos_close(pConn);
//
}
//TEST(testCase, create_db_Test) {
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
...
...
source/dnode/vnode/impl/src/vnodeQuery.c
浏览文件 @
164a80e9
...
...
@@ -16,6 +16,8 @@
#include "vnodeQuery.h"
#include "vnodeDef.h"
static
int32_t
vnodeGetTableList
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
);
int
vnodeQueryOpen
(
SVnode
*
pVnode
)
{
return
qWorkerInit
(
NULL
,
&
pVnode
->
pQuery
);
}
int
vnodeProcessQueryReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
...
...
@@ -39,7 +41,8 @@ int vnodeProcessFetchReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
case
TDMT_VND_SHOW_TABLES
:
return
qWorkerProcessShowMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
case
TDMT_VND_SHOW_TABLES_FETCH
:
return
qWorkerProcessShowFetchMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
return
vnodeGetTableList
(
pVnode
,
pMsg
);
// return qWorkerProcessShowFetchMsg(pVnode->pMeta, pVnode->pQuery, pMsg);
default:
vError
(
"unknown msg type:%d in fetch queue"
,
pMsg
->
msgType
);
return
TSDB_CODE_VND_APP_ERROR
;
...
...
@@ -112,5 +115,55 @@ static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
pSch
->
bytes
=
htonl
(
pSch
->
bytes
);
}
return
0
;
}
/**
* @param pVnode
* @param pMsg
* @param pRsp
*/
static
int32_t
vnodeGetTableList
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
)
{
SMTbCursor
*
pCur
=
metaOpenTbCursor
(
pVnode
->
pMeta
);
SArray
*
pArray
=
taosArrayInit
(
10
,
POINTER_BYTES
);
char
*
name
=
NULL
;
int32_t
totalLen
=
0
;
while
((
name
=
metaTbCursorNext
(
pCur
))
!=
NULL
)
{
taosArrayPush
(
pArray
,
&
name
);
totalLen
+=
strlen
(
name
);
}
metaCloseTbCursor
(
pCur
);
int32_t
rowLen
=
(
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
)
+
8
+
4
+
(
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
)
+
8
+
4
;
int32_t
numOfTables
=
(
int32_t
)
taosArrayGetSize
(
pArray
);
int32_t
payloadLen
=
rowLen
*
numOfTables
;
// SVShowTablesFetchReq *pFetchReq = pMsg->pCont;
SVShowTablesFetchRsp
*
pFetchRsp
=
(
SVShowTablesFetchRsp
*
)
rpcMallocCont
(
sizeof
(
SVShowTablesFetchRsp
)
+
payloadLen
);
memset
(
pFetchRsp
,
0
,
sizeof
(
struct
SVShowTablesFetchRsp
)
+
payloadLen
);
char
*
p
=
pFetchRsp
->
data
;
for
(
int32_t
i
=
0
;
i
<
numOfTables
;
++
i
)
{
char
*
n
=
taosArrayGetP
(
pArray
,
i
);
STR_TO_VARSTR
(
p
,
n
);
p
+=
rowLen
;
}
pFetchRsp
->
numOfRows
=
htonl
(
numOfTables
);
pFetchRsp
->
precision
=
0
;
SRpcMsg
rpcMsg
=
{
.
handle
=
pMsg
->
handle
,
.
ahandle
=
pMsg
->
ahandle
,
.
pCont
=
pFetchRsp
,
.
contLen
=
sizeof
(
SVShowTablesFetchRsp
)
+
payloadLen
,
.
code
=
0
,
};
rpcSendResponse
(
&
rpcMsg
);
return
0
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录