Commit 134d1f3e authored by unknown's avatar unknown

Merge mronstrom@bk-internal.mysql.com:/home/bk/mysql-5.1

into  c-1309e253.1238-1-64736c10.cust.bredbandsbolaget.se:/home/pappa/mysql-5.1

parents ba02b086 11c50356
...@@ -8,6 +8,14 @@ partition by key (a); ...@@ -8,6 +8,14 @@ partition by key (a);
select count(*) from t1; select count(*) from t1;
count(*) count(*)
0 0
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` int(11) NOT NULL,
`c` int(11) NOT NULL,
PRIMARY KEY (`a`,`b`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY KEY (a)
drop table t1; drop table t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
a int not null, a int not null,
......
...@@ -19,6 +19,14 @@ a b c ...@@ -19,6 +19,14 @@ a b c
6 1 1 6 1 1
10 1 1 10 1 1
15 1 1 15 1 1
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` int(11) NOT NULL,
`c` int(11) NOT NULL,
PRIMARY KEY (`a`,`b`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (a) (PARTITION x1 VALUES LESS THAN (5) TABLESPACE = ts1 ENGINE = MyISAM, PARTITION x2 VALUES LESS THAN (10) TABLESPACE = ts2 ENGINE = MyISAM, PARTITION x3 VALUES LESS THAN MAXVALUE TABLESPACE = ts3 ENGINE = MyISAM)
ALTER TABLE t1 ALTER TABLE t1
partition by range (a) partition by range (a)
partitions 3 partitions 3
...@@ -31,6 +39,14 @@ a b c ...@@ -31,6 +39,14 @@ a b c
6 1 1 6 1 1
10 1 1 10 1 1
15 1 1 15 1 1
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` int(11) NOT NULL,
`c` int(11) NOT NULL,
PRIMARY KEY (`a`,`b`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (a) (PARTITION x1 VALUES LESS THAN (5) TABLESPACE = ts1 ENGINE = MyISAM, PARTITION x2 VALUES LESS THAN (10) TABLESPACE = ts2 ENGINE = MyISAM, PARTITION x3 VALUES LESS THAN MAXVALUE TABLESPACE = ts3 ENGINE = MyISAM)
drop table if exists t1; drop table if exists t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
a int not null, a int not null,
...@@ -120,6 +136,24 @@ subpartition x22) ...@@ -120,6 +136,24 @@ subpartition x22)
); );
SELECT * from t1; SELECT * from t1;
a b c a b c
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` int(11) NOT NULL,
`c` int(11) NOT NULL,
PRIMARY KEY (`a`,`b`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (a) SUBPARTITION BY HASH (a+b) (PARTITION x1 VALUES LESS THAN (1) (SUBPARTITION x11 ENGINE = MyISAM, SUBPARTITION x12 ENGINE = MyISAM), PARTITION x2 VALUES LESS THAN (5) (SUBPARTITION x21 ENGINE = MyISAM, SUBPARTITION x22 ENGINE = MyISAM))
ALTER TABLE t1 ADD COLUMN d int;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` int(11) NOT NULL,
`c` int(11) NOT NULL,
`d` int(11) default NULL,
PRIMARY KEY (`a`,`b`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (a) SUBPARTITION BY HASH (a+b) (PARTITION x1 VALUES LESS THAN (1) (SUBPARTITION x11 ENGINE = MyISAM, SUBPARTITION x12 ENGINE = MyISAM), PARTITION x2 VALUES LESS THAN (5) (SUBPARTITION x21 ENGINE = MyISAM, SUBPARTITION x22 ENGINE = MyISAM))
drop table t1; drop table t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
a int not null, a int not null,
......
...@@ -23,6 +23,11 @@ partition by key (a); ...@@ -23,6 +23,11 @@ partition by key (a);
# #
select count(*) from t1; select count(*) from t1;
#
# Test SHOW CREATE TABLE
#
show create table t1;
drop table t1; drop table t1;
# #
# Partition by key no partition, list of fields # Partition by key no partition, list of fields
......
...@@ -30,6 +30,7 @@ INSERT into t1 values (10, 1, 1); ...@@ -30,6 +30,7 @@ INSERT into t1 values (10, 1, 1);
INSERT into t1 values (15, 1, 1); INSERT into t1 values (15, 1, 1);
select * from t1; select * from t1;
show create table t1;
ALTER TABLE t1 ALTER TABLE t1
partition by range (a) partition by range (a)
...@@ -39,6 +40,7 @@ partitions 3 ...@@ -39,6 +40,7 @@ partitions 3
partition x3 values less than maxvalue tablespace ts3); partition x3 values less than maxvalue tablespace ts3);
select * from t1; select * from t1;
show create table t1;
drop table if exists t1; drop table if exists t1;
...@@ -143,6 +145,10 @@ subpartition by hash (a+b) ...@@ -143,6 +145,10 @@ subpartition by hash (a+b)
); );
SELECT * from t1; SELECT * from t1;
show create table t1;
ALTER TABLE t1 ADD COLUMN d int;
show create table t1;
drop table t1; drop table t1;
......
...@@ -686,7 +686,7 @@ void get_full_part_id_from_key(const TABLE *table, byte *buf, ...@@ -686,7 +686,7 @@ void get_full_part_id_from_key(const TABLE *table, byte *buf,
const key_range *key_spec, const key_range *key_spec,
part_id_range *part_spec); part_id_range *part_spec);
bool mysql_unpack_partition(File file, THD *thd, uint part_info_len, bool mysql_unpack_partition(File file, THD *thd, uint part_info_len,
TABLE *table); TABLE *table, enum db_type default_db_type);
#endif #endif
......
...@@ -3081,7 +3081,7 @@ void get_partition_set(const TABLE *table, byte *buf, const uint index, ...@@ -3081,7 +3081,7 @@ void get_partition_set(const TABLE *table, byte *buf, const uint index,
*/ */
bool mysql_unpack_partition(File file, THD *thd, uint part_info_len, bool mysql_unpack_partition(File file, THD *thd, uint part_info_len,
TABLE* table) TABLE* table, enum db_type default_db_type)
{ {
Item *thd_free_list= thd->free_list; Item *thd_free_list= thd->free_list;
bool result= TRUE; bool result= TRUE;
...@@ -3119,6 +3119,12 @@ bool mysql_unpack_partition(File file, THD *thd, uint part_info_len, ...@@ -3119,6 +3119,12 @@ bool mysql_unpack_partition(File file, THD *thd, uint part_info_len,
} }
part_info= lex.part_info; part_info= lex.part_info;
table->s->part_info= part_info; table->s->part_info= part_info;
if (part_info->default_engine_type == DB_TYPE_UNKNOWN)
part_info->default_engine_type= default_db_type;
else
{
DBUG_ASSERT(part_info->default_engine_type == default_db_type);
}
part_info->item_free_list= thd->free_list; part_info->item_free_list= thd->free_list;
{ {
......
...@@ -961,16 +961,19 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet) ...@@ -961,16 +961,19 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet)
packet->append("\n)", 2); packet->append("\n)", 2);
if (!(thd->variables.sql_mode & MODE_NO_TABLE_OPTIONS) && !foreign_db_mode) if (!(thd->variables.sql_mode & MODE_NO_TABLE_OPTIONS) && !foreign_db_mode)
{ {
#if 0 //def HAVE_PARTITION_DB if (thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40))
if (!table->s->part_info) packet->append(" TYPE=", 6);
#endif else
{ packet->append(" ENGINE=", 8);
if (thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40)) #ifdef HAVE_PARTITION_DB
packet->append(" TYPE=", 6); if (table->s->part_info)
else packet->append(ha_get_storage_engine(
packet->append(" ENGINE=", 8); table->s->part_info->default_engine_type));
else
packet->append(file->table_type()); packet->append(file->table_type());
} #else
packet->append(file->table_type());
#endif
if (share->table_charset && if (share->table_charset &&
!(thd->variables.sql_mode & MODE_MYSQL323) && !(thd->variables.sql_mode & MODE_MYSQL323) &&
......
...@@ -1620,6 +1620,10 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -1620,6 +1620,10 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name,
part_engine_type= ha_checktype(thd, part_engine_type= ha_checktype(thd,
part_info->default_engine_type, 0, 0); part_info->default_engine_type, 0, 0);
} }
else
{
part_info->default_engine_type= create_info->db_type;
}
if (check_partition_info(part_info, part_engine_type, if (check_partition_info(part_info, part_engine_type,
file, create_info->max_rows)) file, create_info->max_rows))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
...@@ -3467,16 +3471,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -3467,16 +3471,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
my_error(ER_PARTITION_MGMT_ON_NONPARTITIONED, MYF(0)); my_error(ER_PARTITION_MGMT_ON_NONPARTITIONED, MYF(0));
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
{ default_engine_type= tab_part_info->default_engine_type;
List_iterator<partition_element> t_it(tab_part_info->partitions);
partition_element *t_part_elem= t_it++;
if (is_sub_partitioned(tab_part_info))
{
List_iterator<partition_element> s_it(t_part_elem->subpartitions);
t_part_elem= s_it++;
}
default_engine_type= t_part_elem->engine_type;
}
/* /*
We are going to manipulate the partition info on the table object We are going to manipulate the partition info on the table object
so we need to ensure that the data structure of the table object so we need to ensure that the data structure of the table object
...@@ -3860,7 +3855,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -3860,7 +3855,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
*/ */
if (thd->lex->part_info != table->s->part_info) if (thd->lex->part_info != table->s->part_info)
partition_changed= TRUE; partition_changed= TRUE;
thd->lex->part_info->default_engine_type= create_info->db_type; if (create_info->db_type != DB_TYPE_PARTITION_DB)
thd->lex->part_info->default_engine_type= create_info->db_type;
create_info->db_type= DB_TYPE_PARTITION_DB; create_info->db_type= DB_TYPE_PARTITION_DB;
} }
} }
......
...@@ -3038,7 +3038,11 @@ opt_part_option: ...@@ -3038,7 +3038,11 @@ opt_part_option:
TABLESPACE opt_equal ident_or_text TABLESPACE opt_equal ident_or_text
{ Lex->part_info->curr_part_elem->tablespace_name= $3.str; } { Lex->part_info->curr_part_elem->tablespace_name= $3.str; }
| opt_storage ENGINE_SYM opt_equal storage_engines | opt_storage ENGINE_SYM opt_equal storage_engines
{ Lex->part_info->curr_part_elem->engine_type= $4; } {
LEX *lex= Lex;
lex->part_info->curr_part_elem->engine_type= $4;
lex->part_info->default_engine_type= $4;
}
| NODEGROUP_SYM opt_equal ulong_num | NODEGROUP_SYM opt_equal ulong_num
{ Lex->part_info->curr_part_elem->nodegroup_id= $3; } { Lex->part_info->curr_part_elem->nodegroup_id= $3; }
| MAX_ROWS opt_equal ulonglong_num | MAX_ROWS opt_equal ulonglong_num
......
...@@ -87,6 +87,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, ...@@ -87,6 +87,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
SQL_CRYPT *crypted=0; SQL_CRYPT *crypted=0;
MEM_ROOT **root_ptr, *old_root; MEM_ROOT **root_ptr, *old_root;
TABLE_SHARE *share; TABLE_SHARE *share;
enum db_type default_part_db_type;
DBUG_ENTER("openfrm"); DBUG_ENTER("openfrm");
DBUG_PRINT("enter",("name: '%s' form: 0x%lx",name,outparam)); DBUG_PRINT("enter",("name: '%s' form: 0x%lx",name,outparam));
...@@ -164,6 +165,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, ...@@ -164,6 +165,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
if (share->frm_version == FRM_VER_TRUE_VARCHAR -1 && head[33] == 5) if (share->frm_version == FRM_VER_TRUE_VARCHAR -1 && head[33] == 5)
share->frm_version= FRM_VER_TRUE_VARCHAR; share->frm_version= FRM_VER_TRUE_VARCHAR;
default_part_db_type= ha_checktype(thd,(enum db_type) (uint) *(head+61),0,0);
share->db_type= ha_checktype(thd,(enum db_type) (uint) *(head+3),0,0); share->db_type= ha_checktype(thd,(enum db_type) (uint) *(head+3),0,0);
share->db_create_options= db_create_options=uint2korr(head+30); share->db_create_options= db_create_options=uint2korr(head+30);
share->db_options_in_use= share->db_create_options; share->db_options_in_use= share->db_create_options;
...@@ -452,7 +454,8 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, ...@@ -452,7 +454,8 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
if (part_info_len > 0) if (part_info_len > 0)
{ {
#ifdef HAVE_PARTITION_DB #ifdef HAVE_PARTITION_DB
if (mysql_unpack_partition(file, thd, part_info_len, outparam)) if (mysql_unpack_partition(file, thd, part_info_len,
outparam, default_part_db_type))
goto err; goto err;
#else #else
goto err; goto err;
......
...@@ -149,6 +149,7 @@ bool mysql_create_frm(THD *thd, my_string file_name, ...@@ -149,6 +149,7 @@ bool mysql_create_frm(THD *thd, my_string file_name,
if (part_info) if (part_info)
{ {
int4store(fileinfo+55,part_info->part_info_len); int4store(fileinfo+55,part_info->part_info_len);
fileinfo[61]= (uchar) part_info->default_engine_type;
} }
#endif #endif
int2store(fileinfo+59,db_file->extra_rec_buf_length()); int2store(fileinfo+59,db_file->extra_rec_buf_length());
......
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