Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e068bf33
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看板
提交
e068bf33
编写于
4月 03, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-93] add ref to sdb
上级
61b2342b
变更
17
展开全部
显示空白变更内容
内联
并排
Showing
17 changed file
with
1979 addition
and
2024 deletion
+1979
-2024
src/inc/mnode.h
src/inc/mnode.h
+1
-2
src/mnode/inc/mgmtAcct.h
src/mnode/inc/mgmtAcct.h
+4
-4
src/mnode/inc/mgmtChildTable.h
src/mnode/inc/mgmtChildTable.h
+0
-43
src/mnode/inc/mgmtDb.h
src/mnode/inc/mgmtDb.h
+2
-0
src/mnode/inc/mgmtSdb.h
src/mnode/inc/mgmtSdb.h
+2
-0
src/mnode/inc/mgmtSuperTable.h
src/mnode/inc/mgmtSuperTable.h
+0
-43
src/mnode/inc/mgmtTable.h
src/mnode/inc/mgmtTable.h
+4
-1
src/mnode/inc/mgmtUser.h
src/mnode/inc/mgmtUser.h
+2
-0
src/mnode/src/mgmtAcct.c
src/mnode/src/mgmtAcct.c
+4
-12
src/mnode/src/mgmtChildTable.c
src/mnode/src/mgmtChildTable.c
+0
-1226
src/mnode/src/mgmtDb.c
src/mnode/src/mgmtDb.c
+8
-3
src/mnode/src/mgmtSdb.c
src/mnode/src/mgmtSdb.c
+32
-3
src/mnode/src/mgmtShell.c
src/mnode/src/mgmtShell.c
+1
-2
src/mnode/src/mgmtSuperTable.c
src/mnode/src/mgmtSuperTable.c
+0
-672
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+1904
-7
src/mnode/src/mgmtUser.c
src/mnode/src/mgmtUser.c
+10
-0
src/mnode/src/mgmtVgroup.c
src/mnode/src/mgmtVgroup.c
+5
-6
未找到文件。
src/inc/mnode.h
浏览文件 @
e068bf33
...
@@ -102,9 +102,8 @@ typedef struct {
...
@@ -102,9 +102,8 @@ typedef struct {
}
SVnodeGid
;
}
SVnodeGid
;
typedef
struct
{
typedef
struct
{
char
tableId
[
TSDB_TABLE_ID_LEN
];
char
tableId
[
TSDB_TABLE_ID_LEN
+
1
];
int8_t
type
;
int8_t
type
;
int8_t
dirty
;
}
STableInfo
;
}
STableInfo
;
typedef
struct
SSuperTableObj
{
typedef
struct
SSuperTableObj
{
...
...
src/mnode/inc/mgmtAcct.h
浏览文件 @
e068bf33
...
@@ -32,10 +32,10 @@ void acctCleanUp();
...
@@ -32,10 +32,10 @@ void acctCleanUp();
SAcctObj
*
acctGetAcct
(
char
*
acctName
);
SAcctObj
*
acctGetAcct
(
char
*
acctName
);
int32_t
acctCheck
(
SAcctObj
*
pAcct
,
EAcctGrantType
type
);
int32_t
acctCheck
(
SAcctObj
*
pAcct
,
EAcctGrantType
type
);
int32_t
acctAddDb
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
);
void
acctAddDb
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
);
int32_t
acctRemoveDb
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
);
void
acctRemoveDb
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
);
int32_t
acctAddUser
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
);
void
acctAddUser
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
);
int32_t
acctRemoveUser
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
);
void
acctRemoveUser
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/mnode/inc/mgmtChildTable.h
已删除
100644 → 0
浏览文件 @
61b2342b
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TBASE_MNODE_CHILD_TABLE_H
#define TBASE_MNODE_CHILD_TABLE_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include <stdint.h>
#include <stdbool.h>
#include "taosdef.h"
#include "mnode.h"
int32_t
mgmtInitChildTables
();
void
mgmtCleanUpChildTables
();
void
*
mgmtGetChildTable
(
char
*
tableId
);
void
mgmtCreateChildTable
(
SQueuedMsg
*
pMsg
);
void
mgmtDropChildTable
(
SQueuedMsg
*
pMsg
,
SChildTableObj
*
pTable
);
void
mgmtGetChildTableMeta
(
SQueuedMsg
*
pMsg
,
SChildTableObj
*
pTable
);
void
mgmtAlterChildTable
(
SQueuedMsg
*
pMsg
,
SChildTableObj
*
pTable
);
void
mgmtDropAllChildTables
(
SDbObj
*
pDropDb
);
void
mgmtDropAllChildTablesInStable
(
SSuperTableObj
*
pStable
);
#ifdef __cplusplus
}
#endif
#endif
src/mnode/inc/mgmtDb.h
浏览文件 @
e068bf33
...
@@ -27,6 +27,8 @@ int32_t mgmtInitDbs();
...
@@ -27,6 +27,8 @@ int32_t mgmtInitDbs();
void
mgmtCleanUpDbs
();
void
mgmtCleanUpDbs
();
SDbObj
*
mgmtGetDb
(
char
*
db
);
SDbObj
*
mgmtGetDb
(
char
*
db
);
SDbObj
*
mgmtGetDbByTableId
(
char
*
db
);
SDbObj
*
mgmtGetDbByTableId
(
char
*
db
);
void
mgmtIncDbRef
(
SDbObj
*
pDb
);
void
mgmtDecDbRef
(
SDbObj
*
pDb
)
bool
mgmtCheckIsMonitorDB
(
char
*
db
,
char
*
monitordb
);
bool
mgmtCheckIsMonitorDB
(
char
*
db
,
char
*
monitordb
);
void
mgmtDropAllDbs
(
SAcctObj
*
pAcct
);
void
mgmtDropAllDbs
(
SAcctObj
*
pAcct
);
...
...
src/mnode/inc/mgmtSdb.h
浏览文件 @
e068bf33
...
@@ -62,6 +62,8 @@ int32_t sdbUpdateRow(SSdbOperDesc *pOper);
...
@@ -62,6 +62,8 @@ int32_t sdbUpdateRow(SSdbOperDesc *pOper);
void
*
sdbGetRow
(
void
*
handle
,
void
*
key
);
void
*
sdbGetRow
(
void
*
handle
,
void
*
key
);
void
*
sdbFetchRow
(
void
*
handle
,
void
*
pNode
,
void
**
ppRow
);
void
*
sdbFetchRow
(
void
*
handle
,
void
*
pNode
,
void
**
ppRow
);
void
sdbIncRef
(
void
*
thandle
,
void
*
pRow
);
void
sdbDecRef
(
void
*
thandle
,
void
*
pRow
);
int64_t
sdbGetNumOfRows
(
void
*
handle
);
int64_t
sdbGetNumOfRows
(
void
*
handle
);
int64_t
sdbGetId
(
void
*
handle
);
int64_t
sdbGetId
(
void
*
handle
);
uint64_t
sdbGetVersion
();
uint64_t
sdbGetVersion
();
...
...
src/mnode/inc/mgmtSuperTable.h
已删除
100644 → 0
浏览文件 @
61b2342b
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TBASE_MNODE_SUPER_TABLE_H
#define TBASE_MNODE_SUPER_TABLE_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include <stdint.h>
#include <stdbool.h>
#include "taosdef.h"
#include "mnode.h"
int32_t
mgmtInitSuperTables
();
void
mgmtCleanUpSuperTables
();
void
*
mgmtGetSuperTable
(
char
*
tableId
);
void
mgmtCreateSuperTable
(
SQueuedMsg
*
pMsg
);
void
mgmtDropSuperTable
(
SQueuedMsg
*
pMsg
,
SSuperTableObj
*
pTable
);
void
mgmtGetSuperTableMeta
(
SQueuedMsg
*
pMsg
,
SSuperTableObj
*
pTable
);
void
mgmtAlterSuperTable
(
SQueuedMsg
*
pMsg
,
SSuperTableObj
*
pTable
);
void
mgmtDropAllSuperTables
(
SDbObj
*
pDropDb
);
int32_t
mgmtSetSchemaFromSuperTable
(
SSchema
*
pSchema
,
SSuperTableObj
*
pTable
);
#ifdef __cplusplus
}
#endif
#endif
src/mnode/inc/mgmtTable.h
浏览文件 @
e068bf33
...
@@ -28,7 +28,10 @@ extern "C" {
...
@@ -28,7 +28,10 @@ extern "C" {
int32_t
mgmtInitTables
();
int32_t
mgmtInitTables
();
void
mgmtCleanUpTables
();
void
mgmtCleanUpTables
();
STableInfo
*
mgmtGetTable
(
char
*
tableId
);
STableInfo
*
mgmtGetTable
(
char
*
tableId
);
void
mgmtExtractTableName
(
char
*
tableId
,
char
*
tableName
);
void
mgmtIncTableRef
(
STableInfo
*
pTable
);
void
mgmtDecTableRef
(
STableInfo
*
pTable
);
void
mgmtDropAllChildTables
(
SDbObj
*
pDropDb
);
void
mgmtDropAllSuperTables
(
SDbObj
*
pDropDb
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/mnode/inc/mgmtUser.h
浏览文件 @
e068bf33
...
@@ -24,6 +24,8 @@ extern "C" {
...
@@ -24,6 +24,8 @@ extern "C" {
int32_t
mgmtInitUsers
();
int32_t
mgmtInitUsers
();
void
mgmtCleanUpUsers
();
void
mgmtCleanUpUsers
();
SUserObj
*
mgmtGetUser
(
char
*
name
);
SUserObj
*
mgmtGetUser
(
char
*
name
);
void
mgmtIncUserRef
(
SUserObj
*
pUser
);
void
mgmtDecUserRef
(
SUserObj
*
pUser
);
SUserObj
*
mgmtGetUserFromConn
(
void
*
pConn
,
bool
*
usePublicIp
);
SUserObj
*
mgmtGetUserFromConn
(
void
*
pConn
,
bool
*
usePublicIp
);
int32_t
mgmtCreateUser
(
SAcctObj
*
pAcct
,
char
*
name
,
char
*
pass
);
int32_t
mgmtCreateUser
(
SAcctObj
*
pAcct
,
char
*
name
,
char
*
pass
);
void
mgmtDropAllUsers
(
SAcctObj
*
pAcct
);
void
mgmtDropAllUsers
(
SAcctObj
*
pAcct
);
...
...
src/mnode/src/mgmtAcct.c
浏览文件 @
e068bf33
...
@@ -33,7 +33,7 @@ SAcctObj *acctGetAcct(char *acctName) { return &tsAcctObj; }
...
@@ -33,7 +33,7 @@ SAcctObj *acctGetAcct(char *acctName) { return &tsAcctObj; }
int32_t
acctCheck
(
SAcctObj
*
pAcct
,
EAcctGrantType
type
)
{
return
TSDB_CODE_SUCCESS
;
}
int32_t
acctCheck
(
SAcctObj
*
pAcct
,
EAcctGrantType
type
)
{
return
TSDB_CODE_SUCCESS
;
}
#endif
#endif
int32_t
acctAddDb
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
)
{
void
acctAddDb
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
)
{
pthread_mutex_lock
(
&
pAcct
->
mutex
);
pthread_mutex_lock
(
&
pAcct
->
mutex
);
pDb
->
next
=
pAcct
->
pHead
;
pDb
->
next
=
pAcct
->
pHead
;
pDb
->
prev
=
NULL
;
pDb
->
prev
=
NULL
;
...
@@ -46,11 +46,9 @@ int32_t acctAddDb(SAcctObj *pAcct, SDbObj *pDb) {
...
@@ -46,11 +46,9 @@ int32_t acctAddDb(SAcctObj *pAcct, SDbObj *pDb) {
pAcct
->
pHead
=
pDb
;
pAcct
->
pHead
=
pDb
;
pAcct
->
acctInfo
.
numOfDbs
++
;
pAcct
->
acctInfo
.
numOfDbs
++
;
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
return
0
;
}
}
int32_t
acctRemoveDb
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
)
{
void
acctRemoveDb
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
)
{
pthread_mutex_lock
(
&
pAcct
->
mutex
);
pthread_mutex_lock
(
&
pAcct
->
mutex
);
if
(
pDb
->
prev
)
{
if
(
pDb
->
prev
)
{
pDb
->
prev
->
next
=
pDb
->
next
;
pDb
->
prev
->
next
=
pDb
->
next
;
...
@@ -66,11 +64,9 @@ int32_t acctRemoveDb(SAcctObj *pAcct, SDbObj *pDb) {
...
@@ -66,11 +64,9 @@ int32_t acctRemoveDb(SAcctObj *pAcct, SDbObj *pDb) {
pAcct
->
acctInfo
.
numOfDbs
--
;
pAcct
->
acctInfo
.
numOfDbs
--
;
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
return
0
;
}
}
int32_t
acctAddUser
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
)
{
void
acctAddUser
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
)
{
pthread_mutex_lock
(
&
pAcct
->
mutex
);
pthread_mutex_lock
(
&
pAcct
->
mutex
);
pUser
->
next
=
pAcct
->
pUser
;
pUser
->
next
=
pAcct
->
pUser
;
pUser
->
prev
=
NULL
;
pUser
->
prev
=
NULL
;
...
@@ -83,11 +79,9 @@ int32_t acctAddUser(SAcctObj *pAcct, SUserObj *pUser) {
...
@@ -83,11 +79,9 @@ int32_t acctAddUser(SAcctObj *pAcct, SUserObj *pUser) {
pAcct
->
acctInfo
.
numOfUsers
++
;
pAcct
->
acctInfo
.
numOfUsers
++
;
pUser
->
pAcct
=
pAcct
;
pUser
->
pAcct
=
pAcct
;
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
return
0
;
}
}
int32_t
acctRemoveUser
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
)
{
void
acctRemoveUser
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
)
{
pthread_mutex_lock
(
&
pAcct
->
mutex
);
pthread_mutex_lock
(
&
pAcct
->
mutex
);
if
(
pUser
->
prev
)
{
if
(
pUser
->
prev
)
{
pUser
->
prev
->
next
=
pUser
->
next
;
pUser
->
prev
->
next
=
pUser
->
next
;
...
@@ -103,6 +97,4 @@ int32_t acctRemoveUser(SAcctObj *pAcct, SUserObj *pUser) {
...
@@ -103,6 +97,4 @@ int32_t acctRemoveUser(SAcctObj *pAcct, SUserObj *pUser) {
pAcct
->
acctInfo
.
numOfUsers
--
;
pAcct
->
acctInfo
.
numOfUsers
--
;
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
return
0
;
}
}
\ No newline at end of file
src/mnode/src/mgmtChildTable.c
已删除
100644 → 0
浏览文件 @
61b2342b
此差异已折叠。
点击以展开。
src/mnode/src/mgmtDb.c
浏览文件 @
e068bf33
...
@@ -22,15 +22,12 @@
...
@@ -22,15 +22,12 @@
#include "mnode.h"
#include "mnode.h"
#include "mgmtAcct.h"
#include "mgmtAcct.h"
#include "mgmtBalance.h"
#include "mgmtBalance.h"
#include "mgmtChildTable.h"
#include "mgmtDb.h"
#include "mgmtDb.h"
#include "mgmtDnode.h"
#include "mgmtDnode.h"
#include "mgmtGrant.h"
#include "mgmtGrant.h"
#include "mgmtShell.h"
#include "mgmtShell.h"
#include "mgmtMnode.h"
#include "mgmtMnode.h"
#include "mgmtChildTable.h"
#include "mgmtSdb.h"
#include "mgmtSdb.h"
#include "mgmtSuperTable.h"
#include "mgmtTable.h"
#include "mgmtTable.h"
#include "mgmtUser.h"
#include "mgmtUser.h"
#include "mgmtVgroup.h"
#include "mgmtVgroup.h"
...
@@ -149,6 +146,14 @@ SDbObj *mgmtGetDb(char *db) {
...
@@ -149,6 +146,14 @@ SDbObj *mgmtGetDb(char *db) {
return
(
SDbObj
*
)
sdbGetRow
(
tsDbSdb
,
db
);
return
(
SDbObj
*
)
sdbGetRow
(
tsDbSdb
,
db
);
}
}
void
mgmtIncDbRef
(
SDbObj
*
pDb
)
{
return
sdbIncRef
(
tsDbSdb
,
pDb
);
}
void
mgmtDecDbRef
(
SDbObj
*
pDb
)
{
return
sdbDecRef
(
tsDbSdb
,
pDb
);
}
SDbObj
*
mgmtGetDbByTableId
(
char
*
tableId
)
{
SDbObj
*
mgmtGetDbByTableId
(
char
*
tableId
)
{
char
db
[
TSDB_TABLE_ID_LEN
],
*
pos
;
char
db
[
TSDB_TABLE_ID_LEN
],
*
pos
;
...
...
src/mnode/src/mgmtSdb.c
浏览文件 @
e068bf33
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#include "tutil.h"
#include "tutil.h"
#include "hashint.h"
#include "hashint.h"
#include "hashstr.h"
#include "hashstr.h"
#include "mgmtSdb.h"
#include "mgmtSdb.h"
#define abs(x) (((x) < 0) ? -(x) : (x))
#define abs(x) (((x) < 0) ? -(x) : (x))
...
@@ -65,6 +66,7 @@ typedef struct {
...
@@ -65,6 +66,7 @@ typedef struct {
int64_t
version
;
int64_t
version
;
int64_t
offset
;
int64_t
offset
;
int32_t
rowSize
;
int32_t
rowSize
;
int32_t
refCount
;
void
*
row
;
void
*
row
;
}
SRowMeta
;
}
SRowMeta
;
...
@@ -322,6 +324,7 @@ static int32_t sdbInitTableByFile(SSdbTable *pTable) {
...
@@ -322,6 +324,7 @@ static int32_t sdbInitTableByFile(SSdbTable *pTable) {
.
table
=
pTable
,
.
table
=
pTable
,
.
pObj
=
pMetaRow
.
pObj
=
pMetaRow
};
};
sdbDecRef
(
pTable
,
pMetaRow
);
(
*
pTable
->
destroyFp
)(
&
oper
);
(
*
pTable
->
destroyFp
)(
&
oper
);
(
*
sdbDeleteIndexFp
[
pTable
->
keyType
])(
pTable
->
iHandle
,
rowHead
->
data
);
(
*
sdbDeleteIndexFp
[
pTable
->
keyType
])(
pTable
->
iHandle
,
rowHead
->
data
);
pTable
->
numOfRows
--
;
pTable
->
numOfRows
--
;
...
@@ -338,13 +341,14 @@ static int32_t sdbInitTableByFile(SSdbTable *pTable) {
...
@@ -338,13 +341,14 @@ static int32_t sdbInitTableByFile(SSdbTable *pTable) {
.
rowSize
=
rowHead
->
rowSize
,
.
rowSize
=
rowHead
->
rowSize
,
.
pObj
=
pMetaRow
.
pObj
=
pMetaRow
};
};
sdbDecRef
(
pTable
,
pMetaRow
);
(
*
pTable
->
destroyFp
)(
&
oper
);
(
*
pTable
->
destroyFp
)(
&
oper
);
(
*
sdbDeleteIndexFp
[
pTable
->
keyType
])(
pTable
->
iHandle
,
rowHead
->
data
);
(
*
sdbDeleteIndexFp
[
pTable
->
keyType
])(
pTable
->
iHandle
,
rowHead
->
data
);
int32_t
code
=
(
*
pTable
->
decodeFp
)(
&
oper
);
int32_t
code
=
(
*
pTable
->
decodeFp
)(
&
oper
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
rowMeta
.
row
=
oper
.
pObj
;
rowMeta
.
row
=
oper
.
pObj
;
sdbIncRef
(
pTable
,
pMetaRow
);
(
*
sdbAddIndexFp
[
pTable
->
keyType
])(
pTable
->
iHandle
,
rowMeta
.
row
,
&
rowMeta
);
(
*
sdbAddIndexFp
[
pTable
->
keyType
])(
pTable
->
iHandle
,
rowMeta
.
row
,
&
rowMeta
);
sdbTrace
(
"table:%s, version:%"
PRId64
" numOfRows:%d, read updated record:%s"
,
sdbTrace
(
"table:%s, version:%"
PRId64
" numOfRows:%d, read updated record:%s"
,
pTable
->
tableName
,
pTable
->
version
,
pTable
->
numOfRows
,
sdbGetkeyStr
(
pTable
,
rowHead
->
data
));
pTable
->
tableName
,
pTable
->
version
,
pTable
->
numOfRows
,
sdbGetkeyStr
(
pTable
,
rowHead
->
data
));
...
@@ -433,6 +437,28 @@ static SRowMeta *sdbGetRowMeta(void *handle, void *key) {
...
@@ -433,6 +437,28 @@ static SRowMeta *sdbGetRowMeta(void *handle, void *key) {
return
pMeta
;
return
pMeta
;
}
}
void
sdbIncRef
(
void
*
handle
,
void
*
pRow
)
{
if
(
pRow
)
{
SSdbTable
*
pTable
=
handle
;
SRowMeta
*
pMeta
=
(
pRow
-
4
);
atomic_add_fetch_32
(
&
pMeta
->
refCount
,
1
);
sdbTrace
(
"table:%s, add ref:%d to record:%s"
,
pTable
->
tableName
,
pMeta
->
refCount
,
sdbGetkeyStr
(
pTable
,
pRow
));
}
}
void
sdbDecRef
(
void
*
handle
,
void
*
pRow
)
{
if
(
pRow
)
{
SSdbTable
*
pTable
=
handle
;
SRowMeta
*
pMeta
=
(
pRow
-
4
);
int32_t
refCount
=
atomic_sub_fetch_32
(
&
pMeta
->
refCount
,
1
);
sdbTrace
(
"table:%s, def ref:%d from record:%s"
,
pTable
->
tableName
,
pMeta
->
refCount
,
sdbGetkeyStr
(
pTable
,
pRow
));
if
(
refCount
<=
0
)
{
SSdbOperDesc
oper
=
{.
pObj
=
pRow
};
(
*
pTable
->
destroyFp
)(
&
oper
);
}
}
}
void
*
sdbGetRow
(
void
*
handle
,
void
*
key
)
{
void
*
sdbGetRow
(
void
*
handle
,
void
*
key
)
{
SSdbTable
*
pTable
=
(
SSdbTable
*
)
handle
;
SSdbTable
*
pTable
=
(
SSdbTable
*
)
handle
;
SRowMeta
*
pMeta
;
SRowMeta
*
pMeta
;
...
@@ -441,6 +467,7 @@ void *sdbGetRow(void *handle, void *key) {
...
@@ -441,6 +467,7 @@ void *sdbGetRow(void *handle, void *key) {
pthread_mutex_lock
(
&
pTable
->
mutex
);
pthread_mutex_lock
(
&
pTable
->
mutex
);
pMeta
=
(
*
sdbGetIndexFp
[
pTable
->
keyType
])(
pTable
->
iHandle
,
key
);
pMeta
=
(
*
sdbGetIndexFp
[
pTable
->
keyType
])(
pTable
->
iHandle
,
key
);
if
(
pMeta
)
sdbIncRef
(
pTable
,
pMeta
->
row
);
pthread_mutex_unlock
(
&
pTable
->
mutex
);
pthread_mutex_unlock
(
&
pTable
->
mutex
);
if
(
pMeta
==
NULL
)
{
if
(
pMeta
==
NULL
)
{
...
@@ -459,6 +486,7 @@ int32_t sdbInsertRow(SSdbOperDesc *pOper) {
...
@@ -459,6 +486,7 @@ int32_t sdbInsertRow(SSdbOperDesc *pOper) {
if
(
sdbGetRow
(
pTable
,
pOper
->
pObj
))
{
if
(
sdbGetRow
(
pTable
,
pOper
->
pObj
))
{
sdbError
(
"table:%s, failed to insert record:%s, already exist"
,
pTable
->
tableName
,
sdbGetkeyStr
(
pTable
,
pOper
->
pObj
));
sdbError
(
"table:%s, failed to insert record:%s, already exist"
,
pTable
->
tableName
,
sdbGetkeyStr
(
pTable
,
pOper
->
pObj
));
sdbDecRef
(
pTable
,
pOper
->
pObj
);
return
TSDB_CODE_ALREADY_THERE
;
return
TSDB_CODE_ALREADY_THERE
;
}
}
...
@@ -526,6 +554,7 @@ int32_t sdbInsertRow(SSdbOperDesc *pOper) {
...
@@ -526,6 +554,7 @@ int32_t sdbInsertRow(SSdbOperDesc *pOper) {
rowMeta
.
rowSize
=
pOper
->
rowSize
;
rowMeta
.
rowSize
=
pOper
->
rowSize
;
rowMeta
.
row
=
pOper
->
pObj
;
rowMeta
.
row
=
pOper
->
pObj
;
(
*
sdbAddIndexFp
[
pTable
->
keyType
])(
pTable
->
iHandle
,
pOper
->
pObj
,
&
rowMeta
);
(
*
sdbAddIndexFp
[
pTable
->
keyType
])(
pTable
->
iHandle
,
pOper
->
pObj
,
&
rowMeta
);
sdbIncRef
(
pTable
,
pOper
->
pObj
);
pTable
->
numOfRows
++
;
pTable
->
numOfRows
++
;
...
@@ -626,8 +655,7 @@ int32_t sdbDeleteRow(SSdbOperDesc *pOper) {
...
@@ -626,8 +655,7 @@ int32_t sdbDeleteRow(SSdbOperDesc *pOper) {
pthread_mutex_unlock
(
&
pTable
->
mutex
);
pthread_mutex_unlock
(
&
pTable
->
mutex
);
(
*
pTable
->
deleteFp
)(
pOper
);
(
*
pTable
->
deleteFp
)(
pOper
);
(
*
pTable
->
destroyFp
)(
pOper
);
sdbDecRef
(
pTable
,
pOper
->
pObj
);
return
0
;
return
0
;
}
}
...
@@ -762,6 +790,7 @@ void *sdbFetchRow(void *handle, void *pNode, void **ppRow) {
...
@@ -762,6 +790,7 @@ void *sdbFetchRow(void *handle, void *pNode, void **ppRow) {
if
(
pMeta
==
NULL
)
return
NULL
;
if
(
pMeta
==
NULL
)
return
NULL
;
*
ppRow
=
pMeta
->
row
;
*
ppRow
=
pMeta
->
row
;
sdbIncRef
(
handle
,
pMeta
->
row
);
return
pNode
;
return
pNode
;
}
}
src/mnode/src/mgmtShell.c
浏览文件 @
e068bf33
...
@@ -25,7 +25,6 @@
...
@@ -25,7 +25,6 @@
#include "mnode.h"
#include "mnode.h"
#include "mgmtAcct.h"
#include "mgmtAcct.h"
#include "mgmtBalance.h"
#include "mgmtBalance.h"
#include "mgmtChildTable.h"
#include "mgmtDb.h"
#include "mgmtDb.h"
#include "mgmtDnode.h"
#include "mgmtDnode.h"
#include "mgmtGrant.h"
#include "mgmtGrant.h"
...
@@ -33,7 +32,6 @@
...
@@ -33,7 +32,6 @@
#include "mgmtProfile.h"
#include "mgmtProfile.h"
#include "mgmtSdb.h"
#include "mgmtSdb.h"
#include "mgmtShell.h"
#include "mgmtShell.h"
#include "mgmtSuperTable.h"
#include "mgmtTable.h"
#include "mgmtTable.h"
#include "mgmtUser.h"
#include "mgmtUser.h"
#include "mgmtVgroup.h"
#include "mgmtVgroup.h"
...
@@ -449,6 +447,7 @@ static bool mgmtCheckMeterMetaMsgType(void *pMsg) {
...
@@ -449,6 +447,7 @@ static bool mgmtCheckMeterMetaMsgType(void *pMsg) {
mTrace
(
"table:%s auto created task added"
,
pInfo
->
tableId
);
mTrace
(
"table:%s auto created task added"
,
pInfo
->
tableId
);
}
}
mgmtDecTableRef
(
pTable
);
return
addIntoTranQueue
;
return
addIntoTranQueue
;
}
}
...
...
src/mnode/src/mgmtSuperTable.c
已删除
100644 → 0
浏览文件 @
61b2342b
此差异已折叠。
点击以展开。
src/mnode/src/mgmtTable.c
浏览文件 @
e068bf33
此差异已折叠。
点击以展开。
src/mnode/src/mgmtUser.c
浏览文件 @
e068bf33
...
@@ -48,6 +48,7 @@ static int32_t mgmtUserActionInsert(SSdbOperDesc *pOper) {
...
@@ -48,6 +48,7 @@ static int32_t mgmtUserActionInsert(SSdbOperDesc *pOper) {
if
(
pAcct
!=
NULL
)
{
if
(
pAcct
!=
NULL
)
{
acctAddUser
(
pAcct
,
pUser
);
acctAddUser
(
pAcct
,
pUser
);
mgmtIncUserRef
(
pUser
);
}
}
else
{
else
{
mError
(
"user:%s, acct:%s info not exist in sdb"
,
pUser
->
user
,
pUser
->
acct
);
mError
(
"user:%s, acct:%s info not exist in sdb"
,
pUser
->
user
,
pUser
->
acct
);
...
@@ -63,6 +64,7 @@ static int32_t mgmtUserActionDelete(SSdbOperDesc *pOper) {
...
@@ -63,6 +64,7 @@ static int32_t mgmtUserActionDelete(SSdbOperDesc *pOper) {
if
(
pAcct
!=
NULL
)
{
if
(
pAcct
!=
NULL
)
{
acctRemoveUser
(
pAcct
,
pUser
);
acctRemoveUser
(
pAcct
,
pUser
);
mgmtDecUserRef
(
pUser
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -139,6 +141,14 @@ SUserObj *mgmtGetUser(char *name) {
...
@@ -139,6 +141,14 @@ SUserObj *mgmtGetUser(char *name) {
return
(
SUserObj
*
)
sdbGetRow
(
tsUserSdb
,
name
);
return
(
SUserObj
*
)
sdbGetRow
(
tsUserSdb
,
name
);
}
}
void
mgmtIncUserRef
(
SUserObj
*
pUser
)
{
return
sdbIncRef
(
tsUserSdb
,
pUser
);
}
void
mgmtDecUserRef
(
SUserObj
*
pUser
)
{
return
sdbDecRef
(
tsUserSdb
,
pUser
);
}
static
int32_t
mgmtUpdateUser
(
SUserObj
*
pUser
)
{
static
int32_t
mgmtUpdateUser
(
SUserObj
*
pUser
)
{
SSdbOperDesc
oper
=
{
SSdbOperDesc
oper
=
{
.
type
=
SDB_OPER_TYPE_GLOBAL
,
.
type
=
SDB_OPER_TYPE_GLOBAL
,
...
...
src/mnode/src/mgmtVgroup.c
浏览文件 @
e068bf33
...
@@ -20,7 +20,6 @@
...
@@ -20,7 +20,6 @@
#include "tstatus.h"
#include "tstatus.h"
#include "mnode.h"
#include "mnode.h"
#include "mgmtBalance.h"
#include "mgmtBalance.h"
#include "mgmtChildTable.h"
#include "mgmtDb.h"
#include "mgmtDb.h"
#include "mgmtDClient.h"
#include "mgmtDClient.h"
#include "mgmtDnode.h"
#include "mgmtDnode.h"
...
@@ -278,16 +277,16 @@ int32_t mgmtGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
...
@@ -278,16 +277,16 @@ int32_t mgmtGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
int32_t
maxReplica
=
0
;
int32_t
maxReplica
=
0
;
SVgObj
*
pVgroup
=
NULL
;
SVgObj
*
pVgroup
=
NULL
;
S
ChildTableObj
*
pTable
=
NULL
;
S
TableInfo
*
pTable
=
NULL
;
if
(
pShow
->
payloadLen
>
0
)
{
if
(
pShow
->
payloadLen
>
0
)
{
pTable
=
mgmtGet
Child
Table
(
pShow
->
payload
);
pTable
=
mgmtGetTable
(
pShow
->
payload
);
if
(
NULL
==
pTable
)
{
if
(
NULL
==
pTable
||
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
return
TSDB_CODE_INVALID_TABLE_ID
;
return
TSDB_CODE_INVALID_TABLE_ID
;
}
}
pVgroup
=
mgmtGetVgroup
(
pTable
->
vgId
);
pVgroup
=
mgmtGetVgroup
(
((
SChildTableObj
*
)
pTable
)
->
vgId
);
if
(
NULL
==
pVgroup
)
return
TSDB_CODE_INVALID_TABLE_ID
;
if
(
NULL
==
pVgroup
)
return
TSDB_CODE_INVALID_TABLE_ID
;
mgmtDecTableRef
(
pTable
);
maxReplica
=
pVgroup
->
numOfVnodes
>
maxReplica
?
pVgroup
->
numOfVnodes
:
maxReplica
;
maxReplica
=
pVgroup
->
numOfVnodes
>
maxReplica
?
pVgroup
->
numOfVnodes
:
maxReplica
;
}
else
{
}
else
{
SVgObj
*
pVgroup
=
pDb
->
pHead
;
SVgObj
*
pVgroup
=
pDb
->
pHead
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录