Below is the list of changes that have just been committed into a local
5.1 repository of antony. When antony does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-10-30 13:38:48-07:00, antony@stripped +3 -0
Bug#30671
"ALTER SERVER causes the server to crash"
An attempt to pass NULL into strcmp() caused crash.
mysql-test/r/federated_server.result@stripped, 2007-10-30 13:38:45-07:00, antony@stripped +9 -1
test for bug 30671
fix inconsistent result
mysql-test/t/federated_server.test@stripped, 2007-10-30 13:38:45-07:00, antony@stripped +12 -1
test for bug 30671
sql/sql_servers.cc@stripped, 2007-10-30 13:38:45-07:00, antony@stripped +12 -12
bug30671
existing->value may be NULL which will cause crash when user attempts
to alter value.
diff -Nrup a/mysql-test/r/federated_server.result b/mysql-test/r/federated_server.result
--- a/mysql-test/r/federated_server.result 2007-04-04 14:35:54 -07:00
+++ b/mysql-test/r/federated_server.result 2007-10-30 13:38:45 -07:00
@@ -253,6 +253,14 @@ drop user guest_usage@localhost;
drop user guest_select@localhost;
drop table federated.t1;
drop server 's1';
+create server 's1' foreign data wrapper 'mysql' options (port 3306);
+alter server 's1' options
+(host 'localhost', database '', user '',
+password '', socket '', owner '', port 3306);
+alter server 's1' options
+(host 'localhost', database 'database1', user '',
+password '', socket '', owner '', port 3306);
+drop server 's1';
# End of 5.1 tests
use test;
create procedure p1 ()
@@ -262,7 +270,7 @@ DECLARE e INT DEFAULT 0;
DECLARE i INT;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET e = e + 1;
SET i = sleep(5);
-WHILE v < 20000 do
+WHILE v < 10000 do
CREATE SERVER s
FOREIGN DATA WRAPPER mysql
OPTIONS (USER 'Remote', HOST '192.168.1.106', DATABASE 'test');
diff -Nrup a/mysql-test/t/federated_server.test b/mysql-test/t/federated_server.test
--- a/mysql-test/t/federated_server.test 2007-04-17 04:41:14 -07:00
+++ b/mysql-test/t/federated_server.test 2007-10-30 13:38:45 -07:00
@@ -2,7 +2,7 @@
# if federated can utilise the servers table
# should work with embedded server after mysqltest is fixed
-- source include/not_embedded.inc
--- source include/federated.inc;
+-- source include/federated.inc
-- source include/big_test.inc
connection slave;
@@ -282,6 +282,17 @@ drop user guest_select@localhost;
drop table federated.t1;
drop server 's1';
+#
+# Bug#30671 - ALTER SERVER causes the server to crash
+#
+create server 's1' foreign data wrapper 'mysql' options (port 3306);
+alter server 's1' options
+ (host 'localhost', database '', user '',
+ password '', socket '', owner '', port 3306);
+alter server 's1' options
+ (host 'localhost', database 'database1', user '',
+ password '', socket '', owner '', port 3306);
+drop server 's1';
--echo # End of 5.1 tests
diff -Nrup a/sql/sql_servers.cc b/sql/sql_servers.cc
--- a/sql/sql_servers.cc 2007-08-13 06:11:14 -07:00
+++ b/sql/sql_servers.cc 2007-10-30 13:38:45 -07:00
@@ -1087,6 +1087,11 @@ prepare_server_struct_for_insert(LEX_SER
DBUG_VOID_RETURN;
}
+static bool test_if_altered(const char *new_arg, const char *old_arg)
+{
+ return new_arg && (!old_arg || strcmp(new_arg, old_arg));
+}
+
/*
SYNOPSIS
@@ -1117,21 +1122,19 @@ prepare_server_struct_for_update(LEX_SER
than the existing value?
*/
altered->host=
- (server_options->host && (strcmp(server_options->host, existing->host))) ?
+ test_if_altered(server_options->host, existing->host) ?
strdup_root(&mem, server_options->host) : 0;
altered->db=
- (server_options->db && (strcmp(server_options->db, existing->db))) ?
+ test_if_altered(server_options->db, existing->db) ?
strdup_root(&mem, server_options->db) : 0;
altered->username=
- (server_options->username &&
- (strcmp(server_options->username, existing->username))) ?
+ test_if_altered(server_options->username, existing->username) ?
strdup_root(&mem, server_options->username) : 0;
altered->password=
- (server_options->password &&
- (strcmp(server_options->password, existing->password))) ?
+ test_if_altered(server_options->password, existing->password) ?
strdup_root(&mem, server_options->password) : 0;
/*
@@ -1142,18 +1145,15 @@ prepare_server_struct_for_update(LEX_SER
server_options->port : -1;
altered->socket=
- (server_options->socket &&
- (strcmp(server_options->socket, existing->socket))) ?
+ test_if_altered(server_options->socket, existing->socket) ?
strdup_root(&mem, server_options->socket) : 0;
altered->scheme=
- (server_options->scheme &&
- (strcmp(server_options->scheme, existing->scheme))) ?
+ test_if_altered(server_options->scheme, existing->scheme) ?
strdup_root(&mem, server_options->scheme) : 0;
altered->owner=
- (server_options->owner &&
- (strcmp(server_options->owner, existing->owner))) ?
+ test_if_altered(server_options->owner, existing->owner) ?
strdup_root(&mem, server_options->owner) : 0;
DBUG_VOID_RETURN;