Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
94de43c5
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看板
提交
94de43c5
编写于
2月 08, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update stb
上级
84911399
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
37 addition
and
37 deletion
+37
-37
include/common/tmsg.h
include/common/tmsg.h
+4
-4
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+27
-27
source/dnode/mnode/impl/test/stb/stb.cpp
source/dnode/mnode/impl/test/stb/stb.cpp
+5
-5
source/libs/parser/src/astToMsg.c
source/libs/parser/src/astToMsg.c
+1
-1
未找到文件。
include/common/tmsg.h
浏览文件 @
94de43c5
...
...
@@ -254,7 +254,7 @@ typedef struct {
int8_t
igExists
;
int32_t
numOfTags
;
int32_t
numOfColumns
;
SSchema
pSchema
[];
SSchema
pSchema
s
[];
}
SMCreateStbReq
;
typedef
struct
{
...
...
@@ -264,9 +264,9 @@ typedef struct {
typedef
struct
{
char
name
[
TSDB_TABLE_FNAME_LEN
];
int8_t
alter
Type
;
int32_t
numOf
Column
s
;
SSchema
pSchema
[];
int8_t
update
Type
;
int32_t
numOf
Schema
s
;
SSchema
pSchema
s
[];
}
SMUpdateStbReq
;
typedef
struct
{
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
94de43c5
...
...
@@ -33,10 +33,10 @@ static int32_t mndStbActionInsert(SSdb *pSdb, SStbObj *pStb);
static
int32_t
mndStbActionDelete
(
SSdb
*
pSdb
,
SStbObj
*
pStb
);
static
int32_t
mndStbActionUpdate
(
SSdb
*
pSdb
,
SStbObj
*
pOld
,
SStbObj
*
pNew
);
static
int32_t
mndProcessMCreateStbReq
(
SMnodeMsg
*
pReq
);
static
int32_t
mndProcessM
Alter
StbReq
(
SMnodeMsg
*
pReq
);
static
int32_t
mndProcessM
Update
StbReq
(
SMnodeMsg
*
pReq
);
static
int32_t
mndProcessMDropStbReq
(
SMnodeMsg
*
pReq
);
static
int32_t
mndProcessVCreateStbRsp
(
SMnodeMsg
*
pRsp
);
static
int32_t
mndProcessV
Alter
StbRsp
(
SMnodeMsg
*
pRsp
);
static
int32_t
mndProcessV
Update
StbRsp
(
SMnodeMsg
*
pRsp
);
static
int32_t
mndProcessVDropStbRsp
(
SMnodeMsg
*
pRsp
);
static
int32_t
mndProcessStbMetaReq
(
SMnodeMsg
*
pReq
);
static
int32_t
mndGetStbMeta
(
SMnodeMsg
*
pReq
,
SShowObj
*
pShow
,
STableMetaRsp
*
pMeta
);
...
...
@@ -53,10 +53,10 @@ int32_t mndInitStb(SMnode *pMnode) {
.
deleteFp
=
(
SdbDeleteFp
)
mndStbActionDelete
};
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CREATE_STB
,
mndProcessMCreateStbReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_ALTER_STB
,
mndProcessM
Alter
StbReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_ALTER_STB
,
mndProcessM
Update
StbReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_STB
,
mndProcessMDropStbReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_VND_CREATE_STB_RSP
,
mndProcessVCreateStbRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_VND_ALTER_STB_RSP
,
mndProcessV
Alter
StbRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_VND_ALTER_STB_RSP
,
mndProcessV
Update
StbRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_VND_DROP_STB_RSP
,
mndProcessVDropStbRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_STB_META
,
mndProcessStbMetaReq
);
...
...
@@ -325,7 +325,7 @@ static int32_t mndCheckCreateStbReq(SMCreateStbReq *pCreate) {
pCreate
->
numOfTags
=
htonl
(
pCreate
->
numOfTags
);
int32_t
totalCols
=
pCreate
->
numOfColumns
+
pCreate
->
numOfTags
;
for
(
int32_t
i
=
0
;
i
<
totalCols
;
++
i
)
{
SSchema
*
pSchema
=
&
pCreate
->
pSchema
[
i
];
SSchema
*
pSchema
=
&
pCreate
->
pSchema
s
[
i
];
pSchema
->
bytes
=
htonl
(
pSchema
->
bytes
);
}
...
...
@@ -346,7 +346,7 @@ static int32_t mndCheckCreateStbReq(SMCreateStbReq *pCreate) {
int32_t
maxColId
=
(
TSDB_MAX_COLUMNS
+
TSDB_MAX_TAGS
);
for
(
int32_t
i
=
0
;
i
<
totalCols
;
++
i
)
{
SSchema
*
pSchema
=
&
pCreate
->
pSchema
[
i
];
SSchema
*
pSchema
=
&
pCreate
->
pSchema
s
[
i
];
if
(
pSchema
->
type
<
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
...
...
@@ -483,8 +483,8 @@ static int32_t mndCreateStb(SMnode *pMnode, SMnodeMsg *pReq, SMCreateStbReq *pCr
return
-
1
;
}
memcpy
(
stbObj
.
pColumns
,
pCreate
->
pSchema
,
stbObj
.
numOfColumns
*
sizeof
(
SSchema
));
memcpy
(
stbObj
.
pTags
,
pCreate
->
pSchema
+
stbObj
.
numOfColumns
,
stbObj
.
numOfTags
*
sizeof
(
SSchema
));
memcpy
(
stbObj
.
pColumns
,
pCreate
->
pSchema
s
,
stbObj
.
numOfColumns
*
sizeof
(
SSchema
));
memcpy
(
stbObj
.
pTags
,
pCreate
->
pSchema
s
+
stbObj
.
numOfColumns
,
stbObj
.
numOfTags
*
sizeof
(
SSchema
));
for
(
int32_t
i
=
0
;
i
<
stbObj
.
numOfColumns
;
++
i
)
{
stbObj
.
pColumns
[
i
].
colId
=
stbObj
.
nextColId
;
...
...
@@ -575,11 +575,11 @@ static int32_t mndProcessVCreateStbRsp(SMnodeMsg *pRsp) {
return
0
;
}
static
int32_t
mndCheck
Alter
StbReq
(
SMUpdateStbReq
*
pUpdate
)
{
pUpdate
->
numOf
Columns
=
htonl
(
pUpdate
->
numOfColumn
s
);
static
int32_t
mndCheck
Update
StbReq
(
SMUpdateStbReq
*
pUpdate
)
{
pUpdate
->
numOf
Schemas
=
htonl
(
pUpdate
->
numOfSchema
s
);
for
(
int32_t
i
=
0
;
i
<
pUpdate
->
numOf
Column
s
;
++
i
)
{
SSchema
*
pSchema
=
&
pUpdate
->
pSchema
[
i
];
for
(
int32_t
i
=
0
;
i
<
pUpdate
->
numOf
Schema
s
;
++
i
)
{
SSchema
*
pSchema
=
&
pUpdate
->
pSchema
s
[
i
];
pSchema
->
colId
=
htonl
(
pSchema
->
colId
);
pSchema
->
bytes
=
htonl
(
pSchema
->
bytes
);
...
...
@@ -916,27 +916,27 @@ static int32_t mndUpdateStb(SMnode *pMnode, SMnodeMsg *pReq, const SMUpdateStbRe
int32_t
code
=
-
1
;
switch
(
pUpdate
->
alter
Type
)
{
switch
(
pUpdate
->
update
Type
)
{
case
TSDB_ALTER_TABLE_ADD_TAG_COLUMN
:
code
=
mndAddSuperTableTag
(
pOld
,
&
stbObj
,
pUpdate
->
pSchema
,
1
);
code
=
mndAddSuperTableTag
(
pOld
,
&
stbObj
,
pUpdate
->
pSchema
s
,
1
);
break
;
case
TSDB_ALTER_TABLE_DROP_TAG_COLUMN
:
code
=
mndDropSuperTableTag
(
pOld
,
&
stbObj
,
pUpdate
->
pSchema
[
0
].
name
);
code
=
mndDropSuperTableTag
(
pOld
,
&
stbObj
,
pUpdate
->
pSchema
s
[
0
].
name
);
break
;
case
TSDB_ALTER_TABLE_UPDATE_TAG_NAME
:
code
=
mndUpdateStbTagName
(
pOld
,
&
stbObj
,
pUpdate
->
pSchema
[
0
].
name
,
pUpdate
->
pSchema
[
1
].
name
);
code
=
mndUpdateStbTagName
(
pOld
,
&
stbObj
,
pUpdate
->
pSchema
s
[
0
].
name
,
pUpdate
->
pSchemas
[
1
].
name
);
break
;
case
TSDB_ALTER_TABLE_UPDATE_TAG_BYTES
:
code
=
mndUpdateStbTagBytes
(
pOld
,
&
stbObj
,
&
pUpdate
->
pSchema
[
0
]);
code
=
mndUpdateStbTagBytes
(
pOld
,
&
stbObj
,
&
pUpdate
->
pSchema
s
[
0
]);
break
;
case
TSDB_ALTER_TABLE_ADD_COLUMN
:
code
=
mndAddSuperTableColumn
(
pOld
,
&
stbObj
,
pUpdate
->
pSchema
,
1
);
code
=
mndAddSuperTableColumn
(
pOld
,
&
stbObj
,
pUpdate
->
pSchema
s
,
1
);
break
;
case
TSDB_ALTER_TABLE_DROP_COLUMN
:
code
=
mndDropSuperTableColumn
(
pOld
,
&
stbObj
,
pUpdate
->
pSchema
[
0
].
name
);
code
=
mndDropSuperTableColumn
(
pOld
,
&
stbObj
,
pUpdate
->
pSchema
s
[
0
].
name
);
break
;
case
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
:
code
=
mndUpdateStbColumnBytes
(
pOld
,
&
stbObj
,
&
pUpdate
->
pSchema
[
0
]);
code
=
mndUpdateStbColumnBytes
(
pOld
,
&
stbObj
,
&
pUpdate
->
pSchema
s
[
0
]);
break
;
default:
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
...
...
@@ -965,21 +965,21 @@ UPDATE_STB_OVER:
return
code
;
}
static
int32_t
mndProcessM
Alter
StbReq
(
SMnodeMsg
*
pReq
)
{
static
int32_t
mndProcessM
Update
StbReq
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pMnode
;
SMUpdateStbReq
*
pUpdate
=
pReq
->
rpcMsg
.
pCont
;
mDebug
(
"stb:%s, start to
alter
"
,
pUpdate
->
name
);
mDebug
(
"stb:%s, start to
update
"
,
pUpdate
->
name
);
if
(
mndCheck
Alter
StbReq
(
pUpdate
)
!=
0
)
{
mError
(
"stb:%s, failed to
alter
since %s"
,
pUpdate
->
name
,
terrstr
());
if
(
mndCheck
Update
StbReq
(
pUpdate
)
!=
0
)
{
mError
(
"stb:%s, failed to
update
since %s"
,
pUpdate
->
name
,
terrstr
());
return
-
1
;
}
SStbObj
*
pStb
=
mndAcquireStb
(
pMnode
,
pUpdate
->
name
);
if
(
pStb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_STB_NOT_EXIST
;
mError
(
"stb:%s, failed to
alter
since %s"
,
pUpdate
->
name
,
terrstr
());
mError
(
"stb:%s, failed to
update
since %s"
,
pUpdate
->
name
,
terrstr
());
return
-
1
;
}
...
...
@@ -995,14 +995,14 @@ static int32_t mndProcessMAlterStbReq(SMnodeMsg *pReq) {
mndReleaseStb
(
pMnode
,
pStb
);
if
(
code
!=
0
)
{
mError
(
"stb:%s, failed to
alter
since %s"
,
pUpdate
->
name
,
tstrerror
(
code
));
mError
(
"stb:%s, failed to
update
since %s"
,
pUpdate
->
name
,
tstrerror
(
code
));
return
code
;
}
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
static
int32_t
mndProcessV
Alter
StbRsp
(
SMnodeMsg
*
pRsp
)
{
static
int32_t
mndProcessV
Update
StbRsp
(
SMnodeMsg
*
pRsp
)
{
mndTransProcessRsp
(
pRsp
);
return
0
;
}
...
...
source/dnode/mnode/impl/test/stb/stb.cpp
浏览文件 @
94de43c5
...
...
@@ -67,35 +67,35 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
pReq
->
numOfColumns
=
htonl
(
cols
);
{
SSchema
*
pSchema
=
&
pReq
->
pSchema
[
0
];
SSchema
*
pSchema
=
&
pReq
->
pSchema
s
[
0
];
pSchema
->
bytes
=
htonl
(
8
);
pSchema
->
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
strcpy
(
pSchema
->
name
,
"ts"
);
}
{
SSchema
*
pSchema
=
&
pReq
->
pSchema
[
1
];
SSchema
*
pSchema
=
&
pReq
->
pSchema
s
[
1
];
pSchema
->
bytes
=
htonl
(
4
);
pSchema
->
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
->
name
,
"col1"
);
}
{
SSchema
*
pSchema
=
&
pReq
->
pSchema
[
2
];
SSchema
*
pSchema
=
&
pReq
->
pSchema
s
[
2
];
pSchema
->
bytes
=
htonl
(
2
);
pSchema
->
type
=
TSDB_DATA_TYPE_TINYINT
;
strcpy
(
pSchema
->
name
,
"tag1"
);
}
{
SSchema
*
pSchema
=
&
pReq
->
pSchema
[
3
];
SSchema
*
pSchema
=
&
pReq
->
pSchema
s
[
3
];
pSchema
->
bytes
=
htonl
(
8
);
pSchema
->
type
=
TSDB_DATA_TYPE_BIGINT
;
strcpy
(
pSchema
->
name
,
"tag2"
);
}
{
SSchema
*
pSchema
=
&
pReq
->
pSchema
[
4
];
SSchema
*
pSchema
=
&
pReq
->
pSchema
s
[
4
];
pSchema
->
bytes
=
htonl
(
16
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
"tag3"
);
...
...
source/libs/parser/src/astToMsg.c
浏览文件 @
94de43c5
...
...
@@ -310,7 +310,7 @@ SMCreateStbReq* buildCreateStbMsg(SCreateTableSql* pCreateTableSql, int32_t* len
pCreateStbMsg
->
numOfColumns
=
htonl
(
numOfCols
);
pCreateStbMsg
->
numOfTags
=
htonl
(
numOfTags
);
pSchema
=
(
SSchema
*
)
pCreateStbMsg
->
pSchema
;
pSchema
=
(
SSchema
*
)
pCreateStbMsg
->
pSchema
s
;
for
(
int
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SField
*
pField
=
taosArrayGet
(
pCreateTableSql
->
colInfo
.
pColumns
,
i
);
pSchema
->
type
=
pField
->
type
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录