Commit c90669c4 authored by Mikael Ronstrom's avatar Mikael Ronstrom

Fixed removal of column_list keyword for VALUES part, retained for PARTITION...

Fixed removal of column_list keyword for VALUES part, retained for PARTITION BY RANGE/LIST COLUMN_LIST, not entirely working yet
parent 576dd76a
...@@ -2,24 +2,24 @@ drop table if exists t1; ...@@ -2,24 +2,24 @@ drop table if exists t1;
create table t1 (a varchar(5)) create table t1 (a varchar(5))
engine=memory engine=memory
partition by range column_list(a) partition by range column_list(a)
( partition p0 values less than (column_list('m')), ( partition p0 values less than ('m'),
partition p1 values less than (column_list('za'))); partition p1 values less than ('za'));
insert into t1 values ('j'); insert into t1 values ('j');
update t1 set a = 'z' where (a >= 'j'); update t1 set a = 'z' where (a >= 'j');
drop table t1; drop table t1;
create table t1 (a varchar(5)) create table t1 (a varchar(5))
engine=myisam engine=myisam
partition by range column_list(a) partition by range column_list(a)
( partition p0 values less than (column_list('m')), ( partition p0 values less than ('m'),
partition p1 values less than (column_list('za'))); partition p1 values less than ('za'));
insert into t1 values ('j'); insert into t1 values ('j');
update t1 set a = 'z' where (a >= 'j'); update t1 set a = 'z' where (a >= 'j');
drop table t1; drop table t1;
create table t1 (a varchar(5)) create table t1 (a varchar(5))
engine=innodb engine=innodb
partition by range column_list(a) partition by range column_list(a)
( partition p0 values less than (column_list('m')), ( partition p0 values less than ('m'),
partition p1 values less than (column_list('za'))); partition p1 values less than ('za'));
insert into t1 values ('j'); insert into t1 values ('j');
update t1 set a = 'z' where (a >= 'j'); update t1 set a = 'z' where (a >= 'j');
drop table t1; drop table t1;
......
...@@ -78,12 +78,12 @@ partition by range column_list(a,b) ...@@ -78,12 +78,12 @@ partition by range column_list(a,b)
ERROR 42000: Inconsistency in usage of column lists for partitioning near '))' at line 3 ERROR 42000: Inconsistency in usage of column lists for partitioning near '))' at line 3
create table t1 (a int, b char(20)) create table t1 (a int, b char(20))
partition by range(a) partition by range(a)
(partition p0 values less than (column_list(1,"b"))); (partition p0 values less than (1,"b"));
ERROR HY000: Inconsistency in usage of column lists for partitioning ERROR HY000: Cannot have more than one value for this type of RANGE partitioning
create table t1 (a int, b char(20)) create table t1 (a int, b char(20))
partition by range(a) partition by range(a)
(partition p0 values less than (column_list(1,"b"))); (partition p0 values less than (1,"b"));
ERROR HY000: Inconsistency in usage of column lists for partitioning ERROR HY000: Cannot have more than one value for this type of RANGE partitioning
create table t1 (a int, b char(20)); create table t1 (a int, b char(20));
create global index inx on t1 (a,b) create global index inx on t1 (a,b)
partition by range (a) partition by range (a)
...@@ -91,7 +91,7 @@ partition by range (a) ...@@ -91,7 +91,7 @@ partition by range (a)
drop table t1; drop table t1;
create table t1 (a int, b char(20)) create table t1 (a int, b char(20))
partition by range column_list(b) partition by range column_list(b)
(partition p0 values less than (column_list("b"))); (partition p0 values less than ("b"));
drop table t1; drop table t1;
create table t1 (a int) create table t1 (a int)
partition by range (a) partition by range (a)
......
This diff is collapsed.
...@@ -11,8 +11,8 @@ drop table if exists t1; ...@@ -11,8 +11,8 @@ drop table if exists t1;
create table t1 (a varchar(5)) create table t1 (a varchar(5))
engine=memory engine=memory
partition by range column_list(a) partition by range column_list(a)
( partition p0 values less than (column_list('m')), ( partition p0 values less than ('m'),
partition p1 values less than (column_list('za'))); partition p1 values less than ('za'));
insert into t1 values ('j'); insert into t1 values ('j');
update t1 set a = 'z' where (a >= 'j'); update t1 set a = 'z' where (a >= 'j');
drop table t1; drop table t1;
...@@ -20,8 +20,8 @@ drop table t1; ...@@ -20,8 +20,8 @@ drop table t1;
create table t1 (a varchar(5)) create table t1 (a varchar(5))
engine=myisam engine=myisam
partition by range column_list(a) partition by range column_list(a)
( partition p0 values less than (column_list('m')), ( partition p0 values less than ('m'),
partition p1 values less than (column_list('za'))); partition p1 values less than ('za'));
insert into t1 values ('j'); insert into t1 values ('j');
update t1 set a = 'z' where (a >= 'j'); update t1 set a = 'z' where (a >= 'j');
drop table t1; drop table t1;
...@@ -29,8 +29,8 @@ drop table t1; ...@@ -29,8 +29,8 @@ drop table t1;
create table t1 (a varchar(5)) create table t1 (a varchar(5))
engine=innodb engine=innodb
partition by range column_list(a) partition by range column_list(a)
( partition p0 values less than (column_list('m')), ( partition p0 values less than ('m'),
partition p1 values less than (column_list('za'))); partition p1 values less than ('za'));
insert into t1 values ('j'); insert into t1 values ('j');
update t1 set a = 'z' where (a >= 'j'); update t1 set a = 'z' where (a >= 'j');
drop table t1; drop table t1;
......
...@@ -64,15 +64,15 @@ create table t1 (a int, b char(20)) ...@@ -64,15 +64,15 @@ create table t1 (a int, b char(20))
partition by range column_list(a,b) partition by range column_list(a,b)
(partition p0 values less than (1)); (partition p0 values less than (1));
--error ER_PARTITION_COLUMN_LIST_ERROR --error ER_TOO_MANY_VALUES_ERROR
create table t1 (a int, b char(20)) create table t1 (a int, b char(20))
partition by range(a) partition by range(a)
(partition p0 values less than (column_list(1,"b"))); (partition p0 values less than (1,"b"));
--error ER_PARTITION_COLUMN_LIST_ERROR --error ER_TOO_MANY_VALUES_ERROR
create table t1 (a int, b char(20)) create table t1 (a int, b char(20))
partition by range(a) partition by range(a)
(partition p0 values less than (column_list(1,"b"))); (partition p0 values less than (1,"b"));
create table t1 (a int, b char(20)); create table t1 (a int, b char(20));
create global index inx on t1 (a,b) create global index inx on t1 (a,b)
...@@ -82,7 +82,7 @@ drop table t1; ...@@ -82,7 +82,7 @@ drop table t1;
create table t1 (a int, b char(20)) create table t1 (a int, b char(20))
partition by range column_list(b) partition by range column_list(b)
(partition p0 values less than (column_list("b"))); (partition p0 values less than ("b"));
drop table t1; drop table t1;
# #
......
...@@ -74,6 +74,7 @@ typedef struct p_column_list_val ...@@ -74,6 +74,7 @@ typedef struct p_column_list_val
typedef struct p_elem_val typedef struct p_elem_val
{ {
longlong value; longlong value;
uint added_items;
bool null_value; bool null_value;
bool unsigned_flag; bool unsigned_flag;
part_column_list_val *col_val_array; part_column_list_val *col_val_array;
......
This diff is collapsed.
...@@ -280,11 +280,23 @@ class partition_info : public Sql_alloc ...@@ -280,11 +280,23 @@ class partition_info : public Sql_alloc
handler *file, HA_CREATE_INFO *info, handler *file, HA_CREATE_INFO *info,
bool check_partition_function); bool check_partition_function);
void print_no_partition_found(TABLE *table); void print_no_partition_found(TABLE *table);
void print_debug(const char *str, uint*);
int fix_func_partition(THD *thd,
part_elem_value *val,
partition_element *part_elem);
bool fix_column_value_functions(THD *thd,
part_elem_value *val,
uint part_id);
int fix_parser_data(THD *thd);
int add_max_value();
int reorganize_into_single_field_col_val();
part_column_list_val *add_column_value(); part_column_list_val *add_column_value();
bool set_part_expr(char *start_token, Item *item_ptr, bool set_part_expr(char *start_token, Item *item_ptr,
char *end_token, bool is_subpart); char *end_token, bool is_subpart);
static int compare_column_values(const void *a, const void *b); static int compare_column_values(const void *a, const void *b);
bool set_up_charset_field_preps(); bool set_up_charset_field_preps();
bool init_column_part();
bool add_column_list_value(Item *item);
private: private:
static int list_part_cmp(const void* a, const void* b); static int list_part_cmp(const void* a, const void* b);
bool set_up_default_partitions(handler *file, HA_CREATE_INFO *info, bool set_up_default_partitions(handler *file, HA_CREATE_INFO *info,
...@@ -294,9 +306,6 @@ class partition_info : public Sql_alloc ...@@ -294,9 +306,6 @@ class partition_info : public Sql_alloc
uint start_no); uint start_no);
char *create_subpartition_name(uint subpart_no, const char *part_name); char *create_subpartition_name(uint subpart_no, const char *part_name);
bool has_unique_name(partition_element *element); bool has_unique_name(partition_element *element);
bool fix_column_value_functions(THD *thd,
part_column_list_val *col_val,
uint part_id);
}; };
uint32 get_next_partition_id_range(struct st_partition_iter* part_iter); uint32 get_next_partition_id_range(struct st_partition_iter* part_iter);
......
...@@ -5822,8 +5822,6 @@ ER_SAME_NAME_PARTITION ...@@ -5822,8 +5822,6 @@ ER_SAME_NAME_PARTITION
eng "Duplicate partition name %-.192s" eng "Duplicate partition name %-.192s"
ger "Doppelter Partitionsname: %-.192s" ger "Doppelter Partitionsname: %-.192s"
swe "Duplicerat partitionsnamn %-.192s" swe "Duplicerat partitionsnamn %-.192s"
ER_SAME_NAME_PARTITION_FIELD
eng "Duplicate partition field name %-.192s"
ER_NO_BINLOG_ERROR ER_NO_BINLOG_ERROR
eng "It is not allowed to shut off binlog on this command" eng "It is not allowed to shut off binlog on this command"
ger "Es es nicht erlaubt, bei diesem Befehl binlog abzuschalten" ger "Es es nicht erlaubt, bei diesem Befehl binlog abzuschalten"
...@@ -6192,6 +6190,12 @@ ER_TOO_MANY_PARTITION_FUNC_FIELDS_ERROR ...@@ -6192,6 +6190,12 @@ ER_TOO_MANY_PARTITION_FUNC_FIELDS_ERROR
eng "Too many fields in '%s'" eng "Too many fields in '%s'"
ER_MAXVALUE_IN_LIST_PARTITIONING_ERROR ER_MAXVALUE_IN_LIST_PARTITIONING_ERROR
eng "Cannot use MAXVALUE as value in List partitioning" eng "Cannot use MAXVALUE as value in List partitioning"
ER_TOO_MANY_VALUES_ERROR
eng "Cannot have more than one value for this type of %-.64s partitioning"
ER_SAME_NAME_PARTITION_FIELD
eng "Duplicate partition field name %-.192s"
ER_ROW_SINGLE_PARTITION_FIELD_ERROR
eng "Row expressions in VALUES IN only allowed for multi-field column partitioning"
# When updating these, please update EXPLAIN_FILENAME_MAX_EXTRA_LENGTH in # When updating these, please update EXPLAIN_FILENAME_MAX_EXTRA_LENGTH in
# mysql_priv.h with the new maximal additional length for explain_filename. # mysql_priv.h with the new maximal additional length for explain_filename.
......
...@@ -1990,8 +1990,11 @@ static int add_column_list_values(File fptr, partition_info *part_info, ...@@ -1990,8 +1990,11 @@ static int add_column_list_values(File fptr, partition_info *part_info,
int err= 0; int err= 0;
uint i; uint i;
uint num_elements= part_info->part_field_list.elements; uint num_elements= part_info->part_field_list.elements;
err+= add_string(fptr, partition_keywords[PKW_COLUMNS].str); bool use_parenthesis= (part_info->part_type == LIST_PARTITION &&
err+= add_begin_parenthesis(fptr); part_info->num_columns > 1U);
if (use_parenthesis)
err+= add_begin_parenthesis(fptr);
for (i= 0; i < num_elements; i++) for (i= 0; i < num_elements; i++)
{ {
part_column_list_val *col_val= &list_value->col_val_array[i]; part_column_list_val *col_val= &list_value->col_val_array[i];
...@@ -2032,7 +2035,8 @@ static int add_column_list_values(File fptr, partition_info *part_info, ...@@ -2032,7 +2035,8 @@ static int add_column_list_values(File fptr, partition_info *part_info,
if (i != (num_elements - 1)) if (i != (num_elements - 1))
err+= add_string(fptr, comma_str); err+= add_string(fptr, comma_str);
} }
err+= add_end_parenthesis(fptr); if (use_parenthesis)
err+= add_end_parenthesis(fptr);
return err; return err;
} }
...@@ -3894,10 +3898,12 @@ bool mysql_unpack_partition(THD *thd, ...@@ -3894,10 +3898,12 @@ bool mysql_unpack_partition(THD *thd,
mem_alloc_error(sizeof(partition_info)); mem_alloc_error(sizeof(partition_info));
goto end; goto end;
} }
lex.part_info->part_state= part_state; part_info= lex.part_info;
lex.part_info->part_state_len= part_state_len; part_info->part_state= part_state;
part_info->part_state_len= part_state_len;
DBUG_PRINT("info", ("Parse: %s", part_buf)); DBUG_PRINT("info", ("Parse: %s", part_buf));
if (parse_sql(thd, & parser_state, NULL)) if (parse_sql(thd, & parser_state, NULL) ||
part_info->fix_parser_data(thd))
{ {
thd->free_items(); thd->free_items();
goto end; goto end;
...@@ -3918,7 +3924,6 @@ bool mysql_unpack_partition(THD *thd, ...@@ -3918,7 +3924,6 @@ bool mysql_unpack_partition(THD *thd,
*/ */
DBUG_PRINT("info", ("Successful parse")); DBUG_PRINT("info", ("Successful parse"));
part_info= lex.part_info;
DBUG_PRINT("info", ("default engine = %s, default_db_type = %s", DBUG_PRINT("info", ("default engine = %s, default_db_type = %s",
ha_resolve_storage_engine_name(part_info->default_engine_type), ha_resolve_storage_engine_name(part_info->default_engine_type),
ha_resolve_storage_engine_name(default_db_type))); ha_resolve_storage_engine_name(default_db_type)));
...@@ -4370,6 +4375,11 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, ...@@ -4370,6 +4375,11 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
} }
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
alt_part_info->column_list= tab_part_info->column_list;
if (alt_part_info->fix_parser_data(thd))
{
DBUG_RETURN(TRUE);
}
} }
if (alter_info->flags & ALTER_ADD_PARTITION) if (alter_info->flags & ALTER_ADD_PARTITION)
{ {
...@@ -5126,6 +5136,10 @@ the generated partition syntax in a correct manner. ...@@ -5126,6 +5136,10 @@ the generated partition syntax in a correct manner.
{ {
DBUG_PRINT("info", ("partition changed")); DBUG_PRINT("info", ("partition changed"));
*partition_changed= TRUE; *partition_changed= TRUE;
if (thd->work_part_info->fix_parser_data(thd))
{
DBUG_RETURN(TRUE);
}
} }
/* /*
Set up partition default_engine_type either from the create_info Set up partition default_engine_type either from the create_info
......
This diff is collapsed.
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