Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c54bc769
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看板
提交
c54bc769
编写于
7月 11, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:get meta ok
上级
0a193cf8
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
116 addition
and
85 deletion
+116
-85
examples/c/tmq.c
examples/c/tmq.c
+42
-29
source/client/src/tmq.c
source/client/src/tmq.c
+2
-2
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+72
-54
未找到文件。
examples/c/tmq.c
浏览文件 @
c54bc769
...
...
@@ -51,15 +51,14 @@ static void msg_process(TAOS_RES* msg) {
int32_t
ret
=
taos_write_raw_meta
(
pConn
,
raw
);
printf
(
"write raw data: %s
\n
"
,
tmq_err2str
(
ret
));
free
(
raw
);
taos_close
(
pConn
);
}
tmq_free_raw_meta
(
raw
);
char
*
result
=
tmq_get_json_meta
(
msg
);
if
(
result
){
printf
(
"meta result: %s
\n
"
,
result
);
free
(
result
);
}
printf
(
"meta:%p
\n
"
,
raw
);
tmq_free_json_meta
(
result
);
return
;
}
while
(
1
)
{
...
...
@@ -83,7 +82,7 @@ int32_t init_env() {
return
-
1
;
}
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"create database if not exists abc1 vgroups
1
"
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"create database if not exists abc1 vgroups
3
"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in create db, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
...
...
@@ -126,6 +125,13 @@ int32_t init_env() {
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create table if not exists ct2 using st1 tags(NULL)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create child table ct2, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"insert into ct1 values(now, 3, 4, 'b')"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to insert into ct1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
...
...
@@ -147,12 +153,12 @@ int32_t init_env() {
}
taos_free_result
(
pRes
);
//
pRes = taos_query(pConn, "alter table st1 add column c4 bigint");
//
if (taos_errno(pRes) != 0) {
//
printf("failed to alter super table st1, reason:%s\n", taos_errstr(pRes));
//
return -1;
//
}
//
taos_free_result(pRes);
pRes
=
taos_query
(
pConn
,
"alter table st1 add column c4 bigint"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to alter super table st1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"alter table st1 modify column c3 binary(64)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
...
...
@@ -175,19 +181,19 @@ int32_t init_env() {
}
taos_free_result
(
pRes
);
//
pRes = taos_query(pConn, "drop table ct3 ct1");
//
if (taos_errno(pRes) != 0) {
//
printf("failed to drop child table ct3, reason:%s\n", taos_errstr(pRes));
//
return -1;
//
}
//
taos_free_result(pRes);
//
//
pRes = taos_query(pConn, "drop table st1");
//
if (taos_errno(pRes) != 0) {
//
printf("failed to drop super table st1, reason:%s\n", taos_errstr(pRes));
//
return -1;
//
}
//
taos_free_result(pRes);
pRes
=
taos_query
(
pConn
,
"drop table ct3 ct1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to drop child table ct3, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"drop table st1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to drop super table st1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create table if not exists n1(ts timestamp, c1 int, c2 nchar(4))"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
...
...
@@ -224,12 +230,12 @@ int32_t init_env() {
}
taos_free_result
(
pRes
);
//
pRes = taos_query(pConn, "drop table n1");
//
if (taos_errno(pRes) != 0) {
//
printf("failed to drop normal table n1, reason:%s\n", taos_errstr(pRes));
//
return -1;
//
}
//
taos_free_result(pRes);
pRes
=
taos_query
(
pConn
,
"drop table n1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to drop normal table n1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create table jt(ts timestamp, i int) tags(t json)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
...
...
@@ -245,6 +251,13 @@ int32_t init_env() {
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create table jt2 using jt tags('')"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create super table jt2, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
return
0
;
}
...
...
source/client/src/tmq.c
浏览文件 @
c54bc769
...
...
@@ -2430,7 +2430,7 @@ static int32_t taosCreateStb(TAOS *taos, void *meta, int32_t metaLen){
pReq
.
numOfTags
=
req
.
schemaTag
.
nCols
;
pReq
.
commentLen
=
-
1
;
pReq
.
suid
=
req
.
suid
;
pReq
.
source
=
1
;
pReq
.
source
=
TD_REQ_FROM_TAOX
;
pReq
.
igExists
=
true
;
SName
tableName
;
...
...
@@ -2497,7 +2497,7 @@ static int32_t taosDropStb(TAOS *taos, void *meta, int32_t metaLen){
// build drop stable
pReq
.
igNotExists
=
true
;
pReq
.
source
=
1
;
pReq
.
source
=
TD_REQ_FROM_TAOX
;
pReq
.
suid
=
req
.
suid
;
SName
tableName
;
tNameExtractFullName
(
toName
(
pTscObj
->
acctId
,
pRequest
->
pDb
,
req
.
name
,
&
tableName
),
pReq
.
name
);
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
c54bc769
...
...
@@ -851,6 +851,75 @@ static int32_t mndProcessTtlTimer(SRpcMsg *pReq) {
return
0
;
}
static
int32_t
mndFindSuperTableTagIndex
(
const
SStbObj
*
pStb
,
const
char
*
tagName
)
{
for
(
int32_t
tag
=
0
;
tag
<
pStb
->
numOfTags
;
tag
++
)
{
if
(
strcasecmp
(
pStb
->
pTags
[
tag
].
name
,
tagName
)
==
0
)
{
return
tag
;
}
}
return
-
1
;
}
static
int32_t
mndFindSuperTableColumnIndex
(
const
SStbObj
*
pStb
,
const
char
*
colName
)
{
for
(
int32_t
col
=
0
;
col
<
pStb
->
numOfColumns
;
col
++
)
{
if
(
strcasecmp
(
pStb
->
pColumns
[
col
].
name
,
colName
)
==
0
)
{
return
col
;
}
}
return
-
1
;
}
static
int32_t
mndBuildStbFromAlter
(
SStbObj
*
pStb
,
SStbObj
*
pDst
,
SMCreateStbReq
*
createReq
)
{
taosRLockLatch
(
&
pStb
->
lock
);
memcpy
(
pDst
,
pStb
,
sizeof
(
SStbObj
));
taosRUnLockLatch
(
&
pStb
->
lock
);
pDst
->
updateTime
=
taosGetTimestampMs
();
pDst
->
numOfColumns
=
createReq
->
numOfColumns
;
pDst
->
numOfTags
=
createReq
->
numOfTags
;
pDst
->
pColumns
=
taosMemoryCalloc
(
1
,
pDst
->
numOfColumns
*
sizeof
(
SSchema
));
pDst
->
pTags
=
taosMemoryCalloc
(
1
,
pDst
->
numOfTags
*
sizeof
(
SSchema
));
if
(
pDst
->
pColumns
==
NULL
||
pDst
->
pTags
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
for
(
int32_t
i
=
0
;
i
<
pDst
->
numOfColumns
;
++
i
)
{
SField
*
pField
=
taosArrayGet
(
createReq
->
pColumns
,
i
);
SSchema
*
pSchema
=
&
pDst
->
pColumns
[
i
];
pSchema
->
type
=
pField
->
type
;
pSchema
->
bytes
=
pField
->
bytes
;
pSchema
->
flags
=
pField
->
flags
;
memcpy
(
pSchema
->
name
,
pField
->
name
,
TSDB_COL_NAME_LEN
);
int32_t
cIndex
=
mndFindSuperTableColumnIndex
(
pStb
,
pField
->
name
);
if
(
cIndex
>=
0
){
pSchema
->
colId
=
pStb
->
pColumns
[
cIndex
].
colId
;
}
else
{
pSchema
->
colId
=
pDst
->
nextColId
++
;
}
}
for
(
int32_t
i
=
0
;
i
<
pDst
->
numOfTags
;
++
i
)
{
SField
*
pField
=
taosArrayGet
(
createReq
->
pTags
,
i
);
SSchema
*
pSchema
=
&
pDst
->
pTags
[
i
];
pSchema
->
type
=
pField
->
type
;
pSchema
->
bytes
=
pField
->
bytes
;
memcpy
(
pSchema
->
name
,
pField
->
name
,
TSDB_COL_NAME_LEN
);
int32_t
cIndex
=
mndFindSuperTableTagIndex
(
pStb
,
pField
->
name
);
if
(
cIndex
>=
0
){
pSchema
->
colId
=
pStb
->
pTags
[
cIndex
].
colId
;
}
else
{
pSchema
->
colId
=
pDst
->
nextColId
++
;
}
}
pDst
->
tagVer
=
createReq
->
tagVer
;
pDst
->
colVer
=
createReq
->
colVer
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mndProcessCreateStbReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
...
...
@@ -937,43 +1006,12 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
if
(
isAlter
)
{
bool
needRsp
=
false
;
SStbObj
pDst
=
{
0
};
taosRLockLatch
(
&
pStb
->
lock
);
memcpy
(
&
pDst
,
pStb
,
sizeof
(
SStbObj
));
taosRUnLockLatch
(
&
pStb
->
lock
);
pDst
.
updateTime
=
taosGetTimestampMs
();
pDst
.
nextColId
=
1
;
pDst
.
numOfColumns
=
createReq
.
numOfColumns
;
pDst
.
numOfTags
=
createReq
.
numOfTags
;
pDst
.
pColumns
=
taosMemoryCalloc
(
1
,
pDst
.
numOfColumns
*
sizeof
(
SSchema
));
pDst
.
pTags
=
taosMemoryCalloc
(
1
,
pDst
.
numOfTags
*
sizeof
(
SSchema
));
if
(
pDst
.
pColumns
==
NULL
||
pDst
.
pTags
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
if
(
mndBuildStbFromAlter
(
pStb
,
&
pDst
,
&
createReq
)
!=
0
)
{
taosMemoryFreeClear
(
pDst
.
pTags
);
taosMemoryFreeClear
(
pDst
.
pColumns
);
goto
_OVER
;
}
for
(
int32_t
i
=
0
;
i
<
pDst
.
numOfColumns
;
++
i
)
{
SField
*
pField
=
taosArrayGet
(
createReq
.
pColumns
,
i
);
SSchema
*
pSchema
=
&
pDst
.
pColumns
[
i
];
pSchema
->
type
=
pField
->
type
;
pSchema
->
bytes
=
pField
->
bytes
;
pSchema
->
flags
=
pField
->
flags
;
memcpy
(
pSchema
->
name
,
pField
->
name
,
TSDB_COL_NAME_LEN
);
pSchema
->
colId
=
pDst
.
nextColId
;
pDst
.
nextColId
++
;
}
for
(
int32_t
i
=
0
;
i
<
pDst
.
numOfTags
;
++
i
)
{
SField
*
pField
=
taosArrayGet
(
createReq
.
pTags
,
i
);
SSchema
*
pSchema
=
&
pDst
.
pTags
[
i
];
pSchema
->
type
=
pField
->
type
;
pSchema
->
bytes
=
pField
->
bytes
;
memcpy
(
pSchema
->
name
,
pField
->
name
,
TSDB_COL_NAME_LEN
);
pSchema
->
colId
=
pDst
.
nextColId
;
pDst
.
nextColId
++
;
}
pDst
.
tagVer
=
createReq
.
tagVer
;
pDst
.
colVer
=
createReq
.
colVer
;
code
=
mndAlterStbImp
(
pMnode
,
pReq
,
pDb
,
&
pDst
,
needRsp
,
NULL
,
0
);
taosMemoryFreeClear
(
pDst
.
pTags
);
taosMemoryFreeClear
(
pDst
.
pColumns
);
...
...
@@ -1014,26 +1052,6 @@ static int32_t mndCheckAlterStbReq(SMAlterStbReq *pAlter) {
return
0
;
}
static
int32_t
mndFindSuperTableTagIndex
(
const
SStbObj
*
pStb
,
const
char
*
tagName
)
{
for
(
int32_t
tag
=
0
;
tag
<
pStb
->
numOfTags
;
tag
++
)
{
if
(
strcasecmp
(
pStb
->
pTags
[
tag
].
name
,
tagName
)
==
0
)
{
return
tag
;
}
}
return
-
1
;
}
static
int32_t
mndFindSuperTableColumnIndex
(
const
SStbObj
*
pStb
,
const
char
*
colName
)
{
for
(
int32_t
col
=
0
;
col
<
pStb
->
numOfColumns
;
col
++
)
{
if
(
strcasecmp
(
pStb
->
pColumns
[
col
].
name
,
colName
)
==
0
)
{
return
col
;
}
}
return
-
1
;
}
static
int32_t
mndAllocStbSchemas
(
const
SStbObj
*
pOld
,
SStbObj
*
pNew
)
{
pNew
->
pTags
=
taosMemoryCalloc
(
pNew
->
numOfTags
,
sizeof
(
SSchema
));
pNew
->
pColumns
=
taosMemoryCalloc
(
pNew
->
numOfColumns
,
sizeof
(
SSchema
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录