Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9b7d9356
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看板
提交
9b7d9356
编写于
2月 04, 2023
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
opt index
上级
f19d64e0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
138 addition
and
3 deletion
+138
-3
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+1
-1
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+123
-1
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+14
-1
未找到文件。
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
9b7d9356
...
...
@@ -142,7 +142,7 @@ int metaGetTableEntryByName(SMetaReader* pReader, const char* name);
int
metaAlterCache
(
SMeta
*
pMeta
,
int32_t
nPage
);
int
metaAddIndexToSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
);
int
metaDropIndexFromSTable
(
SMeta
*
pMeta
,
int64_t
version
,
S
VCreateStb
Req
*
pReq
);
int
metaDropIndexFromSTable
(
SMeta
*
pMeta
,
int64_t
version
,
S
DropIndex
Req
*
pReq
);
int64_t
metaGetTimeSeriesNum
(
SMeta
*
pMeta
);
SMCtbCursor
*
metaOpenCtbCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int
lock
);
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
9b7d9356
...
...
@@ -530,9 +530,131 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
_err:
return
TSDB_CODE_VND_COL_ALREADY_EXISTS
;
}
int
metaDropIndexFromSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
)
{
int
metaDropIndexFromSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SDropIndexReq
*
pReq
)
{
SMetaEntry
oStbEntry
=
{
0
};
SMetaEntry
nStbEntry
=
{
0
};
STbDbKey
tbDbKey
=
{
0
};
TBC
*
pUidIdxc
=
NULL
;
TBC
*
pTbDbc
=
NULL
;
int
ret
=
0
;
int
c
=
-
2
;
void
*
pData
=
NULL
;
int
nData
=
0
;
int64_t
oversion
;
SDecoder
dc
=
{
0
};
tb_uid_t
suid
=
pReq
->
stbUid
;
if
(
tdbTbGet
(
pMeta
->
pUidIdx
,
&
suid
,
sizeof
(
tb_uid_t
),
&
pData
,
&
nData
)
!=
0
)
{
ret
=
-
1
;
goto
_err
;
}
tbDbKey
.
uid
=
suid
;
tbDbKey
.
version
=
((
SUidIdxVal
*
)
pData
)[
0
].
version
;
tdbTbGet
(
pMeta
->
pTbDb
,
&
tbDbKey
,
sizeof
(
tbDbKey
),
&
pData
,
&
nData
);
tDecoderInit
(
&
dc
,
pData
,
nData
);
ret
=
metaDecodeEntry
(
&
dc
,
&
oStbEntry
);
if
(
ret
<
0
)
{
goto
_err
;
}
SSchema
*
pCol
=
NULL
;
int32_t
colId
=
-
1
;
for
(
int
i
=
0
;
i
<
oStbEntry
.
stbEntry
.
schemaTag
.
nCols
;
i
++
)
{
SSchema
*
schema
=
oStbEntry
.
stbEntry
.
schemaTag
.
pSchema
+
i
;
if
(
strncmp
(
schema
->
name
,
pReq
->
colName
,
sizeof
(
pReq
->
colName
)))
{
if
(
IS_IDX_ON
(
schema
))
{
pCol
=
schema
;
}
break
;
}
}
if
(
pCol
==
NULL
)
{
goto
_err
;
}
/*
* iterator all pTdDbc by uid and version
*/
TBC
*
pCtbIdxc
=
NULL
;
tdbTbcOpen
(
pMeta
->
pCtbIdx
,
&
pCtbIdxc
,
NULL
);
int
rc
=
tdbTbcMoveTo
(
pCtbIdxc
,
&
(
SCtbIdxKey
){.
suid
=
suid
,
.
uid
=
INT64_MIN
},
sizeof
(
SCtbIdxKey
),
&
c
);
if
(
rc
<
0
)
{
tdbTbcClose
(
pCtbIdxc
);
goto
_err
;
}
for
(;;)
{
void
*
pKey
=
NULL
,
*
pVal
=
NULL
;
int
nKey
=
0
,
nVal
=
0
;
rc
=
tdbTbcNext
(
pCtbIdxc
,
&
pKey
,
&
nKey
,
&
pVal
,
&
nVal
);
if
(
rc
<
0
)
break
;
if
(((
SCtbIdxKey
*
)
pKey
)
->
suid
!=
suid
)
{
tdbFree
(
pKey
);
tdbFree
(
pVal
);
continue
;
}
STagIdxKey
*
pTagIdxKey
=
NULL
;
int32_t
nTagIdxKey
;
const
void
*
pTagData
=
NULL
;
int32_t
nTagData
=
0
;
SCtbIdxKey
*
table
=
(
SCtbIdxKey
*
)
pKey
;
STagVal
tagVal
=
{.
cid
=
pCol
->
colId
};
tTagGet
((
const
STag
*
)
pVal
,
&
tagVal
);
if
(
IS_VAR_DATA_TYPE
(
pCol
->
type
))
{
pTagData
=
tagVal
.
pData
;
nTagData
=
(
int32_t
)
tagVal
.
nData
;
}
else
{
pTagData
=
&
(
tagVal
.
i64
);
nTagData
=
tDataTypes
[
pCol
->
type
].
bytes
;
}
if
(
metaCreateTagIdxKey
(
suid
,
pCol
->
colId
,
pTagData
,
nTagData
,
pCol
->
type
,
table
->
uid
,
&
pTagIdxKey
,
&
nTagIdxKey
)
<
0
)
{
metaDestroyTagIdxKey
(
pTagIdxKey
);
goto
_err
;
}
tdbTbDelete
(
pMeta
->
pTagIdx
,
pTagIdxKey
,
nTagIdxKey
,
pMeta
->
txn
);
metaDestroyTagIdxKey
(
pTagIdxKey
);
}
// clear idx flag
pCol
->
flags
=
0
;
nStbEntry
.
version
=
version
;
nStbEntry
.
type
=
TSDB_SUPER_TABLE
;
nStbEntry
.
uid
=
oStbEntry
.
uid
;
nStbEntry
.
name
=
oStbEntry
.
name
;
SSchemaWrapper
*
row
=
tCloneSSchemaWrapper
(
&
oStbEntry
.
stbEntry
.
schemaRow
);
SSchemaWrapper
*
tag
=
tCloneSSchemaWrapper
(
&
oStbEntry
.
stbEntry
.
schemaTag
);
nStbEntry
.
stbEntry
.
schemaRow
=
*
row
;
nStbEntry
.
stbEntry
.
schemaTag
=
*
tag
;
nStbEntry
.
stbEntry
.
rsmaParam
=
oStbEntry
.
stbEntry
.
rsmaParam
;
taosMemoryFree
(
row
);
taosMemoryFree
(
tag
);
metaWLock
(
pMeta
);
// update table.db
metaSaveToTbDb
(
pMeta
,
&
nStbEntry
);
// update uid index
metaUpdateUidIdx
(
pMeta
,
&
nStbEntry
);
metaULock
(
pMeta
);
if
(
oStbEntry
.
pBuf
)
taosMemoryFree
(
oStbEntry
.
pBuf
);
tDecoderClear
(
&
dc
);
return
TSDB_CODE_SUCCESS
;
// impl later
return
TSDB_CODE_SUCCESS
;
_err:
return
-
1
;
}
int
metaCreateTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateTbReq
*
pReq
,
STableMetaRsp
**
pMetaRsp
)
{
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
9b7d9356
...
...
@@ -1453,6 +1453,19 @@ _err:
return
-
1
;
}
static
int32_t
vnodeProcessDropIndexReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
)
{
// impl later
SDropIndexReq
req
=
{
0
};
pRsp
->
msgType
=
TDMT_VND_CREATE_INDEX_RSP
;
pRsp
->
code
=
TSDB_CODE_SUCCESS
;
pRsp
->
pCont
=
NULL
;
pRsp
->
contLen
=
0
;
if
(
tDeserializeSDropIdxReq
(
pReq
,
len
,
&
req
))
{
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
}
if
(
metaDropIndexFromSTable
(
pVnode
->
pMeta
,
version
,
&
req
)
<
0
)
{
pRsp
->
code
=
terrno
;
return
-
1
;
}
return
TSDB_CODE_SUCCESS
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录