mirror of
https://github.com/MariaDB/server.git
synced 2025-06-25 06:22:03 +03:00
Handle default engine type better for
partitioned tables mysql-test/r/partition.result: New test cases for SHOW CREATE TABLE mysql-test/r/partition_range.result: New test cases for SHOW CREATE TABLE mysql-test/t/partition.test: New test cases for SHOW CREATE TABLE mysql-test/t/partition_range.test: New test cases for SHOW CREATE TABLE sql/handler.h: Handle default engine type better sql/sql_partition.cc: Handle default engine type better sql/sql_show.cc: Handle default engine type better sql/sql_table.cc: Handle default engine type better sql/sql_yacc.yy: Handle default engine type better sql/table.cc: Handle default engine type better sql/unireg.cc: Handle default engine type better
This commit is contained in:
@ -8,6 +8,14 @@ partition by key (a);
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
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;
|
||||
CREATE TABLE t1 (
|
||||
a int not null,
|
||||
|
@ -19,6 +19,14 @@ a b c
|
||||
6 1 1
|
||||
10 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
|
||||
partition by range (a)
|
||||
partitions 3
|
||||
@ -31,6 +39,14 @@ a b c
|
||||
6 1 1
|
||||
10 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;
|
||||
CREATE TABLE t1 (
|
||||
a int not null,
|
||||
@ -120,6 +136,24 @@ subpartition x22)
|
||||
);
|
||||
SELECT * from t1;
|
||||
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;
|
||||
CREATE TABLE t1 (
|
||||
a int not null,
|
||||
|
@ -23,6 +23,11 @@ partition by key (a);
|
||||
#
|
||||
select count(*) from t1;
|
||||
|
||||
#
|
||||
# Test SHOW CREATE TABLE
|
||||
#
|
||||
show create table t1;
|
||||
|
||||
drop table t1;
|
||||
#
|
||||
# Partition by key no partition, list of fields
|
||||
|
@ -30,6 +30,7 @@ INSERT into t1 values (10, 1, 1);
|
||||
INSERT into t1 values (15, 1, 1);
|
||||
|
||||
select * from t1;
|
||||
show create table t1;
|
||||
|
||||
ALTER TABLE t1
|
||||
partition by range (a)
|
||||
@ -39,6 +40,7 @@ partitions 3
|
||||
partition x3 values less than maxvalue tablespace ts3);
|
||||
|
||||
select * from t1;
|
||||
show create table t1;
|
||||
|
||||
drop table if exists t1;
|
||||
|
||||
@ -143,6 +145,10 @@ subpartition by hash (a+b)
|
||||
);
|
||||
|
||||
SELECT * from t1;
|
||||
show create table t1;
|
||||
|
||||
ALTER TABLE t1 ADD COLUMN d int;
|
||||
show create table t1;
|
||||
|
||||
drop table t1;
|
||||
|
||||
|
@ -686,7 +686,7 @@ void get_full_part_id_from_key(const TABLE *table, byte *buf,
|
||||
const key_range *key_spec,
|
||||
part_id_range *part_spec);
|
||||
bool mysql_unpack_partition(File file, THD *thd, uint part_info_len,
|
||||
TABLE *table);
|
||||
TABLE *table, enum db_type default_db_type);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -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,
|
||||
TABLE* table)
|
||||
TABLE* table, enum db_type default_db_type)
|
||||
{
|
||||
Item *thd_free_list= thd->free_list;
|
||||
bool result= TRUE;
|
||||
@ -3119,6 +3119,12 @@ bool mysql_unpack_partition(File file, THD *thd, uint part_info_len,
|
||||
}
|
||||
part_info= lex.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;
|
||||
|
||||
{
|
||||
|
@ -960,17 +960,20 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet)
|
||||
|
||||
packet->append("\n)", 2);
|
||||
if (!(thd->variables.sql_mode & MODE_NO_TABLE_OPTIONS) && !foreign_db_mode)
|
||||
{
|
||||
#if 0 //def HAVE_PARTITION_DB
|
||||
if (!table->s->part_info)
|
||||
#endif
|
||||
{
|
||||
if (thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40))
|
||||
packet->append(" TYPE=", 6);
|
||||
else
|
||||
packet->append(" ENGINE=", 8);
|
||||
#ifdef HAVE_PARTITION_DB
|
||||
if (table->s->part_info)
|
||||
packet->append(ha_get_storage_engine(
|
||||
table->s->part_info->default_engine_type));
|
||||
else
|
||||
packet->append(file->table_type());
|
||||
}
|
||||
#else
|
||||
packet->append(file->table_type());
|
||||
#endif
|
||||
|
||||
if (share->table_charset &&
|
||||
!(thd->variables.sql_mode & MODE_MYSQL323) &&
|
||||
|
@ -1620,6 +1620,10 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name,
|
||||
part_engine_type= ha_checktype(thd,
|
||||
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,
|
||||
file, create_info->max_rows))
|
||||
DBUG_RETURN(TRUE);
|
||||
@ -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));
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
{
|
||||
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;
|
||||
}
|
||||
default_engine_type= tab_part_info->default_engine_type;
|
||||
/*
|
||||
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
|
||||
@ -3860,6 +3855,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
||||
*/
|
||||
if (thd->lex->part_info != table->s->part_info)
|
||||
partition_changed= TRUE;
|
||||
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;
|
||||
}
|
||||
|
@ -3038,7 +3038,11 @@ opt_part_option:
|
||||
TABLESPACE opt_equal ident_or_text
|
||||
{ Lex->part_info->curr_part_elem->tablespace_name= $3.str; }
|
||||
| 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
|
||||
{ Lex->part_info->curr_part_elem->nodegroup_id= $3; }
|
||||
| MAX_ROWS opt_equal ulonglong_num
|
||||
|
@ -87,6 +87,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
|
||||
SQL_CRYPT *crypted=0;
|
||||
MEM_ROOT **root_ptr, *old_root;
|
||||
TABLE_SHARE *share;
|
||||
enum db_type default_part_db_type;
|
||||
DBUG_ENTER("openfrm");
|
||||
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,
|
||||
if (share->frm_version == FRM_VER_TRUE_VARCHAR -1 && head[33] == 5)
|
||||
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_create_options= db_create_options=uint2korr(head+30);
|
||||
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,
|
||||
if (part_info_len > 0)
|
||||
{
|
||||
#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;
|
||||
#else
|
||||
goto err;
|
||||
|
@ -149,6 +149,7 @@ bool mysql_create_frm(THD *thd, my_string file_name,
|
||||
if (part_info)
|
||||
{
|
||||
int4store(fileinfo+55,part_info->part_info_len);
|
||||
fileinfo[61]= (uchar) part_info->default_engine_type;
|
||||
}
|
||||
#endif
|
||||
int2store(fileinfo+59,db_file->extra_rec_buf_length());
|
||||
|
Reference in New Issue
Block a user