Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
db61fbb6
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看板
提交
db61fbb6
编写于
2月 04, 2023
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
opt index
上级
17b7b81c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
113 addition
and
38 deletion
+113
-38
include/common/tmsg.h
include/common/tmsg.h
+1
-7
source/common/src/tmsg.c
source/common/src/tmsg.c
+4
-10
source/dnode/mnode/impl/src/mndIndex.c
source/dnode/mnode/impl/src/mndIndex.c
+108
-21
未找到文件。
include/common/tmsg.h
浏览文件 @
db61fbb6
...
...
@@ -2811,13 +2811,7 @@ typedef struct {
int32_t
tSerializeSCreateTagIdxReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateTagIndexReq
*
pReq
);
int32_t
tDeserializeSCreateTagIdxReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateTagIndexReq
*
pReq
);
typedef
struct
{
char
dbFName
[
TSDB_DB_FNAME_LEN
];
char
stbName
[
TSDB_TABLE_FNAME_LEN
];
char
colName
[
TSDB_COL_NAME_LEN
];
char
idxName
[
TSDB_COL_NAME_LEN
];
int8_t
idxType
;
}
SDropTagIndexReq
;
typedef
SMDropSmaReq
SDropTagIndexReq
;
int32_t
tSerializeSDropTagIdxReq
(
void
*
buf
,
int32_t
bufLen
,
SDropTagIndexReq
*
pReq
);
int32_t
tDeserializeSDropTagIdxReq
(
void
*
buf
,
int32_t
bufLen
,
SDropTagIndexReq
*
pReq
);
...
...
source/common/src/tmsg.c
浏览文件 @
db61fbb6
...
...
@@ -957,11 +957,8 @@ int32_t tSerializeSDropTagIdxReq(void *buf, int32_t bufLen, SDropTagIndexReq *pR
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
dbFName
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
stbName
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
colName
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
idxName
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
idxType
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igNotExists
)
<
0
)
return
-
1
;
int32_t
tlen
=
encoder
.
pos
;
tEncoderClear
(
&
encoder
);
...
...
@@ -972,11 +969,8 @@ int32_t tDeserializeSDropTagIdxReq(void *buf, int32_t bufLen, SDropTagIndexReq *
tDecoderInit
(
&
decoder
,
buf
,
bufLen
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
dbFName
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
stbName
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
colName
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
idxName
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
idxType
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
igNotExists
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
...
...
source/dnode/mnode/impl/src/mndIndex.c
浏览文件 @
db61fbb6
...
...
@@ -122,6 +122,42 @@ int mndSetCreateIdxRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStb
return
0
;
}
int
mndSetDropIdxRedoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SStbObj
*
pStb
,
SIdxObj
*
pIdx
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SVgObj
*
pVgroup
=
NULL
;
void
*
pIter
=
NULL
;
int32_t
contLen
;
while
(
1
)
{
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
if
(
pIter
==
NULL
)
break
;
if
(
!
mndVgroupInDb
(
pVgroup
,
pDb
->
uid
))
{
sdbRelease
(
pSdb
,
pVgroup
);
continue
;
}
void
*
pReq
=
mndBuildVCreateStbReq
(
pMnode
,
pVgroup
,
pStb
,
&
contLen
,
NULL
,
0
);
if
(
pReq
==
NULL
)
{
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pVgroup
);
return
-
1
;
}
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
action
.
pCont
=
pReq
;
action
.
contLen
=
contLen
;
action
.
msgType
=
TDMT_VND_DROP_INDEX
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
taosMemoryFree
(
pReq
);
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pVgroup
);
return
-
1
;
}
sdbRelease
(
pSdb
,
pVgroup
);
}
return
0
;
}
void
mndCleanupIdx
(
SMnode
*
pMnode
)
{
// do nothing
...
...
@@ -388,14 +424,6 @@ static int32_t mndSetDropIdxCommitLogs(SMnode *pMnode, STrans *pTrans, SIdxObj *
return
0
;
}
static
int32_t
mndDropIdx
(
SMnode
*
pMnode
,
SRpcMsg
*
pReq
,
SDbObj
*
pDb
,
SIdxObj
*
pIdx
)
{
int32_t
code
=
-
1
;
SVgObj
*
pVgroup
=
NULL
;
SStbObj
*
pStb
=
NULL
;
STrans
*
pTrans
=
NULL
;
return
0
;
}
int32_t
mndDropIdxsByStb
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SStbObj
*
pStb
)
{
// stb
return
0
;
...
...
@@ -704,6 +732,7 @@ _OVER:
mndTransDrop
(
pTrans
);
return
code
;
}
static
int32_t
mndAddIndex
(
SMnode
*
pMnode
,
SRpcMsg
*
pReq
,
SCreateTagIndexReq
*
req
,
SDbObj
*
pDb
,
SStbObj
*
pStb
)
{
SIdxObj
idxObj
=
{
0
};
memcpy
(
idxObj
.
name
,
req
->
idxName
,
TSDB_TABLE_FNAME_LEN
);
...
...
@@ -750,21 +779,79 @@ static int32_t mndAddIndex(SMnode *pMnode, SRpcMsg *pReq, SCreateTagIndexReq *re
return
code
;
}
static
int32_t
mndDropIdx
(
SMnode
*
pMnode
,
SRpcMsg
*
pReq
,
SDbObj
*
pDb
,
SIdxObj
*
pIdx
)
{
int32_t
code
=
-
1
;
SStbObj
*
pStb
=
NULL
;
STrans
*
pTrans
=
NULL
;
SStbObj
newObj
=
{
0
};
pStb
=
mndAcquireStb
(
pMnode
,
pIdx
->
stb
);
if
(
pStb
==
NULL
)
goto
_OVER
;
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_CONFLICT_DB
,
pReq
,
"drop-index"
);
if
(
pTrans
==
NULL
)
goto
_OVER
;
mInfo
(
"trans:%d, used to drop idx:%s"
,
pTrans
->
id
,
pIdx
->
name
);
mndTransSetDbName
(
pTrans
,
pDb
->
name
,
NULL
);
if
(
mndTrancCheckConflict
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
mndTransSetSerial
(
pTrans
);
if
(
mndSetDropIdxRedoLogs
(
pMnode
,
pTrans
,
pIdx
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropIdxCommitLogs
(
pMnode
,
pTrans
,
pIdx
)
!=
0
)
goto
_OVER
;
if
(
mndSetUpdateIdxStbCommitLogs
(
pMnode
,
pTrans
,
pStb
,
&
newObj
,
pIdx
->
colName
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropIdxRedoActions
(
pMnode
,
pTrans
,
pStb
,
&
newObj
,
pIdx
)
!=
0
)
goto
_OVER
;
_OVER:
mndTransDrop
(
pTrans
);
mndReleaseStb
(
pMnode
,
pStb
);
}
static
int32_t
mndProcessDropIdxReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
// SDbObj *pDb = NULL;
// SStbObj *pStb = NULL;
// SDropTagIndexReq dropReq = {0};
// if (tDeserializeSDropTagIdxReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
// terrno = TSDB_CODE_INVALID_MSG;
// goto _OVER;
// }
//
// return TSDB_CODE_SUCCESS;
//_OVER:
// return code;
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
SDbObj
*
pDb
=
NULL
;
SIdxObj
*
pIdx
=
NULL
;
SDropTagIndexReq
req
=
{
0
};
if
(
tDeserializeSDropTagIdxReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
dropReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
_OVER
;
}
mInfo
(
"idx:%s, start to drop"
,
req
.
name
);
pIdx
=
mndAcquireIdx
(
pMnode
,
req
.
name
);
if
(
pIdx
==
NULL
)
{
if
(
req
.
igNotExists
)
{
mInfo
(
"idx:%s, not exist, ignore not exist is set"
,
req
.
name
);
code
=
0
;
goto
_OVER
;
}
else
{
terrno
=
TSDB_CODE_MND_SMA_NOT_EXIST
;
goto
_OVER
;
}
}
pDb
=
mndAcquireDbByIdx
(
pMnode
,
dropReq
.
name
);
if
(
pDb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_DB_NOT_SELECTED
;
goto
_OVER
;
}
if
(
mndCheckDbPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
code
=
mndDropIdx
(
pMnode
,
pReq
,
pDb
,
pIdx
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
return
code
;
_OVER:
if
(
code
!=
0
&&
code
!=
TSDB_CODE_ACTION_IN_PROGRESS
)
{
mError
(
"idx:%s, failed to drop since %s"
,
req
.
name
,
terrstr
());
}
}
static
int32_t
mndProcessGetIdxReq
(
SRpcMsg
*
pReq
)
{
// do nothing
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录