Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
03da5549
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看板
提交
03da5549
编写于
2月 24, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
get meta message
上级
41149af7
变更
17
展开全部
隐藏空白更改
内联
并排
Showing
17 changed file
with
454 addition
and
532 deletion
+454
-532
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+3
-3
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+1
-1
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+2
-2
src/client/src/tscServer.c
src/client/src/tscServer.c
+21
-21
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+10
-10
src/inc/taosmsg.h
src/inc/taosmsg.h
+19
-18
src/mnode/inc/mgmtChildTable.h
src/mnode/inc/mgmtChildTable.h
+12
-8
src/mnode/inc/mgmtNormalTable.h
src/mnode/inc/mgmtNormalTable.h
+13
-9
src/mnode/inc/mgmtStreamTable.h
src/mnode/inc/mgmtStreamTable.h
+11
-7
src/mnode/inc/mgmtSuperTable.h
src/mnode/inc/mgmtSuperTable.h
+20
-12
src/mnode/inc/mgmtTable.h
src/mnode/inc/mgmtTable.h
+3
-5
src/mnode/src/mgmtChildTable.c
src/mnode/src/mgmtChildTable.c
+29
-2
src/mnode/src/mgmtNormalTable.c
src/mnode/src/mgmtNormalTable.c
+44
-2
src/mnode/src/mgmtShell.c
src/mnode/src/mgmtShell.c
+156
-423
src/mnode/src/mgmtStreamTable.c
src/mnode/src/mgmtStreamTable.c
+44
-3
src/mnode/src/mgmtSuperTable.c
src/mnode/src/mgmtSuperTable.c
+46
-4
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+20
-2
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
03da5549
...
...
@@ -120,7 +120,7 @@ typedef struct SCond {
}
SCond
;
typedef
struct
SJoinNode
{
char
meter
Id
[
TSDB_TABLE_ID_LEN
];
char
table
Id
[
TSDB_TABLE_ID_LEN
];
uint64_t
uid
;
int16_t
tagCol
;
}
SJoinNode
;
...
...
@@ -155,7 +155,7 @@ typedef struct SParamInfo {
}
SParamInfo
;
typedef
struct
STableDataBlocks
{
char
meter
Id
[
TSDB_TABLE_ID_LEN
];
char
table
Id
[
TSDB_TABLE_ID_LEN
];
int8_t
tsSource
;
// where does the UNIX timestamp come from, server or client
bool
ordered
;
// if current rows are ordered or not
int64_t
vgid
;
// virtual group id
...
...
@@ -384,7 +384,7 @@ int tscProcessSql(SSqlObj *pSql);
void
tscAsyncInsertMultiVnodesProxy
(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
);
int
tscRenewMeterMeta
(
SSqlObj
*
pSql
,
char
*
meter
Id
);
int
tscRenewMeterMeta
(
SSqlObj
*
pSql
,
char
*
table
Id
);
void
tscQueueAsyncRes
(
SSqlObj
*
pSql
);
void
tscQueueAsyncError
(
void
(
*
fp
),
void
*
param
);
...
...
src/client/src/tscParseInsert.c
浏览文件 @
03da5549
...
...
@@ -1544,7 +1544,7 @@ void tscProcessMultiVnodesInsertFromFile(SSqlObj *pSql) {
continue
;
}
strncpy
(
pMeterMetaInfo
->
name
,
pDataBlock
->
meter
Id
,
TSDB_TABLE_ID_LEN
);
strncpy
(
pMeterMetaInfo
->
name
,
pDataBlock
->
table
Id
,
TSDB_TABLE_ID_LEN
);
memset
(
pDataBlock
->
pData
,
0
,
pDataBlock
->
nAllocSize
);
int32_t
ret
=
tscGetMeterMeta
(
pSql
,
pMeterMetaInfo
);
...
...
src/client/src/tscSQLParser.c
浏览文件 @
03da5549
...
...
@@ -2867,7 +2867,7 @@ static int32_t getJoinCondInfo(SQueryInfo* pQueryInfo, tSQLExpr* pExpr) {
pLeft
->
uid
=
pMeterMetaInfo
->
pMeterMeta
->
uid
;
pLeft
->
tagCol
=
tagColIndex
;
strcpy
(
pLeft
->
meter
Id
,
pMeterMetaInfo
->
name
);
strcpy
(
pLeft
->
table
Id
,
pMeterMetaInfo
->
name
);
index
=
(
SColumnIndex
)
COLUMN_INDEX_INITIALIZER
;
if
(
getColumnIndexByName
(
&
pExpr
->
pRight
->
colInfo
,
pQueryInfo
,
&
index
)
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -2879,7 +2879,7 @@ static int32_t getJoinCondInfo(SQueryInfo* pQueryInfo, tSQLExpr* pExpr) {
pRight
->
uid
=
pMeterMetaInfo
->
pMeterMeta
->
uid
;
pRight
->
tagCol
=
tagColIndex
;
strcpy
(
pRight
->
meter
Id
,
pMeterMetaInfo
->
name
);
strcpy
(
pRight
->
table
Id
,
pMeterMetaInfo
->
name
);
pTagCond
->
joinInfo
.
hasJoin
=
true
;
return
TSDB_CODE_SUCCESS
;
...
...
src/client/src/tscServer.c
浏览文件 @
03da5549
...
...
@@ -1838,7 +1838,7 @@ int32_t tscBuildDropTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pDropTableMsg
=
(
SDropTableMsg
*
)
pMsg
;
strcpy
(
pDropTableMsg
->
meter
Id
,
pMeterMetaInfo
->
name
);
strcpy
(
pDropTableMsg
->
table
Id
,
pMeterMetaInfo
->
name
);
pDropTableMsg
->
igNotExists
=
pInfo
->
pDCLInfo
->
existsCheck
?
1
:
0
;
pMsg
+=
sizeof
(
SDropTableMsg
);
...
...
@@ -2353,7 +2353,7 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
int
tscBuildMeterMetaMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
S
Meter
InfoMsg
*
pInfoMsg
;
S
Table
InfoMsg
*
pInfoMsg
;
char
*
pMsg
,
*
pStart
;
int
msgLen
=
0
;
...
...
@@ -2381,10 +2381,10 @@ int tscBuildMeterMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pMsg
+=
sizeof
(
SMgmtHead
);
pInfoMsg
=
(
S
Meter
InfoMsg
*
)
pMsg
;
strcpy
(
pInfoMsg
->
meter
Id
,
pMeterMetaInfo
->
name
);
pInfoMsg
=
(
S
Table
InfoMsg
*
)
pMsg
;
strcpy
(
pInfoMsg
->
table
Id
,
pMeterMetaInfo
->
name
);
pInfoMsg
->
createFlag
=
htons
(
pSql
->
cmd
.
createOnDemand
?
1
:
0
);
pMsg
+=
sizeof
(
S
Meter
InfoMsg
);
pMsg
+=
sizeof
(
S
Table
InfoMsg
);
if
(
pSql
->
cmd
.
createOnDemand
)
{
memcpy
(
pInfoMsg
->
tags
,
tmpData
,
sizeof
(
STagData
));
...
...
@@ -2403,7 +2403,7 @@ int tscBuildMeterMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
/**
* multi meter meta req pkg format:
* | SMgmtHead | SMulti
MeterInfoMsg | meterId0 | meterId1 | meter
Id2 | ......
* | SMgmtHead | SMulti
TableInfoMsg | tableId0 | tableId1 | table
Id2 | ......
* no used 4B
**/
int
tscBuildMultiMeterMetaMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
...
...
@@ -2421,16 +2421,16 @@ int tscBuildMultiMeterMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SMgmtHead
*
pMgmt
=
(
SMgmtHead
*
)(
pCmd
->
payload
+
tsRpcHeadSize
);
memset
(
pMgmt
->
db
,
0
,
TSDB_TABLE_ID_LEN
);
// server don't need the db
SMulti
MeterInfoMsg
*
pInfoMsg
=
(
SMultiMeter
InfoMsg
*
)(
pCmd
->
payload
+
tsRpcHeadSize
+
sizeof
(
SMgmtHead
));
pInfoMsg
->
numOf
Meter
s
=
htonl
((
int32_t
)
pCmd
->
count
);
SMulti
TableInfoMsg
*
pInfoMsg
=
(
SMultiTable
InfoMsg
*
)(
pCmd
->
payload
+
tsRpcHeadSize
+
sizeof
(
SMgmtHead
));
pInfoMsg
->
numOf
Table
s
=
htonl
((
int32_t
)
pCmd
->
count
);
if
(
pCmd
->
payloadLen
>
0
)
{
memcpy
(
pInfoMsg
->
meterId
,
tmpData
,
pCmd
->
payloadLen
);
memcpy
(
pInfoMsg
->
tableIds
,
tmpData
,
pCmd
->
payloadLen
);
}
tfree
(
tmpData
);
pCmd
->
payloadLen
+=
sizeof
(
SMgmtHead
)
+
sizeof
(
SMulti
Meter
InfoMsg
);
pCmd
->
payloadLen
+=
sizeof
(
SMgmtHead
)
+
sizeof
(
SMulti
Table
InfoMsg
);
pCmd
->
msgType
=
TSDB_MSG_TYPE_MULTI_TABLE_META
;
assert
(
pCmd
->
payloadLen
+
minMsgSize
()
<=
pCmd
->
allocSize
);
...
...
@@ -2502,13 +2502,13 @@ int tscBuildMetricMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
// todo refactor
pMetaMsg
->
joinCondLen
=
htonl
((
TSDB_TABLE_ID_LEN
+
sizeof
(
int16_t
))
*
2
);
memcpy
(
pMsg
,
pTagCond
->
joinInfo
.
left
.
meter
Id
,
TSDB_TABLE_ID_LEN
);
memcpy
(
pMsg
,
pTagCond
->
joinInfo
.
left
.
table
Id
,
TSDB_TABLE_ID_LEN
);
pMsg
+=
TSDB_TABLE_ID_LEN
;
*
(
int16_t
*
)
pMsg
=
pTagCond
->
joinInfo
.
left
.
tagCol
;
pMsg
+=
sizeof
(
int16_t
);
memcpy
(
pMsg
,
pTagCond
->
joinInfo
.
right
.
meter
Id
,
TSDB_TABLE_ID_LEN
);
memcpy
(
pMsg
,
pTagCond
->
joinInfo
.
right
.
table
Id
,
TSDB_TABLE_ID_LEN
);
pMsg
+=
TSDB_TABLE_ID_LEN
;
*
(
int16_t
*
)
pMsg
=
pTagCond
->
joinInfo
.
right
.
tagCol
;
...
...
@@ -2590,7 +2590,7 @@ int tscBuildMetricMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
}
strcpy
(
pElem
->
meter
Id
,
pMeterMetaInfo
->
name
);
strcpy
(
pElem
->
table
Id
,
pMeterMetaInfo
->
name
);
pElem
->
numOfTags
=
htons
(
pMeterMetaInfo
->
numOfTags
);
int16_t
len
=
pMsg
-
(
char
*
)
pElem
;
...
...
@@ -2751,7 +2751,7 @@ int tscProcessMeterMetaRsp(SSqlObj *pSql) {
/**
* multi meter meta rsp pkg format:
* | STaosRsp | ieType | SMulti
Meter
InfoMsg | SMeterMeta0 | SSchema0 | SMeterMeta1 | SSchema1 | SMeterMeta2 | SSchema2
* | STaosRsp | ieType | SMulti
Table
InfoMsg | SMeterMeta0 | SSchema0 | SMeterMeta1 | SSchema1 | SMeterMeta2 | SSchema2
* |...... 1B 1B 4B
**/
int
tscProcessMultiMeterMetaRsp
(
SSqlObj
*
pSql
)
{
...
...
@@ -2772,13 +2772,13 @@ int tscProcessMultiMeterMetaRsp(SSqlObj *pSql) {
rsp
++
;
SMulti
MeterInfoMsg
*
pInfo
=
(
SMultiMeter
InfoMsg
*
)
rsp
;
totalNum
=
htonl
(
pInfo
->
numOf
Meter
s
);
rsp
+=
sizeof
(
SMulti
Meter
InfoMsg
);
SMulti
TableInfoMsg
*
pInfo
=
(
SMultiTable
InfoMsg
*
)
rsp
;
totalNum
=
htonl
(
pInfo
->
numOf
Table
s
);
rsp
+=
sizeof
(
SMulti
Table
InfoMsg
);
for
(
i
=
0
;
i
<
totalNum
;
i
++
)
{
SMultiMeterMeta
*
pMultiMeta
=
(
SMultiMeterMeta
*
)
rsp
;
SMeterMeta
*
pMeta
=
&
pMultiMeta
->
meta
;
SMeterMeta
*
pMeta
=
&
pMultiMeta
->
meta
s
;
pMeta
->
sid
=
htonl
(
pMeta
->
sid
);
pMeta
->
sversion
=
htons
(
pMeta
->
sversion
);
...
...
@@ -2850,7 +2850,7 @@ int tscProcessMultiMeterMetaRsp(SSqlObj *pSql) {
int32_t
size
=
(
int32_t
)(
rsp
-
((
char
*
)
pMeta
));
// Consistent with SMeterMeta in cache
pMeta
->
index
=
0
;
(
void
)
taosAddDataIntoCache
(
tscCacheHandle
,
pM
ultiMeta
->
meter
Id
,
(
char
*
)
pMeta
,
size
,
tsMeterMetaKeepTimer
);
(
void
)
taosAddDataIntoCache
(
tscCacheHandle
,
pM
eta
->
table
Id
,
(
char
*
)
pMeta
,
size
,
tsMeterMetaKeepTimer
);
}
pSql
->
res
.
code
=
TSDB_CODE_SUCCESS
;
...
...
@@ -3312,10 +3312,10 @@ static void tscWaitingForCreateTable(SSqlCmd *pCmd) {
/**
* in renew metermeta, do not retrieve metadata in cache.
* @param pSql sql object
* @param
meter
Id meter id
* @param
table
Id meter id
* @return status code
*/
int
tscRenewMeterMeta
(
SSqlObj
*
pSql
,
char
*
meter
Id
)
{
int
tscRenewMeterMeta
(
SSqlObj
*
pSql
,
char
*
table
Id
)
{
int
code
=
0
;
// handle metric meta renew process
...
...
src/client/src/tscUtil.c
浏览文件 @
03da5549
...
...
@@ -56,7 +56,7 @@ void tscGetMetricMetaCacheKey(SQueryInfo* pQueryInfo, char* str, uint64_t uid) {
char
join
[
512
]
=
{
0
};
if
(
pTagCond
->
joinInfo
.
hasJoin
)
{
sprintf
(
join
,
"%s,%s"
,
pTagCond
->
joinInfo
.
left
.
meterId
,
pTagCond
->
joinInfo
.
right
.
meter
Id
);
sprintf
(
join
,
"%s,%s"
,
pTagCond
->
joinInfo
.
left
.
tableId
,
pTagCond
->
joinInfo
.
right
.
table
Id
);
}
// estimate the buffer size
...
...
@@ -156,13 +156,13 @@ bool tscIsSelectivityWithTagQuery(SSqlCmd* pCmd) {
return
false
;
}
void
tscGetDBInfoFromMeterId
(
char
*
meter
Id
,
char
*
db
)
{
char
*
st
=
strstr
(
meter
Id
,
TS_PATH_DELIMITER
);
void
tscGetDBInfoFromMeterId
(
char
*
table
Id
,
char
*
db
)
{
char
*
st
=
strstr
(
table
Id
,
TS_PATH_DELIMITER
);
if
(
st
!=
NULL
)
{
char
*
end
=
strstr
(
st
+
1
,
TS_PATH_DELIMITER
);
if
(
end
!=
NULL
)
{
memcpy
(
db
,
meterId
,
(
end
-
meter
Id
));
db
[
end
-
meter
Id
]
=
0
;
memcpy
(
db
,
tableId
,
(
end
-
table
Id
));
db
[
end
-
table
Id
]
=
0
;
return
;
}
}
...
...
@@ -590,12 +590,12 @@ int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock) {
// set the correct metermeta object, the metermeta has been locked in pDataBlocks, so it must be in the cache
if
(
pMeterMetaInfo
->
pMeterMeta
!=
pDataBlock
->
pMeterMeta
)
{
strcpy
(
pMeterMetaInfo
->
name
,
pDataBlock
->
meter
Id
);
strcpy
(
pMeterMetaInfo
->
name
,
pDataBlock
->
table
Id
);
taosRemoveDataFromCache
(
tscCacheHandle
,
(
void
**
)
&
(
pMeterMetaInfo
->
pMeterMeta
),
false
);
pMeterMetaInfo
->
pMeterMeta
=
taosTransferDataInCache
(
tscCacheHandle
,
(
void
**
)
&
pDataBlock
->
pMeterMeta
);
}
else
{
assert
(
strncmp
(
pMeterMetaInfo
->
name
,
pDataBlock
->
meterId
,
tListLen
(
pDataBlock
->
meter
Id
))
==
0
);
assert
(
strncmp
(
pMeterMetaInfo
->
name
,
pDataBlock
->
tableId
,
tListLen
(
pDataBlock
->
table
Id
))
==
0
);
}
/*
...
...
@@ -660,7 +660,7 @@ int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOff
dataBuf
->
size
=
startOffset
;
dataBuf
->
tsSource
=
-
1
;
strncpy
(
dataBuf
->
meter
Id
,
name
,
TSDB_TABLE_ID_LEN
);
strncpy
(
dataBuf
->
table
Id
,
name
,
TSDB_TABLE_ID_LEN
);
/*
* The metermeta may be released since the metermeta cache are completed clean by other thread
...
...
@@ -709,7 +709,7 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, SDataBlockList* pTableDataBlockLi
STableDataBlocks
*
dataBuf
=
NULL
;
int32_t
ret
=
tscGetDataBlockFromList
(
pVnodeDataBlockHashList
,
pVnodeDataBlockList
,
pOneTableBlock
->
vgid
,
TSDB_PAYLOAD_SIZE
,
tsInsertHeadSize
,
0
,
pOneTableBlock
->
meter
Id
,
pOneTableBlock
->
pMeterMeta
,
&
dataBuf
);
tsInsertHeadSize
,
0
,
pOneTableBlock
->
table
Id
,
pOneTableBlock
->
pMeterMeta
,
&
dataBuf
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"%p failed to prepare the data block buffer for merging table data, code:%d"
,
pSql
,
ret
);
taosCleanUpHashTable
(
pVnodeDataBlockHashList
);
...
...
@@ -743,7 +743,7 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, SDataBlockList* pTableDataBlockLi
char
*
e
=
(
char
*
)
pBlocks
->
payLoad
+
pOneTableBlock
->
rowSize
*
(
pBlocks
->
numOfRows
-
1
);
tscTrace
(
"%p
meterId:%s, sid:%d rows:%d sversion:%d skey:%"
PRId64
", ekey:%"
PRId64
,
pSql
,
pOneTableBlock
->
meter
Id
,
pBlocks
->
sid
,
tscTrace
(
"%p
tableId:%s, sid:%d rows:%d sversion:%d skey:%"
PRId64
", ekey:%"
PRId64
,
pSql
,
pOneTableBlock
->
table
Id
,
pBlocks
->
sid
,
pBlocks
->
numOfRows
,
pBlocks
->
sversion
,
GET_INT64_VAL
(
pBlocks
->
payLoad
),
GET_INT64_VAL
(
e
));
pBlocks
->
sid
=
htonl
(
pBlocks
->
sid
);
...
...
src/inc/taosmsg.h
浏览文件 @
03da5549
...
...
@@ -277,11 +277,11 @@ typedef struct {
int16_t
numOfColumns
;
int16_t
sqlLen
;
// the length of SQL, it starts after schema , sql is a null-terminated string
int16_t
reserved
[
16
];
SSchema
schema
[];
SSchema
schema
[];
}
SCreateTableMsg
;
typedef
struct
{
char
meter
Id
[
TSDB_TABLE_ID_LEN
];
char
table
Id
[
TSDB_TABLE_ID_LEN
];
char
db
[
TSDB_DB_NAME_LEN
];
int8_t
igNotExists
;
}
SDropTableMsg
;
...
...
@@ -348,7 +348,7 @@ typedef struct {
short
vnode
;
int32_t
sid
;
uint64_t
uid
;
char
meter
Id
[
TSDB_TABLE_ID_LEN
];
char
table
Id
[
TSDB_TABLE_ID_LEN
];
}
SDRemoveTableMsg
;
typedef
struct
{
...
...
@@ -615,7 +615,7 @@ typedef struct {
typedef
struct
{
uint32_t
destId
;
uint32_t
destIp
;
char
meter
Id
[
TSDB_UNI_LEN
];
char
table
Id
[
TSDB_UNI_LEN
];
char
empty
[
3
];
uint8_t
msgType
;
int32_t
msgLen
;
...
...
@@ -647,20 +647,21 @@ typedef struct {
}
SVPeersMsg
;
typedef
struct
{
char
meterId
[
TSDB_TABLE_ID_LEN
];
short
createFlag
;
char
tags
[];
}
SMeterInfoMsg
;
char
tableId
[
TSDB_TABLE_ID_LEN
];
char
db
[
TSDB_DB_NAME_LEN
];
int16_t
createFlag
;
char
tags
[];
}
STableInfoMsg
;
typedef
struct
{
int32_t
numOf
Meter
s
;
char
meterId
[];
}
SMulti
Meter
InfoMsg
;
int32_t
numOf
Table
s
;
char
tableIds
[];
}
SMulti
Table
InfoMsg
;
typedef
struct
{
int16_t
elemLen
;
char
meter
Id
[
TSDB_TABLE_ID_LEN
];
char
table
Id
[
TSDB_TABLE_ID_LEN
];
int16_t
orderIndex
;
int16_t
orderType
;
// used in group by xx order by xxx
...
...
@@ -701,26 +702,26 @@ typedef struct {
}
SMetricMeta
;
typedef
struct
SMeterMeta
{
char
tableId
[
TSDB_TABLE_ID_LEN
];
// note: This field must be at the front
int32_t
contLen
;
uint8_t
numOfTags
:
6
;
uint8_t
precision
:
2
;
uint8_t
tableType
:
4
;
uint8_t
index
:
4
;
// used locally
int16_t
numOfColumns
;
int16_t
rowSize
;
// used locally, calculated in client
int16_t
sversion
;
SVPeerDesc
vpeerDesc
[
TSDB_VNODES_SUPPORT
];
int32_t
sid
;
int32_t
vgid
;
uint64_t
uid
;
SSchema
schema
[];
}
SMeterMeta
;
typedef
struct
SMultiMeterMeta
{
char
meterId
[
TSDB_TABLE_ID_LEN
];
// note: This field must be at the front
SMeterMeta
meta
;
int32_t
numOfTables
;
int32_t
contLen
;
SMeterMeta
metas
[];
}
SMultiMeterMeta
;
typedef
struct
{
...
...
src/mnode/inc/mgmtChildTable.h
浏览文件 @
03da5549
...
...
@@ -26,14 +26,18 @@ extern "C" {
#include "mnode.h"
int32_t
mgmtInitChildTables
();
void
mgmtCleanUpChildTables
();
int32_t
mgmtCreateChildTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
);
int32_t
mgmtDropChildTable
(
SDbObj
*
pDb
,
SChildTableObj
*
pTable
);
int32_t
mgmtAlterChildTable
(
SDbObj
*
pDb
,
SAlterTableMsg
*
pAlter
);
int32_t
mgmtModifyChildTableTagValueByName
(
SChildTableObj
*
pTable
,
char
*
tagName
,
char
*
nContent
);
SChildTableObj
*
mgmtGetChildTable
(
char
*
tableId
);
int8_t
*
mgmtBuildCreateChildTableMsg
(
SChildTableObj
*
pTable
,
SVgObj
*
pVgroup
);
int32_t
mgmtInitChildTables
();
void
mgmtCleanUpChildTables
();
void
*
mgmtGetChildTable
(
char
*
tableId
);
int32_t
mgmtCreateChildTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
);
int32_t
mgmtDropChildTable
(
SDbObj
*
pDb
,
SChildTableObj
*
pTable
);
int32_t
mgmtAlterChildTable
(
SDbObj
*
pDb
,
SAlterTableMsg
*
pAlter
);
int32_t
mgmtModifyChildTableTagValueByName
(
SChildTableObj
*
pTable
,
char
*
tagName
,
char
*
nContent
);
int8_t
*
mgmtBuildCreateChildTableMsg
(
SChildTableObj
*
pTable
,
SVgObj
*
pVgroup
);
int32_t
mgmtGetChildTableMeta
(
SDbObj
*
pDb
,
SChildTableObj
*
pTable
,
SMeterMeta
*
pMeta
,
bool
usePublicIp
);
#ifdef __cplusplus
}
...
...
src/mnode/inc/mgmtNormalTable.h
浏览文件 @
03da5549
...
...
@@ -23,15 +23,19 @@ extern "C" {
#include <stdint.h>
#include <stdbool.h>
#include "mnode.h"
int32_t
mgmtInitNormalTables
();
void
mgmtCleanUpNormalTables
();
int32_t
mgmtCreateNormalTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
);
int32_t
mgmtDropNormalTable
(
SDbObj
*
pDb
,
SNormalTableObj
*
pTable
);
int32_t
mgmtAddNormalTableColumn
(
SNormalTableObj
*
pTable
,
SSchema
schema
[],
int32_t
ncols
);
int32_t
mgmtDropNormalTableColumnByName
(
SNormalTableObj
*
pTable
,
char
*
colName
);
SNormalTableObj
*
mgmtGetNormalTable
(
char
*
tableId
);
int8_t
*
mgmtBuildCreateNormalTableMsg
(
SNormalTableObj
*
pTable
);
int32_t
mgmtInitNormalTables
();
void
mgmtCleanUpNormalTables
();
void
*
mgmtGetNormalTable
(
char
*
tableId
);
int32_t
mgmtCreateNormalTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
);
int32_t
mgmtDropNormalTable
(
SDbObj
*
pDb
,
SNormalTableObj
*
pTable
);
int32_t
mgmtAddNormalTableColumn
(
SNormalTableObj
*
pTable
,
SSchema
schema
[],
int32_t
ncols
);
int32_t
mgmtDropNormalTableColumnByName
(
SNormalTableObj
*
pTable
,
char
*
colName
);
int8_t
*
mgmtBuildCreateNormalTableMsg
(
SNormalTableObj
*
pTable
);
int32_t
mgmtGetNormalTableMeta
(
SDbObj
*
pDb
,
SNormalTableObj
*
pTable
,
SMeterMeta
*
pMeta
,
bool
usePublicIp
);
#ifdef __cplusplus
}
...
...
src/mnode/inc/mgmtStreamTable.h
浏览文件 @
03da5549
...
...
@@ -24,13 +24,17 @@ extern "C" {
#include <stdbool.h>
#include "mnode.h"
int32_t
mgmtInitStreamTables
();
void
mgmtCleanUpStreamTables
();
int32_t
mgmtCreateStreamTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
);
int32_t
mgmtDropStreamTable
(
SDbObj
*
pDb
,
SStreamTableObj
*
pTable
);
int32_t
mgmtAlterStreamTable
(
SDbObj
*
pDb
,
SAlterTableMsg
*
pAlter
);
SStreamTableObj
*
mgmtGetStreamTable
(
char
*
tableId
);
int8_t
*
mgmtBuildCreateStreamTableMsg
(
SStreamTableObj
*
pTable
,
SVgObj
*
pVgroup
);
int32_t
mgmtInitStreamTables
();
void
mgmtCleanUpStreamTables
();
void
*
mgmtGetStreamTable
(
char
*
tableId
);
int32_t
mgmtCreateStreamTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
);
int32_t
mgmtDropStreamTable
(
SDbObj
*
pDb
,
SStreamTableObj
*
pTable
);
int32_t
mgmtAlterStreamTable
(
SDbObj
*
pDb
,
SAlterTableMsg
*
pAlter
);
int8_t
*
mgmtBuildCreateStreamTableMsg
(
SStreamTableObj
*
pTable
,
SVgObj
*
pVgroup
);
int32_t
mgmtGetStreamTableMeta
(
SDbObj
*
pDb
,
SStreamTableObj
*
pTable
,
SMeterMeta
*
pMeta
,
bool
usePublicIp
);
#ifdef __cplusplus
}
...
...
src/mnode/inc/mgmtSuperTable.h
浏览文件 @
03da5549
...
...
@@ -26,18 +26,26 @@ extern "C" {
#include "taosdef.h"
#include "mnode.h"
int32_t
mgmtInitSuperTables
();
void
mgmtCleanUpSuperTables
();
int32_t
mgmtCreateSuperTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
);
int32_t
mgmtDropSuperTable
(
SDbObj
*
pDb
,
SSuperTableObj
*
pTable
);
SSuperTableObj
*
mgmtGetSuperTable
(
char
*
tableId
);
int32_t
mgmtFindSuperTableTagIndex
(
SSuperTableObj
*
pTable
,
const
char
*
tagName
);
int32_t
mgmtAddSuperTableTag
(
SSuperTableObj
*
pTable
,
SSchema
schema
[],
int32_t
ntags
);
int32_t
mgmtDropSuperTableTag
(
SSuperTableObj
*
pTable
,
char
*
tagName
);
int32_t
mgmtModifySuperTableTagNameByName
(
SSuperTableObj
*
pTable
,
char
*
oldTagName
,
char
*
newTagName
);
int32_t
mgmtAddSuperTableColumn
(
SSuperTableObj
*
pTable
,
SSchema
schema
[],
int32_t
ncols
);
int32_t
mgmtDropSuperTableColumnByName
(
SSuperTableObj
*
pTable
,
char
*
colName
);
int32_t
mgmtGetTagsLength
(
SSuperTableObj
*
pSuperTable
,
int32_t
col
);
int32_t
mgmtInitSuperTables
();
void
mgmtCleanUpSuperTables
();
void
*
mgmtGetSuperTable
(
char
*
tableId
);
int32_t
mgmtGetShowSuperTableMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
int32_t
mgmtRetrieveShowSuperTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
int32_t
mgmtCreateSuperTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
);
int32_t
mgmtDropSuperTable
(
SDbObj
*
pDb
,
SSuperTableObj
*
pTable
);
int32_t
mgmtAddSuperTableTag
(
SSuperTableObj
*
pTable
,
SSchema
schema
[],
int32_t
ntags
);
int32_t
mgmtDropSuperTableTag
(
SSuperTableObj
*
pTable
,
char
*
tagName
);
int32_t
mgmtModifySuperTableTagNameByName
(
SSuperTableObj
*
pTable
,
char
*
oldTagName
,
char
*
newTagName
);
int32_t
mgmtAddSuperTableColumn
(
SSuperTableObj
*
pTable
,
SSchema
schema
[],
int32_t
ncols
);
int32_t
mgmtDropSuperTableColumnByName
(
SSuperTableObj
*
pTable
,
char
*
colName
);
int32_t
mgmtGetSuperTableMeta
(
SDbObj
*
pDb
,
SSuperTableObj
*
pTable
,
SMeterMeta
*
pMeta
,
bool
usePublicIp
);
int32_t
mgmtFindSuperTableTagIndex
(
SSuperTableObj
*
pTable
,
const
char
*
tagName
);
int32_t
mgmtSetSchemaFromSuperTable
(
SSchema
*
pSchema
,
SSuperTableObj
*
pTable
);
int32_t
mgmtGetTagsLength
(
SSuperTableObj
*
pSuperTable
,
int32_t
col
);
#ifdef __cplusplus
}
...
...
src/mnode/inc/mgmtTable.h
浏览文件 @
03da5549
...
...
@@ -28,20 +28,18 @@ extern "C" {
int32_t
mgmtInitTables
();
STableInfo
*
mgmtGetTable
(
char
*
tableId
);
STableInfo
*
mgmtGetTableByPos
(
uint32_t
dnodeIp
,
int32_t
vnode
,
int32_t
sid
);
int32_t
mgmtGetTableMeta
(
SDbObj
*
pDb
,
STableInfo
*
pTable
,
SMeterMeta
*
pMeta
,
bool
usePublicIp
);
int32_t
mgmtRetrieveMetricMeta
(
void
*
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
,
void
*
pConn
);
int32_t
mgmtRetrieveTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
int32_t
mgmtGet
Show
TableMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
int32_t
mgmtRetrieve
Show
Tables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
void
mgmtCleanUpMeters
();
void
mgmtAddTableIntoSuperTable
(
SSuperTableObj
*
pStable
);
void
mgmtRemoveTableFromSuperTable
(
SSuperTableObj
*
pStable
);
int32_t
mgmtGetSuperTableMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
int32_t
mgmtRetrieveSuperTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
#ifdef __cplusplus
...
...
src/mnode/src/mgmtChildTable.c
浏览文件 @
03da5549
...
...
@@ -340,8 +340,8 @@ int32_t mgmtDropChildTable(SDbObj *pDb, SChildTableObj *pTable) {
return
0
;
}
SChildTableObj
*
mgmtGetChildTable
(
char
*
tableId
)
{
return
(
SChildTableObj
*
)
sdbGetRow
(
tsChildTableSdb
,
tableId
);
void
*
mgmtGetChildTable
(
char
*
tableId
)
{
return
sdbGetRow
(
tsChildTableSdb
,
tableId
);
}
int32_t
mgmtModifyChildTableTagValueByName
(
SChildTableObj
*
pTable
,
char
*
tagName
,
char
*
nContent
)
{
...
...
@@ -392,3 +392,30 @@ int32_t mgmtModifyChildTableTagValueByName(SChildTableObj *pTable, char *tagName
return
0
;
}
int32_t
mgmtGetChildTableMeta
(
SDbObj
*
pDb
,
SChildTableObj
*
pTable
,
SMeterMeta
*
pMeta
,
bool
usePublicIp
)
{
pMeta
->
uid
=
htobe64
(
pTable
->
uid
);
pMeta
->
sid
=
htonl
(
pTable
->
sid
);
pMeta
->
vgid
=
htonl
(
pTable
->
vgId
);
pMeta
->
sversion
=
htons
(
pTable
->
superTable
->
sversion
);
pMeta
->
precision
=
pDb
->
cfg
.
precision
;
pMeta
->
numOfTags
=
pTable
->
superTable
->
numOfTags
;
pMeta
->
numOfColumns
=
htons
(
pTable
->
superTable
->
numOfColumns
);
pMeta
->
tableType
=
pTable
->
type
;
pMeta
->
contLen
=
sizeof
(
SMeterMeta
)
+
mgmtSetSchemaFromSuperTable
(
pMeta
->
schema
,
pTable
->
superTable
);
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pTable
->
vgId
);
if
(
pVgroup
==
NULL
)
{
return
TSDB_CODE_INVALID_TABLE
;
}
for
(
int32_t
i
=
0
;
i
<
TSDB_VNODES_SUPPORT
;
++
i
)
{
if
(
usePublicIp
)
{
pMeta
->
vpeerDesc
[
i
].
ip
=
pVgroup
->
vnodeGid
[
i
].
publicIp
;
pMeta
->
vpeerDesc
[
i
].
vnode
=
htonl
(
pVgroup
->
vnodeGid
[
i
].
vnode
);
}
else
{
pMeta
->
vpeerDesc
[
i
].
ip
=
pVgroup
->
vnodeGid
[
i
].
ip
;
pMeta
->
vpeerDesc
[
i
].
vnode
=
htonl
(
pVgroup
->
vnodeGid
[
i
].
vnode
);
}
}
return
TSDB_CODE_SUCCESS
;
}
src/mnode/src/mgmtNormalTable.c
浏览文件 @
03da5549
...
...
@@ -357,8 +357,8 @@ int32_t mgmtDropNormalTable(SDbObj *pDb, SNormalTableObj *pTable) {
return
0
;
}
SNormalTableObj
*
mgmtGetNormalTable
(
char
*
tableId
)
{
return
(
SNormalTableObj
*
)
sdbGetRow
(
tsNormalTableSdb
,
tableId
);
void
*
mgmtGetNormalTable
(
char
*
tableId
)
{
return
sdbGetRow
(
tsNormalTableSdb
,
tableId
);
}
static
int32_t
mgmtFindNormalTableColumnIndex
(
SNormalTableObj
*
pTable
,
char
*
colName
)
{
...
...
@@ -442,3 +442,45 @@ int32_t mgmtDropNormalTableColumnByName(SNormalTableObj *pTable, char *colName)
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mgmtSetSchemaFromNormalTable
(
SSchema
*
pSchema
,
SNormalTableObj
*
pTable
)
{
int32_t
numOfCols
=
pTable
->
numOfColumns
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
strcpy
(
pSchema
->
name
,
pTable
->
schema
[
i
].
name
);
pSchema
->
type
=
pTable
->
schema
[
i
].
type
;
pSchema
->
bytes
=
htons
(
pTable
->
schema
[
i
].
bytes
);
pSchema
->
colId
=
htons
(
pTable
->
schema
[
i
].
colId
);
pSchema
++
;
}
return
numOfCols
*
sizeof
(
SSchema
);
}
int32_t
mgmtGetNormalTableMeta
(
SDbObj
*
pDb
,
SNormalTableObj
*
pTable
,
SMeterMeta
*
pMeta
,
bool
usePublicIp
)
{
pMeta
->
uid
=
htobe64
(
pTable
->
uid
);
pMeta
->
sid
=
htonl
(
pTable
->
sid
);
pMeta
->
vgid
=
htonl
(
pTable
->
vgId
);
pMeta
->
sversion
=
htons
(
pTable
->
sversion
);
pMeta
->
precision
=
pDb
->
cfg
.
precision
;
pMeta
->
numOfTags
=
0
;
pMeta
->
numOfColumns
=
htons
(
pTable
->
numOfColumns
);
pMeta
->
tableType
=
pTable
->
type
;
pMeta
->
contLen
=
sizeof
(
SMeterMeta
)
+
mgmtSetSchemaFromNormalTable
(
pMeta
->
schema
,
pTable
);
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pTable
->
vgId
);
if
(
pVgroup
==
NULL
)
{
return
TSDB_CODE_INVALID_TABLE
;
}
for
(
int32_t
i
=
0
;
i
<
TSDB_VNODES_SUPPORT
;
++
i
)
{
if
(
usePublicIp
)
{
pMeta
->
vpeerDesc
[
i
].
ip
=
pVgroup
->
vnodeGid
[
i
].
publicIp
;
pMeta
->
vpeerDesc
[
i
].
vnode
=
htonl
(
pVgroup
->
vnodeGid
[
i
].
vnode
);
}
else
{
pMeta
->
vpeerDesc
[
i
].
ip
=
pVgroup
->
vnodeGid
[
i
].
ip
;
pMeta
->
vpeerDesc
[
i
].
vnode
=
htonl
(
pVgroup
->
vnodeGid
[
i
].
vnode
);
}
}
return
TSDB_CODE_SUCCESS
;
}
src/mnode/src/mgmtShell.c
浏览文件 @
03da5549
此差异已折叠。
点击以展开。
src/mnode/src/mgmtStreamTable.c
浏览文件 @
03da5549
...
...
@@ -379,6 +379,47 @@ int32_t mgmtDropStreamTable(SDbObj *pDb, SStreamTableObj *pTable) {
return
0
;
}
SStreamTableObj
*
mgmtGetStreamTable
(
char
*
tableId
)
{
return
(
SStreamTableObj
*
)
sdbGetRow
(
tsStreamTableSdb
,
tableId
);
}
\ No newline at end of file
void
*
mgmtGetStreamTable
(
char
*
tableId
)
{
return
sdbGetRow
(
tsStreamTableSdb
,
tableId
);
}
static
int32_t
mgmtSetSchemaFromStreamTable
(
SSchema
*
pSchema
,
SStreamTableObj
*
pTable
)
{
int32_t
numOfCols
=
pTable
->
numOfColumns
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
strcpy
(
pSchema
->
name
,
pTable
->
schema
[
i
].
name
);
pSchema
->
type
=
pTable
->
schema
[
i
].
type
;
pSchema
->
bytes
=
htons
(
pTable
->
schema
[
i
].
bytes
);
pSchema
->
colId
=
htons
(
pTable
->
schema
[
i
].
colId
);
pSchema
++
;
}
return
numOfCols
*
sizeof
(
SSchema
);
}
int32_t
mgmtGetStreamTableMeta
(
SDbObj
*
pDb
,
SStreamTableObj
*
pTable
,
SMeterMeta
*
pMeta
,
bool
usePublicIp
)
{
pMeta
->
uid
=
htobe64
(
pTable
->
uid
);
pMeta
->
sid
=
htonl
(
pTable
->
sid
);
pMeta
->
vgid
=
htonl
(
pTable
->
vgId
);
pMeta
->
sversion
=
htons
(
pTable
->
sversion
);
pMeta
->
precision
=
pDb
->
cfg
.
precision
;
pMeta
->
numOfTags
=
0
;
pMeta
->
numOfColumns
=
htons
(
pTable
->
numOfColumns
);
pMeta
->
tableType
=
pTable
->
type
;
pMeta
->
contLen
=
sizeof
(
SMeterMeta
)
+
mgmtSetSchemaFromStreamTable
(
pMeta
->
schema
,
pTable
);
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pTable
->
vgId
);
if
(
pVgroup
==
NULL
)
{
return
TSDB_CODE_INVALID_TABLE
;
}
for
(
int32_t
i
=
0
;
i
<
TSDB_VNODES_SUPPORT
;
++
i
)
{
if
(
usePublicIp
)
{
pMeta
->
vpeerDesc
[
i
].
ip
=
pVgroup
->
vnodeGid
[
i
].
publicIp
;
pMeta
->
vpeerDesc
[
i
].
vnode
=
htonl
(
pVgroup
->
vnodeGid
[
i
].
vnode
);
}
else
{
pMeta
->
vpeerDesc
[
i
].
ip
=
pVgroup
->
vnodeGid
[
i
].
ip
;
pMeta
->
vpeerDesc
[
i
].
vnode
=
htonl
(
pVgroup
->
vnodeGid
[
i
].
vnode
);
}
}
return
TSDB_CODE_SUCCESS
;
}
src/mnode/src/mgmtSuperTable.c
浏览文件 @
03da5549
...
...
@@ -235,8 +235,8 @@ int32_t mgmtDropSuperTable(SDbObj *pDb, SSuperTableObj *pSuperTable) {
return
sdbDeleteRow
(
tsSuperTableSdb
,
pSuperTable
);
}
SSuperTableObj
*
mgmtGetSuperTable
(
char
*
tableId
)
{
return
(
SSuperTableObj
*
)
sdbGetRow
(
tsSuperTableSdb
,
tableId
);
void
*
mgmtGetSuperTable
(
char
*
tableId
)
{
return
sdbGetRow
(
tsSuperTableSdb
,
tableId
);
}
int32_t
mgmtFindSuperTableTagIndex
(
SSuperTableObj
*
pStable
,
const
char
*
tagName
)
{
...
...
@@ -457,7 +457,7 @@ int32_t mgmtDropSuperTableColumnByName(SSuperTableObj *pStable, char *colName) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
mgmtGetSuperTableMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
mgmtGetS
howS
uperTableMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
// int32_t cols = 0;
//
// SDbObj *pDb = NULL;
...
...
@@ -509,7 +509,7 @@ int32_t mgmtGetSuperTableMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
return
0
;
}
int32_t
mgmtRetrieveSuperTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
)
{
int32_t
mgmtRetrieveS
howS
uperTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
)
{
int32_t
numOfRows
=
0
;
// char * pWrite;
// int32_t cols = 0;
...
...
@@ -602,3 +602,45 @@ int32_t mgmtGetTagsLength(SSuperTableObj* pSuperTable, int32_t col) { // length
return
len
;
}
int32_t
mgmtSetSchemaFromSuperTable
(
SSchema
*
pSchema
,
SSuperTableObj
*
pTable
)
{
int32_t
numOfCols
=
pTable
->
numOfColumns
+
pTable
->
numOfTags
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
strcpy
(
pSchema
->
name
,
pTable
->
schema
[
i
].
name
);
pSchema
->
type
=
pTable
->
schema
[
i
].
type
;
pSchema
->
bytes
=
htons
(
pTable
->
schema
[
i
].
bytes
);
pSchema
->
colId
=
htons
(
pTable
->
schema
[
i
].
colId
);
pSchema
++
;
}
return
(
pTable
->
numOfColumns
+
pTable
->
numOfTags
)
*
sizeof
(
SSchema
);
}
int32_t
mgmtGetSuperTableMeta
(
SDbObj
*
pDb
,
SSuperTableObj
*
pTable
,
SMeterMeta
*
pMeta
,
bool
usePublicIp
)
{
pMeta
->
uid
=
htobe64
(
pTable
->
uid
);
pMeta
->
sid
=
htonl
(
pTable
->
sid
);
pMeta
->
vgid
=
htonl
(
pTable
->
vgId
);
pMeta
->
sversion
=
htons
(
pTable
->
sversion
);
pMeta
->
precision
=
pDb
->
cfg
.
precision
;
pMeta
->
numOfTags
=
pTable
->
numOfTags
;
pMeta
->
numOfColumns
=
htons
(
pTable
->
numOfColumns
);
pMeta
->
tableType
=
pTable
->
type
;
pMeta
->
contLen
=
sizeof
(
SMeterMeta
)
+
mgmtSetSchemaFromSuperTable
(
pMeta
->
schema
,
pTable
);
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pTable
->
vgId
);
if
(
pVgroup
==
NULL
)
{
return
TSDB_CODE_INVALID_TABLE
;
}
for
(
int32_t
i
=
0
;
i
<
TSDB_VNODES_SUPPORT
;
++
i
)
{
if
(
usePublicIp
)
{
pMeta
->
vpeerDesc
[
i
].
ip
=
pVgroup
->
vnodeGid
[
i
].
publicIp
;
pMeta
->
vpeerDesc
[
i
].
vnode
=
htonl
(
pVgroup
->
vnodeGid
[
i
].
vnode
);
}
else
{
pMeta
->
vpeerDesc
[
i
].
ip
=
pVgroup
->
vnodeGid
[
i
].
ip
;
pMeta
->
vpeerDesc
[
i
].
vnode
=
htonl
(
pVgroup
->
vnodeGid
[
i
].
vnode
);
}
}
return
TSDB_CODE_SUCCESS
;
}
src/mnode/src/mgmtTable.c
浏览文件 @
03da5549
...
...
@@ -99,6 +99,24 @@ STableInfo* mgmtGetTableByPos(uint32_t dnodeIp, int32_t vnode, int32_t sid) {
return
NULL
;
}
int32_t
mgmtGetTableMeta
(
SDbObj
*
pDb
,
STableInfo
*
pTable
,
SMeterMeta
*
pMeta
,
bool
usePublicIp
)
{
if
(
pTable
->
type
==
TSDB_TABLE_TYPE_CHILD_TABLE
)
{
mgmtGetChildTableMeta
(
pDb
,
(
SChildTableObj
*
)
pTable
,
pMeta
,
usePublicIp
);
}
else
if
(
pTable
->
type
==
TSDB_TABLE_TYPE_STREAM_TABLE
)
{
mgmtGetStreamTableMeta
(
pDb
,
(
SStreamTableObj
*
)
pTable
,
pMeta
,
usePublicIp
);
}
else
if
(
pTable
->
type
==
TSDB_TABLE_TYPE_NORMAL_TABLE
)
{
mgmtGetNormalTableMeta
(
pDb
,
(
SNormalTableObj
*
)
pTable
,
pMeta
,
usePublicIp
);
}
else
if
(
pTable
->
type
==
TSDB_TABLE_TYPE_SUPER_TABLE
)
{
mgmtGetSuperTableMeta
(
pDb
,
(
SSuperTableObj
*
)
pTable
,
pMeta
,
usePublicIp
);
}
else
{
mTrace
(
"%s, uid:%"
PRIu64
" table meta retrieve failed, invalid type"
,
pTable
->
tableId
,
pTable
->
uid
);
return
TSDB_CODE_INVALID_TABLE
;
}
mTrace
(
"%s, uid:%"
PRIu64
" table meta is retrieved"
,
pTable
->
tableId
,
pTable
->
uid
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
mgmtCreateTable
(
SDbObj
*
pDb
,
SCreateTableMsg
*
pCreate
)
{
STableInfo
*
pTable
=
mgmtGetTable
(
pCreate
->
tableId
);
if
(
pTable
!=
NULL
)
{
...
...
@@ -229,7 +247,7 @@ void mgmtCleanUpMeters() {
mgmtCleanUpSuperTables
();
}
int32_t
mgmtGetTableMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
int32_t
mgmtGet
Show
TableMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
// int32_t cols = 0;
//
// SDbObj *pDb = NULL;
...
...
@@ -292,7 +310,7 @@ static void mgmtVacuumResult(char *data, int32_t numOfCols, int32_t rows, int32_
}
}
int32_t
mgmtRetrieveTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
)
{
int32_t
mgmtRetrieve
Show
Tables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
)
{
int32_t
numOfRows
=
0
;
// int32_t numOfRead = 0;
// int32_t cols = 0;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录