Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
38389ff1
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
38389ff1
编写于
1月 29, 2023
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
del invalid macro
上级
673e3be9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
60 addition
and
53 deletion
+60
-53
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+60
-53
未找到文件。
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
38389ff1
...
...
@@ -73,7 +73,7 @@ int32_t mndInitStb(SMnode *pMnode) {
mndSetMsgHandle
(
pMnode
,
TDMT_MND_TABLE_META
,
mndProcessTableMetaReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_TTL_TIMER
,
mndProcessTtlTimer
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_TABLE_CFG
,
mndProcessTableCfgReq
);
// mndSetMsgHandle(pMnode, TDMT_MND_SYSTABLE_RETRIEVE, mndProcessRetrieveStbReq);
// mndSetMsgHandle(pMnode, TDMT_MND_SYSTABLE_RETRIEVE, mndProcessRetrieveStbReq);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CREATE_INDEX
,
mndProcessCreateIndexReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_INDEX
,
mndProcessDropIndexReq
);
...
...
@@ -2539,30 +2539,30 @@ void mndExtractTbNameFromStbFullName(const char *stbFullName, char *dst, int32_t
}
}
//static int32_t mndProcessRetrieveStbReq(SRpcMsg *pReq) {
// SMnode *pMnode = pReq->info.node;
// SShowMgmt *pMgmt = &pMnode->showMgmt;
// SShowObj *pShow = NULL;
// int32_t rowsToRead = SHOW_STEP_SIZE;
// int32_t rowsRead = 0;
//
static int32_t mndProcessRetrieveStbReq(SRpcMsg *pReq) {
//
SMnode *pMnode = pReq->info.node;
//
SShowMgmt *pMgmt = &pMnode->showMgmt;
//
SShowObj *pShow = NULL;
//
int32_t rowsToRead = SHOW_STEP_SIZE;
//
int32_t rowsRead = 0;
//
// SRetrieveTableReq retrieveReq = {0};
// if (tDeserializeSRetrieveTableReq(pReq->pCont, pReq->contLen, &retrieveReq) != 0) {
// terrno = TSDB_CODE_INVALID_MSG;
// return -1;
// }
//
SRetrieveTableReq retrieveReq = {0};
//
if (tDeserializeSRetrieveTableReq(pReq->pCont, pReq->contLen, &retrieveReq) != 0) {
//
terrno = TSDB_CODE_INVALID_MSG;
//
return -1;
//
}
//
// SMnode *pMnode = pReq->info.node;
// SSdb *pSdb = pMnode->pSdb;
// int32_t numOfRows = 0;
// SDbObj *pDb = NULL;
// ESdbStatus objStatus = 0;
//
SMnode *pMnode = pReq->info.node;
//
SSdb *pSdb = pMnode->pSdb;
//
int32_t numOfRows = 0;
//
SDbObj *pDb = NULL;
//
ESdbStatus objStatus = 0;
//
// SUserObj *pUser = mndAcquireUser(pMnode, pReq->info.conn.user);
// if (pUser == NULL) return 0;
// bool sysinfo = pUser->sysInfo;
//
SUserObj *pUser = mndAcquireUser(pMnode, pReq->info.conn.user);
//
if (pUser == NULL) return 0;
//
bool sysinfo = pUser->sysInfo;
//
// // Append the information_schema database into the result.
//
// Append the information_schema database into the result.
//// if (!pShow->sysDbRsp) {
//// SDbObj infoschemaDb = {0};
//// setInformationSchemaDbCfg(pMnode, &infoschemaDb);
...
...
@@ -2815,7 +2815,6 @@ void mndExtractTbNameFromStbFullName(const char *stbFullName, char *dst, int32_t
// return TSDB_CODE_SUCCESS;
//}
static
int32_t
mndRetrieveStb
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
...
...
@@ -2926,8 +2925,8 @@ static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
return
numOfRows
;
}
static
int32_t
buildDbColsInfoBlock
(
const
SSDataBlock
*
p
,
const
SSysTableMeta
*
pSysDbTableMeta
,
size_t
size
,
const
char
*
dbName
,
const
char
*
tbName
)
{
static
int32_t
buildDbColsInfoBlock
(
const
SSDataBlock
*
p
,
const
SSysTableMeta
*
pSysDbTableMeta
,
size_t
size
,
const
char
*
dbName
,
const
char
*
tbName
)
{
char
tName
[
TSDB_TABLE_FNAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
char
dName
[
TSDB_TABLE_FNAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
char
typeName
[
TSDB_TABLE_FNAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
...
...
@@ -2937,19 +2936,19 @@ static int32_t buildDbColsInfoBlock(const SSDataBlock* p, const SSysTableMeta* p
STR_TO_VARSTR
(
typeName
,
"SYSTEM_TABLE"
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
const
SSysTableMeta
*
pm
=
&
pSysDbTableMeta
[
i
];
// if (pm->sysInfo) {
// continue;
// }
if
(
tbName
[
0
]
&&
strncmp
(
tbName
,
pm
->
name
,
TSDB_TABLE_NAME_LEN
)
!=
0
)
{
const
SSysTableMeta
*
pm
=
&
pSysDbTableMeta
[
i
];
// if (pm->sysInfo) {
// continue;
// }
if
(
tbName
[
0
]
&&
strncmp
(
tbName
,
pm
->
name
,
TSDB_TABLE_NAME_LEN
)
!=
0
)
{
continue
;
}
STR_TO_VARSTR
(
tName
,
pm
->
name
);
for
(
int32_t
j
=
0
;
j
<
pm
->
colNum
;
j
++
)
{
for
(
int32_t
j
=
0
;
j
<
pm
->
colNum
;
j
++
)
{
// table name
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
p
->
pDataBlock
,
0
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
p
->
pDataBlock
,
0
);
colDataAppend
(
pColInfoData
,
numOfRows
,
tName
,
false
);
// database name
...
...
@@ -2971,18 +2970,17 @@ static int32_t buildDbColsInfoBlock(const SSDataBlock* p, const SSysTableMeta* p
char
colTypeStr
[
VARSTR_HEADER_SIZE
+
32
];
int
colTypeLen
=
sprintf
(
varDataVal
(
colTypeStr
),
"%s"
,
tDataTypes
[
colType
].
name
);
if
(
colType
==
TSDB_DATA_TYPE_VARCHAR
)
{
colTypeLen
+=
sprintf
(
varDataVal
(
colTypeStr
)
+
colTypeLen
,
"(%d)"
,
(
int32_t
)(
pm
->
schema
[
j
].
bytes
-
VARSTR_HEADER_SIZE
));
colTypeLen
+=
sprintf
(
varDataVal
(
colTypeStr
)
+
colTypeLen
,
"(%d)"
,
(
int32_t
)(
pm
->
schema
[
j
].
bytes
-
VARSTR_HEADER_SIZE
));
}
else
if
(
colType
==
TSDB_DATA_TYPE_NCHAR
)
{
colTypeLen
+=
sprintf
(
varDataVal
(
colTypeStr
)
+
colTypeLen
,
"(%d)"
,
(
int32_t
)((
pm
->
schema
[
j
].
bytes
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
));
colTypeLen
+=
sprintf
(
varDataVal
(
colTypeStr
)
+
colTypeLen
,
"(%d)"
,
(
int32_t
)((
pm
->
schema
[
j
].
bytes
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
));
}
varDataSetLen
(
colTypeStr
,
colTypeLen
);
colDataAppend
(
pColInfoData
,
numOfRows
,
(
char
*
)
colTypeStr
,
false
);
colDataAppend
(
pColInfoData
,
numOfRows
,
(
char
*
)
colTypeStr
,
false
);
pColInfoData
=
taosArrayGet
(
p
->
pDataBlock
,
5
);
colDataAppend
(
pColInfoData
,
numOfRows
,
(
const
char
*
)
&
pm
->
schema
[
j
].
bytes
,
false
);
colDataAppend
(
pColInfoData
,
numOfRows
,
(
const
char
*
)
&
pm
->
schema
[
j
].
bytes
,
false
);
for
(
int32_t
k
=
6
;
k
<=
8
;
++
k
)
{
pColInfoData
=
taosArrayGet
(
p
->
pDataBlock
,
k
);
colDataAppendNULL
(
pColInfoData
,
numOfRows
);
...
...
@@ -2995,11 +2993,12 @@ static int32_t buildDbColsInfoBlock(const SSDataBlock* p, const SSysTableMeta* p
return
numOfRows
;
}
static
int32_t
buildSysDbColsInfo
(
SSDataBlock
*
p
,
char
*
db
,
char
*
tb
)
{
static
int32_t
buildSysDbColsInfo
(
SSDataBlock
*
p
,
char
*
db
,
char
*
tb
)
{
size_t
size
=
0
;
const
SSysTableMeta
*
pSysDbTableMeta
=
NULL
;
const
SSysTableMeta
*
pSysDbTableMeta
=
NULL
;
if
(
db
[
0
]
&&
strncmp
(
db
,
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_DB_FNAME_LEN
)
!=
0
&&
strncmp
(
db
,
TSDB_PERFORMANCE_SCHEMA_DB
,
TSDB_DB_FNAME_LEN
)
!=
0
){
if
(
db
[
0
]
&&
strncmp
(
db
,
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_DB_FNAME_LEN
)
!=
0
&&
strncmp
(
db
,
TSDB_PERFORMANCE_SCHEMA_DB
,
TSDB_DB_FNAME_LEN
)
!=
0
)
{
return
p
->
info
.
rows
;
}
...
...
@@ -3025,7 +3024,7 @@ static int32_t mndRetrieveStbCol(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
if
(
pDb
==
NULL
)
return
terrno
;
}
char
typeName
[
TSDB_TABLE_FNAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
char
typeName
[
TSDB_TABLE_FNAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_TO_VARSTR
(
typeName
,
"SUPER_TABLE"
);
while
(
numOfRows
<
rows
)
{
pShow
->
pIter
=
sdbFetch
(
pSdb
,
SDB_STB
,
pShow
->
pIter
,
(
void
**
)
&
pStb
);
...
...
@@ -3039,7 +3038,7 @@ static int32_t mndRetrieveStbCol(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
SName
name
=
{
0
};
char
stbName
[
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
mndExtractTbNameFromStbFullName
(
pStb
->
name
,
&
stbName
[
VARSTR_HEADER_SIZE
],
TSDB_TABLE_NAME_LEN
);
if
(
pShow
->
filterTb
[
0
]
&&
strncmp
(
pShow
->
filterTb
,
&
stbName
[
VARSTR_HEADER_SIZE
],
TSDB_TABLE_NAME_LEN
)
!=
0
)
{
if
(
pShow
->
filterTb
[
0
]
&&
strncmp
(
pShow
->
filterTb
,
&
stbName
[
VARSTR_HEADER_SIZE
],
TSDB_TABLE_NAME_LEN
)
!=
0
)
{
sdbRelease
(
pSdb
,
pStb
);
continue
;
}
...
...
@@ -3052,8 +3051,8 @@ static int32_t mndRetrieveStbCol(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
tNameGetDbName
(
&
name
,
varDataVal
(
db
));
varDataSetLen
(
db
,
strlen
(
varDataVal
(
db
)));
for
(
int
i
=
0
;
i
<
pStb
->
numOfColumns
;
i
++
)
{
int32_t
cols
=
0
;
for
(
int
i
=
0
;
i
<
pStb
->
numOfColumns
;
i
++
)
{
int32_t
cols
=
0
;
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
stbName
,
false
);
...
...
@@ -3078,16 +3077,15 @@ static int32_t mndRetrieveStbCol(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
colTypeLen
+=
sprintf
(
varDataVal
(
colTypeStr
)
+
colTypeLen
,
"(%d)"
,
(
int32_t
)(
pStb
->
pColumns
[
i
].
bytes
-
VARSTR_HEADER_SIZE
));
}
else
if
(
colType
==
TSDB_DATA_TYPE_NCHAR
)
{
colTypeLen
+=
sprintf
(
varDataVal
(
colTypeStr
)
+
colTypeLen
,
"(%d)"
,
(
int32_t
)((
pStb
->
pColumns
[
i
].
bytes
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
));
colTypeLen
+=
sprintf
(
varDataVal
(
colTypeStr
)
+
colTypeLen
,
"(%d)"
,
(
int32_t
)((
pStb
->
pColumns
[
i
].
bytes
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
));
}
varDataSetLen
(
colTypeStr
,
colTypeLen
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
char
*
)
colTypeStr
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
char
*
)
colTypeStr
,
false
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pStb
->
pColumns
[
i
].
bytes
,
false
);
while
(
cols
<
pShow
->
numOfColumns
)
{
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pStb
->
pColumns
[
i
].
bytes
,
false
);
while
(
cols
<
pShow
->
numOfColumns
)
{
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppendNULL
(
pColInfo
,
numOfRows
);
}
...
...
@@ -3139,6 +3137,11 @@ int32_t mndAddIndexImpl(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pSt
mndTransSetDbName
(
pTrans
,
pDb
->
name
,
pStb
->
name
);
if
(
mndTrancCheckConflict
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
if
(
needRsp
)
{
void
*
pCont
=
NULL
;
int32_t
contLen
=
0
;
mndTransSetRpcRsp
(
pTrans
,
pCont
,
contLen
);
}
if
(
mndSetAlterStbRedoLogs
(
pMnode
,
pTrans
,
pDb
,
pStb
)
!=
0
)
goto
_OVER
;
if
(
mndSetAlterStbCommitLogs
(
pMnode
,
pTrans
,
pDb
,
pStb
)
!=
0
)
goto
_OVER
;
if
(
mndSetAlterStbRedoActions2
(
pMnode
,
pTrans
,
pDb
,
pStb
,
sql
,
len
)
!=
0
)
goto
_OVER
;
...
...
@@ -3182,7 +3185,7 @@ static int32_t mndAddIndex(SMnode *pMnode, SRpcMsg *pReq, SCreateTagIndexReq *ta
SSchema
*
pTag
=
pNew
->
pTags
+
tag
;
if
(
IS_IDX_ON
(
pTag
))
{
terrno
=
TSDB_CODE_MND_TAG_
NOT
_EXIST
;
terrno
=
TSDB_CODE_MND_TAG_
INDEX_ALREADY
_EXIST
;
return
-
1
;
}
else
{
pTag
->
flags
|=
COL_IDX_ON
;
...
...
@@ -3227,7 +3230,11 @@ static int32_t mndProcessCreateIndexReq(SRpcMsg *pReq) {
}
code
=
mndAddIndex
(
pMnode
,
pReq
,
&
tagIdxReq
,
pDb
,
pStb
);
if
(
code
!=
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
if
(
terrno
==
TSDB_CODE_MND_TAG_INDEX_ALREADY_EXIST
||
terrno
==
TSDB_CODE_MND_TAG_NOT_EXIST
)
{
return
terrno
;
}
else
{
if
(
code
!=
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
}
return
TSDB_CODE_SUCCESS
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录