Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Tonvia
TDengine
提交
f73aaccb
T
TDengine
项目概览
Tonvia
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f73aaccb
编写于
11月 26, 2019
作者:
L
lihui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TBASE-570]
上级
bb5a0f82
变更
11
展开全部
显示空白变更内容
内联
并排
Showing
11 changed file
with
1554 addition
and
1808 deletion
+1554
-1808
src/client/inc/tscSQLParser.h
src/client/inc/tscSQLParser.h
+1
-0
src/client/src/sql.c
src/client/src/sql.c
+1268
-1665
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+18
-1
src/client/src/tscServer.c
src/client/src/tscServer.c
+1
-1
src/inc/sql.y
src/inc/sql.y
+4
-1
src/inc/taosmsg.h
src/inc/taosmsg.h
+1
-0
src/inc/tsqldef.h
src/inc/tsqldef.h
+139
-140
src/system/detail/inc/mgmt.h
src/system/detail/inc/mgmt.h
+3
-0
src/system/detail/src/mgmtDnode.c
src/system/detail/src/mgmtDnode.c
+116
-0
src/system/detail/src/mgmtShell.c
src/system/detail/src/mgmtShell.c
+2
-0
src/util/src/ttokenizer.c
src/util/src/ttokenizer.c
+1
-0
未找到文件。
src/client/inc/tscSQLParser.h
浏览文件 @
f73aaccb
...
...
@@ -105,6 +105,7 @@ enum TSQL_TYPE {
SHOW_MODULES
=
0x6c
,
SHOW_CONNECTIONS
=
0x6d
,
SHOW_GRANTS
=
0x6e
,
SHOW_VNODES
=
0x6f
,
// create dnode
CREATE_DNODE
=
0x80
,
...
...
src/client/src/sql.c
浏览文件 @
f73aaccb
此差异已折叠。
点击以展开。
src/client/src/tscSQLParser.c
浏览文件 @
f73aaccb
...
...
@@ -291,7 +291,8 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
case
SHOW_STREAMS
:
case
SHOW_SCORES
:
case
SHOW_GRANTS
:
case
SHOW_CONFIGS
:
{
case
SHOW_CONFIGS
:
case
SHOW_VNODES
:
{
return
setShowInfo
(
pSql
,
pInfo
);
}
...
...
@@ -2595,6 +2596,9 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
case
SHOW_CONFIGS
:
pCmd
->
showType
=
TSDB_MGMT_TABLE_CONFIGS
;
break
;
case
SHOW_VNODES
:
pCmd
->
showType
=
TSDB_MGMT_TABLE_VNODES
;
break
;
default:
return
TSDB_CODE_INVALID_SQL
;
}
...
...
@@ -2640,6 +2644,19 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
}
}
}
else
if
(
type
==
SHOW_VNODES
)
{
// show vnodes may be ip addr of dnode in payload
if
(
pInfo
->
pDCLInfo
->
nTokens
>
0
)
{
SSQLToken
*
pDnodeIp
=
&
pInfo
->
pDCLInfo
->
a
[
0
];
if
(
pDnodeIp
->
n
>
TSDB_IPv4ADDR_LEN
)
{
// ip addr is too long
setErrMsg
(
pCmd
,
msg
);
return
TSDB_CODE_INVALID_SQL
;
}
strncpy
(
pCmd
->
payload
,
pDnodeIp
->
z
,
pDnodeIp
->
n
);
pCmd
->
payloadLen
=
strdequote
(
pCmd
->
payload
);
}
}
return
TSDB_CODE_SUCCESS
;
...
...
src/client/src/tscServer.c
浏览文件 @
f73aaccb
...
...
@@ -2175,7 +2175,7 @@ int tscBuildShowMsg(SSqlObj *pSql) {
pShowMsg
=
(
SShowMsg
*
)
pMsg
;
pShowMsg
->
type
=
pCmd
->
showType
;
if
((
pShowMsg
->
type
==
TSDB_MGMT_TABLE_TABLE
||
pShowMsg
->
type
==
TSDB_MGMT_TABLE_METRIC
)
&&
pCmd
->
payloadLen
!=
0
)
{
if
((
pShowMsg
->
type
==
TSDB_MGMT_TABLE_TABLE
||
pShowMsg
->
type
==
TSDB_MGMT_TABLE_METRIC
||
pShowMsg
->
type
==
TSDB_MGMT_TABLE_VNODES
)
&&
pCmd
->
payloadLen
!=
0
)
{
// only show tables support wildcard query
pShowMsg
->
payloadLen
=
htons
(
pCmd
->
payloadLen
);
memcpy
(
pShowMsg
->
payload
,
payload
,
pCmd
->
payloadLen
);
...
...
src/inc/sql.y
浏览文件 @
f73aaccb
...
...
@@ -73,6 +73,9 @@ cmd ::= SHOW CONFIGS. { setDCLSQLElems(pInfo, SHOW_CONFIGS, 0); }
cmd ::= SHOW SCORES. { setDCLSQLElems(pInfo, SHOW_SCORES, 0); }
cmd ::= SHOW GRANTS. { setDCLSQLElems(pInfo, SHOW_GRANTS, 0); }
cmd ::= SHOW VNODES. { setDCLSQLElems(pInfo, SHOW_VNODES, 0); }
cmd ::= SHOW VNODES IPTOKEN(X). { setDCLSQLElems(pInfo, SHOW_VNODES, 1, &X); }
%type dbPrefix {SSQLToken}
dbPrefix(A) ::=. {A.n = 0;}
dbPrefix(A) ::= ids(X) DOT. {A = X; }
...
...
src/inc/taosmsg.h
浏览文件 @
f73aaccb
...
...
@@ -158,6 +158,7 @@ enum _mgmt_table {
TSDB_MGMT_TABLE_CONNS
,
TSDB_MGMT_TABLE_SCORES
,
TSDB_MGMT_TABLE_GRANTS
,
TSDB_MGMT_TABLE_VNODES
,
TSDB_MGMT_TABLE_MAX
,
};
...
...
src/inc/tsqldef.h
浏览文件 @
f73aaccb
...
...
@@ -72,145 +72,144 @@
#define TK_CONFIGS 54
#define TK_SCORES 55
#define TK_GRANTS 56
#define TK_DOT 57
#define TK_TABLES 58
#define TK_STABLES 59
#define TK_VGROUPS 60
#define TK_DROP 61
#define TK_TABLE 62
#define TK_DATABASE 63
#define TK_DNODE 64
#define TK_IPTOKEN 65
#define TK_USER 66
#define TK_ACCOUNT 67
#define TK_USE 68
#define TK_DESCRIBE 69
#define TK_ALTER 70
#define TK_PASS 71
#define TK_PRIVILEGE 72
#define TK_LOCAL 73
#define TK_IF 74
#define TK_EXISTS 75
#define TK_CREATE 76
#define TK_PPS 77
#define TK_TSERIES 78
#define TK_DBS 79
#define TK_STORAGE 80
#define TK_QTIME 81
#define TK_CONNS 82
#define TK_STATE 83
#define TK_KEEP 84
#define TK_CACHE 85
#define TK_REPLICA 86
#define TK_DAYS 87
#define TK_ROWS 88
#define TK_ABLOCKS 89
#define TK_TBLOCKS 90
#define TK_CTIME 91
#define TK_CLOG 92
#define TK_COMP 93
#define TK_PRECISION 94
#define TK_LP 95
#define TK_RP 96
#define TK_TAGS 97
#define TK_USING 98
#define TK_AS 99
#define TK_COMMA 100
#define TK_NULL 101
#define TK_SELECT 102
#define TK_FROM 103
#define TK_VARIABLE 104
#define TK_INTERVAL 105
#define TK_FILL 106
#define TK_SLIDING 107
#define TK_ORDER 108
#define TK_BY 109
#define TK_ASC 110
#define TK_DESC 111
#define TK_GROUP 112
#define TK_HAVING 113
#define TK_LIMIT 114
#define TK_OFFSET 115
#define TK_SLIMIT 116
#define TK_SOFFSET 117
#define TK_WHERE 118
#define TK_NOW 119
#define TK_INSERT 120
#define TK_INTO 121
#define TK_VALUES 122
#define TK_RESET 123
#define TK_QUERY 124
#define TK_ADD 125
#define TK_COLUMN 126
#define TK_TAG 127
#define TK_CHANGE 128
#define TK_SET 129
#define TK_KILL 130
#define TK_CONNECTION 131
#define TK_COLON 132
#define TK_STREAM 133
#define TK_ABORT 134
#define TK_AFTER 135
#define TK_ATTACH 136
#define TK_BEFORE 137
#define TK_BEGIN 138
#define TK_CASCADE 139
#define TK_CLUSTER 140
#define TK_CONFLICT 141
#define TK_COPY 142
#define TK_DEFERRED 143
#define TK_DELIMITERS 144
#define TK_DETACH 145
#define TK_EACH 146
#define TK_END 147
#define TK_EXPLAIN 148
#define TK_FAIL 149
#define TK_FOR 150
#define TK_IGNORE 151
#define TK_IMMEDIATE 152
#define TK_INITIALLY 153
#define TK_INSTEAD 154
#define TK_MATCH 155
#define TK_KEY 156
#define TK_OF 157
#define TK_RAISE 158
#define TK_REPLACE 159
#define TK_RESTRICT 160
#define TK_ROW 161
#define TK_STATEMENT 162
#define TK_TRIGGER 163
#define TK_VIEW 164
#define TK_ALL 165
#define TK_COUNT 166
#define TK_SUM 167
#define TK_AVG 168
#define TK_MIN 169
#define TK_MAX 170
#define TK_FIRST 171
#define TK_LAST 172
#define TK_TOP 173
#define TK_BOTTOM 174
#define TK_STDDEV 175
#define TK_PERCENTILE 176
#define TK_APERCENTILE 177
#define TK_LEASTSQUARES 178
#define TK_HISTOGRAM 179
#define TK_DIFF 180
#define TK_SPREAD 181
#define TK_TWA 182
#define TK_INTERP 183
#define TK_LAST_ROW 184
#define TK_SEMI 185
#define TK_NONE 186
#define TK_PREV 187
#define TK_LINEAR 188
#define TK_IMPORT 189
#define TK_METRIC 190
#define TK_TBNAME 191
#define TK_JOIN 192
#define TK_METRICS 193
#define TK_STABLE 194
#define TK_VNODES 57
#define TK_IPTOKEN 58
#define TK_DOT 59
#define TK_TABLES 60
#define TK_STABLES 61
#define TK_VGROUPS 62
#define TK_DROP 63
#define TK_TABLE 64
#define TK_DATABASE 65
#define TK_DNODE 66
#define TK_USER 67
#define TK_ACCOUNT 68
#define TK_USE 69
#define TK_DESCRIBE 70
#define TK_ALTER 71
#define TK_PASS 72
#define TK_PRIVILEGE 73
#define TK_LOCAL 74
#define TK_IF 75
#define TK_EXISTS 76
#define TK_CREATE 77
#define TK_PPS 78
#define TK_TSERIES 79
#define TK_DBS 80
#define TK_STORAGE 81
#define TK_QTIME 82
#define TK_CONNS 83
#define TK_STATE 84
#define TK_KEEP 85
#define TK_CACHE 86
#define TK_REPLICA 87
#define TK_DAYS 88
#define TK_ROWS 89
#define TK_ABLOCKS 90
#define TK_TBLOCKS 91
#define TK_CTIME 92
#define TK_CLOG 93
#define TK_COMP 94
#define TK_PRECISION 95
#define TK_LP 96
#define TK_RP 97
#define TK_TAGS 98
#define TK_USING 99
#define TK_AS 100
#define TK_COMMA 101
#define TK_NULL 102
#define TK_SELECT 103
#define TK_FROM 104
#define TK_VARIABLE 105
#define TK_INTERVAL 106
#define TK_FILL 107
#define TK_SLIDING 108
#define TK_ORDER 109
#define TK_BY 110
#define TK_ASC 111
#define TK_DESC 112
#define TK_GROUP 113
#define TK_HAVING 114
#define TK_LIMIT 115
#define TK_OFFSET 116
#define TK_SLIMIT 117
#define TK_SOFFSET 118
#define TK_WHERE 119
#define TK_NOW 120
#define TK_INSERT 121
#define TK_INTO 122
#define TK_VALUES 123
#define TK_RESET 124
#define TK_QUERY 125
#define TK_ADD 126
#define TK_COLUMN 127
#define TK_TAG 128
#define TK_CHANGE 129
#define TK_SET 130
#define TK_KILL 131
#define TK_CONNECTION 132
#define TK_COLON 133
#define TK_STREAM 134
#define TK_ABORT 135
#define TK_AFTER 136
#define TK_ATTACH 137
#define TK_BEFORE 138
#define TK_BEGIN 139
#define TK_CASCADE 140
#define TK_CLUSTER 141
#define TK_CONFLICT 142
#define TK_COPY 143
#define TK_DEFERRED 144
#define TK_DELIMITERS 145
#define TK_DETACH 146
#define TK_EACH 147
#define TK_END 148
#define TK_EXPLAIN 149
#define TK_FAIL 150
#define TK_FOR 151
#define TK_IGNORE 152
#define TK_IMMEDIATE 153
#define TK_INITIALLY 154
#define TK_INSTEAD 155
#define TK_MATCH 156
#define TK_KEY 157
#define TK_OF 158
#define TK_RAISE 159
#define TK_REPLACE 160
#define TK_RESTRICT 161
#define TK_ROW 162
#define TK_STATEMENT 163
#define TK_TRIGGER 164
#define TK_VIEW 165
#define TK_ALL 166
#define TK_COUNT 167
#define TK_SUM 168
#define TK_AVG 169
#define TK_MIN 170
#define TK_MAX 171
#define TK_FIRST 172
#define TK_LAST 173
#define TK_TOP 174
#define TK_BOTTOM 175
#define TK_STDDEV 176
#define TK_PERCENTILE 177
#define TK_APERCENTILE 178
#define TK_LEASTSQUARES 179
#define TK_HISTOGRAM 180
#define TK_DIFF 181
#define TK_SPREAD 182
#define TK_TWA 183
#define TK_INTERP 184
#define TK_LAST_ROW 185
#define TK_SEMI 186
#define TK_NONE 187
#define TK_PREV 188
#define TK_LINEAR 189
#define TK_IMPORT 190
#define TK_METRIC 191
#define TK_TBNAME 192
#define TK_JOIN 193
#define TK_METRICS 194
#define TK_STABLE 195
#endif
src/system/detail/inc/mgmt.h
浏览文件 @
f73aaccb
...
...
@@ -410,6 +410,9 @@ int mgmtRetrieveScores(SShowObj *pShow, char *data, int rows, SConnObj *pConn);
int
grantGetGrantsMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int
grantRetrieveGrants
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
);
int
mgmtGetVnodeMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int
mgmtRetrieveVnodes
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
);
// dnode balance api
int
mgmtInitBalance
();
void
mgmtCleanupBalance
();
...
...
src/system/detail/src/mgmtDnode.c
浏览文件 @
f73aaccb
...
...
@@ -389,3 +389,119 @@ int mgmtRetrieveConfigs(SShowObj *pShow, char *data, int rows, SConnObj *pConn)
pShow
->
numOfReads
+=
numOfRows
;
return
numOfRows
;
}
int
mgmtGetVnodeMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
cols
=
0
;
if
(
strcmp
(
pConn
->
pAcct
->
user
,
"root"
)
!=
0
)
return
TSDB_CODE_NO_RIGHTS
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"vnode"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"vgid"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
12
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"status"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
12
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"sync status"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pMeta
->
numOfColumns
=
htons
(
cols
);
pShow
->
numOfColumns
=
cols
;
pShow
->
offset
[
0
]
=
0
;
for
(
int
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
// TODO: if other thread drop dnode ????
SDnodeObj
*
pDnode
=
NULL
;
if
(
pShow
->
payloadLen
>
0
)
{
uint32_t
ip
=
ip2uint
(
pShow
->
payload
);
pDnode
=
mgmtGetDnode
(
ip
);
if
(
NULL
==
pDnode
)
{
return
TSDB_CODE_NODE_OFFLINE
;
}
pShow
->
numOfRows
=
pDnode
->
openVnodes
;
pShow
->
pNode
=
pDnode
;
}
else
{
while
(
true
)
{
pShow
->
pNode
=
mgmtGetNextDnode
(
pShow
,
(
SDnodeObj
**
)
&
pDnode
);
if
(
pDnode
==
NULL
)
break
;
pShow
->
numOfRows
+=
pDnode
->
openVnodes
;
if
(
0
==
pShow
->
numOfRows
)
return
TSDB_CODE_NODE_OFFLINE
;
}
pShow
->
pNode
=
NULL
;
}
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
return
0
;
}
int
mgmtRetrieveVnodes
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
)
{
int
numOfRows
=
0
;
SDnodeObj
*
pDnode
=
NULL
;
char
*
pWrite
;
int
cols
=
0
;
char
ipstr
[
20
];
if
(
0
==
rows
)
return
0
;
if
(
pShow
->
payloadLen
)
{
// output the vnodes info of the designated dnode. And output all vnodes of this dnode, instead of rows (max 100)
pDnode
=
(
SDnodeObj
*
)(
pShow
->
pNode
);
if
(
pDnode
!=
NULL
)
{
SVnodeLoad
*
pVnode
;
for
(
int
i
=
0
;
i
<
TSDB_MAX_VNODES
;
i
++
)
{
pVnode
=
&
pDnode
->
vload
[
i
];
if
(
0
==
pVnode
->
vgId
)
{
continue
;
}
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
uint32_t
*
)
pWrite
=
pVnode
->
vnode
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
uint32_t
*
)
pWrite
=
pVnode
->
vgId
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
taosGetVnodeStatusStr
(
pVnode
->
status
));
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
taosGetVnodeSyncStatusStr
(
pVnode
->
syncStatus
));
cols
++
;
numOfRows
++
;
}
}
}
else
{
// TODO: output all vnodes of all dnodes
numOfRows
=
0
;
}
pShow
->
numOfReads
+=
numOfRows
;
return
numOfRows
;
}
src/system/detail/src/mgmtShell.c
浏览文件 @
f73aaccb
...
...
@@ -788,12 +788,14 @@ int (*mgmtGetMetaFp[])(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) = {
mgmtGetAcctMeta
,
mgmtGetUserMeta
,
mgmtGetDbMeta
,
mgmtGetMeterMeta
,
mgmtGetDnodeMeta
,
mgmtGetMnodeMeta
,
mgmtGetVgroupMeta
,
mgmtGetMetricMeta
,
mgmtGetModuleMeta
,
mgmtGetQueryMeta
,
mgmtGetStreamMeta
,
mgmtGetConfigMeta
,
mgmtGetConnsMeta
,
mgmtGetScoresMeta
,
grantGetGrantsMeta
,
mgmtGetVnodeMeta
,
};
int
(
*
mgmtRetrieveFp
[])(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
)
=
{
mgmtRetrieveAccts
,
mgmtRetrieveUsers
,
mgmtRetrieveDbs
,
mgmtRetrieveMeters
,
mgmtRetrieveDnodes
,
mgmtRetrieveMnodes
,
mgmtRetrieveVgroups
,
mgmtRetrieveMetrics
,
mgmtRetrieveModules
,
mgmtRetrieveQueries
,
mgmtRetrieveStreams
,
mgmtRetrieveConfigs
,
mgmtRetrieveConns
,
mgmtRetrieveScores
,
grantRetrieveGrants
,
mgmtRetrieveVnodes
,
};
int
mgmtProcessShowMsg
(
char
*
pMsg
,
int
msgLen
,
SConnObj
*
pConn
)
{
...
...
src/util/src/ttokenizer.c
浏览文件 @
f73aaccb
...
...
@@ -224,6 +224,7 @@ static SKeyword keywordTable[] = {
{
"METRICS"
,
TK_METRICS
},
{
"STABLE"
,
TK_STABLE
},
{
"FILE"
,
TK_FILE
},
{
"VNODES"
,
TK_VNODES
},
};
/* This is the hash table */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录