Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4910ea29
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4910ea29
编写于
11月 11, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename some variables
上级
2bdccc20
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
76 addition
and
67 deletion
+76
-67
include/dnode/mnode/sdb/sdb.h
include/dnode/mnode/sdb/sdb.h
+5
-5
include/util/taoserror.h
include/util/taoserror.h
+10
-9
source/dnode/mnode/impl/src/mnodeAcct.c
source/dnode/mnode/impl/src/mnodeAcct.c
+10
-10
source/dnode/mnode/impl/src/mnodeUser.c
source/dnode/mnode/impl/src/mnodeUser.c
+10
-10
source/dnode/mnode/sdb/src/sdb.c
source/dnode/mnode/sdb/src/sdb.c
+25
-18
source/dnode/mnode/transaction/src/trn.c
source/dnode/mnode/transaction/src/trn.c
+9
-9
source/util/src/terror.c
source/util/src/terror.c
+7
-6
未找到文件。
include/dnode/mnode/sdb/sdb.h
浏览文件 @
4910ea29
...
...
@@ -27,7 +27,7 @@ extern "C" {
(dataLen) -= (valLen); \
(pData) = (char *)(pData) + (valLen); \
} else { \
code = TSDB_CODE_SDB_INVA
ID_RAW_DATA_LEN;
\
code = TSDB_CODE_SDB_INVA
LID_DATA_LEN;
\
} \
}
...
...
@@ -38,7 +38,7 @@ extern "C" {
(dataLen) -= sizeof(int32_t); \
(pData) = (char *)(pData) + sizeof(int32_t); \
} else { \
code = TSDB_CODE_SDB_INVA
ID_RAW_DATA_LEN;
\
code = TSDB_CODE_SDB_INVA
LID_DATA_LEN;
\
} \
}
...
...
@@ -49,7 +49,7 @@ extern "C" {
(dataLen) -= sizeof(int64_t); \
(pData) = (char *)(pData) + sizeof(int64_t); \
} else { \
code = TSDB_CODE_SDB_INVA
ID_RAW_DATA_LEN;
\
code = TSDB_CODE_SDB_INVA
LID_DATA_LEN;
\
} \
}
...
...
@@ -121,11 +121,11 @@ typedef struct {
SdbInsertFp
insertFp
;
SdbUpdateFp
updateFp
;
SdbDeleteFp
deleteFp
;
}
SSdb
Hand
le
;
}
SSdb
Tab
le
;
int32_t
sdbInit
();
void
sdbCleanup
();
void
sdbSet
Handle
(
SSdbHandle
hand
le
);
void
sdbSet
Table
(
SSdbTable
tab
le
);
int32_t
sdbRead
();
int32_t
sdbWrite
(
SSdbRaw
*
pRaw
);
...
...
include/util/taoserror.h
浏览文件 @
4910ea29
...
...
@@ -134,15 +134,16 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_FAILED_TO_INIT_STEP TAOS_DEF_ERROR_CODE(0, 0x0314) //"failed to init components")
#define TSDB_CODE_SDB_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x0320)
#define TSDB_CODE_SDB_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0321)
#define TSDB_CODE_SDB_OBJ_ALREADY_THERE TAOS_DEF_ERROR_CODE(0, 0x0322)
#define TSDB_CODE_SDB_OBJ_NOT_THERE TAOS_DEF_ERROR_CODE(0, 0x0323)
#define TSDB_CODE_SDB_INVAID_RAW_DATA_VER TAOS_DEF_ERROR_CODE(0, 0x0324)
#define TSDB_CODE_SDB_INVAID_RAW_DATA_LEN TAOS_DEF_ERROR_CODE(0, 0x0325)
#define TSDB_CODE_SDB_INVALID_TABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0326)
#define TSDB_CODE_SDB_INVAID_META_ROW TAOS_DEF_ERROR_CODE(0, 0x0327)
#define TSDB_CODE_SDB_INVAID_KEY_TYPE TAOS_DEF_ERROR_CODE(0, 0x0328)
#define TSDB_CODE_SDB_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0320)
#define TSDB_CODE_SDB_OBJ_ALREADY_THERE TAOS_DEF_ERROR_CODE(0, 0x0321)
#define TSDB_CODE_SDB_OBJ_NOT_THERE TAOS_DEF_ERROR_CODE(0, 0x0322)
#define TSDB_CODE_SDB_INVALID_TABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0323)
#define TSDB_CODE_SDB_INVALID_KEY_TYPE TAOS_DEF_ERROR_CODE(0, 0x0324)
#define TSDB_CODE_SDB_INVALID_ACTION_TYPE TAOS_DEF_ERROR_CODE(0, 0x0325)
#define TSDB_CODE_SDB_INVALID_STATUS_TYPE TAOS_DEF_ERROR_CODE(0, 0x0326)
#define TSDB_CODE_SDB_INVALID_DATA_VER TAOS_DEF_ERROR_CODE(0, 0x0327)
#define TSDB_CODE_SDB_INVALID_DATA_LEN TAOS_DEF_ERROR_CODE(0, 0x0328)
#define TSDB_CODE_SDB_INVALID_META_ROW TAOS_DEF_ERROR_CODE(0, 0x0329)
#define TSDB_CODE_MND_DNODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0330) //"DNode already exists")
#define TSDB_CODE_MND_DNODE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0331) //"DNode does not exist")
...
...
source/dnode/mnode/impl/src/mnodeAcct.c
浏览文件 @
4910ea29
...
...
@@ -47,7 +47,7 @@ static SSdbRaw *mnodeAcctActionEncode(SAcctObj *pAcct) {
static
SAcctObj
*
mnodeAcctActionDecode
(
SSdbRaw
*
pRaw
)
{
if
(
pRaw
->
sver
!=
ACCT_VER
)
{
terrno
=
TSDB_CODE_SDB_INVA
ID_RAW
_DATA_VER
;
terrno
=
TSDB_CODE_SDB_INVA
LID
_DATA_VER
;
return
NULL
;
}
...
...
@@ -114,15 +114,15 @@ static int32_t mnodeCreateDefaultAcct() {
}
int32_t
mnodeInitAcct
()
{
SSdb
Handle
hand
le
=
{.
sdbType
=
SDB_ACCT
,
.
keyType
=
SDB_KEY_BINARY
,
.
deployFp
=
(
SdbDeployFp
)
mnodeCreateDefaultAcct
,
.
encodeFp
=
(
SdbEncodeFp
)
mnodeAcctActionEncode
,
.
decodeFp
=
(
SdbDecodeFp
)
mnodeAcctActionDecode
,
.
insertFp
=
(
SdbInsertFp
)
mnodeAcctActionInsert
,
.
updateFp
=
(
SdbUpdateFp
)
mnodeAcctActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mnodeAcctActionDelete
};
sdbSet
Handle
(
hand
le
);
SSdb
Table
tab
le
=
{.
sdbType
=
SDB_ACCT
,
.
keyType
=
SDB_KEY_BINARY
,
.
deployFp
=
(
SdbDeployFp
)
mnodeCreateDefaultAcct
,
.
encodeFp
=
(
SdbEncodeFp
)
mnodeAcctActionEncode
,
.
decodeFp
=
(
SdbDecodeFp
)
mnodeAcctActionDecode
,
.
insertFp
=
(
SdbInsertFp
)
mnodeAcctActionInsert
,
.
updateFp
=
(
SdbUpdateFp
)
mnodeAcctActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mnodeAcctActionDelete
};
sdbSet
Table
(
tab
le
);
return
0
;
}
...
...
source/dnode/mnode/impl/src/mnodeUser.c
浏览文件 @
4910ea29
...
...
@@ -45,7 +45,7 @@ static SSdbRaw *mnodeUserActionEncode(SUserObj *pUser) {
static
SUserObj
*
mnodeUserActionDecode
(
SSdbRaw
*
pRaw
)
{
if
(
pRaw
->
sver
!=
USER_VER
)
{
terrno
=
TSDB_CODE_SDB_INVA
ID_RAW
_DATA_VER
;
terrno
=
TSDB_CODE_SDB_INVA
LID
_DATA_VER
;
return
NULL
;
}
...
...
@@ -234,15 +234,15 @@ static int32_t mnodeProcessCreateUserMsg(SMnodeMsg *pMsg) {
}
int32_t
mnodeInitUser
()
{
SSdb
Handle
hand
le
=
{.
sdbType
=
SDB_USER
,
.
keyType
=
SDB_KEY_BINARY
,
.
deployFp
=
(
SdbDeployFp
)
mnodeCreateDefaultUsers
,
.
encodeFp
=
(
SdbEncodeFp
)
mnodeUserActionEncode
,
.
decodeFp
=
(
SdbDecodeFp
)
mnodeUserActionDecode
,
.
insertFp
=
(
SdbInsertFp
)
mnodeUserActionInsert
,
.
updateFp
=
(
SdbUpdateFp
)
mnodeUserActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mnodeUserActionDelete
};
sdbSet
Handle
(
hand
le
);
SSdb
Table
tab
le
=
{.
sdbType
=
SDB_USER
,
.
keyType
=
SDB_KEY_BINARY
,
.
deployFp
=
(
SdbDeployFp
)
mnodeCreateDefaultUsers
,
.
encodeFp
=
(
SdbEncodeFp
)
mnodeUserActionEncode
,
.
decodeFp
=
(
SdbDecodeFp
)
mnodeUserActionDecode
,
.
insertFp
=
(
SdbInsertFp
)
mnodeUserActionInsert
,
.
updateFp
=
(
SdbUpdateFp
)
mnodeUserActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mnodeUserActionDelete
};
sdbSet
Table
(
tab
le
);
return
0
;
}
...
...
source/dnode/mnode/sdb/src/sdb.c
浏览文件 @
4910ea29
...
...
@@ -21,17 +21,20 @@ static SSdbMgr tsSdb = {0};
static
int32_t
sdbCreateDir
()
{
if
(
!
taosMkDir
(
tsSdb
.
currDir
))
{
mError
(
"failed to create dir:%s"
,
tsSdb
.
currDir
);
return
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
mError
(
"failed to create dir:%s since %s"
,
tsSdb
.
currDir
,
terrstr
());
return
-
1
;
}
if
(
!
taosMkDir
(
tsSdb
.
syncDir
))
{
mError
(
"failed to create dir:%s"
,
tsSdb
.
syncDir
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
mError
(
"failed to create dir:%s since %s"
,
tsSdb
.
syncDir
,
terrstr
());
return
-
1
;
}
if
(
!
taosMkDir
(
tsSdb
.
tmpDir
))
{
mError
(
"failed to create dir:%s"
,
tsSdb
.
tmpDir
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
mError
(
"failed to create dir:%s since %s"
,
tsSdb
.
tmpDir
,
terrstr
());
return
-
1
;
}
...
...
@@ -41,8 +44,10 @@ static int32_t sdbCreateDir() {
static
int32_t
sdbRunDeployFp
()
{
for
(
int32_t
i
=
SDB_START
;
i
<
SDB_MAX
;
++
i
)
{
SdbDeployFp
fp
=
tsSdb
.
deployFps
[
i
];
if
(
fp
)
{
(
*
fp
)();
if
(
fp
==
NULL
)
continue
;
if
((
*
fp
)()
!=
0
)
{
mError
(
"failed to deploy sdb:%d since %s"
,
i
,
terrstr
());
return
-
1
;
}
}
...
...
@@ -51,11 +56,13 @@ static int32_t sdbRunDeployFp() {
static
SHashObj
*
sdbGetHash
(
int32_t
sdb
)
{
if
(
sdb
>=
SDB_MAX
||
sdb
<=
SDB_START
)
{
terrno
=
TSDB_CODE_SDB_INVALID_TABLE_TYPE
;
return
NULL
;
}
SHashObj
*
hash
=
tsSdb
.
hashObjs
[
sdb
];
if
(
hash
==
NULL
)
{
terrno
=
TSDB_CODE_SDB_APP_ERROR
;
return
NULL
;
}
...
...
@@ -112,7 +119,7 @@ static int32_t sdbReadDataFile() {
}
if
(
ret
<
sizeof
(
SSdbRaw
))
{
code
=
TSDB_CODE_SDB_
INTERNAL
_ERROR
;
code
=
TSDB_CODE_SDB_
APP
_ERROR
;
mError
(
"failed to read file:%s since %s"
,
file
,
tstrerror
(
code
));
break
;
}
...
...
@@ -159,7 +166,7 @@ static int32_t sdbWriteDataFile() {
taosWriteFile
(
fd
,
pRaw
,
sizeof
(
SSdbRaw
)
+
pRaw
->
dataLen
);
}
else
{
taosHashCancelIterate
(
hash
,
pRow
);
code
=
TSDB_CODE_SDB_
INTERNAL
_ERROR
;
code
=
TSDB_CODE_SDB_
APP
_ERROR
;
break
;
}
...
...
@@ -232,7 +239,7 @@ void sdbUnDeploy() {}
int32_t
sdbInit
()
{
char
path
[
PATH_MAX
+
100
];
snprintf
(
path
,
PATH_MAX
+
100
,
"%s%scur
rent
%s"
,
tsMnodeDir
,
TD_DIRSEP
,
TD_DIRSEP
);
snprintf
(
path
,
PATH_MAX
+
100
,
"%s%scur%s"
,
tsMnodeDir
,
TD_DIRSEP
,
TD_DIRSEP
);
tsSdb
.
currDir
=
strdup
(
path
);
snprintf
(
path
,
PATH_MAX
+
100
,
"%s%ssync%s"
,
tsMnodeDir
,
TD_DIRSEP
,
TD_DIRSEP
);
...
...
@@ -293,15 +300,15 @@ void sdbCleanup() {
}
}
void
sdbSet
Handle
(
SSdbHandle
hand
le
)
{
ESdbType
sdb
=
hand
le
.
sdbType
;
tsSdb
.
keyTypes
[
sdb
]
=
hand
le
.
keyType
;
tsSdb
.
insertFps
[
sdb
]
=
hand
le
.
insertFp
;
tsSdb
.
updateFps
[
sdb
]
=
hand
le
.
updateFp
;
tsSdb
.
deleteFps
[
sdb
]
=
hand
le
.
deleteFp
;
tsSdb
.
deployFps
[
sdb
]
=
hand
le
.
deployFp
;
tsSdb
.
encodeFps
[
sdb
]
=
hand
le
.
encodeFp
;
tsSdb
.
decodeFps
[
sdb
]
=
hand
le
.
decodeFp
;
void
sdbSet
Table
(
SSdbTable
tab
le
)
{
ESdbType
sdb
=
tab
le
.
sdbType
;
tsSdb
.
keyTypes
[
sdb
]
=
tab
le
.
keyType
;
tsSdb
.
insertFps
[
sdb
]
=
tab
le
.
insertFp
;
tsSdb
.
updateFps
[
sdb
]
=
tab
le
.
updateFp
;
tsSdb
.
deleteFps
[
sdb
]
=
tab
le
.
deleteFp
;
tsSdb
.
deployFps
[
sdb
]
=
tab
le
.
deployFp
;
tsSdb
.
encodeFps
[
sdb
]
=
tab
le
.
encodeFp
;
tsSdb
.
decodeFps
[
sdb
]
=
tab
le
.
decodeFp
;
}
#if 0
...
...
source/dnode/mnode/transaction/src/trn.c
浏览文件 @
4910ea29
...
...
@@ -61,7 +61,7 @@ SSdbRaw *trnActionEncode(STrans *pTrans) {
STrans
*
trnActionDecode
(
SSdbRaw
*
pRaw
)
{
if
(
pRaw
->
sver
!=
TRN_VER
)
{
terrno
=
TSDB_CODE_SDB_INVA
ID_RAW
_DATA_VER
;
terrno
=
TSDB_CODE_SDB_INVA
LID
_DATA_VER
;
return
NULL
;
}
...
...
@@ -223,14 +223,14 @@ int32_t trnAppendUndoAction(STrans *pTrans, SEpSet *pEpSet, void *pMsg) {
}
int32_t
trnInit
()
{
SSdb
Handle
hand
le
=
{.
sdbType
=
SDB_TRANS
,
.
keyType
=
SDB_KEY_INT32
,
.
encodeFp
=
(
SdbEncodeFp
)
trnActionEncode
,
.
decodeFp
=
(
SdbDecodeFp
)
trnActionDecode
,
.
insertFp
=
(
SdbInsertFp
)
trnActionInsert
,
.
updateFp
=
(
SdbUpdateFp
)
trnActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
trnActionDelete
};
sdbSet
Handle
(
hand
le
);
SSdb
Table
tab
le
=
{.
sdbType
=
SDB_TRANS
,
.
keyType
=
SDB_KEY_INT32
,
.
encodeFp
=
(
SdbEncodeFp
)
trnActionEncode
,
.
decodeFp
=
(
SdbDecodeFp
)
trnActionDecode
,
.
insertFp
=
(
SdbInsertFp
)
trnActionInsert
,
.
updateFp
=
(
SdbUpdateFp
)
trnActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
trnActionDelete
};
sdbSet
Table
(
tab
le
);
return
0
;
}
...
...
source/util/src/terror.c
浏览文件 @
4910ea29
...
...
@@ -144,15 +144,16 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_FAILED_TO_START_SYNC, "failed to start sync"
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_FAILED_TO_CREATE_DIR
,
"failed to create mnode dir"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_FAILED_TO_INIT_STEP
,
"failed to init components"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SDB_INTERNAL_ERROR
,
"Unexpected generic error in sdb"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SDB_OUT_OF_MEMORY
,
"Out of memory in sdb"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SDB_APP_ERROR
,
"Unexpected generic error in sdb"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SDB_OBJ_ALREADY_THERE
,
"Object already there"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SDB_OBJ_NOT_THERE
,
"Object not there"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SDB_INVAID_RAW_DATA_VER
,
"Invalid raw data version"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SDB_INVAID_RAW_DATA_LEN
,
"Invalid raw data len"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SDB_INVALID_TABLE_TYPE
,
"Invalid table type"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SDB_INVAID_META_ROW
,
"Invalid meta row"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SDB_INVAID_KEY_TYPE
,
"Invalid key type"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SDB_INVALID_KEY_TYPE
,
"Invalid key type"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SDB_INVALID_ACTION_TYPE
,
"Invalid action type"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SDB_INVALID_STATUS_TYPE
,
"Invalid status type"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SDB_INVALID_DATA_VER
,
"Invalid raw data version"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SDB_INVALID_DATA_LEN
,
"Invalid raw data len"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SDB_INVALID_META_ROW
,
"Invalid meta row"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_DNODE_ALREADY_EXIST
,
"DNode already exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_DNODE_NOT_EXIST
,
"DNode does not exist"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录