Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3035ecd5
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3035ecd5
编写于
4月 22, 2022
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add show topic
上级
9a3365e1
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
24 addition
and
38 deletion
+24
-38
example/src/tmq.c
example/src/tmq.c
+1
-0
source/dnode/mnode/impl/src/mndPerfSchema.c
source/dnode/mnode/impl/src/mndPerfSchema.c
+2
-2
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+3
-2
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+18
-34
未找到文件。
example/src/tmq.c
浏览文件 @
3035ecd5
...
@@ -103,6 +103,7 @@ int32_t create_topic() {
...
@@ -103,6 +103,7 @@ int32_t create_topic() {
/*const char* sql = "select * from tu1";*/
/*const char* sql = "select * from tu1";*/
/*pRes = tmq_create_topic(pConn, "test_stb_topic_1", sql, strlen(sql));*/
/*pRes = tmq_create_topic(pConn, "test_stb_topic_1", sql, strlen(sql));*/
/*pRes = taos_query(pConn, "create topic topic_ctb_column as abc1");*/
pRes
=
taos_query
(
pConn
,
"create topic topic_ctb_column as select ts, c1, c2, c3 from ct1"
);
pRes
=
taos_query
(
pConn
,
"create topic topic_ctb_column as select ts, c1, c2, c3 from ct1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create topic topic_ctb_column, reason:%s
\n
"
,
taos_errstr
(
pRes
));
printf
(
"failed to create topic topic_ctb_column, reason:%s
\n
"
,
taos_errstr
(
pRes
));
...
...
source/dnode/mnode/impl/src/mndPerfSchema.c
浏览文件 @
3035ecd5
...
@@ -41,10 +41,10 @@ static const SPerfsTableSchema queriesSchema[] = {
...
@@ -41,10 +41,10 @@ static const SPerfsTableSchema queriesSchema[] = {
static
const
SPerfsTableSchema
topicSchema
[]
=
{
static
const
SPerfsTableSchema
topicSchema
[]
=
{
{.
name
=
"topic_name"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"topic_name"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"db_name"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
/*{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},*/
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"sql"
,
.
bytes
=
TSDB_SHOW_SQL_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"sql"
,
.
bytes
=
TSDB_SHOW_SQL_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"row_len"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
/*{.name = "row_len", .bytes = 4, .type = TSDB_DATA_TYPE_INT},*/
};
};
static
const
SPerfsTableSchema
consumerSchema
[]
=
{
static
const
SPerfsTableSchema
consumerSchema
[]
=
{
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
3035ecd5
...
@@ -59,7 +59,7 @@ int32_t mndInitStream(SMnode *pMnode) {
...
@@ -59,7 +59,7 @@ int32_t mndInitStream(SMnode *pMnode) {
/*mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM_RSP, mndProcessDropStreamInRsp);*/
/*mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM_RSP, mndProcessDropStreamInRsp);*/
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndRetrieveStream);
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndRetrieveStream);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_TOPICS
,
mndCancelGetNextStream
);
/*mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndCancelGetNextStream);*/
return
sdbSetTable
(
pMnode
->
pSdb
,
table
);
return
sdbSetTable
(
pMnode
->
pSdb
,
table
);
}
}
...
@@ -247,7 +247,8 @@ static int32_t mndStreamGetPlanString(const char *ast, int8_t triggerType, int64
...
@@ -247,7 +247,8 @@ static int32_t mndStreamGetPlanString(const char *ast, int8_t triggerType, int64
return
code
;
return
code
;
}
}
int32_t
mndAddStreamToTrans
(
SMnode
*
pMnode
,
SStreamObj
*
pStream
,
const
char
*
ast
,
int8_t
triggerType
,
int64_t
watermark
,
STrans
*
pTrans
)
{
int32_t
mndAddStreamToTrans
(
SMnode
*
pMnode
,
SStreamObj
*
pStream
,
const
char
*
ast
,
int8_t
triggerType
,
int64_t
watermark
,
STrans
*
pTrans
)
{
SNode
*
pAst
=
NULL
;
SNode
*
pAst
=
NULL
;
if
(
nodesStringToNode
(
ast
,
&
pAst
)
<
0
)
{
if
(
nodesStringToNode
(
ast
,
&
pAst
)
<
0
)
{
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
3035ecd5
...
@@ -35,7 +35,7 @@ static int32_t mndTopicActionUpdate(SSdb *pSdb, SMqTopicObj *pTopic, SMqTopicObj
...
@@ -35,7 +35,7 @@ static int32_t mndTopicActionUpdate(SSdb *pSdb, SMqTopicObj *pTopic, SMqTopicObj
static
int32_t
mndProcessCreateTopicReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessCreateTopicReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessDropTopicReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessDropTopicReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessDropTopicInRsp
(
SNodeMsg
*
pRsp
);
static
int32_t
mndProcessDropTopicInRsp
(
SNodeMsg
*
pRsp
);
static
int32_t
mndRetrieveTopic
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndRetrieveTopic
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
void
mndCancelGetNextTopic
(
SMnode
*
pMnode
,
void
*
pIter
);
static
void
mndCancelGetNextTopic
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitTopic
(
SMnode
*
pMnode
)
{
int32_t
mndInitTopic
(
SMnode
*
pMnode
)
{
...
@@ -51,7 +51,7 @@ int32_t mndInitTopic(SMnode *pMnode) {
...
@@ -51,7 +51,7 @@ int32_t mndInitTopic(SMnode *pMnode) {
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_TOPIC
,
mndProcessDropTopicReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_TOPIC
,
mndProcessDropTopicReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_VND_DROP_TOPIC_RSP
,
mndProcessDropTopicInRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_VND_DROP_TOPIC_RSP
,
mndProcessDropTopicInRsp
);
//
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndRetrieveTopic);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_TOPICS
,
mndRetrieveTopic
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_TOPICS
,
mndCancelGetNextTopic
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_TOPICS
,
mndCancelGetNextTopic
);
return
sdbSetTable
(
pMnode
->
pSdb
,
table
);
return
sdbSetTable
(
pMnode
->
pSdb
,
table
);
...
@@ -511,56 +511,40 @@ static int32_t mndGetNumOfTopics(SMnode *pMnode, char *dbName, int32_t *pNumOfTo
...
@@ -511,56 +511,40 @@ static int32_t mndGetNumOfTopics(SMnode *pMnode, char *dbName, int32_t *pNumOfTo
return
0
;
return
0
;
}
}
static
int32_t
mndRetrieveTopic
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
static
int32_t
mndRetrieveTopic
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rowsCapacity
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SMnode
*
pMnode
=
pReq
->
pNode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
SMqTopicObj
*
pTopic
=
NULL
;
SMqTopicObj
*
pTopic
=
NULL
;
int32_t
cols
=
0
;
char
*
pWrite
;
char
prefix
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
pShow
->
db
);
if
(
pDb
==
NULL
)
return
0
;
tstrncpy
(
prefix
,
pShow
->
db
,
TSDB_DB_FNAME_LEN
);
while
(
numOfRows
<
rowsCapacity
)
{
strcat
(
prefix
,
TS_PATH_DELIMITER
);
int32_t
prefixLen
=
(
int32_t
)
strlen
(
prefix
);
while
(
numOfRows
<
rows
)
{
pShow
->
pIter
=
sdbFetch
(
pSdb
,
SDB_TOPIC
,
pShow
->
pIter
,
(
void
**
)
&
pTopic
);
pShow
->
pIter
=
sdbFetch
(
pSdb
,
SDB_TOPIC
,
pShow
->
pIter
,
(
void
**
)
&
pTopic
);
if
(
pShow
->
pIter
==
NULL
)
break
;
if
(
pShow
->
pIter
==
NULL
)
break
;
if
(
pTopic
->
dbUid
!=
pDb
->
uid
)
{
int32_t
cols
=
0
;
if
(
strncmp
(
pTopic
->
name
,
prefix
,
prefixLen
)
!=
0
)
{
mError
(
"Inconsistent topic data, name:%s, db:%s, dbUid:%"
PRIu64
,
pTopic
->
name
,
pDb
->
name
,
pDb
->
uid
);
}
sdbRelease
(
pSdb
,
pTopic
)
;
char
topicName
[
TSDB_TOPIC_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
}
;
continue
;
tstrncpy
(
&
topicName
[
VARSTR_HEADER_SIZE
],
pTopic
->
name
,
TSDB_TOPIC_NAME_LEN
)
;
}
varDataSetLen
(
topicName
,
strlen
(
&
topicName
[
VARSTR_HEADER_SIZE
]));
cols
=
0
;
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
topicName
,
false
);
char
topicName
[
TSDB_TOPIC_NAME_LEN
]
=
{
0
};
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
tstrncpy
(
topicName
,
pTopic
->
name
+
prefixLen
,
TSDB_TOPIC_NAME_LEN
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pTopic
->
createTime
,
false
);
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_TO_VARSTR
(
pWrite
,
topicName
);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
*
(
int64_t
*
)
pWrite
=
pTopic
->
createTime
;
char
*
sql
=
taosMemoryCalloc
(
1
,
strlen
(
pTopic
->
sql
)
+
1
+
VARSTR_HEADER_SIZE
);
cols
++
;
strcpy
(
&
sql
[
VARSTR_HEADER_SIZE
],
pTopic
->
sql
);
varDataSetLen
(
sql
,
strlen
(
&
sql
[
VARSTR_HEADER_SIZE
]));
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
sql
,
false
);
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
taosMemoryFree
(
sql
);
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
pTopic
->
sql
,
pShow
->
bytes
[
cols
]);
cols
++
;
numOfRows
++
;
numOfRows
++
;
sdbRelease
(
pSdb
,
pTopic
);
sdbRelease
(
pSdb
,
pTopic
);
}
}
mndReleaseDb
(
pMnode
,
pDb
);
pShow
->
numOfRows
+=
numOfRows
;
pShow
->
numOfRows
+=
numOfRows
;
return
numOfRows
;
return
numOfRows
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录