Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
585942ce
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看板
未验证
提交
585942ce
编写于
4月 14, 2022
作者:
L
Liu Jicong
提交者:
GitHub
4月 14, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #11506 from taosdata/feature/check
enh(cluster): adjust show message handle
上级
a908d3f1
f130161f
变更
37
隐藏空白更改
内联
并排
Showing
37 changed file
with
443 addition
and
1003 deletion
+443
-1003
include/common/tmsg.h
include/common/tmsg.h
+17
-16
include/dnode/mnode/mnode.h
include/dnode/mnode/mnode.h
+4
-19
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+18
-17
include/util/tdef.h
include/util/tdef.h
+20
-3
source/common/src/tmsg.c
source/common/src/tmsg.c
+0
-2
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
+0
-1
source/dnode/mgmt/test/sut/inc/sut.h
source/dnode/mgmt/test/sut/inc/sut.h
+30
-62
source/dnode/mgmt/test/sut/src/sut.cpp
source/dnode/mgmt/test/sut/src/sut.cpp
+29
-103
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+1
-1
source/dnode/mnode/impl/inc/mndInfoSchema.h
source/dnode/mnode/impl/inc/mndInfoSchema.h
+7
-7
source/dnode/mnode/impl/inc/mndShow.h
source/dnode/mnode/impl/inc/mndShow.h
+0
-2
source/dnode/mnode/impl/src/mndAcct.c
source/dnode/mnode/impl/src/mndAcct.c
+45
-45
source/dnode/mnode/impl/src/mndAuth.c
source/dnode/mnode/impl/src/mndAuth.c
+21
-16
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+2
-37
source/dnode/mnode/impl/src/mndInfoSchema.c
source/dnode/mnode/impl/src/mndInfoSchema.c
+93
-30
source/dnode/mnode/impl/src/mndProfile.c
source/dnode/mnode/impl/src/mndProfile.c
+0
-197
source/dnode/mnode/impl/src/mndShow.c
source/dnode/mnode/impl/src/mndShow.c
+21
-88
source/dnode/mnode/impl/src/mndSma.c
source/dnode/mnode/impl/src/mndSma.c
+0
-40
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+2
-46
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+2
-47
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+0
-64
source/dnode/mnode/impl/test/CMakeLists.txt
source/dnode/mnode/impl/test/CMakeLists.txt
+5
-5
source/dnode/mnode/impl/test/acct/CMakeLists.txt
source/dnode/mnode/impl/test/acct/CMakeLists.txt
+5
-5
source/dnode/mnode/impl/test/acct/acct.cpp
source/dnode/mnode/impl/test/acct/acct.cpp
+0
-14
source/dnode/mnode/impl/test/bnode/CMakeLists.txt
source/dnode/mnode/impl/test/bnode/CMakeLists.txt
+5
-5
source/dnode/mnode/impl/test/bnode/mbnode.cpp
source/dnode/mnode/impl/test/bnode/mbnode.cpp
+5
-32
source/dnode/mnode/impl/test/db/CMakeLists.txt
source/dnode/mnode/impl/test/db/CMakeLists.txt
+3
-3
source/dnode/mnode/impl/test/dnode/CMakeLists.txt
source/dnode/mnode/impl/test/dnode/CMakeLists.txt
+3
-3
source/dnode/mnode/impl/test/dnode/mdnode.cpp
source/dnode/mnode/impl/test/dnode/mdnode.cpp
+0
-0
source/dnode/mnode/impl/test/stb/CMakeLists.txt
source/dnode/mnode/impl/test/stb/CMakeLists.txt
+3
-3
source/dnode/mnode/impl/test/topic/topic.cpp
source/dnode/mnode/impl/test/topic/topic.cpp
+4
-4
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+32
-14
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+32
-10
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+14
-15
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+0
-12
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+14
-29
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+6
-6
未找到文件。
include/common/tmsg.h
浏览文件 @
585942ce
...
...
@@ -86,30 +86,31 @@ enum {
typedef
enum
_mgmt_table
{
TSDB_MGMT_TABLE_START
,
TSDB_MGMT_TABLE_ACCT
,
TSDB_MGMT_TABLE_USER
,
TSDB_MGMT_TABLE_DB
,
TSDB_MGMT_TABLE_TABLE
,
TSDB_MGMT_TABLE_DNODE
,
TSDB_MGMT_TABLE_MNODE
,
TSDB_MGMT_TABLE_MODULE
,
TSDB_MGMT_TABLE_QNODE
,
TSDB_MGMT_TABLE_SNODE
,
TSDB_MGMT_TABLE_BNODE
,
TSDB_MGMT_TABLE_VGROUP
,
TSDB_MGMT_TABLE_CLUSTER
,
TSDB_MGMT_TABLE_DB
,
TSDB_MGMT_TABLE_FUNC
,
TSDB_MGMT_TABLE_INDEX
,
TSDB_MGMT_TABLE_STB
,
TSDB_MGMT_TABLE_MODULE
,
TSDB_MGMT_TABLE_QUERIES
,
TSDB_MGMT_TABLE_STREAMS
,
TSDB_MGMT_TABLE_VARIABLES
,
TSDB_MGMT_TABLE_CONNS
,
TSDB_MGMT_TABLE_TRANS
,
TSDB_MGMT_TABLE_TABLE
,
TSDB_MGMT_TABLE_USER
,
TSDB_MGMT_TABLE_GRANTS
,
TSDB_MGMT_TABLE_VGROUP
,
TSDB_MGMT_TABLE_TOPICS
,
TSDB_MGMT_TABLE_CONSUMERS
,
TSDB_MGMT_TABLE_SUBSCRIBES
,
TSDB_MGMT_TABLE_TRANS
,
TSDB_MGMT_TABLE_SMAS
,
TSDB_MGMT_TABLE_CONFIGS
,
TSDB_MGMT_TABLE_CONNS
,
TSDB_MGMT_TABLE_QUERIES
,
TSDB_MGMT_TABLE_VNODES
,
TSDB_MGMT_TABLE_CLUSTER
,
TSDB_MGMT_TABLE_STREAMTABLES
,
TSDB_MGMT_TABLE_TP
,
TSDB_MGMT_TABLE_FUNC
,
TSDB_MGMT_TABLE_INDEX
,
TSDB_MGMT_TABLE_MAX
,
}
EShowType
;
...
...
@@ -363,7 +364,7 @@ typedef struct {
int32_t
maxTimeSeries
;
int32_t
maxStreams
;
int32_t
accessState
;
// Configured only by command
int64_t
maxStorage
;
// In unit of GB
int64_t
maxStorage
;
}
SCreateAcctReq
,
SAlterAcctReq
;
int32_t
tSerializeSCreateAcctReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateAcctReq
*
pReq
);
...
...
include/dnode/mnode/mnode.h
浏览文件 @
585942ce
...
...
@@ -74,26 +74,12 @@ void mndStop(SMnode *pMnode);
* @brief Get mnode monitor info.
*
* @param pMnode The mnode object.
* @param pCluster
Info
* @param pVgroup
Info
* @param pGrant
Info
* @param pCluster
* @param pVgroup
* @param pGrant
* @return int32_t 0 for success, -1 for failure.
*/
int32_t
mndGetMonitorInfo
(
SMnode
*
pMnode
,
SMonClusterInfo
*
pClusterInfo
,
SMonVgroupInfo
*
pVgroupInfo
,
SMonGrantInfo
*
pGrantInfo
);
/**
* @brief Get user authentication info.
*
* @param pMnode The mnode object.
* @param user
* @param spi
* @param encrypt
* @param secret
* @param ckey
* @return int32_t 0 for success, -1 for failure.
*/
int32_t
mndRetriveAuth
(
SMnode
*
pMnode
,
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
);
int32_t
mndGetMonitorInfo
(
SMnode
*
pMnode
,
SMonClusterInfo
*
pCluster
,
SMonVgroupInfo
*
pVgroup
,
SMonGrantInfo
*
pGrant
);
/**
* @brief Process the read, write, sync request.
...
...
@@ -105,7 +91,6 @@ int32_t mndProcessMsg(SNodeMsg *pMsg);
/**
* @brief Generate machine code
*
*/
void
mndGenerateMachineCode
();
...
...
include/libs/nodes/nodes.h
浏览文件 @
585942ce
...
...
@@ -52,7 +52,8 @@ extern "C" {
for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); (NULL != cell ? (node = &(cell->pNode), true) : (node = NULL, false)); cell = cell->pNext)
typedef
enum
ENodeType
{
// Syntax nodes are used in parser and planner module, and some are also used in executor module, such as COLUMN, VALUE, OPERATOR, FUNCTION and so on.
// Syntax nodes are used in parser and planner module, and some are also used in executor module, such as COLUMN,
// VALUE, OPERATOR, FUNCTION and so on.
QUERY_NODE_COLUMN
=
1
,
QUERY_NODE_VALUE
,
QUERY_NODE_OPERATOR
,
...
...
@@ -69,7 +70,7 @@ typedef enum ENodeType {
QUERY_NODE_INTERVAL_WINDOW
,
QUERY_NODE_NODE_LIST
,
QUERY_NODE_FILL
,
QUERY_NODE_RAW_EXPR
,
// Only be used in parser module.
QUERY_NODE_RAW_EXPR
,
// Only be used in parser module.
QUERY_NODE_TARGET
,
QUERY_NODE_DATABLOCK_DESC
,
QUERY_NODE_SLOT_DESC
,
...
...
@@ -126,30 +127,30 @@ typedef enum ENodeType {
QUERY_NODE_REDISTRIBUTE_VGROUP_STMT
,
QUERY_NODE_SPLIT_VGROUP_STMT
,
QUERY_NODE_SYNCDB_STMT
,
QUERY_NODE_SHOW_DATABASES_STMT
,
QUERY_NODE_SHOW_TABLES_STMT
,
QUERY_NODE_SHOW_STABLES_STMT
,
QUERY_NODE_SHOW_USERS_STMT
,
QUERY_NODE_SHOW_DNODES_STMT
,
QUERY_NODE_SHOW_VGROUPS_STMT
,
QUERY_NODE_SHOW_MNODES_STMT
,
QUERY_NODE_SHOW_MODULES_STMT
,
QUERY_NODE_SHOW_QNODES_STMT
,
QUERY_NODE_SHOW_SNODES_STMT
,
QUERY_NODE_SHOW_BNODES_STMT
,
QUERY_NODE_SHOW_DATABASES_STMT
,
QUERY_NODE_SHOW_FUNCTIONS_STMT
,
QUERY_NODE_SHOW_INDEXES_STMT
,
QUERY_NODE_SHOW_STABLES_STMT
,
QUERY_NODE_SHOW_STREAMS_STMT
,
QUERY_NODE_SHOW_
APP
S_STMT
,
QUERY_NODE_SHOW_
CONNECTION
S_STMT
,
QUERY_NODE_SHOW_
TABLE
S_STMT
,
QUERY_NODE_SHOW_
USER
S_STMT
,
QUERY_NODE_SHOW_LICENCE_STMT
,
QUERY_NODE_SHOW_CREATE_DATABASE_STMT
,
QUERY_NODE_SHOW_CREATE_TABLE_STMT
,
QUERY_NODE_SHOW_CREATE_STABLE_STMT
,
QUERY_NODE_SHOW_QUERIES_STMT
,
QUERY_NODE_SHOW_SCORES_STMT
,
QUERY_NODE_SHOW_VGROUPS_STMT
,
QUERY_NODE_SHOW_TOPICS_STMT
,
QUERY_NODE_SHOW_VARIABLE_STMT
,
QUERY_NODE_SHOW_BNODES_STMT
,
QUERY_NODE_SHOW_SNODES_STMT
,
QUERY_NODE_SHOW_CONSUMERS_STMT
,
QUERY_NODE_SHOW_SUBSCRIBES_STMT
,
QUERY_NODE_SHOW_TRANS_STMT
,
QUERY_NODE_SHOW_SMAS_STMT
,
QUERY_NODE_SHOW_CONFIGS_STMT
,
QUERY_NODE_SHOW_CONNECTIONS_STMT
,
QUERY_NODE_SHOW_QUERIES_STMT
,
QUERY_NODE_SHOW_VNODES_STMT
,
QUERY_NODE_KILL_CONNECTION_STMT
,
QUERY_NODE_KILL_QUERY_STMT
,
...
...
include/util/tdef.h
浏览文件 @
585942ce
...
...
@@ -106,6 +106,7 @@ extern const int32_t TYPE_BYTES[15];
#define TSDB_INS_TABLE_MODULES "modules"
#define TSDB_INS_TABLE_QNODES "qnodes"
#define TSDB_INS_TABLE_BNODES "bnodes"
#define TSDB_INS_TABLE_SNODES "snodes"
#define TSDB_INS_TABLE_CLUSTER "cluster"
#define TSDB_INS_TABLE_USER_DATABASES "user_databases"
#define TSDB_INS_TABLE_USER_FUNCTIONS "user_functions"
...
...
@@ -115,10 +116,17 @@ extern const int32_t TYPE_BYTES[15];
#define TSDB_INS_TABLE_USER_TABLES "user_tables"
#define TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED "user_table_distributed"
#define TSDB_INS_TABLE_USER_USERS "user_users"
#define TSDB_INS_TABLE_VGROUPS "vgroups"
#define TSDB_INS_TABLE_BNODES "bnodes"
#define TSDB_INS_TABLE_SNODES "snodes"
#define TSDB_INS_TABLE_LICENCES "grants"
#define TSDB_INS_TABLE_VGROUPS "vgroups"
#define TSDB_INS_TABLE_TOPICS "topics"
#define TSDB_INS_TABLE_CONSUMERS "consumers"
#define TSDB_INS_TABLE_SUBSCRIBES "subscribes"
#define TSDB_INS_TABLE_TRANS "trans"
#define TSDB_INS_TABLE_SMAS "smas"
#define TSDB_INS_TABLE_CONFIGS "configs"
#define TSDB_INS_TABLE_CONNS "connections"
#define TSDB_INS_TABLE_QUERIES "queries"
#define TSDB_INS_TABLE_VNODES "vnodes"
#define TSDB_INDEX_TYPE_SMA "SMA"
#define TSDB_INDEX_TYPE_FULLTEXT "FULLTEXT"
...
...
@@ -498,6 +506,15 @@ enum {
#define QNODE_HANDLE 1
#define DEFAULT_HANDLE 0
#define TSDB_CONFIG_OPTION_LEN 16
#define TSDB_CONIIG_VALUE_LEN 48
#define TSDB_CONFIG_NUMBER 8
#define QUERY_ID_SIZE 20
#define QUERY_OBJ_ID_SIZE 18
#define SUBQUERY_INFO_SIZE 6
#define QUERY_SAVE_SIZE 20
#define MAX_NUM_STR_SIZE 40
...
...
source/common/src/tmsg.c
浏览文件 @
585942ce
...
...
@@ -2184,7 +2184,6 @@ int32_t tSerializeSRetrieveTableReq(void *buf, int32_t bufLen, SRetrieveTableReq
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
showId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
type
)
<
0
)
return
-
1
;
// if (tEncodeI8(&encoder, pReq->free) < 0) return -1;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
db
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
tb
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
...
...
@@ -2201,7 +2200,6 @@ int32_t tDeserializeSRetrieveTableReq(void *buf, int32_t bufLen, SRetrieveTableR
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
showId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
type
)
<
0
)
return
-
1
;
// if (tDecodeI8(&decoder, &pReq->free) < 0) return -1;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
db
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
tb
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
...
...
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
浏览文件 @
585942ce
...
...
@@ -174,7 +174,6 @@ void mmInitMsgHandle(SMgmtWrapper *pWrapper) {
dmSetMsgHandle
(
pWrapper
,
TDMT_MND_KILL_QUERY
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
dmSetMsgHandle
(
pWrapper
,
TDMT_MND_KILL_CONN
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
dmSetMsgHandle
(
pWrapper
,
TDMT_MND_HEARTBEAT
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
dmSetMsgHandle
(
pWrapper
,
TDMT_MND_SHOW
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
dmSetMsgHandle
(
pWrapper
,
TDMT_MND_SYSTABLE_RETRIEVE
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
dmSetMsgHandle
(
pWrapper
,
TDMT_MND_STATUS
,
mmProcessReadMsg
,
DEFAULT_HANDLE
);
dmSetMsgHandle
(
pWrapper
,
TDMT_MND_KILL_TRANS
,
mmProcessWriteMsg
,
DEFAULT_HANDLE
);
...
...
source/dnode/mgmt/test/sut/inc/sut.h
浏览文件 @
585942ce
...
...
@@ -20,7 +20,6 @@
#include "os.h"
#include "dnode.h"
#include "tmsg.h"
#include "tdataformat.h"
#include "tglobal.h"
#include "tmsg.h"
...
...
@@ -48,92 +47,61 @@ class Testbase {
int32_t
connId
;
public:
void
SendShowMetaReq
(
int8_t
showType
,
const
char
*
db
);
void
SendShowRetrieveReq
();
STableMetaRsp
*
GetShowMeta
();
SRetrieveTableRsp
*
GetRetrieveRsp
();
int32_t
SendShowReq
(
int8_t
showType
,
const
char
*
tb
,
const
char
*
db
);
int32_t
GetShowRows
();
#if 0
int32_t GetMetaNum();
const char* GetMetaTbName();
int32_t
GetMetaColId
(
int32_t
index
);
int8_t
GetMetaType
(
int32_t
index
);
int32_t
GetMetaBytes
(
int32_t
index
);
const
char
*
GetMetaName
(
int32_t
index
);
const
char
*
GetShowName
();
int32_t
GetShowRows
();
int8_t
GetShowInt8
();
int16_t
GetShowInt16
();
int32_t
GetShowInt32
();
int64_t
GetShowInt64
();
int64_t
GetShowTimestamp
();
const
char
*
GetShowBinary
(
int32_t
len
);
int8_t GetMetaType(int32_t col);
int32_t GetMetaBytes(int32_t col);
const char* GetMetaName(int32_t col);
int8_t GetShowInt8(int32_t row, int32_t col);
int16_t GetShowInt16(int32_t row, int32_t col);
int32_t GetShowInt32(int32_t row, int32_t col);
int64_t GetShowInt64(int32_t row, int32_t col);
int64_t GetShowTimestamp(int32_t row, int32_t col);
const char* GetShowBinary(int32_t row, int32_t col);
#endif
private:
int64_t
showId
;
STableMetaRsp
metaRsp
;
SRetrieveTableRsp
*
pRetrieveRsp
;
char
*
pData
;
int32_t
pos
;
SRetrieveMetaTableRsp
*
showRsp
;
};
#if 0
#define CHECK_META(tbName, numOfColumns) \
{ \
EXPECT_EQ(test.GetMetaNum(), numOfColumns); \
EXPECT_STREQ(test.GetMetaTbName(), tbName); \
}
#define CHECK_SCHEMA(colId, type, bytes, colName) \
{ \
EXPECT_EQ(test.GetMetaType(colId), type); \
EXPECT_EQ(test.GetMetaBytes(colId), bytes); \
EXPECT_STREQ(test.GetMetaName(colId), colName); \
}
#define CheckBinary(val, len) \
{ EXPECT_STREQ(test.GetShowBinary(len), val); }
#define CheckBinaryByte(b, len) \
#define CHECK_SCHEMA(col, type, bytes, colName) \
{ \
char* bytes = (char*)taosMemoryCalloc(1, len); \
for (int32_t i = 0; i < len - 1; ++i) { \
bytes[i] = b; \
} \
EXPECT_STREQ(test.GetShowBinary(len), bytes); \
EXPECT_EQ(test.GetMetaType(col), type); \
EXPECT_EQ(test.GetMetaBytes(col), bytes); \
EXPECT_STREQ(test.GetMetaName(col), colName); \
}
#define CheckBinary(row, col, val) \
{ EXPECT_STREQ(test.GetShowBinary(row, col), val); }
#define CheckInt8(val) \
{ EXPECT_EQ(test.GetShowInt8(), val); }
{ EXPECT_EQ(test.GetShowInt8(
row, col
), val); }
#define CheckInt16(val) \
{ EXPECT_EQ(test.GetShowInt16(), val); }
{ EXPECT_EQ(test.GetShowInt16(
row, col
), val); }
#define CheckInt32(val) \
{ EXPECT_EQ(test.GetShowInt32(), val); }
{ EXPECT_EQ(test.GetShowInt32
row, col
(), val); }
#define CheckInt64(val) \
{ EXPECT_EQ(test.GetShowInt64(), val); }
{ EXPECT_EQ(test.GetShowInt64(
row, col
), val); }
#define CheckTimestamp() \
{ EXPECT_GT(test.GetShowTimestamp(), 0); }
#define IgnoreBinary(len) \
{ test.GetShowBinary(len); }
#define IgnoreInt8() \
{ test.GetShowInt8(); }
#define IgnoreInt16() \
{ test.GetShowInt16(); }
#define IgnoreInt32() \
{ test.GetShowInt32(); }
#define IgnoreInt64() \
{ test.GetShowInt64(); }
{ EXPECT_GT(test.GetShowTimestamp(row, col), 0); }
#define IgnoreTimestamp() \
{ test.GetShowTimestamp(); }
#endif
#endif
/* _TD_TEST_BASE_H_ */
source/dnode/mgmt/test/sut/src/sut.cpp
浏览文件 @
585942ce
...
...
@@ -49,16 +49,14 @@ void Testbase::Init(const char* path, int16_t port) {
InitLog
(
"/tmp/td"
);
server
.
Start
(
path
,
fqdn
,
port
,
firstEp
);
client
.
Init
(
"root"
,
"taosdata"
,
fqdn
,
port
);
tFreeSTableMetaRsp
(
&
metaRsp
);
showId
=
0
;
pData
=
0
;
pos
=
0
;
pRetrieveRsp
=
NULL
;
showRsp
=
NULL
;
}
void
Testbase
::
Cleanup
()
{
tFreeSTableMetaRsp
(
&
metaRsp
);
if
(
showRsp
!=
NULL
)
{
rpcFreeCont
(
showRsp
);
showRsp
=
NULL
;
}
client
.
Cleanup
();
taosMsleep
(
10
);
server
.
Stop
();
...
...
@@ -84,112 +82,40 @@ SRpcMsg* Testbase::SendReq(tmsg_t msgType, void* pCont, int32_t contLen) {
return
client
.
SendReq
(
&
rpcMsg
);
}
void
Testbase
::
SendShowMetaReq
(
int8_t
showType
,
const
char
*
db
)
{
SShowReq
showReq
=
{
0
};
showReq
.
type
=
showType
;
strcpy
(
showReq
.
db
,
db
);
int32_t
contLen
=
tSerializeSShowReq
(
NULL
,
0
,
&
showReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSShowReq
(
pReq
,
contLen
,
&
showReq
);
tFreeSShowReq
(
&
showReq
);
SRpcMsg
*
pRsp
=
SendReq
(
TDMT_MND_SHOW
,
pReq
,
contLen
);
ASSERT
(
pRsp
->
pCont
!=
nullptr
);
if
(
pRsp
->
contLen
==
0
)
return
;
SShowRsp
showRsp
=
{
0
};
tDeserializeSShowRsp
(
pRsp
->
pCont
,
pRsp
->
contLen
,
&
showRsp
);
tFreeSTableMetaRsp
(
&
metaRsp
);
metaRsp
=
showRsp
.
tableMeta
;
showId
=
showRsp
.
showId
;
}
int32_t
Testbase
::
GetMetaColId
(
int32_t
index
)
{
SSchema
*
pSchema
=
&
metaRsp
.
pSchemas
[
index
];
return
pSchema
->
colId
;
}
int8_t
Testbase
::
GetMetaType
(
int32_t
index
)
{
SSchema
*
pSchema
=
&
metaRsp
.
pSchemas
[
index
];
return
pSchema
->
type
;
}
int32_t
Testbase
::
GetMetaBytes
(
int32_t
index
)
{
SSchema
*
pSchema
=
&
metaRsp
.
pSchemas
[
index
];
return
pSchema
->
bytes
;
}
const
char
*
Testbase
::
GetMetaName
(
int32_t
index
)
{
SSchema
*
pSchema
=
&
metaRsp
.
pSchemas
[
index
];
return
pSchema
->
name
;
}
int32_t
Testbase
::
GetMetaNum
()
{
return
metaRsp
.
numOfColumns
;
}
const
char
*
Testbase
::
GetMetaTbName
()
{
return
metaRsp
.
tbName
;
}
int32_t
Testbase
::
SendShowReq
(
int8_t
showType
,
const
char
*
tb
,
const
char
*
db
)
{
if
(
showRsp
!=
NULL
)
{
rpcFreeCont
(
showRsp
);
showRsp
=
NULL
;
}
void
Testbase
::
SendShowRetrieveReq
()
{
SRetrieveTableReq
retrieveReq
=
{
0
};
retrieveReq
.
showId
=
showId
;
// retrieveReq.free = 0;
retrieveReq
.
type
=
showType
;
strcpy
(
retrieveReq
.
db
,
db
);
strcpy
(
retrieveReq
.
tb
,
tb
);
int32_t
contLen
=
tSerializeSRetrieveTableReq
(
NULL
,
0
,
&
retrieveReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSRetrieveTableReq
(
pReq
,
contLen
,
&
retrieveReq
);
// SRpcMsg* pRsp = SendReq(TDMT_MND_SHOW_RETRIEVE, pReq, contLen);
// pRetrieveRsp = (SRetrieveTableRsp*)pRsp->pCont;
// pRetrieveRsp->numOfRows = htonl(pRetrieveRsp->numOfRows);
// pRetrieveRsp->useconds = htobe64(pRetrieveRsp->useconds);
// pRetrieveRsp->compLen = htonl(pRetrieveRsp->compLen);
pData
=
pRetrieveRsp
->
data
;
pos
=
0
;
}
const
char
*
Testbase
::
GetShowName
()
{
return
metaRsp
.
tbName
;
}
int8_t
Testbase
::
GetShowInt8
()
{
int8_t
data
=
*
((
int8_t
*
)(
pData
+
pos
));
pos
+=
sizeof
(
int8_t
);
return
data
;
}
int16_t
Testbase
::
GetShowInt16
()
{
int16_t
data
=
*
((
int16_t
*
)(
pData
+
pos
));
pos
+=
sizeof
(
int16_t
);
return
data
;
}
SRpcMsg
*
pRsp
=
SendReq
(
TDMT_MND_SYSTABLE_RETRIEVE
,
pReq
,
contLen
);
ASSERT
(
pRsp
->
pCont
!=
nullptr
);
int32_t
Testbase
::
GetShowInt32
()
{
int32_t
data
=
*
((
int32_t
*
)(
pData
+
pos
));
pos
+=
sizeof
(
int32_t
);
return
data
;
}
if
(
pRsp
->
contLen
==
0
)
return
-
1
;
int64_t
Testbase
::
GetShowInt64
()
{
int64_t
data
=
*
((
int64_t
*
)(
pData
+
pos
));
pos
+=
sizeof
(
int64_t
);
return
data
;
}
showRsp
=
(
SRetrieveMetaTableRsp
*
)
pRsp
->
pCont
;
showRsp
->
handle
=
htobe64
(
showRsp
->
handle
);
// show Id
showRsp
->
useconds
=
htobe64
(
showRsp
->
useconds
);
showRsp
->
numOfRows
=
htonl
(
showRsp
->
numOfRows
);
showRsp
->
compLen
=
htonl
(
showRsp
->
compLen
);
if
(
showRsp
->
numOfRows
<=
0
)
return
-
1
;
int64_t
Testbase
::
GetShowTimestamp
()
{
int64_t
data
=
*
((
int64_t
*
)(
pData
+
pos
));
pos
+=
sizeof
(
int64_t
);
return
data
;
return
0
;
}
const
char
*
Testbase
::
GetShowBinary
(
int32_t
len
)
{
pos
+=
sizeof
(
VarDataLenT
);
char
*
data
=
(
char
*
)(
pData
+
pos
);
pos
+=
len
;
return
data
;
int32_t
Testbase
::
GetShowRows
()
{
if
(
showRsp
!=
NULL
)
{
return
showRsp
->
numOfRows
;
}
else
{
return
0
;
}
}
int32_t
Testbase
::
GetShowRows
()
{
return
pRetrieveRsp
->
numOfRows
;
}
STableMetaRsp
*
Testbase
::
GetShowMeta
()
{
return
&
metaRsp
;
}
SRetrieveTableRsp
*
Testbase
::
GetRetrieveRsp
()
{
return
pRetrieveRsp
;
}
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
585942ce
...
...
@@ -213,7 +213,7 @@ typedef struct {
int32_t
maxConsumers
;
int32_t
maxConns
;
int32_t
maxTopics
;
int64_t
maxStorage
;
// In unit of GB
int64_t
maxStorage
;
int32_t
accessState
;
// Configured only by command
}
SAcctCfg
;
...
...
source/dnode/mnode/impl/inc/mndInfoSchema.h
浏览文件 @
585942ce
...
...
@@ -23,20 +23,20 @@ extern "C" {
#endif
typedef
struct
SInfosTableSchema
{
char
*
name
;
int32_t
type
;
int32_t
bytes
;
c
onst
c
har
*
name
;
const
int32_t
type
;
const
int32_t
bytes
;
}
SInfosTableSchema
;
typedef
struct
SInfosTableMeta
{
c
har
*
name
;
c
onst
char
*
name
;
const
SInfosTableSchema
*
schema
;
int32_t
colNum
;
const
int32_t
colNum
;
}
SInfosTableMeta
;
int32_t
mndBuildInsTableSchema
(
SMnode
*
pMnode
,
const
char
*
dbFName
,
const
char
*
tbName
,
STableMetaRsp
*
pRsp
);
int32_t
mndInitInfos
(
SMnode
*
pMnode
);
void
mndCleanupInfos
(
SMnode
*
pMnode
);
void
mndCleanupInfos
(
SMnode
*
pMnode
);
int32_t
mndBuildInsTableSchema
(
SMnode
*
pMnode
,
const
char
*
dbFName
,
const
char
*
tbName
,
STableMetaRsp
*
pRsp
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/impl/inc/mndShow.h
浏览文件 @
585942ce
...
...
@@ -26,8 +26,6 @@ int32_t mndInitShow(SMnode *pMnode);
void
mndCleanupShow
(
SMnode
*
pMnode
);
void
mndAddShowRetrieveHandle
(
SMnode
*
pMnode
,
EShowType
showType
,
ShowRetrieveFp
fp
);
void
mndAddShowFreeIterHandle
(
SMnode
*
pMnode
,
EShowType
msgType
,
ShowFreeIterFp
fp
);
void
mndVacuumResult
(
char
*
data
,
int32_t
numOfCols
,
int32_t
rows
,
int32_t
capacity
,
SShowObj
*
pShow
);
char
*
mndShowStr
(
int32_t
showType
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/impl/src/mndAcct.c
浏览文件 @
585942ce
...
...
@@ -17,7 +17,7 @@
#include "mndAcct.h"
#include "mndShow.h"
#define TSDB_ACCT_VER_NUMBER 1
#define TSDB_ACCT_VER_NUMBER
1
#define TSDB_ACCT_RESERVE_SIZE 128
static
int32_t
mndCreateDefaultAcct
(
SMnode
*
pMnode
);
...
...
@@ -80,32 +80,32 @@ static SSdbRaw *mndAcctActionEncode(SAcctObj *pAcct) {
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_ACCT
,
TSDB_ACCT_VER_NUMBER
,
sizeof
(
SAcctObj
)
+
TSDB_ACCT_RESERVE_SIZE
);
if
(
pRaw
==
NULL
)
goto
ACCT_ENCODE
_OVER
;
if
(
pRaw
==
NULL
)
goto
_OVER
;
int32_t
dataPos
=
0
;
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pAcct
->
acct
,
TSDB_USER_LEN
,
ACCT_ENCODE
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pAcct
->
createdTime
,
ACCT_ENCODE
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pAcct
->
updateTime
,
ACCT_ENCODE
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
acctId
,
ACCT_ENCODE
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
status
,
ACCT_ENCODE
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
maxUsers
,
ACCT_ENCODE
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
maxDbs
,
ACCT_ENCODE
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
maxStbs
,
ACCT_ENCODE
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
maxTbs
,
ACCT_ENCODE
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
maxTimeSeries
,
ACCT_ENCODE
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
maxStreams
,
ACCT_ENCODE
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
maxFuncs
,
ACCT_ENCODE
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
maxConsumers
,
ACCT_ENCODE
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
maxConns
,
ACCT_ENCODE
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
maxTopics
,
ACCT_ENCODE
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
maxStorage
,
ACCT_ENCODE
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
accessState
,
ACCT_ENCODE
_OVER
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
TSDB_ACCT_RESERVE_SIZE
,
ACCT_ENCODE
_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
ACCT_ENCODE
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pAcct
->
acct
,
TSDB_USER_LEN
,
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pAcct
->
createdTime
,
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pAcct
->
updateTime
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
acctId
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
status
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
maxUsers
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
maxDbs
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
maxStbs
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
maxTbs
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
maxTimeSeries
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
maxStreams
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
maxFuncs
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
maxConsumers
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
maxConns
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
maxTopics
,
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
maxStorage
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAcct
->
cfg
.
accessState
,
_OVER
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
TSDB_ACCT_RESERVE_SIZE
,
_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
_OVER
)
terrno
=
0
;
ACCT_ENCODE
_OVER:
_OVER:
if
(
terrno
!=
0
)
{
mError
(
"acct:%s, failed to encode to raw:%p since %s"
,
pAcct
->
acct
,
pRaw
,
terrstr
());
sdbFreeRaw
(
pRaw
);
...
...
@@ -120,42 +120,42 @@ static SSdbRow *mndAcctActionDecode(SSdbRaw *pRaw) {
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
int8_t
sver
=
0
;
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
goto
ACCT_DECODE
_OVER
;
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
goto
_OVER
;
if
(
sver
!=
TSDB_ACCT_VER_NUMBER
)
{
terrno
=
TSDB_CODE_SDB_INVALID_DATA_VER
;
goto
ACCT_DECODE
_OVER
;
goto
_OVER
;
}
SSdbRow
*
pRow
=
sdbAllocRow
(
sizeof
(
SAcctObj
));
if
(
pRow
==
NULL
)
goto
ACCT_DECODE
_OVER
;
if
(
pRow
==
NULL
)
goto
_OVER
;
SAcctObj
*
pAcct
=
sdbGetRowObj
(
pRow
);
if
(
pAcct
==
NULL
)
goto
ACCT_DECODE
_OVER
;
if
(
pAcct
==
NULL
)
goto
_OVER
;
int32_t
dataPos
=
0
;
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pAcct
->
acct
,
TSDB_USER_LEN
,
ACCT_DECODE
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pAcct
->
createdTime
,
ACCT_DECODE
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pAcct
->
updateTime
,
ACCT_DECODE
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
acctId
,
ACCT_DECODE
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
status
,
ACCT_DECODE
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
maxUsers
,
ACCT_DECODE
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
maxDbs
,
ACCT_DECODE
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
maxStbs
,
ACCT_DECODE
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
maxTbs
,
ACCT_DECODE
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
maxTimeSeries
,
ACCT_DECODE
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
maxStreams
,
ACCT_DECODE
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
maxFuncs
,
ACCT_DECODE
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
maxConsumers
,
ACCT_DECODE
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
maxConns
,
ACCT_DECODE
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
maxTopics
,
ACCT_DECODE
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
maxStorage
,
ACCT_DECODE
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
accessState
,
ACCT_DECODE
_OVER
)
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
TSDB_ACCT_RESERVE_SIZE
,
ACCT_DECODE
_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pAcct
->
acct
,
TSDB_USER_LEN
,
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pAcct
->
createdTime
,
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pAcct
->
updateTime
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
acctId
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
status
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
maxUsers
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
maxDbs
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
maxStbs
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
maxTbs
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
maxTimeSeries
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
maxStreams
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
maxFuncs
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
maxConsumers
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
maxConns
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
maxTopics
,
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
maxStorage
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pAcct
->
cfg
.
accessState
,
_OVER
)
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
TSDB_ACCT_RESERVE_SIZE
,
_OVER
)
terrno
=
0
;
ACCT_DECODE
_OVER:
_OVER:
if
(
terrno
!=
0
)
{
mError
(
"acct:%s, failed to decode from raw:%p since %s"
,
pAcct
->
acct
,
pRaw
,
terrstr
());
taosMemoryFreeClear
(
pRow
);
...
...
source/dnode/mnode/impl/src/mndAuth.c
浏览文件 @
585942ce
...
...
@@ -26,22 +26,22 @@ int32_t mndInitAuth(SMnode *pMnode) {
void
mndCleanupAuth
(
SMnode
*
pMnode
)
{}
int32_t
mndRetriveAuth
(
SMnode
*
pMnode
,
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
)
{
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
user
);
static
int32_t
mndRetriveAuth
(
SMnode
*
pMnode
,
SAuthRsp
*
pRsp
)
{
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
pRsp
->
user
);
if
(
pUser
==
NULL
)
{
*
secret
=
0
;
mError
(
"user:%s, failed to auth user since %s"
,
user
,
terrstr
());
*
pRsp
->
secret
=
0
;
mError
(
"user:%s, failed to auth user since %s"
,
pRsp
->
user
,
terrstr
());
return
-
1
;
}
*
spi
=
1
;
*
encrypt
=
0
;
*
ckey
=
0
;
pRsp
->
spi
=
1
;
pRsp
->
encrypt
=
0
;
*
pRsp
->
ckey
=
0
;
memcpy
(
secret
,
pUser
->
pass
,
TSDB_PASSWORD_LEN
);
memcpy
(
pRsp
->
secret
,
pUser
->
pass
,
TSDB_PASSWORD_LEN
);
mndReleaseUser
(
pMnode
,
pUser
);
mDebug
(
"user:%s, auth info is returned"
,
user
);
mDebug
(
"user:%s, auth info is returned"
,
pRsp
->
user
);
return
0
;
}
...
...
@@ -55,14 +55,19 @@ static int32_t mndProcessAuthReq(SNodeMsg *pReq) {
SAuthReq
authRsp
=
{
0
};
memcpy
(
authRsp
.
user
,
authReq
.
user
,
TSDB_USER_LEN
);
int32_t
code
=
mndRetriveAuth
(
pReq
->
pNode
,
authRsp
.
user
,
&
authRsp
.
spi
,
&
authRsp
.
encrypt
,
authRsp
.
secret
,
authRsp
.
ckey
);
int32_t
code
=
mndRetriveAuth
(
pReq
->
pNode
,
&
authRsp
);
mTrace
(
"user:%s, auth req received, spi:%d encrypt:%d ruser:%s"
,
pReq
->
user
,
authRsp
.
spi
,
authRsp
.
encrypt
,
authRsp
.
user
);
int32_t
contLen
=
tSerializeSAuthReq
(
NULL
,
0
,
&
authRsp
);
void
*
pRsp
=
rpcMallocCont
(
contLen
);
if
(
pRsp
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
tSerializeSAuthReq
(
pRsp
,
contLen
,
&
authRsp
);
pReq
->
pRsp
=
pRsp
;
pReq
->
rspLen
=
contLen
;
return
code
;
...
...
@@ -95,11 +100,11 @@ int32_t mndCheckAlterUserAuth(SUserObj *pOperUser, SUserObj *pUser, SDbObj *pDb,
}
}
if
(
pAlter
->
alterType
==
TSDB_ALTER_USER_CLEAR_WRITE_DB
||
pAlter
->
alterType
==
TSDB_ALTER_USER_CLEAR_READ_DB
)
{
if
(
pOperUser
->
superUser
)
{
return
0
;
}
if
(
pAlter
->
alterType
==
TSDB_ALTER_USER_CLEAR_WRITE_DB
||
pAlter
->
alterType
==
TSDB_ALTER_USER_CLEAR_READ_DB
)
{
if
(
pOperUser
->
superUser
)
{
return
0
;
}
}
if
(
pAlter
->
alterType
==
TSDB_ALTER_USER_ADD_READ_DB
||
pAlter
->
alterType
==
TSDB_ALTER_USER_REMOVE_READ_DB
||
pAlter
->
alterType
==
TSDB_ALTER_USER_ADD_WRITE_DB
||
pAlter
->
alterType
==
TSDB_ALTER_USER_REMOVE_WRITE_DB
)
{
...
...
@@ -176,4 +181,4 @@ int32_t mndCheckReadAuth(SUserObj *pOperUser, SDbObj *pDb) {
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
return
-
1
;
}
\ No newline at end of file
}
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
585942ce
...
...
@@ -24,9 +24,6 @@
#define TSDB_DNODE_VER_NUMBER 1
#define TSDB_DNODE_RESERVE_SIZE 64
#define TSDB_CONFIG_OPTION_LEN 16
#define TSDB_CONIIG_VALUE_LEN 48
#define TSDB_CONFIG_NUMBER 8
static
const
char
*
offlineReason
[]
=
{
""
,
...
...
@@ -55,7 +52,6 @@ static int32_t mndProcessConfigDnodeReq(SNodeMsg *pReq);
static
int32_t
mndProcessConfigDnodeRsp
(
SNodeMsg
*
pRsp
);
static
int32_t
mndProcessStatusReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndGetConfigMeta
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
STableMetaRsp
*
pMeta
);
static
int32_t
mndRetrieveConfigs
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
void
mndCancelGetNextConfig
(
SMnode
*
pMnode
,
void
*
pIter
);
static
int32_t
mndRetrieveDnodes
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
...
...
@@ -77,8 +73,8 @@ int32_t mndInitDnode(SMnode *pMnode) {
mndSetMsgHandle
(
pMnode
,
TDMT_DND_CONFIG_DNODE_RSP
,
mndProcessConfigDnodeRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_STATUS
,
mndProcessStatusReq
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_
VARIABLE
S
,
mndRetrieveConfigs
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_
VARIABLE
S
,
mndCancelGetNextConfig
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_
CONFIG
S
,
mndRetrieveConfigs
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_
CONFIG
S
,
mndCancelGetNextConfig
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_DNODE
,
mndRetrieveDnodes
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_DNODE
,
mndCancelGetNextDnode
);
...
...
@@ -638,37 +634,6 @@ static int32_t mndProcessConfigDnodeRsp(SNodeMsg *pRsp) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mndGetConfigMeta
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
STableMetaRsp
*
pMeta
)
{
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
pSchemas
;
pShow
->
bytes
[
cols
]
=
TSDB_CONFIG_OPTION_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"name"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
TSDB_CONIIG_VALUE_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"value"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pMeta
->
numOfColumns
=
cols
;
pShow
->
numOfColumns
=
cols
;
pShow
->
offset
[
0
]
=
0
;
for
(
int32_t
i
=
1
;
i
<
cols
;
++
i
)
{
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
}
pShow
->
numOfRows
=
TSDB_CONFIG_NUMBER
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tbName
,
mndShowStr
(
pShow
->
type
));
return
0
;
}
static
int32_t
mndRetrieveConfigs
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
int32_t
totalRows
=
0
;
...
...
source/dnode/mnode/impl/src/mndInfoSchema.c
浏览文件 @
585942ce
...
...
@@ -18,9 +18,8 @@
#define SYSTABLE_SCH_TABLE_NAME_LEN ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
#define SYSTABLE_SCH_DB_NAME_LEN ((TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
#define SYSTABLE_SCH_COL_NAME_LEN
((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
#define SYSTABLE_SCH_COL_NAME_LEN ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
//!!!! Note: only APPEND columns in below tables, NO insert !!!!
static
const
SInfosTableSchema
dnodesSchema
[]
=
{
{.
name
=
"id"
,
.
bytes
=
2
,
.
type
=
TSDB_DATA_TYPE_SMALLINT
},
{.
name
=
"endpoint"
,
.
bytes
=
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
...
...
@@ -30,6 +29,7 @@ static const SInfosTableSchema dnodesSchema[] = {
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"note"
,
.
bytes
=
256
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
};
static
const
SInfosTableSchema
mnodesSchema
[]
=
{
{.
name
=
"id"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"endpoint"
,
.
bytes
=
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
...
...
@@ -37,31 +37,37 @@ static const SInfosTableSchema mnodesSchema[] = {
{.
name
=
"role_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
};
static
const
SInfosTableSchema
modulesSchema
[]
=
{
{.
name
=
"id"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"endpoint"
,
.
bytes
=
134
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"module"
,
.
bytes
=
10
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
};
static
const
SInfosTableSchema
qnodesSchema
[]
=
{
{.
name
=
"id"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"endpoint"
,
.
bytes
=
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
};
static
const
SInfosTableSchema
snodesSchema
[]
=
{
{.
name
=
"id"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"endpoint"
,
.
bytes
=
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
};
static
const
SInfosTableSchema
bnodesSchema
[]
=
{
{.
name
=
"id"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"endpoint"
,
.
bytes
=
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
};
static
const
SInfosTableSchema
clusterSchema
[]
=
{
{.
name
=
"id"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_BIGINT
},
{.
name
=
"name"
,
.
bytes
=
TSDB_CLUSTER_ID_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
};
static
const
SInfosTableSchema
userDBSchema
[]
=
{
{.
name
=
"name"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
...
...
@@ -84,9 +90,9 @@ static const SInfosTableSchema userDBSchema[] = {
{.
name
=
"single_stable"
,
.
bytes
=
1
,
.
type
=
TSDB_DATA_TYPE_TINYINT
},
{.
name
=
"stream_mode"
,
.
bytes
=
1
,
.
type
=
TSDB_DATA_TYPE_TINYINT
},
{.
name
=
"status"
,
.
bytes
=
10
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
// {.name = "update", .bytes = 1, .type =
// TSDB_DATA_TYPE_TINYINT}, // disable update
// {.name = "update", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, // disable update
};
static
const
SInfosTableSchema
userFuncSchema
[]
=
{
{.
name
=
"name"
,
.
bytes
=
32
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
...
...
@@ -94,6 +100,7 @@ static const SInfosTableSchema userFuncSchema[] = {
{.
name
=
"precision"
,
.
bytes
=
2
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"status"
,
.
bytes
=
10
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
};
static
const
SInfosTableSchema
userIdxSchema
[]
=
{
{.
name
=
"db_name"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"table_name"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
...
...
@@ -103,6 +110,7 @@ static const SInfosTableSchema userIdxSchema[] = {
{.
name
=
"index_type"
,
.
bytes
=
10
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"index_extensions"
,
.
bytes
=
256
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
};
static
const
SInfosTableSchema
userStbsSchema
[]
=
{
{.
name
=
"stable_name"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"db_name"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
...
...
@@ -112,6 +120,7 @@ static const SInfosTableSchema userStbsSchema[] = {
{.
name
=
"last_update"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"table_comment"
,
.
bytes
=
1024
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
};
static
const
SInfosTableSchema
userStreamsSchema
[]
=
{
{.
name
=
"stream_name"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"user_name"
,
.
bytes
=
23
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
...
...
@@ -119,6 +128,7 @@ static const SInfosTableSchema userStreamsSchema[] = {
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"sql"
,
.
bytes
=
1024
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
};
static
const
SInfosTableSchema
userTblsSchema
[]
=
{
{.
name
=
"table_name"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"db_name"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
...
...
@@ -130,6 +140,7 @@ static const SInfosTableSchema userTblsSchema[] = {
{.
name
=
"ttl"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"table_comment"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
};
static
const
SInfosTableSchema
userTblDistSchema
[]
=
{
{.
name
=
"db_name"
,
.
bytes
=
32
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"table_name"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
...
...
@@ -145,12 +156,14 @@ static const SInfosTableSchema userTblDistSchema[] = {
{.
name
=
"rows_in_mem"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"seek_header_time"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
};
static
const
SInfosTableSchema
userUsersSchema
[]
=
{
{.
name
=
"name"
,
.
bytes
=
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"privilege"
,
.
bytes
=
10
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"account"
,
.
bytes
=
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
};
static
const
SInfosTableSchema
grantsSchema
[]
=
{
{.
name
=
"version"
,
.
bytes
=
8
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"expire time"
,
.
bytes
=
19
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
...
...
@@ -167,6 +180,7 @@ static const SInfosTableSchema grantsSchema[] = {
{.
name
=
"speed(PPS)"
,
.
bytes
=
9
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"querytime"
,
.
bytes
=
9
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
};
static
const
SInfosTableSchema
vgroupsSchema
[]
=
{
{.
name
=
"vgroup_id"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"db_name"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
...
...
@@ -210,14 +224,62 @@ static const SInfosTableSchema subscribeSchema[] = {
{.
name
=
"client_id"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
};
static
const
SInfosTableSchema
smaSchema
[]
=
{
{.
name
=
"sma_name"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"stable_name"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
};
static
const
SInfosTableSchema
transSchema
[]
=
{
{.
name
=
"id"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"created_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"stage"
,
.
bytes
=
TSDB_TRANS_STAGE_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"db"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"type"
,
.
bytes
=
TSDB_TRANS_TYPE_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"last_exec_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"last_error"
,
.
bytes
=
(
TSDB_TRANS_ERROR_LEN
-
1
)
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
};
static
const
SInfosTableSchema
configSchema
[]
=
{
{.
name
=
"name"
,
.
bytes
=
TSDB_CONFIG_OPTION_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"value"
,
.
bytes
=
TSDB_CONIIG_VALUE_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
};
static
const
SInfosTableSchema
connSchema
[]
=
{
{.
name
=
"connId"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"user"
,
.
bytes
=
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"program"
,
.
bytes
=
TSDB_APP_NAME_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"pid"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"ip:port"
,
.
bytes
=
TSDB_IPv4ADDR_LEN
+
6
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"login_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"last_access"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
};
static
const
SInfosTableSchema
querySchema
[]
=
{
{.
name
=
"queryId"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"connId"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"user"
,
.
bytes
=
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"ip:port"
,
.
bytes
=
TSDB_IPv4ADDR_LEN
+
6
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"qid"
,
.
bytes
=
22
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"created_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_BIGINT
},
{.
name
=
"sql_obj_id"
,
.
bytes
=
QUERY_OBJ_ID_SIZE
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"pid"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"ep"
,
.
bytes
=
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"stable_query"
,
.
bytes
=
1
,
.
type
=
TSDB_DATA_TYPE_BOOL
},
{.
name
=
"sub_queries"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"sub_query_info"
,
.
bytes
=
TSDB_SHOW_SUBQUERY_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"sql"
,
.
bytes
=
TSDB_SHOW_SQL_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
};
static
const
SInfosTableMeta
infosMeta
[]
=
{
{
TSDB_INS_TABLE_DNODES
,
dnodesSchema
,
tListLen
(
dnodesSchema
)},
{
TSDB_INS_TABLE_MNODES
,
mnodesSchema
,
tListLen
(
mnodesSchema
)},
{
TSDB_INS_TABLE_MODULES
,
modulesSchema
,
tListLen
(
modulesSchema
)},
{
TSDB_INS_TABLE_QNODES
,
qnodesSchema
,
tListLen
(
qnodesSchema
)},
{
TSDB_INS_TABLE_SNODES
,
snodesSchema
,
tListLen
(
snodesSchema
)},
{
TSDB_INS_TABLE_BNODES
,
bnodesSchema
,
tListLen
(
bnodesSchema
)},
{
TSDB_INS_TABLE_CLUSTER
,
clusterSchema
,
tListLen
(
clusterSchema
)},
{
TSDB_INS_TABLE_SNODES
,
snodesSchema
,
tListLen
(
snodesSchema
)},
{
TSDB_INS_TABLE_USER_DATABASES
,
userDBSchema
,
tListLen
(
userDBSchema
)},
{
TSDB_INS_TABLE_USER_FUNCTIONS
,
userFuncSchema
,
tListLen
(
userFuncSchema
)},
{
TSDB_INS_TABLE_USER_INDEXES
,
userIdxSchema
,
tListLen
(
userIdxSchema
)},
...
...
@@ -226,12 +288,19 @@ static const SInfosTableMeta infosMeta[] = {
{
TSDB_INS_TABLE_USER_TABLES
,
userTblsSchema
,
tListLen
(
userTblsSchema
)},
{
TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED
,
userTblDistSchema
,
tListLen
(
userTblDistSchema
)},
{
TSDB_INS_TABLE_USER_USERS
,
userUsersSchema
,
tListLen
(
userUsersSchema
)},
{
TSDB_INS_TABLE_VGROUPS
,
vgroupsSchema
,
tListLen
(
vgroupsSchema
)},
{
TSDB_INS_TABLE_LICENCES
,
grantsSchema
,
tListLen
(
grantsSchema
)},
{
TSDB_INS_TABLE_VGROUPS
,
vgroupsSchema
,
tListLen
(
vgroupsSchema
)},
{
TSDB_INS_TABLE_TOPICS
,
topicSchema
,
tListLen
(
topicSchema
)},
{
TSDB_INS_TABLE_CONSUMERS
,
consumerSchema
,
tListLen
(
consumerSchema
)},
{
TSDB_INS_TABLE_SUBSCRIBES
,
subscribeSchema
,
tListLen
(
subscribeSchema
)},
{
TSDB_INS_TABLE_TRANS
,
transSchema
,
tListLen
(
transSchema
)},
{
TSDB_INS_TABLE_SMAS
,
smaSchema
,
tListLen
(
smaSchema
)},
{
TSDB_INS_TABLE_CONFIGS
,
configSchema
,
tListLen
(
configSchema
)},
{
TSDB_INS_TABLE_CONNS
,
connSchema
,
tListLen
(
connSchema
)},
{
TSDB_INS_TABLE_QUERIES
,
querySchema
,
tListLen
(
querySchema
)},
};
// connection/application/
int32_t
mndInitInfosTableSchema
(
const
SInfosTableSchema
*
pSrc
,
int32_t
colNum
,
SSchema
**
pDst
)
{
static
int32_t
mndInitInfosTableSchema
(
const
SInfosTableSchema
*
pSrc
,
int32_t
colNum
,
SSchema
**
pDst
)
{
SSchema
*
schema
=
taosMemoryCalloc
(
colNum
,
sizeof
(
SSchema
));
if
(
NULL
==
schema
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -239,40 +308,39 @@ int32_t mndInitInfosTableSchema(const SInfosTableSchema *pSrc, int32_t colNum, S
}
for
(
int32_t
i
=
0
;
i
<
colNum
;
++
i
)
{
strcpy
(
schema
[
i
].
name
,
pSrc
[
i
].
name
);
tstrncpy
(
schema
[
i
].
name
,
pSrc
[
i
].
name
,
sizeof
(
schema
[
i
].
name
));
schema
[
i
].
type
=
pSrc
[
i
].
type
;
schema
[
i
].
colId
=
i
+
1
;
schema
[
i
].
bytes
=
pSrc
[
i
].
bytes
;
}
*
pDst
=
schema
;
return
TSDB_CODE_SUCCESS
;
return
0
;
}
int32_t
mndInsInitMeta
(
SHashObj
*
hash
)
{
static
int32_t
mndInsInitMeta
(
SHashObj
*
hash
)
{
STableMetaRsp
meta
=
{
0
};
strcpy
(
meta
.
dbFName
,
TSDB_INFORMATION_SCHEMA_DB
);
tstrncpy
(
meta
.
dbFName
,
TSDB_INFORMATION_SCHEMA_DB
,
sizeof
(
meta
.
dbFName
)
);
meta
.
tableType
=
TSDB_SYSTEM_TABLE
;
meta
.
sversion
=
1
;
meta
.
tversion
=
1
;
for
(
int32_t
i
=
0
;
i
<
tListLen
(
infosMeta
);
++
i
)
{
strcpy
(
meta
.
tbName
,
infosMeta
[
i
].
name
);
tstrncpy
(
meta
.
tbName
,
infosMeta
[
i
].
name
,
sizeof
(
meta
.
tbName
)
);
meta
.
numOfColumns
=
infosMeta
[
i
].
colNum
;
if
(
mndInitInfosTableSchema
(
infosMeta
[
i
].
schema
,
infosMeta
[
i
].
colNum
,
&
meta
.
pSchemas
))
{
return
-
1
;
}
if
(
taosHashPut
(
hash
,
meta
.
tbName
,
strlen
(
meta
.
tbName
),
&
meta
,
sizeof
(
meta
)))
{
if
(
taosHashPut
(
hash
,
meta
.
tbName
,
strlen
(
meta
.
tbName
)
+
1
,
&
meta
,
sizeof
(
meta
)))
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
}
return
TSDB_CODE_SUCCESS
;
return
0
;
}
int32_t
mndBuildInsTableSchema
(
SMnode
*
pMnode
,
const
char
*
dbFName
,
const
char
*
tbName
,
STableMetaRsp
*
pRsp
)
{
...
...
@@ -281,24 +349,23 @@ int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *
return
-
1
;
}
STableMetaRsp
*
meta
=
(
STableMetaRsp
*
)
taosHashGet
(
pMnode
->
infosMeta
,
tbName
,
strlen
(
tbName
)
);
if
(
NULL
==
m
eta
)
{
STableMetaRsp
*
pMeta
=
taosHashGet
(
pMnode
->
infosMeta
,
tbName
,
strlen
(
tbName
)
+
1
);
if
(
NULL
==
pM
eta
)
{
mError
(
"invalid information schema table name:%s"
,
tbName
);
terrno
=
TSDB_CODE_MND_INVALID_INFOS_TBL
;
return
-
1
;
}
*
pRsp
=
*
m
eta
;
*
pRsp
=
*
pM
eta
;
pRsp
->
pSchemas
=
taosMemoryCalloc
(
m
eta
->
numOfColumns
,
sizeof
(
SSchema
));
pRsp
->
pSchemas
=
taosMemoryCalloc
(
pM
eta
->
numOfColumns
,
sizeof
(
SSchema
));
if
(
pRsp
->
pSchemas
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
pRsp
->
pSchemas
=
NULL
;
return
-
1
;
}
memcpy
(
pRsp
->
pSchemas
,
meta
->
pSchemas
,
meta
->
numOfColumns
*
sizeof
(
SSchema
));
memcpy
(
pRsp
->
pSchemas
,
pMeta
->
pSchemas
,
pMeta
->
numOfColumns
*
sizeof
(
SSchema
));
return
0
;
}
...
...
@@ -317,16 +384,12 @@ void mndCleanupInfos(SMnode *pMnode) {
return
;
}
void
*
pIter
=
taosHashIterate
(
pMnode
->
infosMeta
,
NULL
);
while
(
pIter
)
{
STableMetaRsp
*
meta
=
(
STableMetaRsp
*
)
pIter
;
taosMemoryFreeClear
(
meta
->
pSchemas
);
pIter
=
taosHashIterate
(
pMnode
->
infosMeta
,
pIter
);
STableMetaRsp
*
pMeta
=
taosHashIterate
(
pMnode
->
infosMeta
,
NULL
);
while
(
pMeta
)
{
taosMemoryFreeClear
(
pMeta
->
pSchemas
);
pMeta
=
taosHashIterate
(
pMnode
->
infosMeta
,
pMeta
);
}
taosHashCleanup
(
pMnode
->
infosMeta
);
pMnode
->
infosMeta
=
NULL
;
}
source/dnode/mnode/impl/src/mndProfile.c
浏览文件 @
585942ce
...
...
@@ -23,11 +23,6 @@
#include "tglobal.h"
#include "version.h"
#define QUERY_ID_SIZE 20
#define QUERY_OBJ_ID_SIZE 18
#define SUBQUERY_INFO_SIZE 6
#define QUERY_SAVE_SIZE 20
typedef
struct
{
int32_t
id
;
int8_t
connType
;
...
...
@@ -56,9 +51,7 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq);
static
int32_t
mndProcessConnectReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessKillQueryReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessKillConnReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndGetConnsMeta
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
STableMetaRsp
*
pMeta
);
static
int32_t
mndRetrieveConns
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndGetQueryMeta
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
STableMetaRsp
*
pMeta
);
static
int32_t
mndRetrieveQueries
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextQuery
(
SMnode
*
pMnode
,
void
*
pIter
);
...
...
@@ -558,81 +551,6 @@ static int32_t mndProcessKillConnReq(SNodeMsg *pReq) {
}
}
static
int32_t
mndGetConnsMeta
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
STableMetaRsp
*
pMeta
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
if
(
pUser
==
NULL
)
return
0
;
if
(
!
pUser
->
superUser
)
{
mndReleaseUser
(
pMnode
,
pUser
);
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
return
-
1
;
}
mndReleaseUser
(
pMnode
,
pUser
);
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
pSchemas
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"connId"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"user"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
// app name
pShow
->
bytes
[
cols
]
=
TSDB_APP_NAME_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"program"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
// app pid
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"pid"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
TSDB_IPv4ADDR_LEN
+
6
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"ip:port"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
8
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
strcpy
(
pSchema
[
cols
].
name
,
"login_time"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
8
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
strcpy
(
pSchema
[
cols
].
name
,
"last_access"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pMeta
->
numOfColumns
=
cols
;
pShow
->
numOfColumns
=
cols
;
pShow
->
offset
[
0
]
=
0
;
for
(
int32_t
i
=
1
;
i
<
cols
;
++
i
)
{
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
}
pShow
->
numOfRows
=
taosCacheGetNumOfObj
(
pMgmt
->
cache
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tbName
,
mndShowStr
(
pShow
->
type
));
return
0
;
}
static
int32_t
mndRetrieveConns
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
int32_t
numOfRows
=
0
;
...
...
@@ -692,121 +610,6 @@ static int32_t mndRetrieveConns(SNodeMsg *pReq, SShowObj *pShow, char *data, int
return
numOfRows
;
}
static
int32_t
mndGetQueryMeta
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
STableMetaRsp
*
pMeta
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
if
(
pUser
==
NULL
)
return
0
;
if
(
!
pUser
->
superUser
)
{
mndReleaseUser
(
pMnode
,
pUser
);
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
return
-
1
;
}
mndReleaseUser
(
pMnode
,
pUser
);
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
pSchemas
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"queryId"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"connId"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"user"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
TSDB_IPv4ADDR_LEN
+
6
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"ip:port"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
22
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"qid"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
8
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
strcpy
(
pSchema
[
cols
].
name
,
"created_time"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
8
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BIGINT
;
strcpy
(
pSchema
[
cols
].
name
,
"time"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
QUERY_OBJ_ID_SIZE
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"sql_obj_id"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"pid"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"ep"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
1
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BOOL
;
strcpy
(
pSchema
[
cols
].
name
,
"stable_query"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"sub_queries"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
TSDB_SHOW_SUBQUERY_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"sub_query_info"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
TSDB_SHOW_SQL_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"sql"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pMeta
->
numOfColumns
=
cols
;
pShow
->
numOfColumns
=
cols
;
pShow
->
offset
[
0
]
=
0
;
for
(
int32_t
i
=
1
;
i
<
cols
;
++
i
)
{
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
}
pShow
->
numOfRows
=
1000000
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tbName
,
mndShowStr
(
pShow
->
type
));
return
0
;
}
static
int32_t
mndRetrieveQueries
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
int32_t
numOfRows
=
0
;
...
...
source/dnode/mnode/impl/src/mndShow.c
浏览文件 @
585942ce
...
...
@@ -115,6 +115,7 @@ static void mndReleaseShowObj(SShowObj *pShow, bool forceRemove) {
static
int32_t
mndProcessRetrieveSysTableReq
(
SNodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SShowMgmt
*
pMgmt
=
&
pMnode
->
showMgmt
;
SShowObj
*
pShow
=
NULL
;
int32_t
rowsToRead
=
SHOW_STEP_SIZE
;
int32_t
size
=
0
;
int32_t
rowsRead
=
0
;
...
...
@@ -125,8 +126,6 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
return
-
1
;
}
SShowObj
*
pShow
=
NULL
;
if
(
retrieveReq
.
showId
==
0
)
{
SShowReq
req
=
{
0
};
req
.
type
=
retrieveReq
.
type
;
...
...
@@ -139,11 +138,11 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
return
-
1
;
}
pShow
->
pMeta
=
(
STableMetaRsp
*
)
taosHashGet
(
pMnode
->
infosMeta
,
retrieveReq
.
tb
,
strlen
(
retrieveReq
.
tb
));
pShow
->
pMeta
=
(
STableMetaRsp
*
)
taosHashGet
(
pMnode
->
infosMeta
,
retrieveReq
.
tb
,
strlen
(
retrieveReq
.
tb
)
+
1
);
pShow
->
numOfColumns
=
pShow
->
pMeta
->
numOfColumns
;
int32_t
offset
=
0
;
for
(
int32_t
i
=
0
;
i
<
pShow
->
pMeta
->
numOfColumns
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pShow
->
pMeta
->
numOfColumns
;
++
i
)
{
pShow
->
offset
[
i
]
=
offset
;
int32_t
bytes
=
pShow
->
pMeta
->
pSchemas
[
i
].
bytes
;
...
...
@@ -162,26 +161,25 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
ShowRetrieveFp
retrieveFp
=
pMgmt
->
retrieveFps
[
pShow
->
type
];
if
(
retrieveFp
==
NULL
)
{
mndReleaseShowObj
(
(
SShowObj
*
)
pShow
,
false
);
mndReleaseShowObj
(
pShow
,
false
);
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
mError
(
"show:0x%"
PRIx64
", failed to retrieve data since %s"
,
pShow
->
id
,
terrstr
());
return
-
1
;
}
mDebug
(
"show:0x%"
PRIx64
", start retrieve data, type:%s"
,
pShow
->
id
,
mndShowStr
(
pShow
->
type
));
int32_t
numOfCols
=
pShow
->
pMeta
->
numOfColumns
;
mDebug
(
"show:0x%"
PRIx64
", start retrieve data, type:%d"
,
pShow
->
id
,
pShow
->
type
);
SSDataBlock
*
pBlock
=
taosMemoryCalloc
(
1
,
sizeof
(
SSDataBlock
));
int32_t
numOfCols
=
pShow
->
pMeta
->
numOfColumns
;
SSDataBlock
*
pBlock
=
taosMemoryCalloc
(
1
,
sizeof
(
SSDataBlock
));
pBlock
->
pDataBlock
=
taosArrayInit
(
numOfCols
,
sizeof
(
SColumnInfoData
));
pBlock
->
info
.
numOfCols
=
numOfCols
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
idata
=
{
0
};
SSchema
*
p
=
&
pShow
->
pMeta
->
pSchemas
[
i
];
SSchema
*
p
=
&
pShow
->
pMeta
->
pSchemas
[
i
];
idata
.
info
.
bytes
=
p
->
bytes
;
idata
.
info
.
type
=
p
->
type
;
idata
.
info
.
type
=
p
->
type
;
idata
.
info
.
colId
=
p
->
colId
;
taosArrayPush
(
pBlock
->
pDataBlock
,
&
idata
);
...
...
@@ -191,15 +189,15 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
}
blockDataEnsureCapacity
(
pBlock
,
rowsToRead
);
if
(
mndCheckRetrieveFinished
(
(
SShowObj
*
)
pShow
))
{
if
(
mndCheckRetrieveFinished
(
pShow
))
{
mDebug
(
"show:0x%"
PRIx64
", read finished, numOfRows:%d"
,
pShow
->
id
,
pShow
->
numOfRows
);
rowsRead
=
0
;
}
else
{
rowsRead
=
(
*
retrieveFp
)(
pReq
,
(
SShowObj
*
)
pShow
,
pBlock
,
rowsToRead
);
rowsRead
=
(
*
retrieveFp
)(
pReq
,
pShow
,
pBlock
,
rowsToRead
);
if
(
rowsRead
<
0
)
{
terrno
=
rowsRead
;
mDebug
(
"show:0x%"
PRIx64
", retrieve completed"
,
pShow
->
id
);
mndReleaseShowObj
(
(
SShowObj
*
)
pShow
,
true
);
mndReleaseShowObj
(
pShow
,
true
);
return
-
1
;
}
...
...
@@ -207,13 +205,12 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
mDebug
(
"show:0x%"
PRIx64
", stop retrieve data, rowsRead:%d numOfRows:%d"
,
pShow
->
id
,
rowsRead
,
pShow
->
numOfRows
);
}
// numOfCols + sizeof(SSysTableSchema) * numOfCols + data payload
size
=
sizeof
(
SRetrieveMetaTableRsp
)
+
sizeof
(
int32_t
)
+
sizeof
(
SSysTableSchema
)
*
pShow
->
pMeta
->
numOfColumns
+
blockDataGetSize
(
pBlock
)
+
blockDataGetSerialMetaSize
(
pBlock
);
size
=
sizeof
(
SRetrieveMetaTableRsp
)
+
sizeof
(
int32_t
)
+
sizeof
(
SSysTableSchema
)
*
pShow
->
pMeta
->
numOfColumns
+
blockDataGetSize
(
pBlock
)
+
blockDataGetSerialMetaSize
(
pBlock
);
SRetrieveMetaTableRsp
*
pRsp
=
rpcMallocCont
(
size
);
if
(
pRsp
==
NULL
)
{
mndReleaseShowObj
(
(
SShowObj
*
)
pShow
,
false
);
mndReleaseShowObj
(
pShow
,
false
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mError
(
"show:0x%"
PRIx64
", failed to retrieve data since %s"
,
pShow
->
id
,
terrstr
());
blockDataDestroy
(
pBlock
);
...
...
@@ -222,9 +219,8 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
pRsp
->
handle
=
htobe64
(
pShow
->
id
);
// if free flag is set, client wants to clean the resources
if
(
rowsRead
>
0
)
{
char
*
pStart
=
pRsp
->
data
;
char
*
pStart
=
pRsp
->
data
;
SSchema
*
ps
=
pShow
->
pMeta
->
pSchemas
;
*
(
int32_t
*
)
pStart
=
htonl
(
pShow
->
pMeta
->
numOfColumns
);
...
...
@@ -245,77 +241,22 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
pRsp
->
numOfRows
=
htonl
(
rowsRead
);
pRsp
->
precision
=
TSDB_TIME_PRECISION_MILLI
;
// millisecond time precision
pReq
->
pRsp
=
pRsp
;
pReq
->
rspLen
=
size
;
pReq
->
pRsp
=
pRsp
;
pReq
->
rspLen
=
size
;
if
(
rowsRead
==
0
||
rowsRead
<
rowsToRead
)
{
pRsp
->
completed
=
1
;
mDebug
(
"show:0x%"
PRIx64
", retrieve completed"
,
pShow
->
id
);
mndReleaseShowObj
(
(
SShowObj
*
)
pShow
,
true
);
mndReleaseShowObj
(
pShow
,
true
);
}
else
{
mDebug
(
"show:0x%"
PRIx64
", retrieve not completed yet"
,
pShow
->
id
);
mndReleaseShowObj
(
(
SShowObj
*
)
pShow
,
false
);
mndReleaseShowObj
(
pShow
,
false
);
}
blockDataDestroy
(
pBlock
);
return
TSDB_CODE_SUCCESS
;
}
char
*
mndShowStr
(
int32_t
showType
)
{
switch
(
showType
)
{
case
TSDB_MGMT_TABLE_ACCT
:
return
"show accounts"
;
case
TSDB_MGMT_TABLE_USER
:
return
"show users"
;
case
TSDB_MGMT_TABLE_DB
:
return
"show databases"
;
case
TSDB_MGMT_TABLE_TABLE
:
return
"show tables"
;
case
TSDB_MGMT_TABLE_DNODE
:
return
"show dnodes"
;
case
TSDB_MGMT_TABLE_MNODE
:
return
"show mnodes"
;
case
TSDB_MGMT_TABLE_QNODE
:
return
"show qnodes"
;
case
TSDB_MGMT_TABLE_SNODE
:
return
"show snodes"
;
case
TSDB_MGMT_TABLE_BNODE
:
return
"show bnodes"
;
case
TSDB_MGMT_TABLE_VGROUP
:
return
"show vgroups"
;
case
TSDB_MGMT_TABLE_STB
:
return
"show stables"
;
case
TSDB_MGMT_TABLE_MODULE
:
return
"show modules"
;
case
TSDB_MGMT_TABLE_QUERIES
:
return
"show queries"
;
case
TSDB_MGMT_TABLE_STREAMS
:
return
"show streams"
;
case
TSDB_MGMT_TABLE_VARIABLES
:
return
"show configs"
;
case
TSDB_MGMT_TABLE_CONNS
:
return
"show connections"
;
case
TSDB_MGMT_TABLE_TRANS
:
return
"show trans"
;
case
TSDB_MGMT_TABLE_GRANTS
:
return
"show grants"
;
case
TSDB_MGMT_TABLE_VNODES
:
return
"show vnodes"
;
case
TSDB_MGMT_TABLE_CLUSTER
:
return
"show cluster"
;
case
TSDB_MGMT_TABLE_STREAMTABLES
:
return
"show streamtables"
;
case
TSDB_MGMT_TABLE_TP
:
return
"show topics"
;
case
TSDB_MGMT_TABLE_FUNC
:
return
"show functions"
;
case
TSDB_MGMT_TABLE_INDEX
:
return
"show indexes"
;
default:
return
"undefined"
;
}
}
static
bool
mndCheckRetrieveFinished
(
SShowObj
*
pShow
)
{
if
(
pShow
->
pIter
==
NULL
&&
pShow
->
numOfRows
!=
0
)
{
return
true
;
...
...
@@ -323,14 +264,6 @@ static bool mndCheckRetrieveFinished(SShowObj *pShow) {
return
false
;
}
void
mndVacuumResult
(
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
);
}
}
}
void
mndAddShowRetrieveHandle
(
SMnode
*
pMnode
,
EShowType
showType
,
ShowRetrieveFp
fp
)
{
SShowMgmt
*
pMgmt
=
&
pMnode
->
showMgmt
;
pMgmt
->
retrieveFps
[
showType
]
=
fp
;
...
...
source/dnode/mnode/impl/src/mndSma.c
浏览文件 @
585942ce
...
...
@@ -724,46 +724,6 @@ static int32_t mndProcessVDropSmaRsp(SNodeMsg *pRsp) {
return
0
;
}
static
int32_t
mndGetSmaMeta
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
STableMetaRsp
*
pMeta
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
pSchemas
;
pShow
->
bytes
[
cols
]
=
TSDB_INDEX_NAME_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"name"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
8
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
strcpy
(
pSchema
[
cols
].
name
,
"create_time"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"stb"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pMeta
->
numOfColumns
=
cols
;
pShow
->
numOfColumns
=
cols
;
pShow
->
offset
[
0
]
=
0
;
for
(
int32_t
i
=
1
;
i
<
cols
;
++
i
)
{
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
}
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_SMA
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tbName
,
mndShowStr
(
pShow
->
type
));
return
0
;
}
static
int32_t
mndRetrieveSma
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
585942ce
...
...
@@ -58,8 +58,8 @@ int32_t mndInitStream(SMnode *pMnode) {
/*mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM, mndProcessDropStreamReq);*/
/*mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM_RSP, mndProcessDropStreamInRsp);*/
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TP
, mndRetrieveStream);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_T
P
,
mndCancelGetNextStream
);
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TOPICS
, mndRetrieveStream);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_T
OPICS
,
mndCancelGetNextStream
);
return
sdbSetTable
(
pMnode
->
pSdb
,
table
);
}
...
...
@@ -421,50 +421,6 @@ static int32_t mndGetNumOfStreams(SMnode *pMnode, char *dbName, int32_t *pNumOfS
return
0
;
}
static
int32_t
mndGetStreamMeta
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
STableMetaRsp
*
pMeta
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
if
(
mndGetNumOfStreams
(
pMnode
,
pShow
->
db
,
&
pShow
->
numOfRows
)
!=
0
)
{
return
-
1
;
}
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
pSchemas
;
pShow
->
bytes
[
cols
]
=
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"name"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
8
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
strcpy
(
pSchema
[
cols
].
name
,
"create_time"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
TSDB_SHOW_SQL_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"sql"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pMeta
->
numOfColumns
=
cols
;
pShow
->
numOfColumns
=
cols
;
pShow
->
offset
[
0
]
=
0
;
for
(
int32_t
i
=
1
;
i
<
cols
;
++
i
)
{
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
}
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_STREAM
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tbName
,
mndShowStr
(
pShow
->
type
));
return
0
;
}
static
int32_t
mndRetrieveStream
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
585942ce
...
...
@@ -35,7 +35,6 @@ static int32_t mndTopicActionUpdate(SSdb *pSdb, SMqTopicObj *pTopic, SMqTopicObj
static
int32_t
mndProcessCreateTopicReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessDropTopicReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessDropTopicInRsp
(
SNodeMsg
*
pRsp
);
static
int32_t
mndGetTopicMeta
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
STableMetaRsp
*
pMeta
);
static
int32_t
mndRetrieveTopic
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextTopic
(
SMnode
*
pMnode
,
void
*
pIter
);
...
...
@@ -52,8 +51,8 @@ int32_t mndInitTopic(SMnode *pMnode) {
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_TOPIC
,
mndProcessDropTopicReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_VND_DROP_TOPIC_RSP
,
mndProcessDropTopicInRsp
);
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_T
P
, mndRetrieveTopic);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_T
P
,
mndCancelGetNextTopic
);
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_T
OPICS
, mndRetrieveTopic);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_T
OPICS
,
mndCancelGetNextTopic
);
return
sdbSetTable
(
pMnode
->
pSdb
,
table
);
}
...
...
@@ -510,50 +509,6 @@ static int32_t mndGetNumOfTopics(SMnode *pMnode, char *dbName, int32_t *pNumOfTo
return
0
;
}
static
int32_t
mndGetTopicMeta
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
STableMetaRsp
*
pMeta
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
if
(
mndGetNumOfTopics
(
pMnode
,
pShow
->
db
,
&
pShow
->
numOfRows
)
!=
0
)
{
return
-
1
;
}
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
pSchemas
;
pShow
->
bytes
[
cols
]
=
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"name"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
8
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
strcpy
(
pSchema
[
cols
].
name
,
"create_time"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
TSDB_SHOW_SQL_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"sql"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pMeta
->
numOfColumns
=
cols
;
pShow
->
numOfColumns
=
cols
;
pShow
->
offset
[
0
]
=
0
;
for
(
int32_t
i
=
1
;
i
<
cols
;
++
i
)
{
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
}
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_TOPIC
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tbName
,
mndShowStr
(
pShow
->
type
));
return
0
;
}
static
int32_t
mndRetrieveTopic
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
585942ce
...
...
@@ -58,7 +58,6 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans);
static
int32_t
mndProcessTransReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessKillTransReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndGetTransMeta
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
STableMetaRsp
*
pMeta
);
static
int32_t
mndRetrieveTrans
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextTrans
(
SMnode
*
pMnode
,
void
*
pIter
);
...
...
@@ -1260,69 +1259,6 @@ void mndTransPullup(SMnode *pMnode) {
sdbWriteFile
(
pMnode
->
pSdb
);
}
static
int32_t
mndGetTransMeta
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
STableMetaRsp
*
pMeta
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
pSchemas
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"id"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
8
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
strcpy
(
pSchema
[
cols
].
name
,
"create_time"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
TSDB_TRANS_STAGE_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"stage"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
(
TSDB_DB_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"db"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
TSDB_TRANS_TYPE_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"type"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
8
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
strcpy
(
pSchema
[
cols
].
name
,
"last_exec_time"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
(
TSDB_TRANS_ERROR_LEN
-
1
)
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"last_error"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pMeta
->
numOfColumns
=
cols
;
pShow
->
numOfColumns
=
cols
;
pShow
->
offset
[
0
]
=
0
;
for
(
int32_t
i
=
1
;
i
<
cols
;
++
i
)
{
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
}
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_TRANS
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tbName
,
mndShowStr
(
pShow
->
type
));
return
0
;
}
static
int32_t
mndRetrieveTrans
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
...
...
source/dnode/mnode/impl/test/CMakeLists.txt
浏览文件 @
585942ce
enable_testing
()
#add_subdirectory(user)
#
add_subdirectory(acct)
add_subdirectory
(
acct
)
#add_subdirectory(trans)
#add_subdirectory(qnode)
#add_subdirectory(snode)
#
add_subdirectory(bnode)
add_subdirectory
(
bnode
)
#add_subdirectory(show)
#add_subdirectory(profile)
add_subdirectory
(
dnode
)
#
add_subdirectory(dnode)
#add_subdirectory(mnode)
add_subdirectory
(
db
)
add_subdirectory
(
stb
)
#
add_subdirectory(db)
#
add_subdirectory(stb)
#add_subdirectory(sma)
#add_subdirectory(func)
#add_subdirectory(topic)
source/dnode/mnode/impl/test/acct/CMakeLists.txt
浏览文件 @
585942ce
aux_source_directory
(
.
ACC
T_SRC
)
add_executable
(
mnode_test_acct
${
ACC
T_SRC
}
)
aux_source_directory
(
.
MNODE_ACCT_TES
T_SRC
)
add_executable
(
acctTest
${
MNODE_ACCT_TES
T_SRC
}
)
target_link_libraries
(
mnode_test_acc
t
acctTes
t
PUBLIC sut
)
add_test
(
NAME
mnode_test_acc
t
COMMAND
mnode_test_acc
t
NAME
acctTes
t
COMMAND
acctTes
t
)
source/dnode/mnode/impl/test/acct/acct.cpp
浏览文件 @
585942ce
...
...
@@ -54,17 +54,3 @@ TEST_F(MndTestAcct, 03_Drop_Acct) {
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_MSG_NOT_PROCESSED
);
}
TEST_F
(
MndTestAcct
,
04
_Show_Acct
)
{
SShowReq
showReq
=
{
0
};
showReq
.
type
=
TSDB_MGMT_TABLE_ACCT
;
int32_t
contLen
=
tSerializeSShowReq
(
NULL
,
0
,
&
showReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSShowReq
(
pReq
,
contLen
,
&
showReq
);
tFreeSShowReq
(
&
showReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_SHOW
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_MSG_TYPE
);
}
\ No newline at end of file
source/dnode/mnode/impl/test/bnode/CMakeLists.txt
浏览文件 @
585942ce
aux_source_directory
(
.
S
TEST_SRC
)
add_executable
(
m
node_test_bnode
${
S
TEST_SRC
}
)
aux_source_directory
(
.
MNODE_BNODE_
TEST_SRC
)
add_executable
(
m
bnodeTest
${
MNODE_BNODE_
TEST_SRC
}
)
target_link_libraries
(
m
node_test_bnode
m
bnodeTest
PUBLIC sut
)
add_test
(
NAME m
node_test_bnode
COMMAND m
node_test_bnode
NAME m
bnodeTest
COMMAND m
bnodeTest
)
source/dnode/mnode/impl/test/bnode/bnode.cpp
→
source/dnode/mnode/impl/test/bnode/
m
bnode.cpp
浏览文件 @
585942ce
...
...
@@ -39,14 +39,7 @@ Testbase MndTestBnode::test;
TestServer
MndTestBnode
::
server2
;
TEST_F
(
MndTestBnode
,
01
_Show_Bnode
)
{
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_BNODE
,
""
);
CHECK_META
(
"show bnodes"
,
3
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"id"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_BINARY
,
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
,
"endpoint"
);
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
test
.
SendShowRetrieveReq
();
test
.
SendShowReq
(
TSDB_MGMT_TABLE_BNODE
,
"bnodes"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
...
...
@@ -76,14 +69,8 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_BNODE
,
""
);
CHECK_META
(
"show bnodes"
,
3
);
test
.
SendShowRetrieveReq
();
test
.
SendShowReq
(
TSDB_MGMT_TABLE_BNODE
,
"bnodes"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckBinary
(
"localhost:9018"
,
TSDB_EP_LEN
);
CheckTimestamp
();
}
{
...
...
@@ -115,8 +102,7 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
ASSERT_EQ
(
pRsp
->
code
,
0
);
taosMsleep
(
1300
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowRetrieveReq
();
test
.
SendShowReq
(
TSDB_MGMT_TABLE_DNODE
,
"dnodes"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
}
...
...
@@ -132,16 +118,8 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_BNODE
,
""
);
test
.
SendShowRetrieveReq
();
test
.
SendShowReq
(
TSDB_MGMT_TABLE_BNODE
,
"bnodes"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
CheckInt16
(
1
);
CheckInt16
(
2
);
CheckBinary
(
"localhost:9018"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:9019"
,
TSDB_EP_LEN
);
CheckTimestamp
();
CheckTimestamp
();
}
{
...
...
@@ -156,13 +134,8 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_BNODE
,
""
);
test
.
SendShowRetrieveReq
();
test
.
SendShowReq
(
TSDB_MGMT_TABLE_BNODE
,
"bnodes"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckBinary
(
"localhost:9018"
,
TSDB_EP_LEN
);
CheckTimestamp
();
}
{
...
...
source/dnode/mnode/impl/test/db/CMakeLists.txt
浏览文件 @
585942ce
aux_source_directory
(
.
DB
_SRC
)
add_executable
(
mnode_test_db
${
DB
_SRC
}
)
aux_source_directory
(
.
MNODE_DB_TEST
_SRC
)
add_executable
(
dbTest
${
MNODE_DB_TEST
_SRC
}
)
target_link_libraries
(
mnode_test_db
dbTest
PUBLIC sut
)
...
...
source/dnode/mnode/impl/test/dnode/CMakeLists.txt
浏览文件 @
585942ce
aux_source_directory
(
.
D
TEST_SRC
)
add_executable
(
m
node_test_dnode
${
D
TEST_SRC
}
)
aux_source_directory
(
.
MNODE_DNODE_
TEST_SRC
)
add_executable
(
m
dnodeTest
${
MNODE_DNODE_
TEST_SRC
}
)
target_link_libraries
(
m
node_test_dnode
m
dnodeTest
PUBLIC sut
)
...
...
source/dnode/mnode/impl/test/dnode/dnode.cpp
→
source/dnode/mnode/impl/test/dnode/
m
dnode.cpp
浏览文件 @
585942ce
文件已移动
source/dnode/mnode/impl/test/stb/CMakeLists.txt
浏览文件 @
585942ce
aux_source_directory
(
.
STB
_SRC
)
add_executable
(
mnode_test_stb
${
STB
_SRC
}
)
aux_source_directory
(
.
MNODE_STB_TEST
_SRC
)
add_executable
(
stbTest
${
MNODE_STB_TEST
_SRC
}
)
target_link_libraries
(
mnode_test_stb
stbTest
PUBLIC sut
)
...
...
source/dnode/mnode/impl/test/topic/topic.cpp
浏览文件 @
585942ce
...
...
@@ -101,7 +101,7 @@ TEST_F(MndTestTopic, 01_Create_Topic) {
ASSERT_EQ(pRsp->code, 0);
}
{ test.SendShowMetaReq(TSDB_MGMT_TABLE_T
P
, ""); }
{ test.SendShowMetaReq(TSDB_MGMT_TABLE_T
OPICS
, ""); }
{
int32_t contLen = 0;
...
...
@@ -128,7 +128,7 @@ TEST_F(MndTestTopic, 01_Create_Topic) {
}
{
test.SendShowMetaReq(TSDB_MGMT_TABLE_T
P
, dbname);
test.SendShowMetaReq(TSDB_MGMT_TABLE_T
OPICS
, dbname);
CHECK_META("show topics", 3);
CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE, "name");
...
...
@@ -145,7 +145,7 @@ TEST_F(MndTestTopic, 01_Create_Topic) {
// restart
test.Restart();
test.SendShowMetaReq(TSDB_MGMT_TABLE_T
P
, dbname);
test.SendShowMetaReq(TSDB_MGMT_TABLE_T
OPICS
, dbname);
test.SendShowRetrieveReq();
EXPECT_EQ(test.GetShowRows(), 1);
...
...
@@ -169,7 +169,7 @@ TEST_F(MndTestTopic, 01_Create_Topic) {
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TOPIC_NOT_EXIST);
test.SendShowMetaReq(TSDB_MGMT_TABLE_T
P
, dbname);
test.SendShowMetaReq(TSDB_MGMT_TABLE_T
OPICS
, dbname);
test.SendShowRetrieveReq();
EXPECT_EQ(test.GetShowRows(), 0);
}
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
585942ce
...
...
@@ -767,24 +767,22 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, SSDataB
// TODO remove it
int32_t
tableType
=
0
;
const
char
*
name
=
tNameGetTableName
(
pName
);
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_USER_DATABASES
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_DB
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_USER_USERS
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_USER
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_DNODES
,
tListLen
(
pName
->
tname
))
==
0
)
{
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_DNODES
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_DNODE
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_LICENCES
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_GRANTS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_MNODES
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_MNODE
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_MODULES
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_MODULE
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_QNODES
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_QNODE
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_SNODES
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_SNODE
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_BNODES
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_BNODE
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_SNODES
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_SNODE
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_CLUSTER
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_CLUSTER
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_USER_DATABASES
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_DB
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_USER_FUNCTIONS
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_FUNC
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_USER_INDEXES
,
tListLen
(
pName
->
tname
))
==
0
)
{
...
...
@@ -795,13 +793,33 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, SSDataB
tableType
=
TSDB_MGMT_TABLE_STREAMS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_USER_TABLES
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_TABLE
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_VGROUPS
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_VGROUP
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED
,
tListLen
(
pName
->
tname
))
==
0
)
{
// tableType = TSDB_MGMT_TABLE_DIST;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_CLUSTER
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_CLUSTER
;
}
else
{
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_USER_USERS
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_USER
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_LICENCES
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_GRANTS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_VGROUPS
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_VGROUP
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_TOPICS
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_TOPICS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_CONSUMERS
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_CONSUMERS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_SUBSCRIBES
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_SUBSCRIBES
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_TRANS
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_TRANS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_SMAS
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_SMAS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_CONFIGS
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_CONFIGS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_CONNS
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_CONNS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_QUERIES
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_QUERIES
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_VNODES
,
tListLen
(
pName
->
tname
))
==
0
)
{
tableType
=
TSDB_MGMT_TABLE_VNODES
;
}
else
{
ASSERT
(
0
);
}
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
585942ce
...
...
@@ -132,30 +132,52 @@ const char* nodesNodeName(ENodeType type) {
return
"DropTopicStmt"
;
case
QUERY_NODE_ALTER_LOCAL_STMT
:
return
"AlterLocalStmt"
;
case
QUERY_NODE_SHOW_DATABASES_STMT
:
return
"ShowDatabaseStmt"
;
case
QUERY_NODE_SHOW_TABLES_STMT
:
return
"ShowTablesStmt"
;
case
QUERY_NODE_SHOW_STABLES_STMT
:
return
"ShowStablesStmt"
;
case
QUERY_NODE_SHOW_USERS_STMT
:
return
"ShowUsersStmt"
;
case
QUERY_NODE_SHOW_DNODES_STMT
:
return
"ShowDnodesStmt"
;
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
return
"ShowVgroupsStmt"
;
case
QUERY_NODE_SHOW_MNODES_STMT
:
return
"ShowMnodesStmt"
;
case
QUERY_NODE_SHOW_MODULES_STMT
:
return
"ShowModulesStmt"
;
case
QUERY_NODE_SHOW_QNODES_STMT
:
return
"ShowQnodesStmt"
;
case
QUERY_NODE_SHOW_SNODES_STMT
:
return
"ShowSnodesStmt"
;
case
QUERY_NODE_SHOW_BNODES_STMT
:
return
"ShowBnodesStmt"
;
case
QUERY_NODE_SHOW_DATABASES_STMT
:
return
"ShowDatabaseStmt"
;
case
QUERY_NODE_SHOW_FUNCTIONS_STMT
:
return
"ShowFunctionsStmt"
;
case
QUERY_NODE_SHOW_INDEXES_STMT
:
return
"ShowIndexesStmt"
;
case
QUERY_NODE_SHOW_STABLES_STMT
:
return
"ShowStablesStmt"
;
case
QUERY_NODE_SHOW_STREAMS_STMT
:
return
"ShowStreamsStmt"
;
case
QUERY_NODE_SHOW_TABLES_STMT
:
return
"ShowTablesStmt"
;
case
QUERY_NODE_SHOW_USERS_STMT
:
return
"ShowUsersStmt"
;
case
QUERY_NODE_SHOW_LICENCE_STMT
:
return
"ShowGrantsStmt"
;
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
return
"ShowVgroupsStmt"
;
case
QUERY_NODE_SHOW_TOPICS_STMT
:
return
"ShowTopicsStmt"
;
case
QUERY_NODE_SHOW_CONSUMERS_STMT
:
return
"ShowConsumersStmt"
;
case
QUERY_NODE_SHOW_SUBSCRIBES_STMT
:
return
"ShowSubscribesStmt"
;
case
QUERY_NODE_SHOW_TRANS_STMT
:
return
"ShowTransStmt"
;
case
QUERY_NODE_SHOW_SMAS_STMT
:
return
"ShowSmasStmt"
;
case
QUERY_NODE_SHOW_CONFIGS_STMT
:
return
"ShowConfigsStmt"
;
case
QUERY_NODE_SHOW_QUERIES_STMT
:
return
"ShowQueriesStmt"
;
case
QUERY_NODE_SHOW_VNODES_STMT
:
return
"ShowVnodeStmt"
;
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
return
"LogicScan"
;
case
QUERY_NODE_LOGIC_PLAN_JOIN
:
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
585942ce
...
...
@@ -146,30 +146,29 @@ SNodeptr nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
SDescribeStmt
));
case
QUERY_NODE_RESET_QUERY_CACHE_STMT
:
return
makeNode
(
type
,
sizeof
(
SNode
));
case
QUERY_NODE_SHOW_DATABASES_STMT
:
case
QUERY_NODE_SHOW_TABLES_STMT
:
case
QUERY_NODE_SHOW_STABLES_STMT
:
case
QUERY_NODE_SHOW_USERS_STMT
:
case
QUERY_NODE_SHOW_DNODES_STMT
:
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
case
QUERY_NODE_SHOW_MNODES_STMT
:
case
QUERY_NODE_SHOW_MODULES_STMT
:
case
QUERY_NODE_SHOW_QNODES_STMT
:
case
QUERY_NODE_SHOW_SNODES_STMT
:
case
QUERY_NODE_SHOW_BNODES_STMT
:
case
QUERY_NODE_SHOW_DATABASES_STMT
:
case
QUERY_NODE_SHOW_FUNCTIONS_STMT
:
case
QUERY_NODE_SHOW_INDEXES_STMT
:
case
QUERY_NODE_SHOW_STABLES_STMT
:
case
QUERY_NODE_SHOW_STREAMS_STMT
:
case
QUERY_NODE_SHOW_
APP
S_STMT
:
case
QUERY_NODE_SHOW_
CONNECTION
S_STMT
:
case
QUERY_NODE_SHOW_
TABLE
S_STMT
:
case
QUERY_NODE_SHOW_
USER
S_STMT
:
case
QUERY_NODE_SHOW_LICENCE_STMT
:
case
QUERY_NODE_SHOW_CREATE_DATABASE_STMT
:
case
QUERY_NODE_SHOW_CREATE_TABLE_STMT
:
case
QUERY_NODE_SHOW_CREATE_STABLE_STMT
:
case
QUERY_NODE_SHOW_QUERIES_STMT
:
case
QUERY_NODE_SHOW_SCORES_STMT
:
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
case
QUERY_NODE_SHOW_TOPICS_STMT
:
case
QUERY_NODE_SHOW_VARIABLE_STMT
:
case
QUERY_NODE_SHOW_BNODES_STMT
:
case
QUERY_NODE_SHOW_SNODES_STMT
:
case
QUERY_NODE_SHOW_CONSUMERS_STMT
:
case
QUERY_NODE_SHOW_SUBSCRIBES_STMT
:
case
QUERY_NODE_SHOW_TRANS_STMT
:
case
QUERY_NODE_SHOW_SMAS_STMT
:
case
QUERY_NODE_SHOW_CONFIGS_STMT
:
case
QUERY_NODE_SHOW_QUERIES_STMT
:
case
QUERY_NODE_SHOW_VNODES_STMT
:
return
makeNode
(
type
,
sizeof
(
SShowStmt
));
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
return
makeNode
(
type
,
sizeof
(
SScanLogicNode
));
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
585942ce
...
...
@@ -911,18 +911,6 @@ SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, S
return
(
SNode
*
)
pStmt
;
}
SNode
*
createShowCreateDatabaseStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDbName
)
{
SNode
*
pStmt
=
nodesMakeNode
(
QUERY_NODE_SHOW_CREATE_DATABASE_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
return
pStmt
;
}
SNode
*
createShowCreateTableStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
SNode
*
pRealTable
)
{
SNode
*
pStmt
=
nodesMakeNode
(
type
);
CHECK_OUT_OF_MEM
(
pStmt
);
return
pStmt
;
}
SNode
*
createCreateUserStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pUserName
,
const
SToken
*
pPassword
)
{
char
password
[
TSDB_USET_PASSWORD_LEN
]
=
{
0
};
if
(
!
checkUserName
(
pCxt
,
pUserName
)
||
!
checkPassword
(
pCxt
,
pPassword
,
password
))
{
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
585942ce
...
...
@@ -1763,24 +1763,20 @@ static int32_t translateAlterDnode(STranslateContext* pCxt, SAlterDnodeStmt* pSt
}
static
int32_t
nodeTypeToShowType
(
ENodeType
nt
)
{
switch
(
nt
)
{
case
QUERY_NODE_SHOW_APPS_STMT
:
return
0
;
// todo
case
QUERY_NODE_SHOW_CONNECTIONS_STMT
:
return
TSDB_MGMT_TABLE_CONNS
;
case
QUERY_NODE_SHOW_LICENCE_STMT
:
return
TSDB_MGMT_TABLE_GRANTS
;
case
QUERY_NODE_SHOW_QUERIES_STMT
:
return
TSDB_MGMT_TABLE_QUERIES
;
case
QUERY_NODE_SHOW_SCORES_STMT
:
return
0
;
// todo
case
QUERY_NODE_SHOW_TOPICS_STMT
:
return
0
;
// todo
case
QUERY_NODE_SHOW_VARIABLE_STMT
:
return
TSDB_MGMT_TABLE_VARIABLES
;
default:
break
;
}
// switch (nt) {
// case QUERY_NODE_SHOW_CONNECTIONS_STMT:
// return TSDB_MGMT_TABLE_CONNS;
// case QUERY_NODE_SHOW_LICENCE_STMT:
// return TSDB_MGMT_TABLE_GRANTS;
// case QUERY_NODE_SHOW_QUERIES_STMT:
// return TSDB_MGMT_TABLE_QUERIES;
// case QUERY_NODE_SHOW_TOPICS_STMT:
// return 0; // todo
// case QUERY_NODE_SHOW_VARIABLE_STMT:
// return TSDB_MGMT_TABLE_VARIABLES;
// default:
// break;
// }
return
0
;
}
...
...
@@ -2120,19 +2116,11 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
case
QUERY_NODE_ALTER_DNODE_STMT
:
code
=
translateAlterDnode
(
pCxt
,
(
SAlterDnodeStmt
*
)
pNode
);
break
;
case
QUERY_NODE_SHOW_APPS_STMT
:
case
QUERY_NODE_SHOW_CONNECTIONS_STMT
:
case
QUERY_NODE_SHOW_QUERIES_STMT
:
case
QUERY_NODE_SHOW_SCORES_STMT
:
case
QUERY_NODE_SHOW_TOPICS_STMT
:
case
QUERY_NODE_SHOW_VARIABLE_STMT
:
code
=
translateShow
(
pCxt
,
(
SShowStmt
*
)
pNode
);
break
;
case
QUERY_NODE_SHOW_CREATE_DATABASE_STMT
:
case
QUERY_NODE_SHOW_CREATE_TABLE_STMT
:
case
QUERY_NODE_SHOW_CREATE_STABLE_STMT
:
// todo
break
;
case
QUERY_NODE_CREATE_INDEX_STMT
:
code
=
translateCreateIndex
(
pCxt
,
(
SCreateIndexStmt
*
)
pNode
);
break
;
...
...
@@ -2303,7 +2291,6 @@ static const char* getSysDbName(ENodeType type) {
case
QUERY_NODE_SHOW_SNODES_STMT
:
case
QUERY_NODE_SHOW_LICENCE_STMT
:
return
TSDB_INFORMATION_SCHEMA_DB
;
case
QUERY_NODE_SHOW_APPS_STMT
:
case
QUERY_NODE_SHOW_CONNECTIONS_STMT
:
case
QUERY_NODE_SHOW_QUERIES_STMT
:
return
TSDB_PERFORMANCE_SCHEMA_DB
;
...
...
@@ -2345,7 +2332,6 @@ static const char* getSysTableName(ENodeType type) {
return
TSDB_INS_TABLE_SNODES
;
case
QUERY_NODE_SHOW_LICENCE_STMT
:
return
TSDB_INS_TABLE_LICENCES
;
case
QUERY_NODE_SHOW_APPS_STMT
:
case
QUERY_NODE_SHOW_CONNECTIONS_STMT
:
case
QUERY_NODE_SHOW_QUERIES_STMT
:
// todo
...
...
@@ -2871,7 +2857,6 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
case
QUERY_NODE_SHOW_STREAMS_STMT
:
case
QUERY_NODE_SHOW_BNODES_STMT
:
case
QUERY_NODE_SHOW_SNODES_STMT
:
case
QUERY_NODE_SHOW_APPS_STMT
:
case
QUERY_NODE_SHOW_CONNECTIONS_STMT
:
case
QUERY_NODE_SHOW_QUERIES_STMT
:
code
=
rewriteShow
(
pCxt
,
pQuery
);
...
...
source/libs/parser/src/sql.c
浏览文件 @
585942ce
...
...
@@ -3178,7 +3178,7 @@ static YYACTIONTYPE yy_reduce(
{
pCxt
->
valid
=
false
;
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_EXPRIE_STATEMENT
);
}
break
;
case
181
:
/* cmd ::= SHOW APPS */
{
pCxt
->
pRootNode
=
createShowStmt
(
pCxt
,
QUERY_NODE_SHOW_APPS_STMT
,
NULL
,
NULL
);
}
//
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT, NULL, NULL); }
break
;
case
182
:
/* cmd ::= SHOW CONNECTIONS */
{
pCxt
->
pRootNode
=
createShowStmt
(
pCxt
,
QUERY_NODE_SHOW_CONNECTIONS_STMT
,
NULL
,
NULL
);
}
...
...
@@ -3188,25 +3188,25 @@ static YYACTIONTYPE yy_reduce(
{
pCxt
->
pRootNode
=
createShowStmt
(
pCxt
,
QUERY_NODE_SHOW_LICENCE_STMT
,
NULL
,
NULL
);
}
break
;
case
185
:
/* cmd ::= SHOW CREATE DATABASE db_name */
{
pCxt
->
pRootNode
=
createShowCreateDatabaseStmt
(
pCxt
,
&
yymsp
[
0
].
minor
.
yy40
9
);
}
// { pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy2
9); }
break
;
case
186
:
/* cmd ::= SHOW CREATE TABLE full_table_name */
{
pCxt
->
pRootNode
=
createShowCreateTableStmt
(
pCxt
,
QUERY_NODE_SHOW_CREATE_TABLE_STMT
,
yymsp
[
0
].
minor
.
yy504
);
}
// { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy182
); }
break
;
case
187
:
/* cmd ::= SHOW CREATE STABLE full_table_name */
{
pCxt
->
pRootNode
=
createShowCreateTableStmt
(
pCxt
,
QUERY_NODE_SHOW_CREATE_STABLE_STMT
,
yymsp
[
0
].
minor
.
yy504
);
}
// { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy182
); }
break
;
case
188
:
/* cmd ::= SHOW QUERIES */
{
pCxt
->
pRootNode
=
createShowStmt
(
pCxt
,
QUERY_NODE_SHOW_QUERIES_STMT
,
NULL
,
NULL
);
}
break
;
case
189
:
/* cmd ::= SHOW SCORES */
{
pCxt
->
pRootNode
=
createShowStmt
(
pCxt
,
QUERY_NODE_SHOW_SCORES_STMT
,
NULL
,
NULL
);
}
//
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT, NULL, NULL); }
break
;
case
190
:
/* cmd ::= SHOW TOPICS */
{
pCxt
->
pRootNode
=
createShowStmt
(
pCxt
,
QUERY_NODE_SHOW_TOPICS_STMT
,
NULL
,
NULL
);
}
break
;
case
191
:
/* cmd ::= SHOW VARIABLES */
{
pCxt
->
pRootNode
=
createShowStmt
(
pCxt
,
QUERY_NODE_SHOW_VARIABLE_STMT
,
NULL
,
NULL
);
}
//
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLE_STMT, NULL, NULL); }
break
;
case
192
:
/* cmd ::= SHOW BNODES */
{
pCxt
->
pRootNode
=
createShowStmt
(
pCxt
,
QUERY_NODE_SHOW_BNODES_STMT
,
NULL
,
NULL
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录