diff options
author | Michael Widenius <monty@askmonty.org> | 2011-02-11 04:28:22 +0200 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2011-02-11 04:28:22 +0200 |
commit | 55c55d85bd8fab635d038d77550f93fc996d47eb (patch) | |
tree | 8b3083f5be550cc65701fba04a171fa92e817110 | |
parent | 7e497abcfb3e761ba5a368316192ae930fb58f6b (diff) | |
download | mariadb-git-55c55d85bd8fab635d038d77550f93fc996d47eb.tar.gz |
Fixed bug in federatedx patch that caused partition tests to fail.
Fixed that connection string is returned for partitioned federated tables.
mysql-test/r/partition_federated.result:
Fixed error message
mysql-test/suite/federated/federated_partition.result:
Added test to show that connection string is returned in 'show create'.
sql/ha_partition.cc:
Fixed a set of bugs introduced by the last federated patch:
- We can't allocate m_ordered_rec_buffer in memroot as it has to survive call to clear_handler_file()
sql/partition_element.h:
Ensure that connect_string is properly initialized.
(This caused crashed in partition tests)
sql/sql_partition.cc:
Print CONNECTION option for federated partitioned tables
-rw-r--r-- | mysql-test/r/partition_federated.result | 2 | ||||
-rw-r--r-- | mysql-test/suite/federated/federated_partition.result | 9 | ||||
-rw-r--r-- | mysql-test/suite/federated/federated_partition.test | 3 | ||||
-rw-r--r-- | sql/ha_partition.cc | 12 | ||||
-rw-r--r-- | sql/partition_element.h | 4 | ||||
-rw-r--r-- | sql/sql_partition.cc | 3 |
6 files changed, 27 insertions, 6 deletions
diff --git a/mysql-test/r/partition_federated.result b/mysql-test/r/partition_federated.result index 2d98e366c95..789cfb562ad 100644 --- a/mysql-test/r/partition_federated.result +++ b/mysql-test/r/partition_federated.result @@ -2,5 +2,5 @@ drop table if exists t1; create table t1 (s1 int) engine=federated connection='mysql://root@localhost/federated/t1' partition by list (s1) (partition p1 values in (1), partition p2 values in (2)); -ERROR HY000: Engine cannot be used in partitioned tables +ERROR HY000: Unable to connect to foreign data source: CONNECTION not valid for partition End of 5.1 tests diff --git a/mysql-test/suite/federated/federated_partition.result b/mysql-test/suite/federated/federated_partition.result index ebcafca4563..26a6443ffad 100644 --- a/mysql-test/suite/federated/federated_partition.result +++ b/mysql-test/suite/federated/federated_partition.result @@ -9,6 +9,15 @@ partition by list (s1) connection='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1_1', partition p2 values in (2,4) connection='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1_2'); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `s1` int(11) NOT NULL, + PRIMARY KEY (`s1`) +) ENGINE=FEDERATED DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (s1) +(PARTITION p1 VALUES IN (1,3) CONNECTION = 'mysql://root@127.0.0.1:SLAVE_PORT/federated/t1_1' ENGINE = FEDERATED, + PARTITION p2 VALUES IN (2,4) CONNECTION = 'mysql://root@127.0.0.1:SLAVE_PORT/federated/t1_2' ENGINE = FEDERATED) */ insert into t1 values (1), (2), (3), (4); select * from t1; s1 diff --git a/mysql-test/suite/federated/federated_partition.test b/mysql-test/suite/federated/federated_partition.test index 223dab6af16..6f093bfb63d 100644 --- a/mysql-test/suite/federated/federated_partition.test +++ b/mysql-test/suite/federated/federated_partition.test @@ -30,6 +30,9 @@ eval create table t1 (s1 int primary key) engine=federated partition p2 values in (2,4) connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1_2'); +--replace_result $SLAVE_MYPORT SLAVE_PORT +show create table t1; + insert into t1 values (1), (2), (3), (4); select * from t1; diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 286cb94c830..0f6f52014ac 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -289,6 +289,7 @@ ha_partition::~ha_partition() for (i= 0; i < m_tot_parts; i++) delete m_file[i]; } + my_free(m_ordered_rec_buffer, MYF(MY_ALLOW_ZERO_PTR)); clear_handler_file(); @@ -2234,9 +2235,10 @@ bool ha_partition::create_handler_file(const char *name) part_elem= part_it++; uint length = part_elem->connect_string.length; int4store(buffer, length); - my_write(file, buffer, 4, MYF(MY_WME | MY_NABP)); - my_write(file, (uchar *) part_elem->connect_string.str, length, - MYF(MY_WME | MY_NABP)); + if (my_write(file, buffer, 4, MYF(MY_WME | MY_NABP)) || + my_write(file, (uchar *) part_elem->connect_string.str, length, + MYF(MY_WME | MY_NABP))) + result= TRUE; } VOID(my_close(file, MYF(0))); } @@ -2264,7 +2266,6 @@ void ha_partition::clear_handler_file() m_file_buffer= NULL; m_engine_array= NULL; m_connect_string= NULL; - m_ordered_rec_buffer= NULL; } /* @@ -2568,7 +2569,8 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked) alloc_len+= table_share->max_key_length; if (!m_ordered_rec_buffer) { - if (!(m_ordered_rec_buffer= (uchar*) alloc_root(&m_mem_root, alloc_len))) + if (!(m_ordered_rec_buffer= (uchar*) (uchar*)my_malloc(alloc_len, + MYF(MY_WME)))) { DBUG_RETURN(1); } diff --git a/sql/partition_element.h b/sql/partition_element.h index 2fe2bba74cd..2158063cfef 100644 --- a/sql/partition_element.h +++ b/sql/partition_element.h @@ -81,6 +81,8 @@ public: nodegroup_id(UNDEF_NODEGROUP), has_null_value(FALSE), signed_flag(FALSE), max_value(FALSE) { + connect_string.str= 0; + connect_string.length= 0; } partition_element(partition_element *part_elem) : part_max_rows(part_elem->part_max_rows), @@ -95,6 +97,8 @@ public: nodegroup_id(part_elem->nodegroup_id), has_null_value(FALSE) { + connect_string.str= 0; + connect_string.length= 0; } ~partition_element() {} }; diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 71e5185012c..509a4d65964 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1982,6 +1982,9 @@ static int add_partition_options(File fptr, partition_element *p_elem) } if (p_elem->part_comment) err+= add_keyword_string(fptr, "COMMENT", TRUE, p_elem->part_comment); + if (p_elem->connect_string.length) + err+= add_keyword_string(fptr, "CONNECTION", TRUE, + p_elem->connect_string.str); return err + add_engine(fptr,p_elem->engine_type); } |