Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
06a370c8
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看板
提交
06a370c8
编写于
4月 25, 2022
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh(tmq): remove topic out of db
上级
df1ebbc2
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
97 addition
and
73 deletion
+97
-73
example/src/tmq.c
example/src/tmq.c
+6
-2
include/common/tmsg.h
include/common/tmsg.h
+10
-6
source/client/src/tmq.c
source/client/src/tmq.c
+7
-2
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+4
-6
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+70
-57
未找到文件。
example/src/tmq.c
浏览文件 @
06a370c8
...
...
@@ -17,6 +17,7 @@
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include "taos.h"
static
int
running
=
1
;
...
...
@@ -47,6 +48,7 @@ int32_t init_env() {
return
-
1
;
}
taos_free_result
(
pRes
);
sleep
(
1
);
pRes
=
taos_query
(
pConn
,
"use abc1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
...
...
@@ -58,6 +60,7 @@ int32_t init_env() {
pRes
=
taos_query
(
pConn
,
"create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(10)) tags(t1 int)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
assert
(
0
);
printf
(
"failed to create super table st1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
...
...
@@ -265,10 +268,11 @@ void perf_loop(tmq_t* tmq, tmq_list_t* topics) {
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
code
;
if
(
argc
>
1
)
{
printf
(
"env init
\n
"
);
code
=
init_env
();
if
(
init_env
()
<
0
)
{
return
-
1
;
}
create_topic
();
}
tmq_t
*
tmq
=
build_consumer
();
...
...
include/common/tmsg.h
浏览文件 @
06a370c8
...
...
@@ -1314,7 +1314,6 @@ typedef struct {
}
SMqConsumerLostMsg
;
typedef
struct
{
int32_t
topicNum
;
int64_t
consumerId
;
char
cgroup
[
TSDB_CGROUP_LEN
];
SArray
*
topicNames
;
// SArray<char*>
...
...
@@ -1322,22 +1321,27 @@ typedef struct {
static
FORCE_INLINE
int32_t
tSerializeSCMSubscribeReq
(
void
**
buf
,
const
SCMSubscribeReq
*
pReq
)
{
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
topicNum
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
consumerId
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
cgroup
);
for
(
int32_t
i
=
0
;
i
<
pReq
->
topicNum
;
i
++
)
{
int32_t
topicNum
=
taosArrayGetSize
(
pReq
->
topicNames
);
tlen
+=
taosEncodeFixedI32
(
buf
,
topicNum
);
for
(
int32_t
i
=
0
;
i
<
topicNum
;
i
++
)
{
tlen
+=
taosEncodeString
(
buf
,
(
char
*
)
taosArrayGetP
(
pReq
->
topicNames
,
i
));
}
return
tlen
;
}
static
FORCE_INLINE
void
*
tDeserializeSCMSubscribeReq
(
void
*
buf
,
SCMSubscribeReq
*
pReq
)
{
buf
=
taosDecodeFixedI32
(
buf
,
&
pReq
->
topicNum
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
consumerId
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
cgroup
);
pReq
->
topicNames
=
taosArrayInit
(
pReq
->
topicNum
,
sizeof
(
void
*
));
for
(
int32_t
i
=
0
;
i
<
pReq
->
topicNum
;
i
++
)
{
int32_t
topicNum
;
buf
=
taosDecodeFixedI32
(
buf
,
&
topicNum
);
pReq
->
topicNames
=
taosArrayInit
(
topicNum
,
sizeof
(
void
*
));
for
(
int32_t
i
=
0
;
i
<
topicNum
;
i
++
)
{
char
*
name
;
buf
=
taosDecodeString
(
buf
,
&
name
);
taosArrayPush
(
pReq
->
topicNames
,
&
name
);
...
...
source/client/src/tmq.c
浏览文件 @
06a370c8
...
...
@@ -506,7 +506,6 @@ tmq_resp_err_t tmq_subscribe(tmq_t* tmq, tmq_list_t* topic_list) {
tmq
->
clientTopics
=
taosArrayInit
(
sz
,
sizeof
(
SMqClientTopic
));
SCMSubscribeReq
req
;
req
.
topicNum
=
sz
;
req
.
consumerId
=
tmq
->
consumerId
;
strcpy
(
req
.
cgroup
,
tmq
->
groupId
);
req
.
topicNames
=
taosArrayInit
(
sz
,
sizeof
(
void
*
));
...
...
@@ -516,12 +515,16 @@ tmq_resp_err_t tmq_subscribe(tmq_t* tmq, tmq_list_t* topic_list) {
char
*
topicName
=
taosArrayGetP
(
container
,
i
);
SName
name
=
{
0
};
#if 0
char* dbName = getDbOfConnection(tmq->pTscObj);
if (dbName == NULL) {
return TMQ_RESP_ERR__FAIL;
}
tNameSetDbName
(
&
name
,
tmq
->
pTscObj
->
acctId
,
dbName
,
strlen
(
dbName
));
#endif
tNameSetDbName
(
&
name
,
tmq
->
pTscObj
->
acctId
,
topicName
,
strlen
(
topicName
));
#if 0
tNameFromString(&name, topicName, T_NAME_TABLE);
#endif
char
*
topicFname
=
taosMemoryCalloc
(
1
,
TSDB_TOPIC_FNAME_LEN
);
if
(
topicFname
==
NULL
)
{
...
...
@@ -539,7 +542,9 @@ tmq_resp_err_t tmq_subscribe(tmq_t* tmq, tmq_list_t* topic_list) {
topic
.
vgs
=
taosArrayInit
(
0
,
sizeof
(
SMqClientVg
));
taosArrayPush
(
tmq
->
clientTopics
,
&
topic
);
taosArrayPush
(
req
.
topicNames
,
&
topicFname
);
#if 0
taosMemoryFree(dbName);
#endif
}
int
tlen
=
tSerializeSCMSubscribeReq
(
NULL
,
&
req
);
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
06a370c8
...
...
@@ -232,6 +232,7 @@ void mndReleaseTopic(SMnode *pMnode, SMqTopicObj *pTopic) {
sdbRelease
(
pSdb
,
pTopic
);
}
#if 0
static SDbObj *mndAcquireDbByTopic(SMnode *pMnode, char *topicName) {
SName name = {0};
tNameFromString(&name, topicName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
...
...
@@ -241,6 +242,7 @@ static SDbObj *mndAcquireDbByTopic(SMnode *pMnode, char *topicName) {
return mndAcquireDb(pMnode, db);
}
#endif
static
SDDropTopicReq
*
mndBuildDropTopicMsg
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SMqTopicObj
*
pTopic
)
{
int32_t
contLen
=
sizeof
(
SDDropTopicReq
);
...
...
@@ -260,15 +262,11 @@ static SDDropTopicReq *mndBuildDropTopicMsg(SMnode *pMnode, SVgObj *pVgroup, SMq
}
static
int32_t
mndCheckCreateTopicReq
(
SCMCreateTopicReq
*
pCreate
)
{
if
(
pCreate
->
name
[
0
]
==
0
||
pCreate
->
sql
==
NULL
||
pCreate
->
sql
[
0
]
==
0
)
{
if
(
pCreate
->
name
[
0
]
==
0
||
pCreate
->
sql
==
NULL
||
pCreate
->
sql
[
0
]
==
0
||
pCreate
->
subscribeDbName
[
0
]
==
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_TOPIC_OPTION
;
return
-
1
;
}
if
((
pCreate
->
ast
==
NULL
||
pCreate
->
ast
[
0
]
==
0
)
&&
pCreate
->
subscribeDbName
[
0
]
==
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_TOPIC_OPTION
;
return
-
1
;
}
return
0
;
}
...
...
@@ -384,7 +382,7 @@ static int32_t mndProcessCreateTopicReq(SNodeMsg *pReq) {
goto
CREATE_TOPIC_OVER
;
}
pDb
=
mndAcquireDb
ByTopic
(
pMnode
,
createTopicReq
.
n
ame
);
pDb
=
mndAcquireDb
(
pMnode
,
createTopicReq
.
subscribeDbN
ame
);
if
(
pDb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_DB_NOT_SELECTED
;
goto
CREATE_TOPIC_OVER
;
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
06a370c8
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录