diff options
author | Sergei Golubchik <sergii@pisem.net> | 2010-05-11 16:49:23 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2010-05-11 16:49:23 +0200 |
commit | a3e8ae12805fb85a0b175b3ccbce36da62f8fdc4 (patch) | |
tree | b72575d93228cb5bf4caa6c25559b3abef8e0d71 | |
parent | 8792d8a3acd58b9417ee991166d76ba17f517836 (diff) | |
download | mariadb-git-a3e8ae12805fb85a0b175b3ccbce36da62f8fdc4.tar.gz |
A temporary solution to make CREATE TABLE attributes
to work when a table is partitioned
-rw-r--r-- | mysql-test/r/partition_example.result | 31 | ||||
-rw-r--r-- | mysql-test/t/partition_example-master.opt | 1 | ||||
-rw-r--r-- | mysql-test/t/partition_example.test | 23 | ||||
-rw-r--r-- | mysql-test/t/plugin.test | 2 | ||||
-rw-r--r-- | sql/ha_partition.cc | 4 | ||||
-rw-r--r-- | sql/ha_partition.h | 23 | ||||
-rw-r--r-- | sql/handler.cc | 3 | ||||
-rw-r--r-- | sql/handler.h | 4 | ||||
-rw-r--r-- | sql/sql_table.cc | 2 | ||||
-rw-r--r-- | sql/table.cc | 2 |
10 files changed, 86 insertions, 9 deletions
diff --git a/mysql-test/r/partition_example.result b/mysql-test/r/partition_example.result new file mode 100644 index 00000000000..2129eea0818 --- /dev/null +++ b/mysql-test/r/partition_example.result @@ -0,0 +1,31 @@ +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; diff --git a/mysql-test/t/partition_example-master.opt b/mysql-test/t/partition_example-master.opt new file mode 100644 index 00000000000..367d5233e0e --- /dev/null +++ b/mysql-test/t/partition_example-master.opt @@ -0,0 +1 @@ +$EXAMPLE_PLUGIN_OPT diff --git a/mysql-test/t/partition_example.test b/mysql-test/t/partition_example.test new file mode 100644 index 00000000000..e6ac1bd222a --- /dev/null +++ b/mysql-test/t/partition_example.test @@ -0,0 +1,23 @@ +--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; diff --git a/mysql-test/t/plugin.test b/mysql-test/t/plugin.test index 3bbe615ebe6..7a1ca27d589 100644 --- a/mysql-test/t/plugin.test +++ b/mysql-test/t/plugin.test @@ -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; diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index c065a35b8e3..31c010cbaa2 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -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))) { diff --git a/sql/ha_partition.h b/sql/ha_partition.h index 98af55bc038..15744b36edb 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -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; + } }; diff --git a/sql/handler.cc b/sql/handler.cc index 90884daaae4..19c615a289c 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -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)); diff --git a/sql/handler.h b/sql/handler.h index 81e0eab141c..4b1954fc34f 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -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; } }; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 5f38a3432f3..5aede352708 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -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); diff --git a/sql/table.cc b/sql/table.cc index 2d73e15d5fb..ac026120964 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -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)); |