Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d1a4e2d2
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看板
提交
d1a4e2d2
编写于
5月 25, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: drop stable
上级
b6738d6d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
43 addition
and
101 deletion
+43
-101
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+43
-101
未找到文件。
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
d1a4e2d2
...
@@ -23,6 +23,7 @@ static int metaUpdateTtlIdx(SMeta *pMeta, const SMetaEntry *pME);
...
@@ -23,6 +23,7 @@ static int metaUpdateTtlIdx(SMeta *pMeta, const SMetaEntry *pME);
static
int
metaSaveToSkmDb
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
int
metaSaveToSkmDb
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
int
metaUpdateCtbIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
int
metaUpdateCtbIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
int
metaUpdateTagIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pCtbEntry
);
static
int
metaUpdateTagIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pCtbEntry
);
static
int
metaDropTableByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int
*
type
);
int
metaCreateSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
)
{
int
metaCreateSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
)
{
SMetaEntry
me
=
{
0
};
SMetaEntry
me
=
{
0
};
...
@@ -116,7 +117,7 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq) {
...
@@ -116,7 +117,7 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq) {
for
(
int32_t
iChild
=
0
;
iChild
<
taosArrayGetSize
(
pArray
);
iChild
++
)
{
for
(
int32_t
iChild
=
0
;
iChild
<
taosArrayGetSize
(
pArray
);
iChild
++
)
{
tb_uid_t
uid
=
*
(
tb_uid_t
*
)
taosArrayGet
(
pArray
,
iChild
);
tb_uid_t
uid
=
*
(
tb_uid_t
*
)
taosArrayGet
(
pArray
,
iChild
);
metaDropTableByUid
(
pMeta
,
uid
);
metaDropTableByUid
(
pMeta
,
uid
,
NULL
);
}
}
taosArrayDestroy
(
pArray
);
taosArrayDestroy
(
pArray
);
...
@@ -263,122 +264,63 @@ _err:
...
@@ -263,122 +264,63 @@ _err:
}
}
int
metaDropTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVDropTbReq
*
pReq
,
SArray
*
tbUids
)
{
int
metaDropTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVDropTbReq
*
pReq
,
SArray
*
tbUids
)
{
TBC
*
pTbDbc
=
NULL
;
void
*
pData
=
NULL
;
TBC
*
pUidIdxc
=
NULL
;
int
nData
=
0
;
TBC
*
pNameIdxc
=
NULL
;
int
rc
=
0
;
const
void
*
pData
;
tb_uid_t
uid
;
int
nData
;
int
type
;
tb_uid_t
uid
;
int64_t
tver
;
SMetaEntry
me
=
{
0
};
SDecoder
coder
=
{
0
};
int8_t
type
;
int64_t
ctime
;
tb_uid_t
suid
;
int
c
=
0
,
ret
;
// search & delete the name idx
tdbTbcOpen
(
pMeta
->
pNameIdx
,
&
pNameIdxc
,
&
pMeta
->
txn
);
ret
=
tdbTbcMoveTo
(
pNameIdxc
,
pReq
->
name
,
strlen
(
pReq
->
name
)
+
1
,
&
c
);
if
(
ret
<
0
||
!
tdbTbcIsValid
(
pNameIdxc
)
||
c
)
{
tdbTbcClose
(
pNameIdxc
);
terrno
=
TSDB_CODE_VND_TABLE_NOT_EXIST
;
return
-
1
;
}
r
et
=
tdbTbcGet
(
pNameIdxc
,
NULL
,
NULL
,
&
pData
,
&
nData
);
r
c
=
tdbTbGet
(
pMeta
->
pNameIdx
,
pReq
->
name
,
strlen
(
pReq
->
name
)
+
1
,
&
pData
,
&
nData
);
if
(
r
et
<
0
)
{
if
(
r
c
<
0
)
{
ASSERT
(
0
)
;
terrno
=
TSDB_CODE_VND_TABLE_NOT_EXIST
;
return
-
1
;
return
-
1
;
}
}
uid
=
*
(
tb_uid_t
*
)
pData
;
uid
=
*
(
tb_uid_t
*
)
pData
;
tdbTbcDelete
(
pNameIdxc
);
metaWLock
(
pMeta
);
tdbTbcClose
(
pNameIdxc
);
metaDropTableByUid
(
pMeta
,
uid
,
&
type
);
metaULock
(
pMeta
);
// search & delete uid idx
tdbTbcOpen
(
pMeta
->
pUidIdx
,
&
pUidIdxc
,
&
pMeta
->
txn
);
ret
=
tdbTbcMoveTo
(
pUidIdxc
,
&
uid
,
sizeof
(
uid
),
&
c
);
if
(
ret
<
0
||
c
!=
0
)
{
ASSERT
(
0
);
return
-
1
;
}
ret
=
tdbTbcGet
(
pUidIdxc
,
NULL
,
NULL
,
&
pData
,
&
nData
);
if
(
ret
<
0
)
{
ASSERT
(
0
);
return
-
1
;
}
tver
=
*
(
int64_t
*
)
pData
;
tdbTbcDelete
(
pUidIdxc
);
tdbTbcClose
(
pUidIdxc
);
// search and get meta entry
tdbTbcOpen
(
pMeta
->
pTbDb
,
&
pTbDbc
,
&
pMeta
->
txn
);
ret
=
tdbTbcMoveTo
(
pTbDbc
,
&
(
STbDbKey
){.
uid
=
uid
,
.
version
=
tver
},
sizeof
(
STbDbKey
),
&
c
);
if
(
ret
<
0
||
c
!=
0
)
{
ASSERT
(
0
);
return
-
1
;
}
ret
=
tdbTbcGet
(
pTbDbc
,
NULL
,
NULL
,
&
pData
,
&
nData
);
if
(
type
==
TSDB_CHILD_TABLE
&&
tbUids
)
{
if
(
ret
<
0
)
{
taosArrayPush
(
tbUids
,
&
uid
);
ASSERT
(
0
);
return
-
1
;
}
}
// decode entry
tdbFree
(
pData
);
void
*
pDataCopy
=
taosMemoryMalloc
(
nData
);
// remove the copy (todo)
return
0
;
memcpy
(
pDataCopy
,
pData
,
nData
);
}
tDecoderInit
(
&
coder
,
pDataCopy
,
nData
);
ret
=
metaDecodeEntry
(
&
coder
,
&
me
);
if
(
ret
<
0
)
{
ASSERT
(
0
);
return
-
1
;
}
type
=
me
.
type
;
static
int
metaDropTableByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int
*
type
)
{
if
(
type
==
TSDB_CHILD_TABLE
)
{
void
*
pData
=
NULL
;
ctime
=
me
.
ctbEntry
.
ctime
;
int
nData
=
0
;
suid
=
me
.
ctbEntry
.
suid
;
int
rc
=
0
;
taosArrayPush
(
tbUids
,
&
me
.
uid
);
int64_t
version
;
}
else
if
(
type
==
TSDB_NORMAL_TABLE
)
{
SMetaEntry
e
=
{
0
};
ctime
=
me
.
ntbEntry
.
ctime
;
SDecoder
dc
=
{
0
};
suid
=
0
;
}
else
{
ASSERT
(
0
);
}
taosMemoryFree
(
pDataCopy
);
rc
=
tdbTbGet
(
pMeta
->
pUidIdx
,
&
uid
,
sizeof
(
uid
),
&
pData
,
&
nData
);
tDecoderClear
(
&
coder
);
version
=
*
(
int64_t
*
)
pData
;
tdbTbcClose
(
pTbDbc
);
if
(
type
==
TSDB_CHILD_TABLE
)
{
tdbTbGet
(
pMeta
->
pTbDb
,
&
(
STbDbKey
){.
version
=
version
,
.
uid
=
uid
},
sizeof
(
STbDbKey
),
&
pData
,
&
nData
);
// remove the pCtbIdx
TBC
*
pCtbIdxc
=
NULL
;
tdbTbcOpen
(
pMeta
->
pCtbIdx
,
&
pCtbIdxc
,
&
pMeta
->
txn
);
ret
=
tdbTbcMoveTo
(
pCtbIdxc
,
&
(
SCtbIdxKey
){.
suid
=
suid
,
.
uid
=
uid
},
sizeof
(
SCtbIdxKey
),
&
c
);
tDecoderInit
(
&
dc
,
pData
,
nData
);
if
(
ret
<
0
||
c
!=
0
)
{
metaDecodeEntry
(
&
dc
,
&
e
);
ASSERT
(
0
);
return
-
1
;
}
tdbTbcDelete
(
pCtbIdxc
);
if
(
type
)
*
type
=
e
.
type
;
tdbTbcClose
(
pCtbIdxc
);
// remove tags from pTagIdx (todo)
tdbTbDelete
(
pMeta
->
pTbDb
,
&
(
STbDbKey
){.
version
=
version
,
.
uid
=
uid
},
sizeof
(
STbDbKey
),
&
pMeta
->
txn
);
}
else
if
(
type
==
TSDB_NORMAL_TABLE
)
{
tdbTbDelete
(
pMeta
->
pNameIdx
,
e
.
name
,
strlen
(
e
.
name
)
+
1
,
&
pMeta
->
txn
);
// remove from pSkmDb
tdbTbDelete
(
pMeta
->
pUidIdx
,
&
uid
,
sizeof
(
uid
),
&
pMeta
->
txn
);
}
else
{
if
(
e
.
type
==
TSDB_CHILD_TABLE
)
{
ASSERT
(
0
);
tdbTbDelete
(
pMeta
->
pCtbIdx
,
&
(
SCtbIdxKey
){.
suid
=
e
.
ctbEntry
.
suid
,
.
uid
=
uid
},
sizeof
(
SCtbIdxKey
),
&
pMeta
->
txn
);
}
else
if
(
e
.
type
==
TSDB_NORMAL_TABLE
)
{
// drop schema.db (todo)
// drop ttl.idx (todo)
}
else
if
(
e
.
type
==
TSDB_SUPER_TABLE
)
{
// drop schema.db (todo)
}
}
// remove from ttl (todo)
tDecoderClear
(
&
dc
);
if
(
ctime
>
0
)
{
tdbFree
(
pData
);
}
return
0
;
return
0
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录