Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
b6313b34
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看板
提交
b6313b34
编写于
3月 26, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-9] fix compile errors
上级
2180f6eb
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
127 addition
and
118 deletion
+127
-118
src/inc/mnode.h
src/inc/mnode.h
+2
-1
src/mnode/inc/mgmtUser.h
src/mnode/inc/mgmtUser.h
+1
-1
src/mnode/src/mgmtChildTable.c
src/mnode/src/mgmtChildTable.c
+65
-57
src/mnode/src/mgmtDb.c
src/mnode/src/mgmtDb.c
+2
-4
src/mnode/src/mgmtDnode.c
src/mnode/src/mgmtDnode.c
+3
-3
src/mnode/src/mgmtMnode.c
src/mnode/src/mgmtMnode.c
+1
-1
src/mnode/src/mgmtProfile.c
src/mnode/src/mgmtProfile.c
+3
-3
src/mnode/src/mgmtShell.c
src/mnode/src/mgmtShell.c
+3
-4
src/mnode/src/mgmtSuperTable.c
src/mnode/src/mgmtSuperTable.c
+29
-27
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+14
-14
src/mnode/src/mgmtUser.c
src/mnode/src/mgmtUser.c
+1
-1
src/mnode/src/mgmtVgroup.c
src/mnode/src/mgmtVgroup.c
+3
-2
未找到文件。
src/inc/mnode.h
浏览文件 @
b6313b34
...
...
@@ -154,7 +154,7 @@ typedef struct _vg_obj {
struct
_db_obj
*
pDb
;
int32_t
numOfTables
;
void
*
idPool
;
S
TableInfo
**
tableList
;
S
ChildTableObj
**
tableList
;
}
SVgObj
;
typedef
struct
_db_obj
{
...
...
@@ -241,6 +241,7 @@ typedef struct {
int8_t
usePublicIp
;
int8_t
received
;
int8_t
successed
;
int8_t
expected
;
int32_t
contLen
;
int32_t
code
;
void
*
ahandle
;
...
...
src/mnode/inc/mgmtUser.h
浏览文件 @
b6313b34
...
...
@@ -24,7 +24,7 @@ extern "C" {
int32_t
mgmtInitUsers
();
void
mgmtCleanUpUsers
();
SUserObj
*
mgmtGetUser
(
char
*
name
);
SUserObj
*
mgmtGetUserFromConn
(
void
*
pConn
,
bool
*
usePublicIp
)
SUserObj
*
mgmtGetUserFromConn
(
void
*
pConn
,
bool
*
usePublicIp
)
;
#ifdef __cplusplus
}
...
...
src/mnode/src/mgmtChildTable.c
浏览文件 @
b6313b34
...
...
@@ -21,11 +21,23 @@
#include "ttime.h"
#include "tstatus.h"
#include "tutil.h"
#include "qast.h"
#include "qextbuffer.h"
#include "taoserror.h"
#include "taosmsg.h"
#include "tscompression.h"
#include "tskiplist.h"
#include "tsqlfunction.h"
#include "tstatus.h"
#include "ttime.h"
#include "name.h"
#include "mnode.h"
#include "mgmtAcct.h"
#include "mgmtChildTable.h"
#include "mgmtDb.h"
#include "mgmtDClient.h"
#include "mgmtDnode.h"
#include "mgmtDServer.h"
#include "mgmtGrant.h"
#include "mgmtMnode.h"
#include "mgmtProfile.h"
...
...
@@ -34,6 +46,7 @@
#include "mgmtSuperTable.h"
#include "mgmtTable.h"
#include "mgmtVgroup.h"
#include "mgmtUser.h"
static
void
*
tsChildTableSdb
;
static
int32_t
tsChildTableUpdateSize
;
...
...
@@ -79,7 +92,7 @@ static int32_t mgmtChildTableActionInsert(SSdbOperDesc *pOper) {
if
(
pTable
->
info
.
type
==
TSDB_CHILD_TABLE
)
{
pTable
->
superTable
=
mgmtGetSuperTable
(
pTable
->
superTableId
);
p
St
able
->
numOfTables
++
;
p
Table
->
superT
able
->
numOfTables
++
;
mgmtAddTimeSeries
(
pAcct
,
pTable
->
superTable
->
numOfColumns
-
1
);
}
else
{
mgmtAddTimeSeries
(
pAcct
,
pTable
->
numOfColumns
-
1
);
...
...
@@ -115,12 +128,12 @@ static int32_t mgmtChildTableActionDelete(SSdbOperDesc *pOper) {
if
(
pTable
->
info
.
type
==
TSDB_CHILD_TABLE
)
{
mgmtRestoreTimeSeries
(
pAcct
,
pTable
->
superTable
->
numOfColumns
-
1
);
p
St
able
->
numOfTables
--
;
p
Table
->
superT
able
->
numOfTables
--
;
}
else
{
mgmtRestoreTimeSeries
(
pAcct
,
pTable
->
numOfColumns
-
1
);
}
mgmtRemoveTableFromDb
(
pDb
);
mgmtRemoveTableFromVgroup
(
pVgroup
,
(
STableInfo
*
)
pTable
);
mgmtRemoveTableFromVgroup
(
pVgroup
,
pTable
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -163,14 +176,14 @@ static int32_t mgmtChildTableActionDecode(SSdbOperDesc *pOper) {
int32_t
schemaSize
=
pTable
->
numOfColumns
*
sizeof
(
SSchema
);
pTable
->
schema
=
(
SSchema
*
)
malloc
(
schemaSize
);
if
(
pTable
->
schema
==
NULL
)
{
mgmtDestroy
Normal
Table
(
pTable
);
mgmtDestroy
Child
Table
(
pTable
);
return
TSDB_CODE_SERV_OUT_OF_MEMORY
;
}
memcpy
(
pTable
->
schema
,
pOper
->
rowData
+
tsChildTableUpdateSize
,
schemaSize
);
pTable
->
sql
=
(
char
*
)
malloc
(
pTable
->
sqlLen
);
if
(
pTable
->
sql
==
NULL
)
{
mgmtDestroy
Normal
Table
(
pTable
);
mgmtDestroy
Child
Table
(
pTable
);
return
TSDB_CODE_SERV_OUT_OF_MEMORY
;
}
memcpy
(
pTable
->
sql
,
pOper
->
rowData
+
tsChildTableUpdateSize
+
schemaSize
,
pTable
->
sqlLen
);
...
...
@@ -191,7 +204,7 @@ int32_t mgmtInitChildTables() {
SSdbTableDesc
tableDesc
=
{
.
tableName
=
"ctables"
,
.
hashSessions
=
tsMaxTables
,
.
maxRowSize
=
sizeof
(
SChildTableObj
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
,
,
.
maxRowSize
=
sizeof
(
SChildTableObj
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
,
.
keyType
=
SDB_KEY_TYPE_STRING
,
.
insertFp
=
mgmtChildTableActionInsert
,
.
deleteFp
=
mgmtChildTableActionDelete
,
...
...
@@ -319,7 +332,7 @@ static void *mgmtBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableOb
}
memcpy
(
pCreate
->
tableId
,
pTable
->
info
.
tableId
,
TSDB_TABLE_ID_LEN
+
1
);
memcpy
(
pCreate
->
superTableId
,
pTable
->
superTable
->
tableId
,
TSDB_TABLE_ID_LEN
+
1
);
memcpy
(
pCreate
->
superTableId
,
pTable
->
superTable
->
info
.
tableId
,
TSDB_TABLE_ID_LEN
+
1
);
pCreate
->
contLen
=
htonl
(
contLen
);
pCreate
->
vgId
=
htonl
(
pTable
->
vgId
);
pCreate
->
tableType
=
pTable
->
info
.
type
;
...
...
@@ -381,7 +394,7 @@ static SChildTableObj* mgmtDoCreateChildTable(SCMCreateTableMsg *pCreate, SVgObj
pTable
->
sid
=
tid
;
pTable
->
vgId
=
pVgroup
->
vgId
;
if
(
Table
->
info
.
type
==
TSDB_CHILD_TABLE
)
{
if
(
p
Table
->
info
.
type
==
TSDB_CHILD_TABLE
)
{
char
*
pTagData
=
(
char
*
)
pCreate
->
schema
;
// it is a tag key
SSuperTableObj
*
pSuperTable
=
mgmtGetSuperTable
(
pTagData
);
if
(
pSuperTable
==
NULL
)
{
...
...
@@ -391,7 +404,7 @@ static SChildTableObj* mgmtDoCreateChildTable(SCMCreateTableMsg *pCreate, SVgObj
return
NULL
;
}
strcpy
(
pTable
->
superTableId
,
pSuperTable
->
tableId
);
strcpy
(
pTable
->
superTableId
,
pSuperTable
->
info
.
tableId
);
pTable
->
uid
=
(((
uint64_t
)
pTable
->
vgId
)
<<
40
)
+
((((
uint64_t
)
pTable
->
sid
)
&
((
1ul
<<
24
)
-
1ul
))
<<
16
)
+
(
sdbGetVersion
()
&
((
1ul
<<
16
)
-
1ul
));
pTable
->
superTable
=
pSuperTable
;
...
...
@@ -503,7 +516,7 @@ void mgmtCreateChildTable(SQueuedMsg *pMsg) {
mgmtSendMsgToDnode
(
&
ipSet
,
&
rpcMsg
);
}
static
int32_t
mgmtDropChildTable
(
SQueuedMsg
*
new
Msg
,
SChildTableObj
*
pTable
)
{
void
mgmtDropChildTable
(
SQueuedMsg
*
p
Msg
,
SChildTableObj
*
pTable
)
{
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pTable
->
vgId
);
if
(
pVgroup
==
NULL
)
{
mError
(
"ctable:%s, failed to drop child table, vgroup not exist"
,
pTable
->
info
.
tableId
);
...
...
@@ -528,14 +541,14 @@ static int32_t mgmtDropChildTable(SQueuedMsg *newMsg, SChildTableObj *pTable) {
mTrace
(
"ctable:%s, send drop table msg"
,
pDrop
->
tableId
);
SRpcMsg
rpcMsg
=
{
.
handle
=
new
Msg
,
.
handle
=
p
Msg
,
.
pCont
=
pDrop
,
.
contLen
=
sizeof
(
SMDDropTableMsg
),
.
code
=
0
,
.
msgType
=
TSDB_MSG_TYPE_MD_DROP_TABLE
};
new
Msg
->
ahandle
=
pTable
;
p
Msg
->
ahandle
=
pTable
;
mgmtSendMsgToDnode
(
&
ipSet
,
&
rpcMsg
);
}
...
...
@@ -593,7 +606,7 @@ int32_t mgmtModifyChildTableTagValueByName(SChildTableObj *pTable, char *tagName
}
static
int32_t
mgmtFindNormalTableColumnIndex
(
S
Normal
TableObj
*
pTable
,
char
*
colName
)
{
static
int32_t
mgmtFindNormalTableColumnIndex
(
S
Child
TableObj
*
pTable
,
char
*
colName
)
{
SSchema
*
schema
=
(
SSchema
*
)
pTable
->
schema
;
for
(
int32_t
i
=
0
;
i
<
pTable
->
numOfColumns
;
i
++
)
{
if
(
strcasecmp
(
schema
[
i
].
name
,
colName
)
==
0
)
{
...
...
@@ -604,7 +617,7 @@ static int32_t mgmtFindNormalTableColumnIndex(SNormalTableObj *pTable, char *col
return
-
1
;
}
static
int32_t
mgmtAddNormalTableColumn
(
S
Normal
TableObj
*
pTable
,
SSchema
schema
[],
int32_t
ncols
)
{
static
int32_t
mgmtAddNormalTableColumn
(
S
Child
TableObj
*
pTable
,
SSchema
schema
[],
int32_t
ncols
)
{
if
(
ncols
<=
0
)
{
return
TSDB_CODE_APP_ERROR
;
}
...
...
@@ -644,7 +657,7 @@ static int32_t mgmtAddNormalTableColumn(SNormalTableObj *pTable, SSchema schema[
SSdbOperDesc
desc
=
{
0
};
desc
.
type
=
SDB_OPER_TYPE_GLOBAL
;
desc
.
pObj
=
pTable
;
desc
.
table
=
ts
Normal
TableSdb
;
desc
.
table
=
ts
Child
TableSdb
;
desc
.
rowData
=
pTable
;
desc
.
rowSize
=
tsChildTableUpdateSize
;
sdbUpdateRow
(
&
desc
);
...
...
@@ -652,7 +665,7 @@ static int32_t mgmtAddNormalTableColumn(SNormalTableObj *pTable, SSchema schema[
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mgmtDropNormalTableColumnByName
(
S
Normal
TableObj
*
pTable
,
char
*
colName
)
{
static
int32_t
mgmtDropNormalTableColumnByName
(
S
Child
TableObj
*
pTable
,
char
*
colName
)
{
int32_t
col
=
mgmtFindNormalTableColumnIndex
(
pTable
,
colName
);
if
(
col
<
0
)
{
return
TSDB_CODE_APP_ERROR
;
...
...
@@ -681,7 +694,7 @@ static int32_t mgmtDropNormalTableColumnByName(SNormalTableObj *pTable, char *co
SSdbOperDesc
desc
=
{
0
};
desc
.
type
=
SDB_OPER_TYPE_GLOBAL
;
desc
.
pObj
=
pTable
;
desc
.
table
=
ts
Normal
TableSdb
;
desc
.
table
=
ts
Child
TableSdb
;
desc
.
rowData
=
pTable
;
desc
.
rowSize
=
tsChildTableUpdateSize
;
sdbUpdateRow
(
&
desc
);
...
...
@@ -702,14 +715,7 @@ static int32_t mgmtSetSchemaFromNormalTable(SSchema *pSchema, SChildTableObj *pT
return
numOfCols
*
sizeof
(
SSchema
);
}
static
void
mgmtGetChildTableMeta
(
SQueuedMsg
*
pMsg
,
SDbObj
*
pDb
,
SChildTableObj
*
pTable
)
{
STableMetaMsg
*
pMeta
=
rpcMallocCont
(
sizeof
(
STableMetaMsg
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
);
if
(
pMeta
==
NULL
)
{
mError
(
"table:%s, failed to get table meta, no enough memory"
,
pTable
->
info
.
tableId
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_SERV_OUT_OF_MEMORY
);
return
;
}
static
int32_t
mgmtDoGetChildTableMeta
(
SDbObj
*
pDb
,
SChildTableObj
*
pTable
,
STableMetaMsg
*
pMeta
,
bool
usePublicIp
)
{
pMeta
->
uid
=
htobe64
(
pTable
->
uid
);
pMeta
->
sid
=
htonl
(
pTable
->
sid
);
pMeta
->
vgId
=
htonl
(
pTable
->
vgId
);
...
...
@@ -732,12 +738,11 @@ static void mgmtGetChildTableMeta(SQueuedMsg *pMsg, SDbObj *pDb, SChildTableObj
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pTable
->
vgId
);
if
(
pVgroup
==
NULL
)
{
mError
(
"table:%s, failed to get table meta, db not selected"
,
pTable
->
info
.
tableId
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_INVALID_VGROUP_ID
);
return
;
return
TSDB_CODE_INVALID_VGROUP_ID
;
}
for
(
int32_t
i
=
0
;
i
<
TSDB_VNODES_SUPPORT
;
++
i
)
{
if
(
pMsg
->
usePublicIp
)
{
if
(
usePublicIp
)
{
pMeta
->
vpeerDesc
[
i
].
ip
=
pVgroup
->
vnodeGid
[
i
].
publicIp
;
}
else
{
pMeta
->
vpeerDesc
[
i
].
ip
=
pVgroup
->
vnodeGid
[
i
].
privateIp
;
...
...
@@ -746,18 +751,12 @@ static void mgmtGetChildTableMeta(SQueuedMsg *pMsg, SDbObj *pDb, SChildTableObj
}
pMeta
->
numOfVpeers
=
pVgroup
->
numOfVnodes
;
SRpcMsg
rpcRsp
=
{
.
handle
=
pMsg
->
thandle
,
.
pCont
=
pMeta
,
.
contLen
=
pMeta
->
contLen
,
};
pMeta
->
contLen
=
htons
(
pMeta
->
contLen
);
rpcSendResponse
(
&
rpcRsp
);
mTrace
(
"table:%s, uid:%"
PRIu64
" table meta is retrieved"
,
pTable
->
info
.
tableId
,
pTable
->
uid
);
return
TSDB_CODE_SUCCESS
;
}
void
mgmt
ProcessChildTableMetaMsg
(
SQueuedMsg
*
pMsg
)
{
void
mgmt
GetChildTableMeta
(
SQueuedMsg
*
pMsg
,
SChildTableObj
*
pTable
)
{
SCMTableInfoMsg
*
pInfo
=
pMsg
->
pCont
;
SDbObj
*
pDb
=
mgmtGetDbByTableId
(
pTable
->
info
.
tableId
);
if
(
pDb
==
NULL
||
pDb
->
dirty
)
{
...
...
@@ -766,7 +765,6 @@ void mgmtProcessChildTableMetaMsg(SQueuedMsg *pMsg) {
return
;
}
STableInfo
*
pTable
=
mgmtGetTable
(
pInfo
->
tableId
);
if
(
pTable
==
NULL
)
{
if
(
htons
(
pInfo
->
createFlag
)
!=
1
)
{
mError
(
"table:%s, failed to get table meta, table not exist"
,
pInfo
->
tableId
);
...
...
@@ -796,7 +794,22 @@ void mgmtProcessChildTableMetaMsg(SQueuedMsg *pMsg) {
}
}
mgmtGetChildTableMeta
(
pMsg
,
pDb
,
pTable
);
STableMetaMsg
*
pMeta
=
rpcMallocCont
(
sizeof
(
STableMetaMsg
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
);
if
(
pMeta
==
NULL
)
{
mError
(
"table:%s, failed to get table meta, no enough memory"
,
pTable
->
info
.
tableId
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_SERV_OUT_OF_MEMORY
);
return
;
}
mgmtDoGetChildTableMeta
(
pDb
,
pTable
,
pMeta
,
pMsg
->
usePublicIp
);
SRpcMsg
rpcRsp
=
{
.
handle
=
pMsg
->
thandle
,
.
pCont
=
pMeta
,
.
contLen
=
pMeta
->
contLen
,
};
pMeta
->
contLen
=
htons
(
pMeta
->
contLen
);
rpcSendResponse
(
&
rpcRsp
);
}
void
mgmtDropAllChildTables
(
SDbObj
*
pDropDb
)
{
...
...
@@ -853,7 +866,7 @@ void mgmtDropAllChildTablesInStable(SSuperTableObj *pStable) {
}
}
mTrace
(
"stable:%s, all child tables:%d is dropped from sdb"
,
pStable
->
tableId
,
numOfTables
);
mTrace
(
"stable:%s, all child tables:%d is dropped from sdb"
,
pStable
->
info
.
tableId
,
numOfTables
);
}
static
STableInfo
*
mgmtGetTableByPos
(
uint32_t
dnodeId
,
int32_t
vnode
,
int32_t
sid
)
{
...
...
@@ -908,7 +921,7 @@ static void mgmtProcessDropTableRsp(SRpcMsg *rpcMsg) {
SQueuedMsg
*
queueMsg
=
rpcMsg
->
handle
;
queueMsg
->
received
++
;
S
TableInfo
*
pTable
=
queueMsg
->
ahandle
;
S
ChildTableObj
*
pTable
=
queueMsg
->
ahandle
;
mTrace
(
"table:%s, drop table rsp received, thandle:%p result:%s"
,
pTable
->
info
.
tableId
,
queueMsg
->
thandle
,
tstrerror
(
rpcMsg
->
code
));
if
(
rpcMsg
->
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -948,17 +961,13 @@ static void mgmtProcessDropTableRsp(SRpcMsg *rpcMsg) {
free
(
queueMsg
);
}
static
void
mgmtProcessDropStableRsp
(
SRpcMsg
*
rpcMsg
)
{
mTrace
(
"drop stable rsp received, handle:%p code:%d"
,
rpcMsg
->
handle
,
rpcMsg
->
code
);
}
static
void
mgmtProcessCreateTableRsp
(
SRpcMsg
*
rpcMsg
)
{
if
(
rpcMsg
->
handle
==
NULL
)
return
;
SQueuedMsg
*
queueMsg
=
rpcMsg
->
handle
;
queueMsg
->
received
++
;
S
TableInfo
*
pTable
=
queueMsg
->
ahandle
;
S
ChildTableObj
*
pTable
=
queueMsg
->
ahandle
;
mTrace
(
"table:%s, create table rsp received, thandle:%p ahandle:%p result:%s"
,
pTable
->
info
.
tableId
,
queueMsg
->
thandle
,
rpcMsg
->
handle
,
tstrerror
(
rpcMsg
->
code
));
...
...
@@ -1026,7 +1035,7 @@ static void mgmtProcessMultiTableMetaMsg(SQueuedMsg *pMsg) {
for
(
int
t
=
0
;
t
<
pInfo
->
numOfTables
;
++
t
)
{
char
*
tableId
=
(
char
*
)(
pInfo
->
tableIds
+
t
*
TSDB_TABLE_ID_LEN
);
S
TableInfo
*
pTable
=
mgmtGet
Table
(
tableId
);
S
ChildTableObj
*
pTable
=
mgmtGetChild
Table
(
tableId
);
if
(
pTable
==
NULL
)
continue
;
SDbObj
*
pDb
=
mgmtGetDbByTableId
(
tableId
);
...
...
@@ -1047,7 +1056,7 @@ static void mgmtProcessMultiTableMetaMsg(SQueuedMsg *pMsg) {
}
STableMetaMsg
*
pMeta
=
(
STableMetaMsg
*
)(
pMultiMeta
->
metas
+
pMultiMeta
->
contLen
);
int32_t
code
=
mgmt
Get
TableMeta
(
pDb
,
pTable
,
pMeta
,
usePublicIp
);
int32_t
code
=
mgmt
DoGetChild
TableMeta
(
pDb
,
pTable
,
pMeta
,
usePublicIp
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
pMultiMeta
->
numOfTables
++
;
pMultiMeta
->
contLen
+=
pMeta
->
contLen
;
...
...
@@ -1120,7 +1129,7 @@ static int32_t mgmtRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows,
SDbObj
*
pDb
=
mgmtGetDb
(
pShow
->
db
);
if
(
pDb
==
NULL
)
return
0
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
,
NULL
);
if
(
pUser
==
NULL
)
return
0
;
if
(
mgmtCheckIsMonitorDB
(
pDb
->
name
,
tsMonitorDbName
))
{
...
...
@@ -1140,18 +1149,17 @@ static int32_t mgmtRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows,
int32_t
prefixLen
=
strlen
(
prefix
);
while
(
numOfRows
<
rows
)
{
pShow
->
pNode
=
sdbFetchRow
(
ts
Normal
TableSdb
,
pShow
->
pNode
,
(
void
**
)
&
pTable
);
pShow
->
pNode
=
sdbFetchRow
(
ts
Child
TableSdb
,
pShow
->
pNode
,
(
void
**
)
&
pTable
);
if
(
pTable
==
NULL
)
break
;
// not belong to current db
if
(
strncmp
(
tableId
,
prefix
,
prefixLen
))
{
if
(
strncmp
(
pTable
->
info
.
tableId
,
prefix
,
prefixLen
))
{
continue
;
}
char
tableName
[
TSDB_TABLE_NAME_LEN
]
=
{
0
};
memset
(
tableName
,
0
,
tListLen
(
tableName
));
numOfRead
++
;
// pattern compare for meter name
mgmtExtractTableName
(
pTable
->
info
.
tableId
,
tableName
);
...
...
@@ -1188,7 +1196,7 @@ static int32_t mgmtRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows,
numOfRows
++
;
}
pShow
->
numOfReads
+=
numOfR
ead
;
pShow
->
numOfReads
+=
numOfR
ows
;
const
int32_t
NUM_OF_COLUMNS
=
4
;
mgmtVacuumResult
(
data
,
NUM_OF_COLUMNS
,
numOfRows
,
rows
,
pShow
);
...
...
@@ -1201,11 +1209,11 @@ void mgmtAlterChildTable(SQueuedMsg *pMsg, SChildTableObj *pTable) {
SCMAlterTableMsg
*
pAlter
=
pMsg
->
pCont
;;
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_UPDATE_TAG_VAL
)
{
code
=
mgmtModifyChildTableTagValueByName
(
(
SChildTableObj
*
)
pTable
,
pAlter
->
schema
[
0
].
name
,
pAlter
->
tagVal
);
code
=
mgmtModifyChildTableTagValueByName
(
pTable
,
pAlter
->
schema
[
0
].
name
,
pAlter
->
tagVal
);
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_ADD_COLUMN
)
{
code
=
mgmtAddNormalTableColumn
(
(
SNormalTableObj
*
)
pTable
,
pAlter
->
schema
,
1
);
code
=
mgmtAddNormalTableColumn
(
pTable
,
pAlter
->
schema
,
1
);
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_DROP_COLUMN
)
{
code
=
mgmtDropNormalTableColumnByName
(
(
SNormalTableObj
*
)
pTable
,
pAlter
->
schema
[
0
].
name
);
code
=
mgmtDropNormalTableColumnByName
(
pTable
,
pAlter
->
schema
[
0
].
name
);
}
else
{
}
...
...
src/mnode/src/mgmtDb.c
浏览文件 @
b6313b34
...
...
@@ -28,7 +28,6 @@
#include "mgmtGrant.h"
#include "mgmtShell.h"
#include "mgmtMnode.h"
#include "mgmtNormalTable.h"
#include "mgmtChildTable.h"
#include "mgmtSdb.h"
#include "mgmtSuperTable.h"
...
...
@@ -82,7 +81,6 @@ static int32_t mgmtDbActionDelete(SSdbOperDesc *pOper) {
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pDb
->
cfg
.
acct
);
mgmtRemoveDbFromAcct
(
pAcct
,
pDb
);
mgmtDropAllNormalTables
(
pDb
);
mgmtDropAllChildTables
(
pDb
);
mgmtDropAllSuperTables
(
pDb
);
mgmtDropAllVgroups
(
pDb
);
...
...
@@ -382,7 +380,7 @@ static int32_t mgmtGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn)
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
schema
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
,
NULL
);
if
(
pUser
==
NULL
)
return
0
;
pShow
->
bytes
[
cols
]
=
TSDB_DB_NAME_LEN
;
...
...
@@ -532,7 +530,7 @@ static int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void *
SDbObj
*
pDb
=
NULL
;
char
*
pWrite
;
int32_t
cols
=
0
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
,
NULL
);
if
(
pUser
==
NULL
)
return
0
;
while
(
numOfRows
<
rows
)
{
...
...
src/mnode/src/mgmtDnode.c
浏览文件 @
b6313b34
...
...
@@ -76,7 +76,7 @@ bool mgmtCheckModuleInDnode(SDnodeObj *pDnode, int32_t moduleType) {
int32_t
mgmtGetModuleMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
cols
=
0
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
,
NULL
);
if
(
pUser
==
NULL
)
return
0
;
if
(
strcmp
(
pUser
->
user
,
"root"
)
!=
0
)
return
TSDB_CODE_NO_RIGHTS
;
...
...
@@ -169,7 +169,7 @@ int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pCo
static
int32_t
mgmtGetConfigMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
cols
=
0
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
,
NULL
);
if
(
pUser
==
NULL
)
return
0
;
if
(
strcmp
(
pUser
->
user
,
"root"
)
!=
0
)
return
TSDB_CODE_NO_RIGHTS
;
...
...
@@ -256,7 +256,7 @@ static int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, vo
static
int32_t
mgmtGetVnodeMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
cols
=
0
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
,
NULL
);
if
(
pUser
==
NULL
)
return
0
;
if
(
strcmp
(
pUser
->
user
,
"root"
)
!=
0
)
return
TSDB_CODE_NO_RIGHTS
;
...
...
src/mnode/src/mgmtMnode.c
浏览文件 @
b6313b34
...
...
@@ -118,7 +118,7 @@ static void *mgmtGetNextMnode(SShowObj *pShow, SMnodeObj **pMnode) {
static
int32_t
mgmtGetMnodeMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
cols
=
0
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
,
NULL
);
if
(
pUser
==
NULL
)
return
0
;
if
(
strcmp
(
pUser
->
user
,
"root"
)
!=
0
)
return
TSDB_CODE_NO_RIGHTS
;
...
...
src/mnode/src/mgmtProfile.c
浏览文件 @
b6313b34
...
...
@@ -678,7 +678,7 @@ void mgmtProcessKillQueryMsg(SQueuedMsg *pMsg) {
SRpcMsg
rpcRsp
=
{.
handle
=
pMsg
->
thandle
,
.
pCont
=
NULL
,
.
contLen
=
0
,
.
code
=
0
,
.
msgType
=
0
};
if
(
mgmtCheckRedirect
(
pMsg
->
thandle
))
return
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pMsg
->
thandle
);
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pMsg
->
thandle
,
NULL
);
if
(
pUser
==
NULL
)
{
rpcRsp
.
code
=
TSDB_CODE_INVALID_USER
;
rpcSendResponse
(
&
rpcRsp
);
...
...
@@ -702,7 +702,7 @@ void mgmtProcessKillStreamMsg(SQueuedMsg *pMsg) {
SRpcMsg
rpcRsp
=
{.
handle
=
pMsg
->
thandle
,
.
pCont
=
NULL
,
.
contLen
=
0
,
.
code
=
0
,
.
msgType
=
0
};
if
(
mgmtCheckRedirect
(
pMsg
->
thandle
))
return
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pMsg
->
thandle
);
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pMsg
->
thandle
,
NULL
);
if
(
pUser
==
NULL
)
{
rpcRsp
.
code
=
TSDB_CODE_INVALID_USER
;
rpcSendResponse
(
&
rpcRsp
);
...
...
@@ -726,7 +726,7 @@ void mgmtProcessKillConnectionMsg(SQueuedMsg *pMsg) {
SRpcMsg
rpcRsp
=
{.
handle
=
pMsg
->
thandle
,
.
pCont
=
NULL
,
.
contLen
=
0
,
.
code
=
0
,
.
msgType
=
0
};
if
(
mgmtCheckRedirect
(
pMsg
->
thandle
))
return
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pMsg
->
thandle
);
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pMsg
->
thandle
,
NULL
);
if
(
pUser
==
NULL
)
{
rpcRsp
.
code
=
TSDB_CODE_INVALID_USER
;
rpcSendResponse
(
&
rpcRsp
);
...
...
src/mnode/src/mgmtShell.c
浏览文件 @
b6313b34
...
...
@@ -30,7 +30,6 @@
#include "mgmtDnode.h"
#include "mgmtGrant.h"
#include "mgmtMnode.h"
#include "mgmtNormalTable.h"
#include "mgmtProfile.h"
#include "mgmtSdb.h"
#include "mgmtShell.h"
...
...
@@ -139,7 +138,7 @@ static void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg) {
}
if
(
mgmtCheckExpired
())
{
mgmtSendSimpleResp
(
pMsg
->
t
handle
,
TSDB_CODE_GRANT_EXPIRED
);
mgmtSendSimpleResp
(
rpcMsg
->
handle
,
TSDB_CODE_GRANT_EXPIRED
);
return
;
}
...
...
@@ -174,7 +173,7 @@ static void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg) {
queuedMsg
->
contLen
=
rpcMsg
->
contLen
;
queuedMsg
->
pCont
=
rpcMsg
->
pCont
;
queuedMsg
->
pUser
=
pUser
;
queuedMsg
.
usePublicIp
=
usePublicIp
;
queuedMsg
->
usePublicIp
=
usePublicIp
;
mgmtAddToShellQueue
(
queuedMsg
);
}
}
...
...
@@ -448,7 +447,7 @@ static bool mgmtCheckMeterMetaMsgType(void *pMsg) {
static
bool
mgmtCheckMsgReadOnly
(
int8_t
type
,
void
*
pCont
)
{
if
((
type
==
TSDB_MSG_TYPE_CM_TABLE_META
&&
(
!
mgmtCheckMeterMetaMsgType
(
pCont
)))
||
type
==
TSDB_MSG_TYPE_CM_STABLE_
META
||
type
==
TSDB_MSG_TYPE_RETRIEVE
||
type
==
TSDB_MSG_TYPE_CM_STABLE_
VGROUP
||
type
==
TSDB_MSG_TYPE_RETRIEVE
||
type
==
TSDB_MSG_TYPE_CM_SHOW
||
type
==
TSDB_MSG_TYPE_CM_TABLES_META
||
type
==
TSDB_MSG_TYPE_CM_CONNECT
)
{
return
true
;
...
...
src/mnode/src/mgmtSuperTable.c
浏览文件 @
b6313b34
...
...
@@ -20,6 +20,7 @@
#include "mgmtAcct.h"
#include "mgmtChildTable.h"
#include "mgmtDb.h"
#include "mgmtDClient.h"
#include "mgmtDnode.h"
#include "mgmtGrant.h"
#include "mgmtShell.h"
...
...
@@ -47,8 +48,8 @@ static int32_t mgmtSuperTableActionDestroy(SSdbOperDesc *pOper) {
}
static
int32_t
mgmtSuperTableActionInsert
(
SSdbOperDesc
*
pOper
)
{
S
TableInfo
*
pStable
=
pOper
->
pObj
;
SDbObj
*
pDb
=
mgmtGetDbByTableId
(
pStable
->
tableId
);
S
SuperTableObj
*
pStable
=
pOper
->
pObj
;
SDbObj
*
pDb
=
mgmtGetDbByTableId
(
pStable
->
info
.
tableId
);
if
(
pDb
!=
NULL
)
{
mgmtAddSuperTableIntoDb
(
pDb
);
}
...
...
@@ -56,8 +57,8 @@ static int32_t mgmtSuperTableActionInsert(SSdbOperDesc *pOper) {
}
static
int32_t
mgmtSuperTableActionDelete
(
SSdbOperDesc
*
pOper
)
{
S
TableInfo
*
pStable
=
pOper
->
pObj
;
SDbObj
*
pDb
=
mgmtGetDbByTableId
(
pStable
->
tableId
);
S
SuperTableObj
*
pStable
=
pOper
->
pObj
;
SDbObj
*
pDb
=
mgmtGetDbByTableId
(
pStable
->
info
.
tableId
);
if
(
pDb
!=
NULL
)
{
mgmtRemoveSuperTableFromDb
(
pDb
);
mgmtDropAllChildTablesInStable
((
SSuperTableObj
*
)
pStable
);
...
...
@@ -151,11 +152,9 @@ void mgmtCreateSuperTable(SQueuedMsg *pMsg) {
return
;
}
strcpy
(
pStable
->
tableId
,
pCreate
->
tableId
);
pStable
->
type
=
TSDB_SUPER_TABLE
;
strcpy
(
pStable
->
info
.
tableId
,
pCreate
->
tableId
);
pStable
->
info
.
type
=
TSDB_SUPER_TABLE
;
pStable
->
createdTime
=
taosGetTimestampMs
();
pStable
->
vgId
=
0
;
pStable
->
sid
=
0
;
pStable
->
uid
=
(((
uint64_t
)
pStable
->
createdTime
)
<<
16
)
+
(
sdbGetVersion
()
&
((
1ul
<<
16
)
-
1ul
));
pStable
->
sversion
=
0
;
pStable
->
numOfColumns
=
htons
(
pCreate
->
numOfColumns
);
...
...
@@ -191,14 +190,14 @@ void mgmtCreateSuperTable(SQueuedMsg *pMsg) {
mgmtDestroySuperTable
(
pStable
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_SDB_ERROR
);
}
else
{
mLPrint
(
"stable:%s, is created, tags:%d cols:%d"
,
pStable
->
tableId
,
pStable
->
numOfTags
,
pStable
->
numOfColumns
);
mLPrint
(
"stable:%s, is created, tags:%d cols:%d"
,
pStable
->
info
.
tableId
,
pStable
->
numOfTags
,
pStable
->
numOfColumns
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_SUCCESS
);
}
}
void
mgmtDropSuperTable
(
SQueuedMsg
*
newMsg
,
SSuperTableObj
*
pT
able
)
{
void
mgmtDropSuperTable
(
SQueuedMsg
*
pMsg
,
SSuperTableObj
*
pSt
able
)
{
if
(
pStable
->
numOfTables
!=
0
)
{
mError
(
"stable:%s, numOfTables:%d not 0"
,
pStable
->
tableId
,
pStable
->
numOfTables
);
mError
(
"stable:%s, numOfTables:%d not 0"
,
pStable
->
info
.
tableId
,
pStable
->
numOfTables
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_OTHERS
);
}
else
{
SSdbOperDesc
oper
=
{
...
...
@@ -207,7 +206,7 @@ void mgmtDropSuperTable(SQueuedMsg *newMsg, SSuperTableObj *pTable) {
.
pObj
=
pStable
};
int32_t
code
=
sdbDeleteRow
(
&
oper
);
mLPrint
(
"stable:%s, is dropped from sdb, result:%s"
,
pStable
->
tableId
,
tstrerror
(
code
));
mLPrint
(
"stable:%s, is dropped from sdb, result:%s"
,
pStable
->
info
.
tableId
,
tstrerror
(
code
));
mgmtSendSimpleResp
(
pMsg
->
thandle
,
code
);
}
}
...
...
@@ -248,9 +247,9 @@ static int32_t mgmtAddSuperTableTag(SSuperTableObj *pStable, SSchema schema[], i
}
}
SDbObj
*
pDb
=
mgmtGetDbByTableId
(
pStable
->
tableId
);
SDbObj
*
pDb
=
mgmtGetDbByTableId
(
pStable
->
info
.
tableId
);
if
(
pDb
==
NULL
)
{
mError
(
"meter: %s not belongs to any database"
,
pStable
->
tableId
);
mError
(
"meter: %s not belongs to any database"
,
pStable
->
info
.
tableId
);
return
TSDB_CODE_APP_ERROR
;
}
...
...
@@ -278,7 +277,7 @@ static int32_t mgmtAddSuperTableTag(SSuperTableObj *pStable, SSchema schema[], i
pAcct
->
acctInfo
.
numOfTimeSeries
+=
(
ntags
*
pStable
->
numOfTables
);
// sdbUpdateRow(tsSuperTableSdb, pStable, tsSuperTableUpdateSize, SDB_OPER_GLOBAL);
mTrace
(
"Succeed to add tag column %s to table %s"
,
schema
[
0
].
name
,
pStable
->
tableId
);
mTrace
(
"Succeed to add tag column %s to table %s"
,
schema
[
0
].
name
,
pStable
->
info
.
tableId
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -288,9 +287,9 @@ static int32_t mgmtDropSuperTableTag(SSuperTableObj *pStable, char *tagName) {
return
TSDB_CODE_APP_ERROR
;
}
SDbObj
*
pDb
=
mgmtGetDbByTableId
(
pStable
->
tableId
);
SDbObj
*
pDb
=
mgmtGetDbByTableId
(
pStable
->
info
.
tableId
);
if
(
pDb
==
NULL
)
{
mError
(
"table: %s not belongs to any database"
,
pStable
->
tableId
);
mError
(
"table: %s not belongs to any database"
,
pStable
->
info
.
tableId
);
return
TSDB_CODE_APP_ERROR
;
}
...
...
@@ -318,11 +317,11 @@ static int32_t mgmtModifySuperTableTagNameByName(SSuperTableObj *pStable, char *
int32_t
col
=
mgmtFindSuperTableTagIndex
(
pStable
,
oldTagName
);
if
(
col
<
0
)
{
// Tag name does not exist
mError
(
"Failed to modify table %s tag column, oname: %s, nname: %s"
,
pStable
->
tableId
,
oldTagName
,
newTagName
);
mError
(
"Failed to modify table %s tag column, oname: %s, nname: %s"
,
pStable
->
info
.
tableId
,
oldTagName
,
newTagName
);
return
TSDB_CODE_INVALID_MSG_TYPE
;
}
int32_t
rowSize
=
0
;
//
int32_t rowSize = 0;
uint32_t
len
=
strlen
(
newTagName
);
if
(
col
>=
pStable
->
numOfTags
||
len
>=
TSDB_COL_NAME_LEN
||
mgmtFindSuperTableTagIndex
(
pStable
,
newTagName
)
>=
0
)
{
...
...
@@ -346,11 +345,11 @@ static int32_t mgmtModifySuperTableTagNameByName(SSuperTableObj *pStable, char *
tfree
(
msg
);
if
(
ret
<
0
)
{
mError
(
"Failed to modify table %s tag column"
,
pStable
->
tableId
);
mError
(
"Failed to modify table %s tag column"
,
pStable
->
info
.
tableId
);
return
TSDB_CODE_APP_ERROR
;
}
mTrace
(
"Succeed to modify table %s tag column"
,
pStable
->
tableId
);
mTrace
(
"Succeed to modify table %s tag column"
,
pStable
->
info
.
tableId
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -376,9 +375,9 @@ static int32_t mgmtAddSuperTableColumn(SSuperTableObj *pStable, SSchema schema[]
}
}
SDbObj
*
pDb
=
mgmtGetDbByTableId
(
pStable
->
tableId
);
SDbObj
*
pDb
=
mgmtGetDbByTableId
(
pStable
->
info
.
tableId
);
if
(
pDb
==
NULL
)
{
mError
(
"meter: %s not belongs to any database"
,
pStable
->
tableId
);
mError
(
"meter: %s not belongs to any database"
,
pStable
->
info
.
tableId
);
return
TSDB_CODE_APP_ERROR
;
}
...
...
@@ -415,9 +414,9 @@ static int32_t mgmtDropSuperTableColumnByName(SSuperTableObj *pStable, char *col
return
TSDB_CODE_APP_ERROR
;
}
SDbObj
*
pDb
=
mgmtGetDbByTableId
(
pStable
->
tableId
);
SDbObj
*
pDb
=
mgmtGetDbByTableId
(
pStable
->
info
.
tableId
);
if
(
pDb
==
NULL
)
{
mError
(
"table: %s not belongs to any database"
,
pStable
->
tableId
);
mError
(
"table: %s not belongs to any database"
,
pStable
->
info
.
tableId
);
return
TSDB_CODE_APP_ERROR
;
}
...
...
@@ -504,7 +503,7 @@ int32_t mgmtRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows, v
SDbObj
*
pDb
=
mgmtGetDb
(
pShow
->
db
);
if
(
pDb
==
NULL
)
return
0
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
,
NULL
);
if
(
mgmtCheckIsMonitorDB
(
pDb
->
name
,
tsMonitorDbName
))
{
if
(
strcmp
(
pUser
->
user
,
"root"
)
!=
0
&&
strcmp
(
pUser
->
user
,
"_root"
)
!=
0
&&
strcmp
(
pUser
->
user
,
"monitor"
)
!=
0
)
{
...
...
@@ -605,7 +604,6 @@ int32_t mgmtSetSchemaFromSuperTable(SSchema *pSchema, SSuperTableObj *pTable) {
}
void
mgmtGetSuperTableMeta
(
SQueuedMsg
*
pMsg
,
SSuperTableObj
*
pTable
)
{
SCMTableInfoMsg
*
pInfo
=
pMsg
->
pCont
;
SDbObj
*
pDb
=
pMsg
->
pDb
;
STableMetaMsg
*
pMeta
=
rpcMallocCont
(
sizeof
(
STableMetaMsg
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
);
...
...
@@ -667,4 +665,8 @@ void mgmtAlterSuperTable(SQueuedMsg *pMsg, SSuperTableObj *pTable) {
}
else
{}
mgmtSendSimpleResp
(
pMsg
->
thandle
,
code
);
}
static
void
mgmtProcessDropStableRsp
(
SRpcMsg
*
rpcMsg
)
{
mTrace
(
"drop stable rsp received, handle:%p code:%d"
,
rpcMsg
->
handle
,
rpcMsg
->
code
);
}
\ No newline at end of file
src/mnode/src/mgmtTable.c
浏览文件 @
b6313b34
...
...
@@ -73,7 +73,7 @@ void mgmtCleanUpTables() {
mgmtCleanUpSuperTables
();
}
void
mgmtExtractTableName
(
c
onst
c
har
*
tableId
,
char
*
name
)
{
void
mgmtExtractTableName
(
char
*
tableId
,
char
*
name
)
{
int
pos
=
-
1
;
int
num
=
0
;
for
(
pos
=
0
;
tableId
[
pos
]
!=
0
;
++
pos
)
{
...
...
@@ -139,14 +139,14 @@ static void mgmtProcessDropTableMsg(SQueuedMsg *pMsg) {
return
;
}
pMsg
->
pDb
=
mgmtGetDb
(
pCreate
->
db
);
pMsg
->
pDb
=
mgmtGetDb
ByTableId
(
pDrop
->
tableId
);
if
(
pMsg
->
pDb
==
NULL
||
pMsg
->
pDb
->
dirty
)
{
mError
(
"table:%s, failed to drop table, db not selected"
,
pDrop
->
tableId
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_DB_NOT_SELECTED
);
return
;
}
if
(
mgmtCheckIsMonitorDB
(
pDb
->
name
,
tsMonitorDbName
))
{
if
(
mgmtCheckIsMonitorDB
(
p
Msg
->
p
Db
->
name
,
tsMonitorDbName
))
{
mError
(
"table:%s, failed to drop table, in monitor database"
,
pDrop
->
tableId
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_MONITOR_DB_FORBIDDEN
);
return
;
...
...
@@ -170,7 +170,7 @@ static void mgmtProcessDropTableMsg(SQueuedMsg *pMsg) {
mgmtDropSuperTable
(
pMsg
,
(
SSuperTableObj
*
)
pTable
);
}
else
{
mTrace
(
"table:%s, start to drop ctable"
,
pDrop
->
tableId
);
mgmtDropChildTable
(
pMsg
,
(
S
Normal
TableObj
*
)
pTable
);
mgmtDropChildTable
(
pMsg
,
(
S
Child
TableObj
*
)
pTable
);
}
}
...
...
@@ -186,15 +186,15 @@ static void mgmtProcessAlterTableMsg(SQueuedMsg *pMsg) {
return
;
}
pMsg
->
pDb
=
mgmtGetDbByTableId
(
p
Table
->
tableId
);
pMsg
->
pDb
=
mgmtGetDbByTableId
(
p
Alter
->
tableId
);
if
(
pMsg
->
pDb
==
NULL
||
pMsg
->
pDb
->
dirty
)
{
mError
(
"table:%s, failed to alter table, db not selected"
,
p
Table
->
tableId
);
mError
(
"table:%s, failed to alter table, db not selected"
,
p
Alter
->
tableId
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_DB_NOT_SELECTED
);
return
;
}
if
(
mgmtCheckIsMonitorDB
(
pDb
->
name
,
tsMonitorDbName
))
{
mError
(
"table:%s, failed to alter table, its log db"
,
p
Table
->
tableId
);
if
(
mgmtCheckIsMonitorDB
(
p
Msg
->
p
Db
->
name
,
tsMonitorDbName
))
{
mError
(
"table:%s, failed to alter table, its log db"
,
p
Alter
->
tableId
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_MONITOR_DB_FORBIDDEN
);
return
;
}
...
...
@@ -218,22 +218,22 @@ static void mgmtProcessAlterTableMsg(SQueuedMsg *pMsg) {
}
if
(
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
mTrace
(
"table:%s, start to alter stable"
,
p
Drop
->
tableId
);
mTrace
(
"table:%s, start to alter stable"
,
p
Alter
->
tableId
);
mgmtAlterSuperTable
(
pMsg
,
(
SSuperTableObj
*
)
pTable
);
}
else
{
mTrace
(
"table:%s, start to alter ctable"
,
p
Drop
->
tableId
);
mgmtAlterChildTable
(
pMsg
,
(
S
Normal
TableObj
*
)
pTable
);
mTrace
(
"table:%s, start to alter ctable"
,
p
Alter
->
tableId
);
mgmtAlterChildTable
(
pMsg
,
(
S
Child
TableObj
*
)
pTable
);
}
}
static
void
mgmtProcessTableMetaMsg
(
SQueuedMsg
*
pMsg
)
{
SCMTableInfoMsg
*
pInfo
=
mgmtGetTable
(
pInfo
->
tableId
)
;
SCMTableInfoMsg
*
pInfo
=
pMsg
->
pCont
;
mTrace
(
"table:%s, table meta msg is received from thandle:%p"
,
pInfo
->
tableId
,
pMsg
->
thandle
);
STableInfo
*
pTable
=
mgmtGetTable
(
pInfo
->
tableId
);
if
(
pTable
==
NULL
||
pTable
->
type
!=
TSDB_SUPER_TABLE
)
{
mgmtGetChildTableMeta
(
pMsg
,
(
S
Super
TableObj
*
)
pTable
);
mgmtGetChildTableMeta
(
pMsg
,
(
S
Child
TableObj
*
)
pTable
);
}
else
{
mgmtGetSuperTableMeta
(
pMsg
,
(
S
Normal
TableObj
*
)
pTable
);
mgmtGetSuperTableMeta
(
pMsg
,
(
S
Super
TableObj
*
)
pTable
);
}
}
\ No newline at end of file
src/mnode/src/mgmtUser.c
浏览文件 @
b6313b34
...
...
@@ -231,7 +231,7 @@ static int32_t mgmtDropUser(SAcctObj *pAcct, char *name) {
}
static
int32_t
mgmtGetUserMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
);
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
,
NULL
);
if
(
pUser
==
NULL
)
{
return
TSDB_CODE_INVALID_USER
;
}
...
...
src/mnode/src/mgmtVgroup.c
浏览文件 @
b6313b34
...
...
@@ -20,6 +20,7 @@
#include "tstatus.h"
#include "mnode.h"
#include "mgmtBalance.h"
#include "mgmtChildTable.h"
#include "mgmtDb.h"
#include "mgmtDClient.h"
#include "mgmtDnode.h"
...
...
@@ -276,9 +277,9 @@ int32_t mgmtGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
int32_t
maxReplica
=
0
;
SVgObj
*
pVgroup
=
NULL
;
S
TableInfo
*
pTable
=
NULL
;
S
ChildTableObj
*
pTable
=
NULL
;
if
(
pShow
->
payloadLen
>
0
)
{
pTable
=
mgmtGetTable
(
pShow
->
payload
);
pTable
=
mgmtGet
Child
Table
(
pShow
->
payload
);
if
(
NULL
==
pTable
)
{
return
TSDB_CODE_INVALID_TABLE_ID
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录