Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e29bb8b6
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
e29bb8b6
编写于
12月 12, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-10431 alter stb
上级
9c1827f9
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
176 addition
and
6 deletion
+176
-6
include/common/taosmsg.h
include/common/taosmsg.h
+7
-3
source/dnode/mgmt/impl/test/CMakeLists.txt
source/dnode/mgmt/impl/test/CMakeLists.txt
+1
-0
source/dnode/mgmt/impl/test/dnode/CMakeLists.txt
source/dnode/mgmt/impl/test/dnode/CMakeLists.txt
+29
-0
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+2
-0
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+130
-3
source/dnode/mnode/impl/src/mnode.c
source/dnode/mnode/impl/src/mnode.c
+7
-0
未找到文件。
include/common/taosmsg.h
浏览文件 @
e29bb8b6
...
...
@@ -320,10 +320,14 @@ typedef struct {
typedef
struct
{
char
name
[
TSDB_TABLE_FNAME_LEN
];
// if user specify DROP STABLE, this flag will be set. And an error will be returned if it is not a super table
int8_t
supertable
;
int8_t
igNotExists
;
}
SCMDropTableMsg
;
}
SDropStbMsg
;
typedef
struct
{
char
name
[
TSDB_TABLE_FNAME_LEN
];
int8_t
alterType
;
SSchema
schema
;
}
SAlterStbMsg
;
typedef
struct
{
char
tableFname
[
TSDB_TABLE_FNAME_LEN
];
...
...
source/dnode/mgmt/impl/test/CMakeLists.txt
浏览文件 @
e29bb8b6
# add_subdirectory(acct)
# add_subdirectory(cluster)
add_subdirectory
(
dnode
)
# add_subdirectory(profile)
# add_subdirectory(show)
add_subdirectory
(
user
)
source/dnode/mgmt/impl/test/dnode/CMakeLists.txt
0 → 100644
浏览文件 @
e29bb8b6
add_executable
(
dndTestDnode
""
)
target_sources
(
dndTestDnode
PRIVATE
"dnode.cpp"
"../sut/deploy.cpp"
)
target_link_libraries
(
dndTestDnode
PUBLIC dnode
PUBLIC util
PUBLIC os
PUBLIC gtest_main
)
target_include_directories
(
dndTestDnode
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/server/dnode/mgmt"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../sut"
)
enable_testing
()
add_test
(
NAME dndTestDnode
COMMAND dndTestDnode
)
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
e29bb8b6
...
...
@@ -88,6 +88,8 @@ void mndSendMsgToMnode(SMnode *pMnode, SRpcMsg *pMsg);
void
mndSendRedirectMsg
(
SMnode
*
pMnode
,
SRpcMsg
*
pMsg
);
void
mndSetMsgHandle
(
SMnode
*
pMnode
,
int32_t
msgType
,
MndMsgFp
fp
);
uint64_t
mndGenerateUid
(
char
*
name
,
int32_t
len
)
;
#ifdef __cplusplus
}
#endif
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
e29bb8b6
...
...
@@ -240,7 +240,7 @@ static int32_t mndCreateStb(SMnode *pMnode, SMnodeMsg *pMsg, SCreateStbMsg *pCre
tstrncpy
(
stbObj
.
db
,
pDb
->
name
,
TSDB_FULL_DB_NAME_LEN
);
stbObj
.
createdTime
=
taosGetTimestampMs
();
stbObj
.
updateTime
=
stbObj
.
createdTime
;
stbObj
.
uid
=
1234
;
stbObj
.
uid
=
mndGenerateUid
(
pCreate
->
name
,
TSDB_TABLE_FNAME_LEN
)
;
stbObj
.
version
=
1
;
stbObj
.
numOfColumns
=
pCreate
->
numOfColumns
;
stbObj
.
numOfTags
=
pCreate
->
numOfTags
;
...
...
@@ -340,11 +340,138 @@ static int32_t mndProcessCreateStbMsg(SMnodeMsg *pMsg) {
static
int32_t
mndProcessCreateStbInRsp
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
static
int32_t
mndProcessAlterStbMsg
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
static
int32_t
mndCheckAlterStbMsg
(
SAlterStbMsg
*
pAlter
)
{
SSchema
*
pSchema
=
&
pAlter
->
schema
;
pSchema
->
colId
=
htonl
(
pSchema
->
colId
);
pSchema
->
bytes
=
htonl
(
pSchema
->
bytes
);
if
(
pSchema
->
type
<=
0
)
{
terrno
=
TSDB_CODE_MND_STB_INVALID_COL_TYPE
;
return
-
1
;
}
if
(
pSchema
->
colId
<
0
||
pSchema
->
colId
>=
(
TSDB_MAX_COLUMNS
+
TSDB_MAX_TAGS
))
{
terrno
=
TSDB_CODE_MND_STB_INVALID_COL_ID
;
return
-
1
;
}
if
(
pSchema
->
bytes
<=
0
)
{
terrno
=
TSDB_CODE_MND_STB_INVALID_COL_BYTES
;
return
-
1
;
}
if
(
pSchema
->
name
[
0
]
==
0
)
{
terrno
=
TSDB_CODE_MND_STB_INVALID_COL_NAME
;
return
-
1
;
}
return
0
;
}
static
int32_t
mndUpdateStb
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
SStbObj
*
pOldStb
,
SStbObj
*
pNewStb
)
{
return
0
;
}
static
int32_t
mndProcessAlterStbMsg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SAlterStbMsg
*
pAlter
=
pMsg
->
rpcMsg
.
pCont
;
mDebug
(
"stb:%s, start to alter"
,
pAlter
->
name
);
if
(
mndCheckAlterStbMsg
(
pAlter
)
!=
0
)
{
mError
(
"stb:%s, failed to alter since %s"
,
pAlter
->
name
,
terrstr
());
return
-
1
;
}
SStbObj
*
pStb
=
mndAcquireStb
(
pMnode
,
pAlter
->
name
);
if
(
pStb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_STB_NOT_EXIST
;
mError
(
"stb:%s, failed to alter since %s"
,
pAlter
->
name
,
terrstr
());
return
-
1
;
}
SStbObj
stbObj
=
{
0
};
memcpy
(
&
stbObj
,
pStb
,
sizeof
(
SStbObj
));
int32_t
code
=
mndUpdateStb
(
pMnode
,
pMsg
,
pStb
,
&
stbObj
);
mndReleaseStb
(
pMnode
,
pStb
);
if
(
code
!=
0
)
{
mError
(
"stb:%s, failed to alter since %s"
,
pAlter
->
name
,
tstrerror
(
code
));
return
code
;
}
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
static
int32_t
mndProcessAlterStbInRsp
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
static
int32_t
mndProcessDropStbMsg
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
static
int32_t
mndDropStb
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
SStbObj
*
pStb
)
{
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
pMsg
->
rpcMsg
.
handle
);
if
(
pTrans
==
NULL
)
{
mError
(
"stb:%s, failed to drop since %s"
,
pStb
->
name
,
terrstr
());
return
-
1
;
}
mDebug
(
"trans:%d, used to drop stb:%s"
,
pTrans
->
id
,
pStb
->
name
);
SSdbRaw
*
pRedoRaw
=
mndStbActionEncode
(
pStb
);
if
(
pRedoRaw
==
NULL
||
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append redo log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_DROPPING
);
SSdbRaw
*
pUndoRaw
=
mndStbActionEncode
(
pStb
);
if
(
pUndoRaw
==
NULL
||
mndTransAppendUndolog
(
pTrans
,
pUndoRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append undo log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pUndoRaw
,
SDB_STATUS_READY
);
SSdbRaw
*
pCommitRaw
=
mndStbActionEncode
(
pStb
);
if
(
pCommitRaw
==
NULL
||
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append commit log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_DROPPED
);
if
(
mndTransPrepare
(
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
mndTransDrop
(
pTrans
);
return
0
;
}
static
int32_t
mndProcessDropStbMsg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SDropStbMsg
*
pDrop
=
pMsg
->
rpcMsg
.
pCont
;
mDebug
(
"stb:%s, start to drop"
,
pDrop
->
name
);
SStbObj
*
pStb
=
mndAcquireStb
(
pMnode
,
pDrop
->
name
);
if
(
pStb
==
NULL
)
{
if
(
pDrop
->
igNotExists
)
{
mDebug
(
"stb:%s, not exist, ignore not exist is set"
,
pDrop
->
name
);
return
0
;
}
else
{
terrno
=
TSDB_CODE_MND_STB_NOT_EXIST
;
mError
(
"stb:%s, failed to drop since %s"
,
pDrop
->
name
,
terrstr
());
return
-
1
;
}
}
int32_t
code
=
mndDropStb
(
pMnode
,
pMsg
,
pStb
);
mndReleaseStb
(
pMnode
,
pStb
);
if
(
code
!=
0
)
{
terrno
=
code
;
mError
(
"stb:%s, failed to drop since %s"
,
pDrop
->
name
,
terrstr
());
return
-
1
;
}
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
static
int32_t
mndProcessDropStbInRsp
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
...
...
source/dnode/mnode/impl/src/mnode.c
浏览文件 @
e29bb8b6
...
...
@@ -430,3 +430,10 @@ void mndProcessWriteMsg(SMnodeMsg *pMsg) { mndProcessRpcMsg(pMsg); }
void
mndProcessSyncMsg
(
SMnodeMsg
*
pMsg
)
{
mndProcessRpcMsg
(
pMsg
);
}
void
mndProcessApplyMsg
(
SMnodeMsg
*
pMsg
)
{}
uint64_t
mndGenerateUid
(
char
*
name
,
int32_t
len
)
{
int64_t
us
=
taosGetTimestampUs
();
int32_t
hashval
=
MurmurHash3_32
(
name
,
len
);
uint64_t
x
=
(
us
&
0x000000FFFFFFFFFF
)
<<
24
;
return
x
+
((
hashval
&
((
1ul
<<
16
)
-
1ul
))
<<
8
)
+
(
taosRand
()
&
((
1ul
<<
8
)
-
1ul
));
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录