Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
74f27466
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看板
提交
74f27466
编写于
5月 25, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
drop super table
上级
75c47328
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
54 addition
and
47 deletion
+54
-47
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+54
-47
未找到文件。
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
74f27466
...
...
@@ -71,64 +71,71 @@ _err:
}
int
metaDropSTable
(
SMeta
*
pMeta
,
int64_t
verison
,
SVDropStbReq
*
pReq
)
{
TBC
*
pNameIdxc
=
NULL
;
TBC
*
pUidIdxc
=
NULL
;
TBC
*
pCtbIdxc
=
NULL
;
SCtbIdxKey
*
pCtbIdxKey
;
const
void
*
pKey
=
NULL
;
int
nKey
;
const
void
*
pData
=
NULL
;
int
nData
;
int
c
,
ret
;
// prepare uid idx cursor
tdbTbcOpen
(
pMeta
->
pUidIdx
,
&
pUidIdxc
,
&
pMeta
->
txn
);
ret
=
tdbTbcMoveTo
(
pUidIdxc
,
&
pReq
->
suid
,
sizeof
(
tb_uid_t
),
&
c
);
if
(
ret
<
0
||
c
!=
0
)
{
terrno
=
TSDB_CODE_VND_TB_NOT_EXIST
;
tdbTbcClose
(
pUidIdxc
);
goto
_err
;
}
void
*
pKey
=
NULL
;
int
nKey
=
0
;
void
*
pData
=
NULL
;
int
nData
=
0
;
int
c
=
0
;
int
rc
=
0
;
//
prepare name idx cursor
tdbTbcOpen
(
pMeta
->
pNameIdx
,
&
pNameIdxc
,
&
pMeta
->
txn
);
ret
=
tdbTbcMoveTo
(
pNameIdxc
,
pReq
->
name
,
strlen
(
pReq
->
name
)
+
1
,
&
c
);
if
(
ret
<
0
||
c
!=
0
)
{
ASSERT
(
0
)
;
//
check if super table exists
rc
=
tdbTbGet
(
pMeta
->
pNameIdx
,
pReq
->
name
,
strlen
(
pReq
->
name
)
+
1
,
&
pData
,
&
nData
);
if
(
rc
<
0
||
*
(
tb_uid_t
*
)
pData
!=
pReq
->
suid
)
{
terrno
=
TSDB_CODE_VND_TABLE_NOT_EXIST
;
return
-
1
;
}
tdbTbcDelete
(
pUidIdxc
);
tdbTbcDelete
(
pNameIdxc
);
tdbTbcClose
(
pUidIdxc
);
tdbTbcClose
(
pNameIdxc
);
// drop all child tables
TBC
*
pCtbIdxc
=
NULL
;
SArray
*
pArray
=
taosArrayInit
(
8
,
sizeof
(
tb_uid_t
));
// loop to drop each child table
tdbTbcOpen
(
pMeta
->
pCtbIdx
,
&
pCtbIdxc
,
&
pMeta
->
txn
);
r
et
=
tdbTbcMoveTo
(
pCtbIdxc
,
&
(
SCtbIdxKey
){.
suid
=
pReq
->
suid
,
.
uid
=
INT64_MIN
},
sizeof
(
SCtbIdxKey
),
&
c
);
if
(
r
et
<
0
||
(
c
<
0
&&
tdbTbcMoveToNext
(
pCtbIdxc
)
<
0
)
)
{
r
c
=
tdbTbcMoveTo
(
pCtbIdxc
,
&
(
SCtbIdxKey
){.
suid
=
pReq
->
suid
,
.
uid
=
INT64_MIN
},
sizeof
(
SCtbIdxKey
),
&
c
);
if
(
r
c
<
0
)
{
tdbTbcClose
(
pCtbIdxc
);
goto
_exit
;
metaWLock
(
pMeta
);
goto
_drop_super_table
;
}
for
(;;)
{
tdbTbcGe
t
(
pCtbIdxc
,
&
pKey
,
&
nKey
,
NULL
,
NULL
);
pCtbIdxKey
=
(
SCtbIdxKey
*
)
pKey
;
rc
=
tdbTbcNex
t
(
pCtbIdxc
,
&
pKey
,
&
nKey
,
NULL
,
NULL
);
if
(
rc
<
0
)
break
;
if
(
pCtbIdxKey
->
suid
>
pReq
->
suid
)
break
;
if
(((
SCtbIdxKey
*
)
pKey
)
->
suid
<
pReq
->
suid
)
{
continue
;
}
else
if
(((
SCtbIdxKey
*
)
pKey
)
->
suid
>
pReq
->
suid
)
{
break
;
}
taosArrayPush
(
pArray
,
&
(((
SCtbIdxKey
*
)
pKey
)
->
uid
));
}
// drop the child table (TODO)
tdbTbcClose
(
pCtbIdxc
);
if
(
tdbTbcMoveToNext
(
pCtbIdxc
)
<
0
)
break
;
metaWLock
(
pMeta
);
for
(
int32_t
iChild
=
0
;
iChild
<
taosArrayGetSize
(
pArray
);
iChild
++
)
{
tb_uid_t
uid
=
*
(
tb_uid_t
*
)
taosArrayGet
(
pArray
,
iChild
);
metaDropTableByUid
(
pMeta
,
uid
);
}
taosArrayDestroy
(
pArray
);
// drop super table
_drop_super_table:
tdbTbGet
(
pMeta
->
pUidIdx
,
&
pReq
->
suid
,
sizeof
(
tb_uid_t
),
&
pData
,
&
nData
);
tdbTbDelete
(
pMeta
->
pTbDb
,
&
(
STbDbKey
){.
version
=
*
(
int64_t
*
)
pData
,
.
uid
=
pReq
->
suid
},
sizeof
(
STbDbKey
),
&
pMeta
->
txn
);
tdbTbDelete
(
pMeta
->
pNameIdx
,
pReq
->
name
,
strlen
(
pReq
->
name
)
+
1
,
&
pMeta
->
txn
);
tdbTbDelete
(
pMeta
->
pUidIdx
,
&
pReq
->
suid
,
sizeof
(
tb_uid_t
),
&
pMeta
->
txn
);
metaULock
(
pMeta
);
_exit:
tdbFree
(
pKey
);
tdbFree
(
pData
);
metaDebug
(
"vgId:%d super table %s uid:%"
PRId64
" is dropped"
,
TD_VID
(
pMeta
->
pVnode
),
pReq
->
name
,
pReq
->
suid
);
return
0
;
_err:
metaError
(
"vgId:%d failed to drop super table %s uid:%"
PRId64
" since %s"
,
TD_VID
(
pMeta
->
pVnode
),
pReq
->
name
,
pReq
->
suid
,
tstrerror
(
terrno
));
return
-
1
;
}
int
metaAlterSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
)
{
...
...
@@ -608,14 +615,14 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
// TODO : need to update tag index
}
ctbEntry
.
version
=
version
;
if
(
pTagSchema
->
nCols
==
1
&&
pTagSchema
->
pSchema
[
0
].
type
==
TSDB_DATA_TYPE_JSON
)
{
if
(
pTagSchema
->
nCols
==
1
&&
pTagSchema
->
pSchema
[
0
].
type
==
TSDB_DATA_TYPE_JSON
)
{
ctbEntry
.
ctbEntry
.
pTags
=
taosMemoryMalloc
(
pAlterTbReq
->
nTagVal
);
if
(
ctbEntry
.
ctbEntry
.
pTags
==
NULL
)
{
if
(
ctbEntry
.
ctbEntry
.
pTags
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
}
memcpy
((
void
*
)
ctbEntry
.
ctbEntry
.
pTags
,
pAlterTbReq
->
pTagVal
,
pAlterTbReq
->
nTagVal
);
}
else
{
memcpy
((
void
*
)
ctbEntry
.
ctbEntry
.
pTags
,
pAlterTbReq
->
pTagVal
,
pAlterTbReq
->
nTagVal
);
}
else
{
SKVRowBuilder
kvrb
=
{
0
};
const
SKVRow
pOldTag
=
(
const
SKVRow
)
ctbEntry
.
ctbEntry
.
pTags
;
SKVRow
pNewTag
=
NULL
;
...
...
@@ -649,7 +656,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
tDecoderClear
(
&
dc1
);
tDecoderClear
(
&
dc2
);
if
(
ctbEntry
.
ctbEntry
.
pTags
)
taosMemoryFree
((
void
*
)
ctbEntry
.
ctbEntry
.
pTags
);
if
(
ctbEntry
.
ctbEntry
.
pTags
)
taosMemoryFree
((
void
*
)
ctbEntry
.
ctbEntry
.
pTags
);
if
(
ctbEntry
.
pBuf
)
taosMemoryFree
(
ctbEntry
.
pBuf
);
if
(
stbEntry
.
pBuf
)
tdbFree
(
stbEntry
.
pBuf
);
tdbTbcClose
(
pTbDbc
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录