From a03997db4329a7dea36fc94916d10b6231b6f844 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 1 May 2014 18:27:52 +0200 Subject: [PATCH] MDEV-6085 ALTER TABLE looses the connection string --- sql/sql_table.cc | 3 +++ .../connect/mysql-test/connect/r/mysql.result | 23 +++++++++++++++++++ .../connect/mysql-test/connect/t/mysql.test | 16 +++++++++++++ 3 files changed, 42 insertions(+) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index dec010bb24f..502f1b30e8f 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -7239,6 +7239,9 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, if (!(used_fields & HA_CREATE_USED_TRANSACTIONAL)) create_info->transactional= table->s->transactional; + if (!(used_fields & HA_CREATE_USED_CONNECTION)) + create_info->connect_string= table->s->connect_string; + restore_record(table, s->default_values); // Empty record for DEFAULT if ((create_info->fields_option_struct= (ha_field_option_struct**) diff --git a/storage/connect/mysql-test/connect/r/mysql.result b/storage/connect/mysql-test/connect/r/mysql.result index 51ec571486f..fc2fe2418cf 100644 --- a/storage/connect/mysql-test/connect/r/mysql.result +++ b/storage/connect/mysql-test/connect/r/mysql.result @@ -273,3 +273,26 @@ a b c d e 255 65535 4294967295 18446744073709551615 Hello DROP TABLE t2; DROP TABLE t1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (10),(20),(30); +CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL CONNECTION='mysql://root@localhost:PORT/test/t1'; +SELECT * FROM t2; +a +10 +20 +30 +ALTER TABLE t2 MODIFY a TINYINT; +Warnings: +Warning 1105 This is an outward table, table data were not modified. +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` tinyint(4) DEFAULT NULL +) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='mysql://root@localhost:PORT/test/t1' `TABLE_TYPE`='MYSQL' +SELECT * FROM t2; +a +10 +20 +30 +DROP TABLE t2; +DROP TABLE t1; diff --git a/storage/connect/mysql-test/connect/t/mysql.test b/storage/connect/mysql-test/connect/t/mysql.test index bcba0db753d..e245587e562 100644 --- a/storage/connect/mysql-test/connect/t/mysql.test +++ b/storage/connect/mysql-test/connect/t/mysql.test @@ -454,3 +454,19 @@ SELECT * FROM t2; DROP TABLE t2; DROP TABLE t1; + +# +# MDEV-6085 ALTER TABLE looses the connection string +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (10),(20),(30); +--replace_result $PORT PORT +--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL CONNECTION='mysql://root@localhost:$PORT/test/t1' +SELECT * FROM t2; +ALTER TABLE t2 MODIFY a TINYINT; +--replace_result $PORT PORT +SHOW CREATE TABLE t2; +SELECT * FROM t2; +DROP TABLE t2; +DROP TABLE t1; +