Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
哥们要飞
TDengine
提交
c9f72ce6
T
TDengine
项目概览
哥们要飞
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c9f72ce6
编写于
7月 24, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-977]
上级
74647708
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
96 addition
and
0 deletion
+96
-0
src/inc/taosmsg.h
src/inc/taosmsg.h
+1
-0
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+95
-0
未找到文件。
src/inc/taosmsg.h
浏览文件 @
c9f72ce6
...
...
@@ -149,6 +149,7 @@ enum _mgmt_table {
#define TSDB_ALTER_TABLE_ADD_COLUMN 5
#define TSDB_ALTER_TABLE_DROP_COLUMN 6
#define TSDB_ALTER_TABLE_CHANGE_COLUMN 7
#define TSDB_FILL_NONE 0
#define TSDB_FILL_NULL 1
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
c9f72ce6
...
...
@@ -1223,6 +1223,55 @@ static int32_t mnodeDropSuperTableColumn(SMnodeMsg *pMsg, char *colName) {
return
code
;
}
static
int32_t
mnodeChangeSuperTableColumnCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
SSuperTableObj
*
pStable
=
(
SSuperTableObj
*
)
pMsg
->
pTable
;
mLInfo
(
"app:%p:%p, stable %s, change column result:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
tstrerror
(
code
));
return
code
;
}
static
int32_t
mnodeChangeSuperTableColumn
(
SMnodeMsg
*
pMsg
,
char
*
oldName
,
char
*
newName
)
{
SSuperTableObj
*
pStable
=
(
SSuperTableObj
*
)
pMsg
->
pTable
;
int32_t
col
=
mnodeFindSuperTableColumnIndex
(
pStable
,
oldName
);
if
(
col
<
0
)
{
mError
(
"app:%p:%p, stable:%s, change column, oldName: %s, newName: %s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
oldName
,
newName
);
return
TSDB_CODE_MND_FIELD_NOT_EXIST
;
}
// int32_t rowSize = 0;
uint32_t
len
=
strlen
(
newName
);
if
(
len
>=
TSDB_COL_NAME_LEN
)
{
return
TSDB_CODE_MND_COL_NAME_TOO_LONG
;
}
if
(
mnodeFindSuperTableColumnIndex
(
pStable
,
newName
)
>=
0
)
{
return
TSDB_CODE_MND_FIELD_ALREAY_EXIST
;
}
// update
SSchema
*
schema
=
(
SSchema
*
)
(
pStable
->
schema
+
col
);
tstrncpy
(
schema
->
name
,
newName
,
sizeof
(
schema
->
name
));
mInfo
(
"app:%p:%p, stable %s, start to modify column %s to %s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
oldName
,
newName
);
SSdbOper
oper
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsSuperTableSdb
,
.
pObj
=
pStable
,
.
pMsg
=
pMsg
,
.
cb
=
mnodeChangeSuperTableColumnCb
};
int32_t
code
=
sdbUpdateRow
(
&
oper
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
return
code
;
}
// show super tables
static
int32_t
mnodeGetShowSuperTableMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
SDbObj
*
pDb
=
mnodeGetDb
(
pShow
->
db
);
...
...
@@ -1977,6 +2026,48 @@ static int32_t mnodeDropNormalTableColumn(SMnodeMsg *pMsg, char *colName) {
return
code
;
}
static
int32_t
mnodeChangeNormalTableColumn
(
SMnodeMsg
*
pMsg
,
char
*
oldName
,
char
*
newName
)
{
SChildTableObj
*
pTable
=
(
SChildTableObj
*
)
pMsg
->
pTable
;
int32_t
col
=
mnodeFindNormalTableColumnIndex
(
pTable
,
oldName
);
if
(
col
<
0
)
{
mError
(
"app:%p:%p, ctable:%s, change column, oldName: %s, newName: %s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
,
oldName
,
newName
);
return
TSDB_CODE_MND_FIELD_NOT_EXIST
;
}
// int32_t rowSize = 0;
uint32_t
len
=
strlen
(
newName
);
if
(
len
>=
TSDB_COL_NAME_LEN
)
{
return
TSDB_CODE_MND_COL_NAME_TOO_LONG
;
}
if
(
mnodeFindNormalTableColumnIndex
(
pTable
,
newName
)
>=
0
)
{
return
TSDB_CODE_MND_FIELD_ALREAY_EXIST
;
}
// update
SSchema
*
schema
=
(
SSchema
*
)
(
pTable
->
schema
+
col
);
tstrncpy
(
schema
->
name
,
newName
,
sizeof
(
schema
->
name
));
mInfo
(
"app:%p:%p, ctable %s, start to modify column %s to %s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
,
oldName
,
newName
);
SSdbOper
oper
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsChildTableSdb
,
.
pObj
=
pTable
,
.
pMsg
=
pMsg
,
.
cb
=
mnodeAlterNormalTableColumnCb
};
int32_t
code
=
sdbUpdateRow
(
&
oper
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
return
code
;
}
static
int32_t
mnodeSetSchemaFromNormalTable
(
SSchema
*
pSchema
,
SChildTableObj
*
pTable
)
{
int32_t
numOfCols
=
pTable
->
numOfColumns
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
...
...
@@ -2596,6 +2687,8 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) {
code
=
mnodeAddSuperTableColumn
(
pMsg
,
pAlter
->
schema
,
1
);
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_DROP_COLUMN
)
{
code
=
mnodeDropSuperTableColumn
(
pMsg
,
pAlter
->
schema
[
0
].
name
);
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_CHANGE_COLUMN
)
{
code
=
mnodeChangeSuperTableColumn
(
pMsg
,
pAlter
->
schema
[
0
].
name
,
pAlter
->
schema
[
1
].
name
);
}
else
{
}
}
else
{
...
...
@@ -2606,6 +2699,8 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) {
code
=
mnodeAddNormalTableColumn
(
pMsg
,
pAlter
->
schema
,
1
);
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_DROP_COLUMN
)
{
code
=
mnodeDropNormalTableColumn
(
pMsg
,
pAlter
->
schema
[
0
].
name
);
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_CHANGE_COLUMN
)
{
code
=
mnodeChangeNormalTableColumn
(
pMsg
,
pAlter
->
schema
[
0
].
name
,
pAlter
->
schema
[
1
].
name
);
}
else
{
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录