Skip to content

Commit

Permalink
Expose nonsuper_connections as a new status variable (#1070)
Browse files Browse the repository at this point in the history
Summary:
Expose nonsuper_connections as a new status variable

Squash with D13987618

Reference Patch: a4de2e872ca

Pull Request resolved: #1070

Reviewed By: yizhang82

Differential Revision: D19161994

Pulled By: mzait

fbshipit-source-id: e6be893
  • Loading branch information
mzait authored and facebook-github-bot committed Dec 30, 2019
1 parent 8a269ee commit c53bf24
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mysql-test/r/max_nonsuper_connections.result
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SET @@global.max_nonsuper_connections = 10;
SELECT @@global.max_nonsuper_connections;
@@global.max_nonsuper_connections
10
include/assert.inc [Non_super_connections should be 0]
connection default;
connect con$i, localhost, test_user,,test;
connect con$i, localhost, test_user,,test;
Expand All @@ -25,13 +26,19 @@ connection con_root;
SELECT @@global.max_nonsuper_connections;
@@global.max_nonsuper_connections
10
include/assert.inc [Non_super_connections should be 10]
connection con_root;
connection con_root;
disconnect con_root;
connection default;
connect con_super, localhost, super_user,,test;
connection con_super;
SELECT @@global.max_nonsuper_connections;
@@global.max_nonsuper_connections
10
include/assert.inc [Non_super_connections should be 10]
connection con_super;
connection con_super;
mysqltest: At line 1: Query 'change_user test_user' failed.
ERROR 1040 (08004): Too many connections
disconnect con_super;
Expand Down Expand Up @@ -89,6 +96,9 @@ SET @@global.max_nonsuper_connections = @start_value;
SELECT @@global.max_nonsuper_connections;
@@global.max_nonsuper_connections
0
include/assert.inc [Non_super_connections should be 10]
connection default;
connection default;
drop user test_user@localhost;
drop user super_user@localhost;
disconnect con10;
Expand Down
14 changes: 14 additions & 0 deletions mysql-test/t/max_nonsuper_connections.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ SET @start_value = @@global.max_nonsuper_connections;

SET @@global.max_nonsuper_connections = 10;
SELECT @@global.max_nonsuper_connections;
--let $assert_text= Non_super_connections should be 0
--let $assert_cond= "[SHOW GLOBAL STATUS like \'Non_super_connections\', Value, 1]" = "0"
--source include/assert.inc

enable_connect_log;
connection default;
Expand Down Expand Up @@ -40,6 +43,10 @@ connect (con_root, localhost, root,,test);
--echo # connection con_root
connection con_root;
SELECT @@global.max_nonsuper_connections;
--let $assert_text= Non_super_connections should be 10
--let $assert_cond= "[SHOW GLOBAL STATUS like \'Non_super_connections\', Value, 1]" = "10"
--source include/assert.inc

disconnect con_root;
connection default;

Expand All @@ -49,6 +56,9 @@ connection default;
connect (con_super, localhost, super_user,,test);
connection con_super;
SELECT @@global.max_nonsuper_connections;
--let $assert_text= Non_super_connections should be 10
--let $assert_cond= "[SHOW GLOBAL STATUS like \'Non_super_connections\', Value, 1]" = "10"
--source include/assert.inc

#
# change admin user to regular user in the current connection will fail
Expand Down Expand Up @@ -129,6 +139,10 @@ enable_query_log;
connection default;
SET @@global.max_nonsuper_connections = @start_value;
SELECT @@global.max_nonsuper_connections;
--let $assert_text= Non_super_connections should be 10
--let $assert_cond= "[SHOW GLOBAL STATUS like \'Non_super_connections\', Value, 1]" = "10"
--source include/assert.inc

drop user test_user@localhost;
drop user super_user@localhost;
let $i= 10;
Expand Down
2 changes: 2 additions & 0 deletions sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8970,6 +8970,8 @@ SHOW_VAR status_vars[] = {
SHOW_SCOPE_GLOBAL},
{"Max_used_connections_time", (char *)&show_max_used_connections_time,
SHOW_FUNC, SHOW_SCOPE_GLOBAL},
{"Non_super_connections", (char *)&nonsuper_connections, SHOW_LONG,
SHOW_SCOPE_GLOBAL},
{"Not_flushed_delayed_rows", (char *)&delayed_rows_in_use,
SHOW_LONG_NOFLUSH, SHOW_SCOPE_GLOBAL},
{"Open_files", (char *)&my_file_opened, SHOW_LONG_NOFLUSH,
Expand Down

0 comments on commit c53bf24

Please sign in to comment.