Commit 55c55d85 authored by Michael Widenius's avatar Michael Widenius

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
parent 7e497abc
......@@ -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
......@@ -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
......
......@@ -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;
......
......@@ -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));
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));
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);
}
......
......@@ -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() {}
};
......@@ -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);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment