Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Cherenkov effect
TDengine
提交
95f748ca
T
TDengine
项目概览
Cherenkov effect
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
2
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
95f748ca
编写于
2月 20, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mgmtTable.c
上级
b7050af1
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
81 addition
and
142 deletion
+81
-142
src/mnode/inc/mgmtSupertableQuery.h
src/mnode/inc/mgmtSupertableQuery.h
+0
-30
src/mnode/inc/mgmtTable.h
src/mnode/inc/mgmtTable.h
+11
-18
src/mnode/src/mgmtSuperTable.c
src/mnode/src/mgmtSuperTable.c
+0
-1
src/mnode/src/mgmtSystem.c
src/mnode/src/mgmtSystem.c
+1
-1
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+69
-92
未找到文件。
src/mnode/inc/mgmtSupertableQuery.h
已删除
100644 → 0
浏览文件 @
b7050af1
/*
* 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_QUERY_H
#define TBASE_MNODE_SUPER_TABLE_QUERY_H
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "mnode.h"
#include "tast.h"
int32_t
mgmtRetrieveMetersFromSuperTable
(
SSuperTableMetaMsg
*
pInfo
,
int32_t
tableIndex
,
tQueryResultset
*
pRes
);
int32_t
mgmtDoJoin
(
SSuperTableMetaMsg
*
pSuperTableMetaMsg
,
tQueryResultset
*
pRes
);
void
mgmtReorganizeMetersInMetricMeta
(
SSuperTableMetaMsg
*
pInfo
,
int32_t
index
,
tQueryResultset
*
pRes
);
#endif
src/mnode/inc/mgmtTable.h
浏览文件 @
95f748ca
...
...
@@ -25,30 +25,23 @@ extern "C" {
#include <stdint.h>
#include "mnode.h"
typedef
struct
{
ETableType
type
;
void
*
obj
;
}
STableObj
;
int
mgmtInitMeters
();
int32_t
mgmtInitTables
();
STableInfo
*
mgmtGetTable
(
char
*
tableId
);
STableInfo
*
mgmtGetTableByPos
(
uint32_t
dnodeIp
,
int32_t
vnode
,
int32_t
sid
);
STabObj
*
mgmtGetTableInfo
(
char
*
src
,
char
*
tags
[]);
int
mgmtRetrieveMetricMeta
(
SConnObj
*
pConn
,
char
**
pStart
,
SSuperTableMetaMsg
*
pInfo
);
int
mgmtCreateTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
);
int
mgmtDropTable
(
SDbObj
*
pDb
,
char
*
meterId
,
int
ignore
);
int
mgmtAlterTable
(
SDbObj
*
pDb
,
SAlterTableMsg
*
pAlter
);
int
mgmtGetTableMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int
mgmtRetrieveTables
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
);
int32_t
mgmtRetrieveMetricMeta
(
SConnObj
*
pConn
,
char
**
pStart
,
SSuperTableMetaMsg
*
pInfo
);
int32_t
mgmtCreateTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
);
int32_t
mgmtDropTable
(
SDbObj
*
pDb
,
char
*
meterId
,
int32_t
ignore
);
int32_t
mgmtAlterTable
(
SDbObj
*
pDb
,
SAlterTableMsg
*
pAlter
);
int32_t
mgmtGetTableMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int32_t
mgmtRetrieveTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
SConnObj
*
pConn
);
void
mgmtCleanUpMeters
();
SSchema
*
mgmtGetTableSchema
(
STabObj
*
pTable
);
// get schema for a meter
int
mgmtAddMeterIntoMetric
(
STabObj
*
pMetric
,
STabObj
*
pTable
);
int
mgmtRemoveMeterFromMetric
(
STabObj
*
pMetric
,
STabObj
*
pTable
);
int
mgmtGetSuperTableMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int
mgmtRetrieveSuperTables
(
SShowObj
*
pShow
,
char
*
data
,
in
t
rows
,
SConnObj
*
pConn
);
int
32_t
mgmtAddMeterIntoMetric
(
STabObj
*
pMetric
,
STabObj
*
pTable
);
int
32_t
mgmtRemoveMeterFromMetric
(
STabObj
*
pMetric
,
STabObj
*
pTable
);
int
32_t
mgmtGetSuperTableMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int
32_t
mgmtRetrieveSuperTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_
t
rows
,
SConnObj
*
pConn
);
...
...
src/mnode/src/mgmtSuperTable.c
浏览文件 @
95f748ca
...
...
@@ -23,7 +23,6 @@
#include "mgmtDb.h"
#include "mgmtDnodeInt.h"
#include "mgmtVgroup.h"
#include "mgmtSupertableQuery.h"
#include "mgmtTable.h"
#include "taosmsg.h"
#include "tast.h"
...
...
src/mnode/src/mgmtSystem.c
浏览文件 @
95f748ca
...
...
@@ -101,7 +101,7 @@ int32_t mgmtStartSystem() {
return
-
1
;
}
if
(
mgmtInit
Meter
s
()
<
0
)
{
if
(
mgmtInit
Table
s
()
<
0
)
{
mError
(
"failed to init meters"
);
return
-
1
;
}
...
...
src/mnode/src/mgmtTable.c
浏览文件 @
95f748ca
...
...
@@ -15,16 +15,7 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "mnode.h"
#include "mgmtAcct.h"
#include "mgmtGrant.h"
#include "mgmtUtil.h"
#include "mgmtDb.h"
#include "mgmtDnodeInt.h"
#include "mgmtVgroup.h"
#include "mgmtSupertableQuery.h"
#include "mgmtTable.h"
#include "taoserror.h"
#include "taosmsg.h"
#include "tast.h"
#include "textbuffer.h"
...
...
@@ -32,46 +23,23 @@
#include "tscompression.h"
#include "tskiplist.h"
#include "tsqlfunction.h"
#include "ttime.h"
#include "tstatus.h"
#include "mgmtSuperTable.h"
#include "ttime.h"
#include "mnode.h"
#include "mgmtAcct.h"
#include "mgmtChildTable.h"
#include "mgmtDb.h"
#include "mgmtDnode.h"
#include "mgmtDnodeInt.h"
#include "mgmtGrant.h"
#include "mgmtNormalTable.h"
#include "mgmtStreamTable.h"
#include "mgmtSuperTable.h"
#include "mgmtTable.h"
#include "mgmtUtil.h"
#include "mgmtVgroup.h"
#include "taoserror.h"
extern
int64_t
sdbVersion
;
static
int32_t
mgmtGetReqTagsLength
(
STabObj
*
pMetric
,
int16_t
*
cols
,
int32_t
numOfCols
)
{
assert
(
mgmtIsSuperTable
(
pMetric
)
&&
numOfCols
>=
0
&&
numOfCols
<=
TSDB_MAX_TAGS
+
1
);
int32_t
len
=
0
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
assert
(
cols
[
i
]
<
pMetric
->
numOfTags
);
if
(
cols
[
i
]
==
-
1
)
{
len
+=
TSDB_METER_NAME_LEN
;
}
else
{
len
+=
((
SSchema
*
)
pMetric
->
schema
)[
pMetric
->
numOfColumns
+
cols
[
i
]].
bytes
;
}
}
return
len
;
}
/*
* remove the hole in result set
*/
static
void
mgmtVacuumResult
(
char
*
data
,
int32_t
numOfCols
,
int32_t
rows
,
int32_t
capacity
,
SShowObj
*
pShow
)
{
if
(
rows
<
capacity
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
memmove
(
data
+
pShow
->
offset
[
i
]
*
rows
,
data
+
pShow
->
offset
[
i
]
*
capacity
,
pShow
->
bytes
[
i
]
*
rows
);
}
}
}
int
mgmtInitMeters
()
{
int32_t
mgmtInitTables
()
{
int32_t
code
=
mgmtInitSuperTables
();
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
...
...
@@ -120,12 +88,21 @@ STableInfo* mgmtGetTable(char *tableId) {
}
STableInfo
*
mgmtGetTableByPos
(
uint32_t
dnodeIp
,
int32_t
vnode
,
int32_t
sid
)
{
SDnodeObj
*
pObj
=
mgmtGetDnode
(
dnodeIp
);
if
(
pObj
!=
NULL
&&
vnode
>=
0
&&
vnode
<
pObj
->
numOfVnodes
)
{
int32_t
vgId
=
pObj
->
vload
[
vnode
].
vgId
;
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
vgId
);
if
(
pVgroup
)
{
return
pVgroup
->
tableList
[
sid
];
}
}
return
NULL
;
}
int32_t
mgmtCreateTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
)
{
STableInfo
*
t
able
=
mgmtGetTable
(
pCreate
->
meterId
);
if
(
t
able
!=
NULL
)
{
STableInfo
*
pT
able
=
mgmtGetTable
(
pCreate
->
meterId
);
if
(
pT
able
!=
NULL
)
{
if
(
pCreate
->
igExists
)
{
return
TSDB_CODE_SUCCESS
;
}
else
{
...
...
@@ -135,7 +112,7 @@ int32_t mgmtCreateTable(SDbObj *pDb, SCreateTableMsg *pCreate) {
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pDb
->
cfg
.
acct
);
assert
(
pAcct
!=
NULL
);
int
code
=
mgmtCheckTableLimit
(
pAcct
,
pCreate
);
int
32_t
code
=
mgmtCheckTableLimit
(
pAcct
,
pCreate
);
if
(
code
!=
0
)
{
mError
(
"table:%s, exceed the limit"
,
pCreate
->
meterId
);
return
code
;
...
...
@@ -147,7 +124,7 @@ int32_t mgmtCreateTable(SDbObj *pDb, SCreateTableMsg *pCreate) {
}
if
(
pCreate
->
numOfTags
==
0
)
{
int
grantCode
=
mgmtCheckTimeSeries
(
pCreate
->
numOfColumns
);
int
32_t
grantCode
=
mgmtCheckTimeSeries
(
pCreate
->
numOfColumns
);
if
(
grantCode
!=
0
)
{
mError
(
"table:%s, grant expired"
,
pCreate
->
meterId
);
return
grantCode
;
...
...
@@ -175,9 +152,9 @@ int32_t mgmtCreateTable(SDbObj *pDb, SCreateTableMsg *pCreate) {
}
}
int
mgmtDropTable
(
SDbObj
*
pDb
,
char
*
tableId
,
in
t
ignore
)
{
STableInfo
*
t
able
=
mgmtGetTable
(
tableId
);
if
(
t
able
==
NULL
)
{
int
32_t
mgmtDropTable
(
SDbObj
*
pDb
,
char
*
tableId
,
int32_
t
ignore
)
{
STableInfo
*
pT
able
=
mgmtGetTable
(
tableId
);
if
(
pT
able
==
NULL
)
{
if
(
ignore
)
{
return
TSDB_CODE_SUCCESS
;
}
else
{
...
...
@@ -185,72 +162,61 @@ int mgmtDropTable(SDbObj *pDb, char *tableId, int ignore) {
}
}
// 0.log
if
(
mgmtCheckIsMonitorDB
(
pDb
->
name
,
tsMonitorDbName
))
{
return
TSDB_CODE_MONITOR_DB_FORBIDDEN
;
}
switch
(
t
able
->
type
)
{
switch
(
pT
able
->
type
)
{
case
TSDB_TABLE_TYPE_SUPER_TABLE
:
return
mgmtDropSuperTable
(
pDb
,
t
able
);
return
mgmtDropSuperTable
(
pDb
,
(
SSuperTableObj
*
)
pT
able
);
case
TSDB_TABLE_TYPE_CHILD_TABLE
:
return
mgmtDropChildTable
(
pDb
,
t
able
);
return
mgmtDropChildTable
(
pDb
,
(
SChildTableObj
*
)
pT
able
);
case
TSDB_TABLE_TYPE_STREAM_TABLE
:
return
mgmtDropStreamTable
(
pDb
,
t
able
);
return
mgmtDropStreamTable
(
pDb
,
(
SStreamTableObj
*
)
pT
able
);
case
TSDB_TABLE_TYPE_NORMAL_TABLE
:
return
mgmtDropNormalTable
(
pDb
,
t
able
);
return
mgmtDropNormalTable
(
pDb
,
(
SNormalTableObj
*
)
pT
able
);
default:
return
TSDB_CODE_INVALID_TABLE
;
}
}
int
mgmtAlterTable
(
SDbObj
*
pDb
,
SAlterTableMsg
*
pAlter
)
{
STableInfo
*
t
able
=
mgmtGetTable
(
pAlter
->
meterId
);
if
(
t
able
==
NULL
)
{
int
32_t
mgmtAlterTable
(
SDbObj
*
pDb
,
SAlterTableMsg
*
pAlter
)
{
STableInfo
*
pT
able
=
mgmtGetTable
(
pAlter
->
meterId
);
if
(
pT
able
==
NULL
)
{
return
TSDB_CODE_INVALID_TABLE
;
}
// 0.log
if
(
mgmtCheckIsMonitorDB
(
pDb
->
name
,
tsMonitorDbName
))
{
return
TSDB_CODE_MONITOR_DB_FORBIDDEN
;
}
// if (pAlter->type == TSDB_ALTER_TABLE_UPDATE_TAG_VAL) {
// return mgmtUpdate
// if (!mgmtIsNormalTable(pTable) || !mgmtTableCreateFromSuperTable(pTable)) {
// return TSDB_CODE_OPS_NOT_SUPPORT;
// }
// }
// todo add
/* mgmtMeterAddTags */
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_ADD_TAG_COLUMN
)
{
if
(
t
able
->
type
==
TSDB_TABLE_TYPE_SUPER_TABLE
)
{
return
mgmtAddSuperTableTag
(
t
able
,
pAlter
->
schema
,
1
);
if
(
pT
able
->
type
==
TSDB_TABLE_TYPE_SUPER_TABLE
)
{
return
mgmtAddSuperTableTag
(
(
SSuperTableObj
*
)
pT
able
,
pAlter
->
schema
,
1
);
}
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_DROP_TAG_COLUMN
)
{
if
(
t
able
->
type
==
TSDB_TABLE_TYPE_SUPER_TABLE
)
{
return
mgmtDropSuperTableTag
(
t
able
,
pAlter
->
schema
[
0
].
name
);
if
(
pT
able
->
type
==
TSDB_TABLE_TYPE_SUPER_TABLE
)
{
return
mgmtDropSuperTableTag
(
(
SSuperTableObj
*
)
pT
able
,
pAlter
->
schema
[
0
].
name
);
}
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN
)
{
if
(
t
able
->
type
==
TSDB_TABLE_TYPE_SUPER_TABLE
)
{
return
mgmtModifySuperTableTagNameByName
(
t
able
,
pAlter
->
schema
[
0
].
name
,
pAlter
->
schema
[
1
].
name
);
if
(
pT
able
->
type
==
TSDB_TABLE_TYPE_SUPER_TABLE
)
{
return
mgmtModifySuperTableTagNameByName
(
(
SSuperTableObj
*
)
pT
able
,
pAlter
->
schema
[
0
].
name
,
pAlter
->
schema
[
1
].
name
);
}
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_UPDATE_TAG_VAL
)
{
if
(
t
able
->
type
==
TSDB_TABLE_TYPE_CHILD_TABLE
)
{
return
mgmtModifyChildTableTagValueByName
(
t
able
,
pAlter
->
schema
[
0
].
name
,
pAlter
->
tagVal
);
if
(
pT
able
->
type
==
TSDB_TABLE_TYPE_CHILD_TABLE
)
{
return
mgmtModifyChildTableTagValueByName
(
(
SChildTableObj
*
)
pT
able
,
pAlter
->
schema
[
0
].
name
,
pAlter
->
tagVal
);
}
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_ADD_COLUMN
)
{
if
(
t
able
->
type
==
TSDB_TABLE_TYPE_NORMAL_TABLE
)
{
return
mgmtAddNormalTableColumn
(
t
able
,
pAlter
->
schema
,
1
);
}
else
if
(
t
able
->
type
==
TSDB_TABLE_TYPE_SUPER_TABLE
)
{
return
mgmtAddSuperTableColumn
(
t
able
,
pAlter
->
schema
,
1
);
if
(
pT
able
->
type
==
TSDB_TABLE_TYPE_NORMAL_TABLE
)
{
return
mgmtAddNormalTableColumn
(
(
SNormalTableObj
*
)
pT
able
,
pAlter
->
schema
,
1
);
}
else
if
(
pT
able
->
type
==
TSDB_TABLE_TYPE_SUPER_TABLE
)
{
return
mgmtAddSuperTableColumn
(
(
SSuperTableObj
*
)
pT
able
,
pAlter
->
schema
,
1
);
}
else
{}
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_DROP_COLUMN
)
{
if
(
t
able
->
type
==
TSDB_TABLE_TYPE_NORMAL_TABLE
)
{
return
mgmtDropNormalTableColumnByName
(
t
able
,
pAlter
->
schema
[
0
].
name
);
}
else
if
(
t
able
->
type
==
TSDB_TABLE_TYPE_SUPER_TABLE
)
{
return
mgmtDropSuperTableColumnByName
(
t
able
,
pAlter
->
schema
[
0
].
name
);
if
(
pT
able
->
type
==
TSDB_TABLE_TYPE_NORMAL_TABLE
)
{
return
mgmtDropNormalTableColumnByName
(
(
SNormalTableObj
*
)
pT
able
,
pAlter
->
schema
[
0
].
name
);
}
else
if
(
pT
able
->
type
==
TSDB_TABLE_TYPE_SUPER_TABLE
)
{
return
mgmtDropSuperTableColumnByName
(
(
SSuperTableObj
*
)
pT
able
,
pAlter
->
schema
[
0
].
name
);
}
else
{}
}
else
{}
...
...
@@ -316,7 +282,18 @@ int32_t mgmtGetTableMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
return
0
;
}
int32_t
mgmtRetrieveTables
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
)
{
/*
* remove the hole in result set
*/
static
void
mgmtVacuumResult
(
char
*
data
,
int32_t
numOfCols
,
int32_t
rows
,
int32_t
capacity
,
SShowObj
*
pShow
)
{
if
(
rows
<
capacity
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
memmove
(
data
+
pShow
->
offset
[
i
]
*
rows
,
data
+
pShow
->
offset
[
i
]
*
capacity
,
pShow
->
bytes
[
i
]
*
rows
);
}
}
}
int32_t
mgmtRetrieveTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
SConnObj
*
pConn
)
{
int32_t
numOfRows
=
0
;
int32_t
numOfRead
=
0
;
int32_t
cols
=
0
;
...
...
@@ -327,7 +304,7 @@ int32_t mgmtRetrieveTables(SShowObj *pShow, char *data, int rows, SConnObj *pCon
int64_t
createdTime
;
char
*
tableId
;
char
*
superTableId
;
SPatternCompareInfo
info
=
PATTERN_COMPARE_INFO_INITIALIZER
;
SPatternCompareInfo
info
=
PATTERN_COMPARE_INFO_INITIALIZER
;
SDbObj
*
pDb
=
NULL
;
if
(
pConn
->
pDb
!=
NULL
)
{
...
...
@@ -415,9 +392,9 @@ int32_t mgmtRetrieveTables(SShowObj *pShow, char *data, int rows, SConnObj *pCon
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
// if (pTable->pTagData
) {
//
extractTableName(superTableId, pWrite);
//
}
if
(
superTableId
!=
NULL
)
{
extractTableName
(
superTableId
,
pWrite
);
}
cols
++
;
numOfRows
++
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录