-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDEV-15935 Adding global/session system var redirect_url
Adding a global/session var `redirect_url' of string type. The initial value is empty. Can be supplied in mysqld with --redirect-url or set in --init-connect. A valid redirect_url should be of the format {mysql,mariadb}://host[:port] where <host> is an arbitrary string not containing colons, and <port> is a number between 0 and 65535 inclusive. The variable will be used by the server to notify clients that they should connect to another server, specified by the value of the variable, if not empty. The notification is done by the inclusion of the variable in session_track_system_variable.
- Loading branch information
1 parent
6151bde
commit 5af70de
Showing
12 changed files
with
286 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# | ||
# MDEV-32254 Server crashes when adding records to table after setting redirect_url with empty variable | ||
# | ||
set @old_redirect_url=@@global.redirect_url; | ||
set global redirect_url=@empty_value; | ||
ERROR 42000: Variable 'redirect_url' can't be set to the value of 'NULL' | ||
CREATE TABLE t (c1 INT) ENGINE=INNODB; | ||
INSERT INTO t VALUES (1),(1); | ||
drop table t; | ||
set global redirect_url=@old_redirect_url; | ||
# | ||
# end of test mdev_32254 | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# | ||
# MDEV-15935 Connection Redirection Mechanism in MariaDB Client/Server Protocol | ||
# | ||
connect con,localhost,anyone_but_root; | ||
select @@redirect_url; | ||
@@redirect_url | ||
mysql://foobar | ||
connection default; | ||
set @old_global_redirect_url=@@global.redirect_url; | ||
set @old_session_redirect_url=@@session.redirect_url; | ||
set @old_session_track_system_variables=@@session_track_system_variables; | ||
set session_track_system_variables=""; | ||
select @@global.redirect_url; | ||
@@global.redirect_url | ||
|
||
set global redirect_url=default; | ||
select @@global.redirect_url; | ||
@@global.redirect_url | ||
|
||
set global redirect_url="mariadb.org"; | ||
ERROR 42000: Variable 'redirect_url' can't be set to the value of 'mariadb.org' | ||
set global redirect_url="https://mariadb.org"; | ||
ERROR 42000: Variable 'redirect_url' can't be set to the value of 'https://mariadb.org' | ||
set global redirect_url="mysql://mariadb.org:"; | ||
ERROR 42000: Variable 'redirect_url' can't be set to the value of 'mysql://mariadb.org:' | ||
set global redirect_url="mysql://mariadb.org:hello"; | ||
ERROR 42000: Variable 'redirect_url' can't be set to the value of 'mysql://mariadb.org:hello' | ||
set global redirect_url="mysql://"; | ||
ERROR 42000: Variable 'redirect_url' can't be set to the value of 'mysql://' | ||
set global redirect_url="mysql://mariadb.org"; | ||
select @@global.redirect_url; | ||
@@global.redirect_url | ||
mysql://mariadb.org | ||
set global redirect_url="mysql://mariadb.org:12a"; | ||
ERROR 42000: Variable 'redirect_url' can't be set to the value of 'mysql://mariadb.org:12a' | ||
set global redirect_url="mysql://mariadb.org:66666"; | ||
ERROR 42000: Variable 'redirect_url' can't be set to the value of 'mysql://mariadb.org:66666' | ||
set global redirect_url="mysql://mariadb.org:12345"; | ||
select @@global.redirect_url; | ||
@@global.redirect_url | ||
mysql://mariadb.org:12345 | ||
set global redirect_url="maria"; | ||
ERROR 42000: Variable 'redirect_url' can't be set to the value of 'maria' | ||
set global redirect_url="mariadb://mariadb.org:"; | ||
ERROR 42000: Variable 'redirect_url' can't be set to the value of 'mariadb://mariadb.org:' | ||
set global redirect_url="mariadb://mariadb.org:hello"; | ||
ERROR 42000: Variable 'redirect_url' can't be set to the value of 'mariadb://mariadb.org:hello' | ||
set global redirect_url="mariadb://"; | ||
ERROR 42000: Variable 'redirect_url' can't be set to the value of 'mariadb://' | ||
set global redirect_url="mariadb://mariadb.org"; | ||
select @@global.redirect_url; | ||
@@global.redirect_url | ||
mariadb://mariadb.org | ||
set global redirect_url="mariadb://mariadb.org:12a"; | ||
ERROR 42000: Variable 'redirect_url' can't be set to the value of 'mariadb://mariadb.org:12a' | ||
set global redirect_url="mariadb://mariadb.org:66666"; | ||
ERROR 42000: Variable 'redirect_url' can't be set to the value of 'mariadb://mariadb.org:66666' | ||
set global redirect_url="mariadb://mariadb.org:12345"; | ||
select @@global.redirect_url; | ||
@@global.redirect_url | ||
mariadb://mariadb.org:12345 | ||
select @@session.redirect_url; | ||
@@session.redirect_url | ||
|
||
set session redirect_url=default; | ||
select @@session.redirect_url; | ||
@@session.redirect_url | ||
mariadb://mariadb.org:12345 | ||
set session redirect_url="mysql://localhost"; | ||
select @@session.redirect_url; | ||
@@session.redirect_url | ||
mysql://localhost | ||
select @@global.redirect_url; | ||
@@global.redirect_url | ||
mariadb://mariadb.org:12345 | ||
set global redirect_url=@old_global_redirect_url; | ||
set session redirect_url=@old_session_redirect_url; | ||
set session session_track_system_variables=@old_session_track_system_variables; | ||
# | ||
# end of test MDEV-15935 | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--echo # | ||
--echo # MDEV-32254 Server crashes when adding records to table after setting redirect_url with empty variable | ||
--echo # | ||
--source include/have_innodb.inc | ||
# redirect_url is undefined in embedded. | ||
--source include/not_embedded.inc | ||
set @old_redirect_url=@@global.redirect_url; | ||
--error ER_WRONG_VALUE_FOR_VAR | ||
set global redirect_url=@empty_value; | ||
CREATE TABLE t (c1 INT) ENGINE=INNODB; | ||
INSERT INTO t VALUES (1),(1); | ||
drop table t; | ||
set global redirect_url=@old_redirect_url; | ||
|
||
--echo # | ||
--echo # end of test mdev_32254 | ||
--echo # |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--init-connect="set redirect_url='mysql://foobar'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--echo # | ||
--echo # MDEV-15935 Connection Redirection Mechanism in MariaDB Client/Server Protocol | ||
--echo # | ||
# redirect_url is undefined in embedded. | ||
--source include/not_embedded.inc | ||
|
||
# We need to connect as a non super user for the init-connect to take | ||
# effect | ||
--source include/add_anonymous_users.inc | ||
connect (con,localhost,anyone_but_root); | ||
select @@redirect_url; | ||
|
||
connection default; | ||
--source include/delete_anonymous_users.inc | ||
set @old_global_redirect_url=@@global.redirect_url; | ||
set @old_session_redirect_url=@@session.redirect_url; | ||
set @old_session_track_system_variables=@@session_track_system_variables; | ||
set session_track_system_variables=""; | ||
|
||
select @@global.redirect_url; | ||
set global redirect_url=default; | ||
select @@global.redirect_url; | ||
--error ER_WRONG_VALUE_FOR_VAR | ||
set global redirect_url="mariadb.org"; | ||
--error ER_WRONG_VALUE_FOR_VAR | ||
set global redirect_url="https://mariadb.org"; | ||
|
||
--error ER_WRONG_VALUE_FOR_VAR | ||
set global redirect_url="mysql://mariadb.org:"; | ||
--error ER_WRONG_VALUE_FOR_VAR | ||
set global redirect_url="mysql://mariadb.org:hello"; | ||
--error ER_WRONG_VALUE_FOR_VAR | ||
set global redirect_url="mysql://"; | ||
set global redirect_url="mysql://mariadb.org"; | ||
select @@global.redirect_url; | ||
--error ER_WRONG_VALUE_FOR_VAR | ||
set global redirect_url="mysql://mariadb.org:12a"; | ||
--error ER_WRONG_VALUE_FOR_VAR | ||
set global redirect_url="mysql://mariadb.org:66666"; | ||
set global redirect_url="mysql://mariadb.org:12345"; | ||
select @@global.redirect_url; | ||
|
||
--error ER_WRONG_VALUE_FOR_VAR | ||
set global redirect_url="maria"; | ||
--error ER_WRONG_VALUE_FOR_VAR | ||
set global redirect_url="mariadb://mariadb.org:"; | ||
--error ER_WRONG_VALUE_FOR_VAR | ||
set global redirect_url="mariadb://mariadb.org:hello"; | ||
--error ER_WRONG_VALUE_FOR_VAR | ||
set global redirect_url="mariadb://"; | ||
set global redirect_url="mariadb://mariadb.org"; | ||
select @@global.redirect_url; | ||
--error ER_WRONG_VALUE_FOR_VAR | ||
set global redirect_url="mariadb://mariadb.org:12a"; | ||
--error ER_WRONG_VALUE_FOR_VAR | ||
set global redirect_url="mariadb://mariadb.org:66666"; | ||
set global redirect_url="mariadb://mariadb.org:12345"; | ||
select @@global.redirect_url; | ||
|
||
select @@session.redirect_url; | ||
# Test that session default is global value | ||
set session redirect_url=default; | ||
select @@session.redirect_url; | ||
set session redirect_url="mysql://localhost"; | ||
select @@session.redirect_url; | ||
select @@global.redirect_url; | ||
|
||
set global redirect_url=@old_global_redirect_url; | ||
set session redirect_url=@old_session_redirect_url; | ||
set session session_track_system_variables=@old_session_track_system_variables; | ||
|
||
--echo # | ||
--echo # end of test MDEV-15935 | ||
--echo # |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.