Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
5362a0b1
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
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看板
提交
5362a0b1
编写于
4月 28, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-202]
上级
608f2394
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
37 addition
and
35 deletion
+37
-35
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+37
-35
未找到文件。
src/mnode/src/mgmtTable.c
浏览文件 @
5362a0b1
...
...
@@ -74,6 +74,7 @@ static void mgmtProcessTableCfgMsg(SRpcMsg *rpcMsg);
static
void
mgmtProcessTableMetaMsg
(
SQueuedMsg
*
queueMsg
);
static
void
mgmtGetSuperTableMeta
(
SQueuedMsg
*
pMsg
);
static
void
mgmtGetChildTableMeta
(
SQueuedMsg
*
pMsg
);
static
void
mgmtAutoCreateChildTable
(
SQueuedMsg
*
pMsg
);
static
void
mgmtProcessAlterTableMsg
(
SQueuedMsg
*
queueMsg
);
static
void
mgmtProcessAlterTableRsp
(
SRpcMsg
*
rpcMsg
);
...
...
@@ -612,9 +613,12 @@ static void mgmtExtractTableName(char* tableId, char* name) {
static
void
mgmtProcessCreateTableMsg
(
SQueuedMsg
*
pMsg
)
{
SCMCreateTableMsg
*
pCreate
=
pMsg
->
pCont
;
pMsg
->
pTable
=
mgmtGetTable
(
pCreate
->
tableId
);
if
(
pMsg
->
pTable
==
NULL
)
pMsg
->
pTable
=
mgmtGetTable
(
pCreate
->
tableId
);
if
(
pMsg
->
pTable
!=
NULL
&&
pMsg
->
retry
==
0
)
{
if
(
pCreate
->
igExists
)
{
if
(
pCreate
->
getMeta
)
{
mTrace
(
"table:%s, continue to get meta"
,
pCreate
->
tableId
);
mgmtProcessTableMetaMsg
(
pMsg
);
}
else
if
(
pCreate
->
igExists
)
{
mTrace
(
"table:%s, is already exist"
,
pCreate
->
tableId
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_SUCCESS
);
}
else
{
...
...
@@ -624,7 +628,7 @@ static void mgmtProcessCreateTableMsg(SQueuedMsg *pMsg) {
return
;
}
pMsg
->
pDb
=
mgmtGetDb
(
pCreate
->
db
);
if
(
pMsg
->
pDb
==
NULL
)
pMsg
->
pDb
=
mgmtGetDb
(
pCreate
->
db
);
if
(
pMsg
->
pDb
==
NULL
||
pMsg
->
pDb
->
status
!=
TSDB_DB_STATUS_READY
)
{
mError
(
"table:%s, failed to create, db not selected"
,
pCreate
->
tableId
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_DB_NOT_SELECTED
);
...
...
@@ -681,15 +685,21 @@ static void mgmtProcessTableMetaMsg(SQueuedMsg *pMsg) {
SCMTableInfoMsg
*
pInfo
=
pMsg
->
pCont
;
mTrace
(
"table:%s, table meta msg is received from thandle:%p"
,
pInfo
->
tableId
,
pMsg
->
thandle
);
pMsg
->
pDb
=
mgmtGetDbByTableId
(
pInfo
->
tableId
);
if
(
pMsg
->
pDb
==
NULL
)
pMsg
->
pDb
=
mgmtGetDbByTableId
(
pInfo
->
tableId
);
if
(
pMsg
->
pDb
==
NULL
||
pMsg
->
pDb
->
status
!=
TSDB_DB_STATUS_READY
)
{
mError
(
"table:%s, failed to get table meta, db not selected"
,
pInfo
->
tableId
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_DB_NOT_SELECTED
);
return
;
}
if
(
pMsg
->
pTable
==
NULL
)
pMsg
->
pTable
=
mgmtGetTable
(
pInfo
->
tableId
);
if
(
pMsg
->
pTable
==
NULL
)
{
mgmtGetChildTableMeta
(
pMsg
);
if
(
htons
(
pInfo
->
createFlag
)
!=
1
)
{
mError
(
"table:%s, failed to get table meta, table not exist"
,
pInfo
->
tableId
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_INVALID_TABLE
);
}
else
{
mgmtAutoCreateChildTable
(
pMsg
);
}
}
else
{
if
(
pMsg
->
pTable
->
type
!=
TSDB_SUPER_TABLE
)
{
mgmtGetChildTableMeta
(
pMsg
);
...
...
@@ -1654,17 +1664,8 @@ static int32_t mgmtDoGetChildTableMeta(SQueuedMsg *pMsg, STableMetaMsg *pMeta) {
return
TSDB_CODE_SUCCESS
;
}
void
mgmtGetChildTableMeta
(
SQueuedMsg
*
pMsg
)
{
SChildTableObj
*
pTable
=
(
SChildTableObj
*
)
pMsg
->
pTable
;
static
void
mgmtAutoCreateChildTable
(
SQueuedMsg
*
pMsg
)
{
SCMTableInfoMsg
*
pInfo
=
pMsg
->
pCont
;
if
(
pTable
==
NULL
)
{
if
(
htons
(
pInfo
->
createFlag
)
!=
1
)
{
mError
(
"table:%s, failed to get table meta, table not exist"
,
pInfo
->
tableId
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_INVALID_TABLE
);
return
;
}
else
{
//TODO: on demand create table from super table if table does not exists
int32_t
contLen
=
sizeof
(
SCMCreateTableMsg
)
+
sizeof
(
STagData
);
SCMCreateTableMsg
*
pCreateMsg
=
rpcMallocCont
(
contLen
);
if
(
pCreateMsg
==
NULL
)
{
...
...
@@ -1672,24 +1673,25 @@ void mgmtGetChildTableMeta(SQueuedMsg *pMsg) {
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_SERV_OUT_OF_MEMORY
);
return
;
}
memcpy
(
pCreateMsg
->
schema
,
pInfo
->
tags
,
sizeof
(
STagData
));
strncpy
(
pCreateMsg
->
tableId
,
pInfo
->
tableId
,
tListLen
(
pInfo
->
tableId
));
SQueuedMsg
*
newMsg
=
malloc
(
sizeof
(
SQueuedMsg
));
memcpy
(
newMsg
,
pMsg
,
sizeof
(
SQueuedMsg
));
pMsg
->
pCont
=
NULL
;
strncpy
(
pCreateMsg
->
tableId
,
pInfo
->
tableId
,
tListLen
(
pInfo
->
tableId
));
strcpy
(
pCreateMsg
->
db
,
pMsg
->
pDb
->
name
);
pCreateMsg
->
igExists
=
1
;
pCreateMsg
->
getMeta
=
1
;
memcpy
(
pCreateMsg
->
schema
,
pInfo
->
tags
,
sizeof
(
STagData
));
newMsg
->
ahandle
=
newMsg
->
pCont
;
SQueuedMsg
*
newMsg
=
mgmtCloneQueuedMsg
(
pMsg
);
pMsg
->
pCont
=
newMsg
->
pCont
;
newMsg
->
pCont
=
pCreateMsg
;
mTrace
(
"table:%s, start to create in demand"
,
pInfo
->
tableId
);
mTrace
(
"table:%s, start to create on demand"
,
pInfo
->
tableId
);
mgmtAddToShellQueue
(
newMsg
);
return
;
}
}
}
static
void
mgmtGetChildTableMeta
(
SQueuedMsg
*
pMsg
)
{
STableMetaMsg
*
pMeta
=
rpcMallocCont
(
sizeof
(
STableMetaMsg
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
);
if
(
pMeta
==
NULL
)
{
mError
(
"table:%s, failed to get table meta, no enough memory"
,
p
Table
->
info
.
tableId
);
mError
(
"table:%s, failed to get table meta, no enough memory"
,
p
Msg
->
pTable
->
tableId
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_SERV_OUT_OF_MEMORY
);
return
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录