From: gluh Date: December 19 2005 9:24am Subject: bk commit into 5.1 tree (gluh:1.1973) List-Archive: http://lists.mysql.com/commits/240 Message-Id: <20051219092425.C9D383006C@eagle.intranet.mysql.r18.ru> Below is the list of changes that have just been committed into a local 5.1 repository of gluh. When gluh does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.1973 05/12/19 13:24:14 gluh@stripped +9 -0 WL#2506: Information Schema tables for PARTITIONing(2nd version) added I_S 'PARTITIONS' table mysql-test/t/information_schema_part.test 1.1 05/12/19 13:24:05 gluh@stripped +86 -0 mysql-test/t/information_schema_part.test 1.0 05/12/19 13:24:05 gluh@stripped +0 -0 BitKeeper file /home/gluh/MySQL/Devel/5.1-new.2506/mysql-test/t/information_schema_part.test mysql-test/r/information_schema_part.result 1.1 05/12/19 13:24:04 gluh@stripped +95 -0 sql/table.h 1.119 05/12/19 13:24:04 gluh@stripped +1 -0 WL#2506: Information Schema tables for PARTITIONing(2nd version) added I_S 'PARTITIONS' table sql/sql_show.cc 1.286 05/12/19 13:24:04 gluh@stripped +299 -0 WL#2506: Information Schema tables for PARTITIONing(2nd version) added I_S 'PARTITIONS' table sql/sql_partition.cc 1.17 05/12/19 13:24:04 gluh@stripped +17 -13 WL#2506: Information Schema tables for PARTITIONing(2nd version) added I_S 'PARTITIONS' table sql/mysql_priv.h 1.355 05/12/19 13:24:04 gluh@stripped +3 -0 WL#2506: Information Schema tables for PARTITIONing(2nd version) added I_S 'PARTITIONS' table sql/ha_partition.h 1.7 05/12/19 13:24:04 gluh@stripped +7 -0 WL#2506: Information Schema tables for PARTITIONing(2nd version) added I_S 'PARTITIONS' table mysql-test/r/information_schema_part.result 1.0 05/12/19 13:24:04 gluh@stripped +0 -0 BitKeeper file /home/gluh/MySQL/Devel/5.1-new.2506/mysql-test/r/information_schema_part.result mysql-test/r/information_schema_db.result 1.7 05/12/19 13:24:04 gluh@stripped +1 -0 WL#2506: Information Schema tables for PARTITIONing(2nd version) added I_S 'PARTITIONS' table mysql-test/r/information_schema.result 1.92 05/12/19 13:24:04 gluh@stripped +10 -2 WL#2506: Information Schema tables for PARTITIONing(2nd version) added I_S 'PARTITIONS' table # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: gluh # Host: eagle.intranet.mysql.r18.ru # Root: /home/gluh/MySQL/Devel/5.1-new.2506 --- 1.354/sql/mysql_priv.h Mon Dec 12 23:55:12 2005 +++ 1.355/sql/mysql_priv.h Mon Dec 19 13:24:04 2005 @@ -886,6 +886,9 @@ void append_definer(THD *thd, String *bu /* information schema */ extern LEX_STRING information_schema_name; +#ifdef WITH_PARTITION_STORAGE_ENGINE +const extern LEX_STRING partition_keywords[]; +#endif LEX_STRING *make_lex_string(THD *thd, LEX_STRING *lex_str, const char* str, uint length, bool allocate_lex_string); --- 1.285/sql/sql_show.cc Thu Dec 1 13:02:45 2005 +++ 1.286/sql/sql_show.cc Mon Dec 19 13:24:04 2005 @@ -26,6 +26,9 @@ #include "authors.h" #include +#ifdef WITH_PARTITION_STORAGE_ENGINE +#include "ha_partition.h" +#endif static const char *grant_names[]={ "select","insert","update","delete","create","drop","reload","shutdown", @@ -3368,6 +3371,269 @@ static int get_schema_key_column_usage_r } +#ifdef WITH_PARTITION_STORAGE_ENGINE +static void collect_partition_expr(List &field_list, String *str) +{ + List_iterator part_it(field_list); + ulong no_fields= field_list.elements; + const char *field_str; + str->length(0); + while ((field_str= part_it++)) + { + str->append(field_str); + if (--no_fields != 0) + str->append(","); + } + return; +} + + +static void store_schema_partitions_record(THD *thd, TABLE *table, + partition_element *part_elem, + ha_partition *partition_file, + uint part_id) +{ + CHARSET_INFO *cs= system_charset_info; + TIME time; + handler *file= partition_file->get_parttition_part_handler(part_id); + + file->info(HA_STATUS_CONST | HA_STATUS_TIME | HA_STATUS_VARIABLE | + HA_STATUS_NO_LOCK); + table->field[12]->store((longlong) file->records, TRUE); + table->field[13]->store((longlong) file->mean_rec_length, TRUE); + table->field[14]->store((longlong) file->data_file_length, TRUE); + if (file->max_data_file_length) + { + table->field[15]->store((longlong) file->max_data_file_length, TRUE); + table->field[15]->set_notnull(); + } + table->field[16]->store((longlong) file->index_file_length, TRUE); + table->field[17]->store((longlong) file->delete_length, TRUE); + if (file->create_time) + { + thd->variables.time_zone->gmt_sec_to_TIME(&time, + file->create_time); + table->field[18]->store_time(&time, MYSQL_TIMESTAMP_DATETIME); + table->field[18]->set_notnull(); + } + if (file->update_time) + { + thd->variables.time_zone->gmt_sec_to_TIME(&time, + file->update_time); + table->field[19]->store_time(&time, MYSQL_TIMESTAMP_DATETIME); + table->field[19]->set_notnull(); + } + if (file->check_time) + { + thd->variables.time_zone->gmt_sec_to_TIME(&time, file->check_time); + table->field[20]->store_time(&time, MYSQL_TIMESTAMP_DATETIME); + table->field[20]->set_notnull(); + } + if (file->table_flags() & (ulong) HA_HAS_CHECKSUM) + { + table->field[21]->store((longlong) file->checksum(), TRUE); + table->field[21]->set_notnull(); + } + + if (part_elem->part_comment) + table->field[22]->store(part_elem->part_comment, + strlen(part_elem->part_comment), cs); + else + table->field[22]->store(STRING_WITH_LEN("default"), cs); + if (part_elem->nodegroup_id != UNDEF_NODEGROUP) + table->field[23]->store((longlong) part_elem->nodegroup_id, TRUE); + else + table->field[23]->store(STRING_WITH_LEN("default"), cs); + if (part_elem->tablespace_name) + table->field[24]->store(part_elem->tablespace_name, + strlen(part_elem->tablespace_name), cs); + else + table->field[24]->store(STRING_WITH_LEN("default"), cs); + return; +} +#endif + + +static int get_schema_partitions_record(THD *thd, struct st_table_list *tables, + TABLE *table, bool res, + const char *base_name, + const char *file_name) +{ +#ifdef WITH_PARTITION_STORAGE_ENGINE + CHARSET_INFO *cs= system_charset_info; + char buff[61]; + String tmp_res(buff, sizeof(buff), cs); + String tmp_str; + TIME time; + TABLE *show_table= tables->table; + handler *file= show_table->file; + partition_info *part_info= show_table->part_info; + DBUG_ENTER("get_schema_partitions_record"); + + if (res) + { + if (part_info) + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + thd->net.last_errno, thd->net.last_error); + thd->clear_error(); + DBUG_RETURN(0); + } + + if (part_info) + { + partition_element *part_elem; + List_iterator part_it(part_info->partitions); + uint part_pos= 0, part_id= 0; + uint no_parts= part_info->no_parts; + handler *part_file; + + restore_record(table, s->default_values); + table->field[1]->store(base_name, strlen(base_name), cs); + table->field[2]->store(file_name, strlen(file_name), cs); + + + /* Partition method*/ + switch (part_info->part_type) { + case RANGE_PARTITION: + table->field[7]->store(partition_keywords[PKW_RANGE].str, + partition_keywords[PKW_RANGE].length, cs); + break; + case LIST_PARTITION: + table->field[7]->store(partition_keywords[PKW_LIST].str, + partition_keywords[PKW_LIST].length, cs); + break; + case HASH_PARTITION: + if (part_info->list_of_part_fields) + table->field[7]->store(partition_keywords[PKW_KEY].str, + partition_keywords[PKW_KEY].length, cs); + else + table->field[7]->store(partition_keywords[PKW_HASH].str, + partition_keywords[PKW_HASH].length, cs); + break; + default: + DBUG_ASSERT(0); + current_thd->fatal_error(); + DBUG_RETURN(1); + } + table->field[7]->set_notnull(); + + /* Partition expression */ + if (part_info->part_expr) + { + table->field[9]->store(part_info->part_func_string, + part_info->part_func_len, cs); + table->field[9]->set_notnull(); + } + else if (part_info->list_of_part_fields) + { + collect_partition_expr(part_info->part_field_list, &tmp_str); + table->field[9]->store(tmp_str.ptr(), tmp_str.length(), cs); + table->field[9]->set_notnull(); + } + + if (is_sub_partitioned(part_info)) + { + /* Subpartition method */ + if (part_info->list_of_subpart_fields) + table->field[8]->store(partition_keywords[PKW_KEY].str, + partition_keywords[PKW_KEY].length, cs); + else + table->field[8]->store(partition_keywords[PKW_HASH].str, + partition_keywords[PKW_HASH].length, cs); + table->field[8]->set_notnull(); + + /* Subpartition expression */ + if (part_info->subpart_expr) + { + table->field[10]->store(part_info->subpart_func_string, + part_info->subpart_func_len, cs); + table->field[10]->set_notnull(); + } + else if (part_info->list_of_subpart_fields) + { + collect_partition_expr(part_info->subpart_field_list, &tmp_str); + table->field[10]->store(tmp_str.ptr(), tmp_str.length(), cs); + table->field[10]->set_notnull(); + } + } + + while ((part_elem= part_it++)) + { + + + table->field[3]->store(part_elem->partition_name, + strlen(part_elem->partition_name), cs); + table->field[3]->set_notnull(); + /* PARTITION_ORDINAL_POSITION */ + table->field[5]->store((longlong) ++part_pos, TRUE); + table->field[5]->set_notnull(); + + /* Partition description */ + if (part_info->part_type == RANGE_PARTITION) + { + if (part_elem->range_value != LONGLONG_MAX) + table->field[11]->store((longlong) part_elem->range_value, FALSE); + else + table->field[11]->store(partition_keywords[PKW_MAXVALUE].str, + partition_keywords[PKW_MAXVALUE].length, cs); + table->field[11]->set_notnull(); + } + else if (part_info->part_type == LIST_PARTITION) + { + List_iterator list_val_it(part_elem->list_val_list); + longlong *list_value; + uint no_items= part_elem->list_val_list.elements; + tmp_str.length(0); + tmp_res.length(0); + while ((list_value= list_val_it++)) + { + tmp_res.set(*list_value, cs); + tmp_str.append(tmp_res); + if (--no_items != 0) + tmp_str.append(","); + }; + table->field[11]->store(tmp_str.ptr(), tmp_str.length(), cs); + table->field[11]->set_notnull(); + } + + if (part_elem->subpartitions.elements) + { + List_iterator sub_it(part_elem->subpartitions); + partition_element *subpart_elem; + uint subpart_pos= 0; + + while ((subpart_elem= sub_it++)) + { + table->field[4]->store(subpart_elem->partition_name, + strlen(subpart_elem->partition_name), cs); + table->field[4]->set_notnull(); + /* SUBPARTITION_ORDINAL_POSITION */ + table->field[6]->store((longlong) ++subpart_pos, TRUE); + table->field[6]->set_notnull(); + + store_schema_partitions_record(thd, table, subpart_elem, + (ha_partition *)file, part_id); + part_id++; + if(schema_table_store_record(thd, table)) + DBUG_RETURN(1); + } + } + else + { + store_schema_partitions_record(thd, table, part_elem, + (ha_partition *)file, part_id); + part_id++; + if(schema_table_store_record(thd, table)) + DBUG_RETURN(1); + } + } + DBUG_RETURN(0); + } +#endif + DBUG_RETURN(0); +} + + int fill_open_tables(THD *thd, TABLE_LIST *tables, COND *cond) { DBUG_ENTER("fill_open_tables"); @@ -4164,6 +4430,37 @@ ST_FIELD_INFO triggers_fields_info[]= }; +ST_FIELD_INFO partitions_fields_info[]= +{ + {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0}, + {"TABLE_SCHEMA",NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, + {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, + {"PARTITION_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, + {"SUBPARTITION_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, + {"PARTITION_ORDINAL_POSITION", 21 , MYSQL_TYPE_LONG, 0, 1, 0}, + {"SUBPARTITION_ORDINAL_POSITION", 21 , MYSQL_TYPE_LONG, 0, 1, 0}, + {"PARTITION_METHOD", 5, MYSQL_TYPE_STRING, 0, 1, 0}, + {"SUBPARTITION_METHOD", 5, MYSQL_TYPE_STRING, 0, 1, 0}, + {"PARTITION_EXPRESSION", 65535, MYSQL_TYPE_STRING, 0, 1, 0}, + {"SUBPARTITION_EXPRESSION", 65535, MYSQL_TYPE_STRING, 0, 1, 0}, + {"PARTITION_DESCRIPTION", 65535, MYSQL_TYPE_STRING, 0, 1, 0}, + {"TABLE_ROWS", 21 , MYSQL_TYPE_LONG, 0, 0, 0}, + {"AVG_ROW_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 0, 0}, + {"DATA_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 0, 0}, + {"MAX_DATA_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, 0}, + {"INDEX_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 0, 0}, + {"DATA_FREE", 21 , MYSQL_TYPE_LONG, 0, 0, 0}, + {"CREATE_TIME", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, 0}, + {"UPDATE_TIME", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, 0}, + {"CHECK_TIME", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, 0}, + {"CHECKSUM", 21 , MYSQL_TYPE_LONG, 0, 1, 0}, + {"PARTITION_COMMENT", 255, MYSQL_TYPE_STRING, 0, 0, 0}, + {"NODEGROUP", 21 , MYSQL_TYPE_LONG, 0, 0, 0}, + {"TABLESPACE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} +}; + + ST_FIELD_INFO variables_fields_info[]= { {"Variable_name", 80, MYSQL_TYPE_STRING, 0, 0, "Variable_name"}, @@ -4192,6 +4489,8 @@ ST_SCHEMA_TABLE schema_tables[]= get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0}, {"OPEN_TABLES", open_tables_fields_info, create_schema_table, fill_open_tables, make_old_format, 0, -1, -1, 1}, + {"PARTITIONS", partitions_fields_info, create_schema_table, + get_all_tables, 0, get_schema_partitions_record, 1, 2, 0}, {"ROUTINES", proc_fields_info, create_schema_table, fill_schema_proc, make_proc_old_format, 0, -1, -1, 0}, {"SCHEMATA", schema_fields_info, create_schema_table, --- 1.118/sql/table.h Wed Dec 7 10:28:13 2005 +++ 1.119/sql/table.h Mon Dec 19 13:24:04 2005 @@ -324,6 +324,7 @@ enum enum_schema_tables SCH_COLUMN_PRIVILEGES, SCH_KEY_COLUMN_USAGE, SCH_OPEN_TABLES, + SCH_PARTITIONS, SCH_PROCEDURES, SCH_SCHEMATA, SCH_SCHEMA_PRIVILEGES, --- 1.91/mysql-test/r/information_schema.result Thu Dec 1 11:08:05 2005 +++ 1.92/mysql-test/r/information_schema.result Mon Dec 19 13:24:04 2005 @@ -42,6 +42,7 @@ COLLATION_CHARACTER_SET_APPLICABILITY COLUMNS COLUMN_PRIVILEGES KEY_COLUMN_USAGE +PARTITIONS ROUTINES SCHEMATA SCHEMA_PRIVILEGES @@ -723,7 +724,7 @@ CREATE TABLE t_crashme ( f1 BIGINT); CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1; CREATE VIEW a2 AS SELECT t_CRASHME FROM a1; count(*) -102 +103 drop view a2, a1; drop table t_crashme; select table_schema,table_name, column_name from @@ -731,6 +732,9 @@ information_schema.columns where data_type = 'longtext'; table_schema table_name column_name information_schema COLUMNS COLUMN_TYPE +information_schema PARTITIONS PARTITION_EXPRESSION +information_schema PARTITIONS SUBPARTITION_EXPRESSION +information_schema PARTITIONS PARTITION_DESCRIPTION information_schema ROUTINES ROUTINE_DEFINITION information_schema ROUTINES SQL_MODE information_schema TRIGGERS ACTION_CONDITION @@ -741,6 +745,9 @@ information_schema VIEWS VIEW_DEFINITION select table_name, column_name, data_type from information_schema.columns where data_type = 'datetime'; table_name column_name data_type +PARTITIONS CREATE_TIME datetime +PARTITIONS UPDATE_TIME datetime +PARTITIONS CHECK_TIME datetime ROUTINES CREATED datetime ROUTINES LAST_ALTERED datetime TABLES CREATE_TIME datetime @@ -783,6 +790,7 @@ TABLE_NAME COLUMN_NAME PRIVILEGES COLUMNS TABLE_NAME select COLUMN_PRIVILEGES TABLE_NAME select KEY_COLUMN_USAGE TABLE_NAME select +PARTITIONS TABLE_NAME select STATISTICS TABLE_NAME select TABLES TABLE_NAME select TABLE_CONSTRAINTS TABLE_NAME select @@ -793,7 +801,7 @@ delete from mysql.db where user='mysqlte flush privileges; SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA; table_schema count(*) -information_schema 16 +information_schema 17 mysql 18 create table t1 (i int, j int); create trigger trg1 before insert on t1 for each row --- 1.6/mysql-test/r/information_schema_db.result Sat Aug 6 02:50:34 2005 +++ 1.7/mysql-test/r/information_schema_db.result Mon Dec 19 13:24:04 2005 @@ -7,6 +7,7 @@ COLLATION_CHARACTER_SET_APPLICABILITY COLUMNS COLUMN_PRIVILEGES KEY_COLUMN_USAGE +PARTITIONS ROUTINES SCHEMATA SCHEMA_PRIVILEGES --- New file --- +++ mysql-test/r/information_schema_part.result 05/12/19 13:24:04 drop table if exists t1,t2,t3,t4; create table t1 (a int not null,b int not null,c int not null, primary key(a,b)) partition by list (b*a) (partition x1 values in (1) tablespace ts1, partition x2 values in (3, 11, 5, 7) tablespace ts2, partition x3 values in (16, 8, 5+19, 70-43) tablespace ts3); select * from information_schema.partitions where table_schema="test" and table_name="t1"; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME NULL test t1 x1 NULL 1 NULL LIST NULL b*a NULL 1 0 0 0 # 1024 0 # # NULL NULL default 0 ts1 NULL test t1 x2 NULL 2 NULL LIST NULL b*a NULL 3,11,5,7 0 0 0 # 1024 0 # # NULL NULL default 0 ts2 NULL test t1 x3 NULL 3 NULL LIST NULL b*a NULL 16,8,24,27 0 0 0 # 1024 0 # # NULL NULL default 0 ts3 create table t2 (a int not null,b int not null,c int not null, primary key(a,b)) partition by range (a) partitions 3 (partition x1 values less than (5) tablespace ts1, partition x2 values less than (10) tablespace ts2, partition x3 values less than maxvalue tablespace ts3); select * from information_schema.partitions where table_schema="test" and table_name="t2"; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME NULL test t2 x1 NULL 1 NULL RANGE NULL a NULL 5 0 0 0 # 1024 0 # # NULL NULL default 0 ts1 NULL test t2 x2 NULL 2 NULL RANGE NULL a NULL 10 0 0 0 # 1024 0 # # NULL NULL default 0 ts2 NULL test t2 x3 NULL 3 NULL RANGE NULL a NULL MAXVALUE 0 0 0 # 1024 0 # # NULL NULL default 0 ts3 create table t3 (f1 date) partition by hash(month(f1)) partitions 3; select * from information_schema.partitions where table_schema="test" and table_name="t3"; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME NULL test t3 p0 NULL 1 NULL HASH NULL month(f1) NULL NULL 0 0 0 # 1024 0 # # NULL NULL default 0 default NULL test t3 p1 NULL 2 NULL HASH NULL month(f1) NULL NULL 0 0 0 # 1024 0 # # NULL NULL default 0 default NULL test t3 p2 NULL 3 NULL HASH NULL month(f1) NULL NULL 0 0 0 # 1024 0 # # NULL NULL default 0 default create table t4 (f1 date, f2 int) partition by key(f1,f2) partitions 3; select * from information_schema.partitions where table_schema="test" and table_name="t4"; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME NULL test t4 p0 NULL 1 NULL KEY NULL f1,f2 NULL NULL 0 0 0 # 1024 0 # # NULL NULL default 0 default NULL test t4 p1 NULL 2 NULL KEY NULL f1,f2 NULL NULL 0 0 0 # 1024 0 # # NULL NULL default 0 default NULL test t4 p2 NULL 3 NULL KEY NULL f1,f2 NULL NULL 0 0 0 # 1024 0 # # NULL NULL default 0 default drop table t1,t2,t3,t4; create table t1 (a int not null,b int not null,c int not null,primary key (a,b)) partition by range (a) subpartition by hash (a+b) ( partition x1 values less than (1) ( subpartition x11 tablespace t1, subpartition x12 tablespace t2), partition x2 values less than (5) ( subpartition x21 tablespace t1, subpartition x22 tablespace t2) ); create table t2 (a int not null,b int not null,c int not null,primary key (a,b)) partition by range (a) subpartition by key (a) ( partition x1 values less than (1) ( subpartition x11 tablespace t1, subpartition x12 tablespace t2), partition x2 values less than (5) ( subpartition x21 tablespace t1, subpartition x22 tablespace t2) ); select * from information_schema.partitions where table_schema="test"; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME NULL test t1 x1 x11 1 1 RANGE HASH a a+b 1 0 0 0 # 1024 0 # # NULL NULL default 0 t1 NULL test t1 x1 x12 1 2 RANGE HASH a a+b 1 0 0 0 # 1024 0 # # NULL NULL default 0 t2 NULL test t1 x2 x21 2 1 RANGE HASH a a+b 5 0 0 0 # 1024 0 # # NULL NULL default 0 t1 NULL test t1 x2 x22 2 2 RANGE HASH a a+b 5 0 0 0 # 1024 0 # # NULL NULL default 0 t2 NULL test t2 x1 x11 1 1 RANGE KEY a a 1 0 0 0 # 1024 0 # # NULL NULL default 0 t1 NULL test t2 x1 x12 1 2 RANGE KEY a a 1 0 0 0 # 1024 0 # # NULL NULL default 0 t2 NULL test t2 x2 x21 2 1 RANGE KEY a a 5 0 0 0 # 1024 0 # # NULL NULL default 0 t1 NULL test t2 x2 x22 2 2 RANGE KEY a a 5 0 0 0 # 1024 0 # # NULL NULL default 0 t2 drop table t1,t2; create table t1 ( a int not null, b int not null, c int not null, primary key (a,b)) partition by range (a) subpartition by hash (a+b) ( partition x1 values less than (1) ( subpartition x11 tablespace t1 nodegroup 0, subpartition x12 tablespace t2 nodegroup 1), partition x2 values less than (5) ( subpartition x21 tablespace t1 nodegroup 0, subpartition x22 tablespace t2 nodegroup 1) ); select * from information_schema.partitions; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME NULL test t1 x1 x11 1 1 RANGE HASH a a+b 1 0 0 0 # 1024 0 # # NULL NULL default 0 t1 NULL test t1 x1 x12 1 2 RANGE HASH a a+b 1 0 0 0 # 1024 0 # # NULL NULL default 1 t2 NULL test t1 x2 x21 2 1 RANGE HASH a a+b 5 0 0 0 # 1024 0 # # NULL NULL default 0 t1 NULL test t1 x2 x22 2 2 RANGE HASH a a+b 5 0 0 0 # 1024 0 # # NULL NULL default 1 t2 drop table t1; --- New file --- +++ mysql-test/t/information_schema_part.test 05/12/19 13:24:05 -- source include/have_partition.inc --disable_warnings drop table if exists t1,t2,t3,t4; --enable_warnings create table t1 (a int not null,b int not null,c int not null, primary key(a,b)) partition by list (b*a) (partition x1 values in (1) tablespace ts1, partition x2 values in (3, 11, 5, 7) tablespace ts2, partition x3 values in (16, 8, 5+19, 70-43) tablespace ts3); --replace_column 16 # 19 # 20 # select * from information_schema.partitions where table_schema="test" and table_name="t1"; create table t2 (a int not null,b int not null,c int not null, primary key(a,b)) partition by range (a) partitions 3 (partition x1 values less than (5) tablespace ts1, partition x2 values less than (10) tablespace ts2, partition x3 values less than maxvalue tablespace ts3); --replace_column 16 # 19 # 20 # select * from information_schema.partitions where table_schema="test" and table_name="t2"; create table t3 (f1 date) partition by hash(month(f1)) partitions 3; --replace_column 16 # 19 # 20 # select * from information_schema.partitions where table_schema="test" and table_name="t3"; create table t4 (f1 date, f2 int) partition by key(f1,f2) partitions 3; --replace_column 16 # 19 # 20 # select * from information_schema.partitions where table_schema="test" and table_name="t4"; drop table t1,t2,t3,t4; create table t1 (a int not null,b int not null,c int not null,primary key (a,b)) partition by range (a) subpartition by hash (a+b) ( partition x1 values less than (1) ( subpartition x11 tablespace t1, subpartition x12 tablespace t2), partition x2 values less than (5) ( subpartition x21 tablespace t1, subpartition x22 tablespace t2) ); create table t2 (a int not null,b int not null,c int not null,primary key (a,b)) partition by range (a) subpartition by key (a) ( partition x1 values less than (1) ( subpartition x11 tablespace t1, subpartition x12 tablespace t2), partition x2 values less than (5) ( subpartition x21 tablespace t1, subpartition x22 tablespace t2) ); --replace_column 16 # 19 # 20 # select * from information_schema.partitions where table_schema="test"; drop table t1,t2; create table t1 ( a int not null, b int not null, c int not null, primary key (a,b)) partition by range (a) subpartition by hash (a+b) ( partition x1 values less than (1) ( subpartition x11 tablespace t1 nodegroup 0, subpartition x12 tablespace t2 nodegroup 1), partition x2 values less than (5) ( subpartition x21 tablespace t1 nodegroup 0, subpartition x22 tablespace t2 nodegroup 1) ); --replace_column 16 # 19 # 20 # select * from information_schema.partitions; drop table t1; --- 1.6/sql/ha_partition.h Fri Nov 25 12:08:30 2005 +++ 1.7/sql/ha_partition.h Mon Dec 19 13:24:04 2005 @@ -18,6 +18,11 @@ #pragma interface /* gcc class implementation */ #endif +enum partition_keywords +{ + PKW_HASH= 0, PKW_RANGE, PKW_LIST, PKW_KEY, PKW_MAXVALUE +}; + /* PARTITION_SHARE is a structure that will be shared amoung all open handlers The partition implements the minimum of what you will probably need. @@ -407,6 +412,8 @@ public: purposes. ------------------------------------------------------------------------- */ + handler *get_parttition_part_handler(uint part_id) + { return m_file[part_id]; } virtual void info(uint); virtual int extra(enum ha_extra_function operation); virtual int extra_opt(enum ha_extra_function operation, ulong cachesize); --- 1.16/sql/sql_partition.cc Thu Dec 15 15:22:59 2005 +++ 1.17/sql/sql_partition.cc Mon Dec 19 13:24:04 2005 @@ -43,13 +43,17 @@ /* Partition related functions declarations and some static constants; */ -static const char *hash_str= "HASH"; -static const char *range_str= "RANGE"; -static const char *list_str= "LIST"; +const LEX_STRING partition_keywords[]= +{ + { (char *) STRING_WITH_LEN("HASH") }, + { (char *) STRING_WITH_LEN("RANGE") }, + { (char *) STRING_WITH_LEN("LIST") }, + { (char *) STRING_WITH_LEN("KEY") }, + { (char *) STRING_WITH_LEN("MAXVALUE") } +}; static const char *part_str= "PARTITION"; static const char *sub_str= "SUB"; static const char *by_str= "BY"; -static const char *key_str= "KEY"; static const char *space_str= " "; static const char *equal_str= "="; static const char *end_paren_str= ")"; @@ -629,9 +633,9 @@ static bool set_up_default_partitions(pa { const char *error_string; if (part_info->part_type == RANGE_PARTITION) - error_string= range_str; + error_string= partition_keywords[PKW_RANGE].str; else - error_string= list_str; + error_string= partition_keywords[PKW_LIST].str; my_error(ER_PARTITIONS_MUST_BE_DEFINED_ERROR, MYF(0), error_string); goto end; } @@ -1770,13 +1774,13 @@ bool fix_partition_func(THD *thd, const const char *error_str; if (part_info->part_type == RANGE_PARTITION) { - error_str= range_str; + error_str= partition_keywords[PKW_RANGE].str; if (unlikely(check_range_constants(part_info))) goto end; } else if (part_info->part_type == LIST_PARTITION) { - error_str= list_str; + error_str= partition_keywords[PKW_LIST].str; if (unlikely(check_list_constants(part_info))) goto end; } @@ -1878,7 +1882,7 @@ static int add_part_key_word(File fptr, static int add_hash(File fptr) { - return add_part_key_word(fptr, hash_str); + return add_part_key_word(fptr, partition_keywords[PKW_HASH].str); } static int add_partition(File fptr) @@ -1910,7 +1914,7 @@ static int add_key_partition(File fptr, uint i, no_fields; int err; List_iterator part_it(field_list); - err= add_part_key_word(fptr, key_str); + err= add_part_key_word(fptr, partition_keywords[PKW_KEY].str); no_fields= field_list.elements; i= 0; do @@ -1992,7 +1996,7 @@ static int add_partition_values(File fpt err+= add_end_parenthesis(fptr); } else - err+= add_string(fptr, "MAXVALUE"); + err+= add_string(fptr, partition_keywords[PKW_MAXVALUE].str); } else if (part_info->part_type == LIST_PARTITION) { @@ -2080,11 +2084,11 @@ char *generate_partition_syntax(partitio { case RANGE_PARTITION: add_default_info= TRUE; - err+= add_part_key_word(fptr, range_str); + err+= add_part_key_word(fptr, partition_keywords[PKW_RANGE].str); break; case LIST_PARTITION: add_default_info= TRUE; - err+= add_part_key_word(fptr, list_str); + err+= add_part_key_word(fptr, partition_keywords[PKW_LIST].str); break; case HASH_PARTITION: if (part_info->linear_hash_ind)