Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9f1ed547
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看板
提交
9f1ed547
编写于
11月 20, 2022
作者:
K
kailixu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: update time series when add/drop column for stable/normal table
上级
d96d7d2c
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
46 addition
and
0 deletion
+46
-0
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+46
-0
未找到文件。
src/mnode/src/mnodeTable.c
浏览文件 @
9f1ed547
...
...
@@ -236,6 +236,41 @@ static int32_t mnodeChildTableActionDelete(SSdbRow *pRow) {
return
TSDB_CODE_SUCCESS
;
}
static
void
mnodeTableActionUpdateTimeSeries
(
const
char
*
tableId
,
int64_t
diffCols
)
{
if
(
diffCols
>
0
)
{
grantAdd
(
TSDB_GRANT_TIMESERIES
,
diffCols
);
}
else
if
(
diffCols
<
0
)
{
grantRestore
(
TSDB_GRANT_TIMESERIES
,
-
diffCols
);
}
else
{
return
;
}
if
(
tableId
)
{
SName
sName
=
{
0
};
char
db
[
TSDB_DB_NAME_LEN
]
=
{
0
};
SDbObj
*
pDb
=
NULL
;
SAcctObj
*
pAcct
=
NULL
;
if
(
tNameFromString
(
&
sName
,
tableId
,
T_NAME_ACCT
|
T_NAME_DB
))
{
mWarn
(
"table:%s, failed to get SName to update timeseries"
,
tableId
);
return
;
}
if
(
tNameExtractFullName
((
const
SName
*
)
&
sName
,
db
))
{
mWarn
(
"table:%s, failed to extract SName to update timeseries"
,
tableId
);
return
;
}
if
(
!
(
pDb
=
mnodeGetDb
(
db
)))
{
mWarn
(
"table:%s, db:%s not exist to update timeseries"
,
tableId
,
db
);
return
;
};
if
(
!
(
pAcct
=
mnodeGetAcct
(
pDb
->
acct
)))
{
mWarn
(
"table:%s, acct:%s not exist to update timeseries"
,
tableId
,
pDb
->
acct
);
return
;
}
if
(
pAcct
)
pAcct
->
acctInfo
.
numOfTimeSeries
+=
diffCols
;
}
}
static
int32_t
mnodeChildTableActionUpdate
(
SSdbRow
*
pRow
)
{
SCTableObj
*
pNew
=
pRow
->
pObj
;
SCTableObj
*
pTable
=
mnodeGetChildTable
(
pNew
->
info
.
tableId
);
...
...
@@ -246,6 +281,10 @@ static int32_t mnodeChildTableActionUpdate(SSdbRow *pRow) {
void
*
oldSTable
=
pTable
->
superTable
;
int32_t
oldRefCount
=
pTable
->
refCount
;
if
(
pTable
->
info
.
type
==
TSDB_NORMAL_TABLE
)
{
mnodeTableActionUpdateTimeSeries
(
pTable
->
info
.
tableId
,
pNew
->
numOfColumns
-
pTable
->
numOfColumns
);
}
memcpy
(
pTable
,
pNew
,
sizeof
(
SCTableObj
));
pTable
->
refCount
=
oldRefCount
;
...
...
@@ -528,6 +567,9 @@ static int32_t mnodeSuperTableActionUpdate(SSdbRow *pRow) {
int32_t
oldRefCount
=
pTable
->
refCount
;
int32_t
oldNumOfTables
=
pTable
->
numOfTables
;
mnodeTableActionUpdateTimeSeries
(
pTable
->
info
.
tableId
,
(
int64_t
)
oldNumOfTables
*
(
pNew
->
numOfColumns
-
pTable
->
numOfColumns
));
memcpy
(
pTable
,
pNew
,
sizeof
(
SSTableObj
));
pTable
->
vgHash
=
oldVgHash
;
...
...
@@ -1464,6 +1506,7 @@ static int32_t mnodeAddSuperTableColumn(SMnodeMsg *pMsg, SSchema schema[], int32
pAcct
->
acctInfo
.
numOfTimeSeries
+=
(
ncols
*
pStable
->
numOfTables
);
mnodeDecAcctRef
(
pAcct
);
}
grantAdd
(
TSDB_GRANT_TIMESERIES
,
(
uint64_t
)
ncols
*
pStable
->
numOfTables
);
mInfo
(
"msg:%p, app:%p stable %s, start to add column"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pStable
->
info
.
tableId
);
...
...
@@ -1514,6 +1557,7 @@ static int32_t mnodeDropSuperTableColumn(SMnodeMsg *pMsg, char *colName) {
pAcct
->
acctInfo
.
numOfTimeSeries
-=
pStable
->
numOfTables
;
mnodeDecAcctRef
(
pAcct
);
}
grantRestore
(
TSDB_GRANT_TIMESERIES
,
pStable
->
numOfTables
);
mInfo
(
"msg:%p, app:%p stable %s, start to delete column"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pStable
->
info
.
tableId
);
...
...
@@ -2471,6 +2515,7 @@ static int32_t mnodeAddNormalTableColumn(SMnodeMsg *pMsg, SSchema schema[], int3
pAcct
->
acctInfo
.
numOfTimeSeries
+=
ncols
;
mnodeDecAcctRef
(
pAcct
);
}
grantAdd
(
TSDB_GRANT_TIMESERIES
,
ncols
);
mInfo
(
"msg:%p, app:%p ctable %s, start to add column"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pTable
->
info
.
tableId
);
monSaveAuditLog
(
MON_DDL_CMD_ADD_COLUMN
,
mnodeGetUserFromMsg
(
pMsg
),
pTable
->
info
.
tableId
,
true
);
...
...
@@ -2506,6 +2551,7 @@ static int32_t mnodeDropNormalTableColumn(SMnodeMsg *pMsg, char *colName) {
pAcct
->
acctInfo
.
numOfTimeSeries
--
;
mnodeDecAcctRef
(
pAcct
);
}
grantRestore
(
TSDB_GRANT_TIMESERIES
,
1
);
mInfo
(
"msg:%p, app:%p ctable %s, start to drop column %s"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pTable
->
info
.
tableId
,
colName
);
monSaveAuditLog
(
MON_DDL_CMD_DROP_COLUMN
,
mnodeGetUserFromMsg
(
pMsg
),
pTable
->
info
.
tableId
,
true
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录