@@ -44,32 +44,45 @@ where
44
44
45
45
trace ! ( "Admin query: {}" , query) ;
46
46
47
- if query. starts_with ( "SHOW STATS" ) {
48
- trace ! ( "SHOW STATS" ) ;
49
- show_stats ( stream) . await
50
- } else if query. starts_with ( "RELOAD" ) {
51
- trace ! ( "RELOAD" ) ;
52
- reload ( stream, client_server_map) . await
53
- } else if query. starts_with ( "SHOW CONFIG" ) {
54
- trace ! ( "SHOW CONFIG" ) ;
55
- show_config ( stream) . await
56
- } else if query. starts_with ( "SHOW DATABASES" ) {
57
- trace ! ( "SHOW DATABASES" ) ;
58
- show_databases ( stream) . await
59
- } else if query. starts_with ( "SHOW POOLS" ) {
60
- trace ! ( "SHOW POOLS" ) ;
61
- show_pools ( stream) . await
62
- } else if query. starts_with ( "SHOW LISTS" ) {
63
- trace ! ( "SHOW LISTS" ) ;
64
- show_lists ( stream) . await
65
- } else if query. starts_with ( "SHOW VERSION" ) {
66
- trace ! ( "SHOW VERSION" ) ;
67
- show_version ( stream) . await
68
- } else if query. starts_with ( "SET " ) {
69
- trace ! ( "SET" ) ;
70
- ignore_set ( stream) . await
71
- } else {
72
- error_response ( stream, "Unsupported query against the admin database" ) . await
47
+ let query_parts: Vec < & str > = query. trim_end_matches ( ';' ) . split_whitespace ( ) . collect ( ) ;
48
+
49
+ match query_parts[ 0 ] {
50
+ "RELOAD" => {
51
+ trace ! ( "RELOAD" ) ;
52
+ reload ( stream, client_server_map) . await
53
+ }
54
+ "SET" => {
55
+ trace ! ( "SET" ) ;
56
+ ignore_set ( stream) . await
57
+ }
58
+ "SHOW" => match query_parts[ 1 ] {
59
+ "CONFIG" => {
60
+ trace ! ( "SHOW CONFIG" ) ;
61
+ show_config ( stream) . await
62
+ }
63
+ "DATABASES" => {
64
+ trace ! ( "SHOW DATABASES" ) ;
65
+ show_databases ( stream) . await
66
+ }
67
+ "LISTS" => {
68
+ trace ! ( "SHOW LISTS" ) ;
69
+ show_lists ( stream) . await
70
+ }
71
+ "POOLS" => {
72
+ trace ! ( "SHOW POOLS" ) ;
73
+ show_pools ( stream) . await
74
+ }
75
+ "STATS" => {
76
+ trace ! ( "SHOW STATS" ) ;
77
+ show_stats ( stream) . await
78
+ }
79
+ "VERSION" => {
80
+ trace ! ( "SHOW VERSION" ) ;
81
+ show_version ( stream) . await
82
+ }
83
+ _ => error_response ( stream, "Unsupported SHOW query against the admin database" ) . await ,
84
+ } ,
85
+ _ => error_response ( stream, "Unsupported query against the admin database" ) . await ,
73
86
}
74
87
}
75
88
0 commit comments