1
1
use crate :: pool:: BanReason ;
2
2
use crate :: stats:: pool:: PoolStats ;
3
3
use bytes:: { Buf , BufMut , BytesMut } ;
4
- use log:: { error, info, trace} ;
4
+ use log:: { debug , error, info, trace} ;
5
5
use nix:: sys:: signal:: { self , Signal } ;
6
6
use nix:: unistd:: Pid ;
7
7
use std:: collections:: HashMap ;
84
84
shutdown ( stream) . await
85
85
}
86
86
"SHOW" => match query_parts[ 1 ] . to_ascii_uppercase ( ) . as_str ( ) {
87
+ "HELP" => {
88
+ trace ! ( "SHOW HELP" ) ;
89
+ show_help ( stream) . await
90
+ }
87
91
"BANS" => {
88
92
trace ! ( "SHOW BANS" ) ;
89
93
show_bans ( stream) . await
@@ -271,6 +275,48 @@ where
271
275
write_all_half ( stream, & res) . await
272
276
}
273
277
278
+ /// Show all available options.
279
+ async fn show_help < T > ( stream : & mut T ) -> Result < ( ) , Error >
280
+ where
281
+ T : tokio:: io:: AsyncWrite + std:: marker:: Unpin ,
282
+ {
283
+ let mut res = BytesMut :: new ( ) ;
284
+
285
+
286
+ let detail_msg = vec ! [
287
+ "" ,
288
+ "SHOW HELP|CONFIG|DATABASES|POOLS|CLIENTS|SERVERS|USERS|VERSION" ,
289
+ // "SHOW PEERS|PEER_POOLS", // missing PEERS|PEER_POOLS
290
+ // "SHOW FDS|SOCKETS|ACTIVE_SOCKETS|LISTS|MEM|STATE", // missing FDS|SOCKETS|ACTIVE_SOCKETS|MEM|STATE
291
+ "SHOW LISTS" ,
292
+ // "SHOW DNS_HOSTS|DNS_ZONES", // missing DNS_HOSTS|DNS_ZONES
293
+ "SHOW STATS" , // missing STATS_TOTALS|STATS_AVERAGES|TOTALS
294
+ "SET key = arg" ,
295
+ "RELOAD" ,
296
+ "PAUSE [<db>, <user>]" ,
297
+ "RESUME [<db>, <user>]" ,
298
+ // "DISABLE <db>", // missing
299
+ // "ENABLE <db>", // missing
300
+ // "RECONNECT [<db>]", missing
301
+ // "KILL <db>",
302
+ // "SUSPEND",
303
+ "SHUTDOWN" ,
304
+ // "WAIT_CLOSE [<db>]", // missing
305
+ ] ;
306
+
307
+ res. put ( notify ( "Console usage" , detail_msg. join ( "\n \t " ) ) ) ;
308
+ res. put ( command_complete ( "SHOW" ) ) ;
309
+
310
+ // ReadyForQuery
311
+ res. put_u8 ( b'Z' ) ;
312
+ res. put_i32 ( 5 ) ;
313
+ res. put_u8 ( b'I' ) ;
314
+
315
+ debug ! ( "{:?}" , res) ;
316
+
317
+ write_all_half ( stream, & res) . await
318
+ }
319
+
274
320
/// Show shards and replicas.
275
321
async fn show_databases < T > ( stream : & mut T ) -> Result < ( ) , Error >
276
322
where
0 commit comments