Commit a3e8ae12 authored by Sergei Golubchik's avatar Sergei Golubchik

A temporary solution to make CREATE TABLE attributes

to work when a table is partitioned
parent 8792d8a3
install plugin example soname 'ha_example.so';
create table t1 (a int not null)
engine=example
partition by list (a)
(partition p0 values in (1), partition p1 values in (2));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL
) ENGINE=EXAMPLE DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST (a)
(PARTITION p0 VALUES IN (1) ENGINE = EXAMPLE,
PARTITION p1 VALUES IN (2) ENGINE = EXAMPLE) */
drop table t1;
create table t1 (a int not null)
engine=example ull=12340
partition by list (a)
(partition p0 values in (1), partition p1 values in (2));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL
) ENGINE=EXAMPLE DEFAULT CHARSET=latin1 `ull`=12340
/*!50100 PARTITION BY LIST (a)
(PARTITION p0 VALUES IN (1) ENGINE = EXAMPLE,
PARTITION p1 VALUES IN (2) ENGINE = EXAMPLE) */
drop table t1;
select 1;
1
1
uninstall plugin example;
--source include/not_windows_embedded.inc
--source include/have_example_plugin.inc
--source include/have_partition.inc
--replace_regex /\.dll/.so/
eval install plugin example soname $HA_EXAMPLE_SO;
create table t1 (a int not null)
engine=example
partition by list (a)
(partition p0 values in (1), partition p1 values in (2));
show create table t1;
drop table t1;
create table t1 (a int not null)
engine=example ull=12340
partition by list (a)
(partition p0 values in (1), partition p1 values in (2));
show create table t1;
drop table t1;
select 1;
uninstall plugin example;
......@@ -131,7 +131,7 @@ SET @@SQL_MODE=@OLD_SQL_MODE;
# The only preparable statement above was CREATE TABLE.
# We need to prepare another statement here to force the
# previous one to be deallocated (mysqltest reuses the same handle)
# and to unlock all thread-local plugin locks. Otherwise it won't
# and to unlock all thread-local plugin locks. Otherwise the plugin won't
# uninstall.
#
select 1;
......
......@@ -1219,9 +1219,7 @@ int ha_partition::prepare_new_partition(TABLE *tbl,
DBUG_ENTER("prepare_new_partition");
if ((error= set_up_table_before_create(tbl, part_name, create_info,
0, p_elem)) ||
parse_engine_table_options(ha_thd(), file->ht,
file->table_share))
0, p_elem)))
goto error_create;
if ((error= file->ha_create(part_name, tbl, create_info)))
{
......
......@@ -1113,4 +1113,27 @@ public:
-------------------------------------------------------------------------
virtual void append_create_info(String *packet)
*/
/*
the following heavily relies on the fact that all partitions
are in the same storage engine.
When this limitation is lifted, the following hack should go away,
and a proper interface for engines needs to be introduced:
an PARTITION_SHARE structure that has a pointer to the TABLE_SHARE.
is given to engines everywhere where TABLE_SHARE is used now
has members like option_struct, ha_data
perhaps TABLE needs to be split the same way too...
this can also be done before partition will support a mix of engines,
but preferably together with other incompatible API changes.
*/
virtual handlerton *partition_ht() const
{
handlerton *h= m_file[0]->ht;
for (int i=1; i < m_tot_parts; i++)
DBUG_ASSERT(h == m_file[i]->ht);
return h;
}
};
......@@ -3720,9 +3720,6 @@ int ha_create_table(THD *thd, const char *path,
name= get_canonical_filename(table.file, share.path.str, name_buff);
if (parse_engine_table_options(thd, table.file->ht, &share))
goto err;
error= table.file->ha_create(name, &table, create_info);
VOID(closefrm(&table, 0));
......
......@@ -2230,6 +2230,10 @@ private:
virtual int rename_partitions(const char *path)
{ return HA_ERR_WRONG_COMMAND; }
friend class ha_partition;
public:
/* XXX to be removed, see ha_partition::partition_ht() */
virtual handlerton *partition_ht() const
{ return ht; }
};
......
......@@ -3445,7 +3445,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
if (parse_option_list(thd, &create_info->option_struct,
create_info->option_list,
create_info->db_type->table_options, FALSE,
file->partition_ht()->table_options, FALSE,
thd->mem_root))
DBUG_RETURN(TRUE);
......
......@@ -1636,7 +1636,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
if (engine_table_options_frm_read(options, options_len, share))
goto free_and_err;
}
if (parse_engine_table_options(thd, handler_file->ht, share))
if (parse_engine_table_options(thd, handler_file->partition_ht(), share))
goto free_and_err;
my_free(buff, MYF(MY_ALLOW_ZERO_PTR));
......
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