mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 04:22:27 +01:00
Merge mronstrom@bk-internal.mysql.com:/home/bk/mysql-5.1
into c-8b0ae253.1238-1-64736c10.cust.bredbandsbolaget.se:/home/pappa/mysql-5.1
This commit is contained in:
commit
451cffcf47
6 changed files with 49 additions and 47 deletions
|
@ -290,7 +290,8 @@ partition by range (a)
|
|||
partitions 2
|
||||
(partition x1 values less than (4.0) tablespace ts1,
|
||||
partition x2 values less than (8) tablespace ts2);
|
||||
ERROR HY000: VALUES LESS THAN value must be of same type as partition function
|
||||
ERROR 42000: VALUES value must be of same type as partition function near ') tablespace ts1,
|
||||
partition x2 values less than (8) tablespace ts2)' at line 8
|
||||
CREATE TABLE t1 (
|
||||
a int not null,
|
||||
b int not null,
|
||||
|
@ -530,7 +531,8 @@ partition by list (a)
|
|||
partitions 2
|
||||
(partition x1 values in (4.0, 12+8),
|
||||
partition x2 values in (3, 21));
|
||||
ERROR HY000: VALUES IN value must be of same type as partition function
|
||||
ERROR 42000: VALUES value must be of same type as partition function near ' 12+8),
|
||||
partition x2 values in (3, 21))' at line 8
|
||||
CREATE TABLE t1 (
|
||||
a int not null,
|
||||
b int not null,
|
||||
|
|
|
@ -389,7 +389,7 @@ partitions 2
|
|||
#
|
||||
# Partition by range, inconsistent partition function and constants
|
||||
#
|
||||
--error 1450
|
||||
--error 1064
|
||||
CREATE TABLE t1 (
|
||||
a int not null,
|
||||
b int not null,
|
||||
|
@ -702,7 +702,7 @@ partitions 2
|
|||
#
|
||||
# Partition by list, wrong constant result type (not INT)
|
||||
#
|
||||
--error 1450
|
||||
--error 1064
|
||||
CREATE TABLE t1 (
|
||||
a int not null,
|
||||
b int not null,
|
||||
|
|
|
@ -402,12 +402,12 @@ class Item;
|
|||
class partition_element :public Sql_alloc {
|
||||
public:
|
||||
List<partition_element> subpartitions;
|
||||
List<Item> list_expr_list;
|
||||
List<longlong> list_val_list;
|
||||
ulonglong part_max_rows;
|
||||
ulonglong part_min_rows;
|
||||
char *partition_name;
|
||||
char *tablespace_name;
|
||||
Item* range_expr;
|
||||
longlong range_value;
|
||||
char* part_comment;
|
||||
char* data_file_name;
|
||||
char* index_file_name;
|
||||
|
@ -416,12 +416,12 @@ public:
|
|||
|
||||
partition_element()
|
||||
: part_max_rows(0), part_min_rows(0), partition_name(NULL),
|
||||
tablespace_name(NULL), range_expr(NULL), part_comment(NULL),
|
||||
tablespace_name(NULL), range_value(0), part_comment(NULL),
|
||||
data_file_name(NULL), index_file_name(NULL),
|
||||
engine_type(DB_TYPE_UNKNOWN), nodegroup_id(UNDEF_NODEGROUP)
|
||||
{
|
||||
subpartitions.empty();
|
||||
list_expr_list.empty();
|
||||
list_val_list.empty();
|
||||
}
|
||||
~partition_element() {}
|
||||
};
|
||||
|
|
|
@ -5427,8 +5427,8 @@ ER_RANGE_NOT_INCREASING_ERROR
|
|||
eng "VALUES LESS THAN value must be strictly increasing for each partition"
|
||||
swe "Värden i VALUES LESS THAN måste vara strikt växande för varje partition"
|
||||
ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR
|
||||
eng "VALUES %s value must be of same type as partition function"
|
||||
swe "Värden i VALUES %s måste vara av samma typ som partitioneringsfunktionen"
|
||||
eng "VALUES value must be of same type as partition function"
|
||||
swe "Värden i VALUES måste vara av samma typ som partitioneringsfunktionen"
|
||||
ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR
|
||||
eng "Multiple definition of same constant in list partitioning"
|
||||
swe "Multipel definition av samma konstant i list partitionering"
|
||||
|
|
|
@ -250,16 +250,7 @@ static bool check_range_constants(partition_info *part_info)
|
|||
{
|
||||
part_def= it++;
|
||||
if ((i != (no_parts - 1)) || !part_info->defined_max_value)
|
||||
{
|
||||
if (likely(part_def->range_expr->result_type() == INT_RESULT))
|
||||
part_range_value_int= part_def->range_expr->val_int();
|
||||
else
|
||||
{
|
||||
my_error(ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR, MYF(0),
|
||||
"LESS THAN");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
part_range_value_int= part_def->range_value;
|
||||
else
|
||||
part_range_value_int= LONGLONG_MAX;
|
||||
if (likely(current_largest_int < part_range_value_int))
|
||||
|
@ -327,7 +318,7 @@ static int list_part_cmp(const void* a, const void* b)
|
|||
static bool check_list_constants(partition_info *part_info)
|
||||
{
|
||||
uint i, no_list_values= 0, no_parts, list_index= 0;
|
||||
Item *list_expr;
|
||||
longlong *list_value;
|
||||
bool not_first, result= TRUE;
|
||||
longlong curr_value, prev_value;
|
||||
partition_element* part_def;
|
||||
|
@ -342,8 +333,7 @@ static bool check_list_constants(partition_info *part_info)
|
|||
|
||||
We use this number to allocate a properly sized array of structs
|
||||
to keep the partition id and the value to use in that partition.
|
||||
In the second traversal we check that all Item trees are of the
|
||||
same type (INT_RESULT) and assign them values in the struct array.
|
||||
In the second traversal we assign them values in the struct array.
|
||||
|
||||
Finally we sort the array of structs in order of values to enable
|
||||
a quick binary search for the proper value to discover the
|
||||
|
@ -357,7 +347,7 @@ static bool check_list_constants(partition_info *part_info)
|
|||
do
|
||||
{
|
||||
part_def= list_func_it++;
|
||||
List_iterator<Item> list_val_it1(part_def->list_expr_list);
|
||||
List_iterator<longlong> list_val_it1(part_def->list_val_list);
|
||||
while (list_val_it1++)
|
||||
no_list_values++;
|
||||
} while (++i < no_parts);
|
||||
|
@ -375,19 +365,11 @@ static bool check_list_constants(partition_info *part_info)
|
|||
do
|
||||
{
|
||||
part_def= list_func_it++;
|
||||
List_iterator<Item> list_val_it2(part_def->list_expr_list);
|
||||
while ((list_expr= list_val_it2++))
|
||||
List_iterator<longlong> list_val_it2(part_def->list_val_list);
|
||||
while ((list_value= list_val_it2++))
|
||||
{
|
||||
if (likely(list_expr->result_type() == INT_RESULT))
|
||||
{
|
||||
part_info->list_array[list_index].list_value= list_expr->val_int();
|
||||
part_info->list_array[list_index++].partition_id= i;
|
||||
}
|
||||
else
|
||||
{
|
||||
my_error(ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR, MYF(0), "IN");
|
||||
goto end;
|
||||
}
|
||||
part_info->list_array[list_index].list_value= *list_value;
|
||||
part_info->list_array[list_index++].partition_id= i;
|
||||
}
|
||||
} while (++i < no_parts);
|
||||
|
||||
|
@ -1820,10 +1802,10 @@ static int add_partition_values(File fptr, partition_info *part_info,
|
|||
if (part_info->part_type == RANGE_PARTITION)
|
||||
{
|
||||
err+= add_string(fptr, "VALUES LESS THAN ");
|
||||
if (p_elem->range_expr)
|
||||
if (p_elem->range_value != LONGLONG_MAX)
|
||||
{
|
||||
err+= add_begin_parenthesis(fptr);
|
||||
err+= add_int(fptr,p_elem->range_expr->val_int());
|
||||
err+= add_int(fptr, p_elem->range_value);
|
||||
err+= add_end_parenthesis(fptr);
|
||||
}
|
||||
else
|
||||
|
@ -1832,15 +1814,15 @@ static int add_partition_values(File fptr, partition_info *part_info,
|
|||
else if (part_info->part_type == LIST_PARTITION)
|
||||
{
|
||||
uint i;
|
||||
List_iterator<Item> list_expr_it(p_elem->list_expr_list);
|
||||
List_iterator<longlong> list_val_it(p_elem->list_val_list);
|
||||
err+= add_string(fptr, "VALUES IN ");
|
||||
uint no_items= p_elem->list_expr_list.elements;
|
||||
uint no_items= p_elem->list_val_list.elements;
|
||||
err+= add_begin_parenthesis(fptr);
|
||||
i= 0;
|
||||
do
|
||||
{
|
||||
Item *list_expr= list_expr_it++;
|
||||
err+= add_int(fptr, list_expr->val_int());
|
||||
longlong *list_value= list_val_it++;
|
||||
err+= add_int(fptr, *list_value);
|
||||
if (i != (no_items-1))
|
||||
err+= add_comma(fptr);
|
||||
} while (++i < no_items);
|
||||
|
|
|
@ -73,6 +73,7 @@ inline Item *is_truth_value(Item *A, bool v1, bool v2)
|
|||
int num;
|
||||
ulong ulong_num;
|
||||
ulonglong ulonglong_number;
|
||||
longlong longlong_number;
|
||||
LEX_STRING lex_str;
|
||||
LEX_STRING *lex_str_ptr;
|
||||
LEX_SYMBOL symbol;
|
||||
|
@ -716,6 +717,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
|
|||
%type <ulonglong_number>
|
||||
ulonglong_num
|
||||
|
||||
%type <longlong_number>
|
||||
part_bit_expr
|
||||
|
||||
%type <lock_type>
|
||||
replace_lock_option opt_low_priority insert_lock_option load_data_lock
|
||||
|
||||
|
@ -732,7 +736,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
|
|||
sp_opt_default
|
||||
simple_ident_nospvar simple_ident_q
|
||||
field_or_var limit_option
|
||||
part_bit_expr part_func_expr
|
||||
part_func_expr
|
||||
|
||||
%type <item_num>
|
||||
NUM_literal
|
||||
|
@ -2860,6 +2864,7 @@ part_func_max:
|
|||
YYABORT;
|
||||
}
|
||||
lex->part_info->defined_max_value= TRUE;
|
||||
lex->part_info->curr_part_elem->range_value= LONGLONG_MAX;
|
||||
}
|
||||
| part_range_func
|
||||
{
|
||||
|
@ -2873,7 +2878,7 @@ part_func_max:
|
|||
part_range_func:
|
||||
'(' part_bit_expr ')'
|
||||
{
|
||||
Lex->part_info->curr_part_elem->range_expr= $2;
|
||||
Lex->part_info->curr_part_elem->range_value= $2;
|
||||
};
|
||||
|
||||
part_list_func:
|
||||
|
@ -2883,7 +2888,14 @@ part_list_func:
|
|||
part_list_item:
|
||||
part_bit_expr
|
||||
{
|
||||
Lex->part_info->curr_part_elem->list_expr_list.push_back($1);
|
||||
longlong *value_ptr;
|
||||
if (!(value_ptr= (longlong*)sql_alloc(sizeof(longlong))))
|
||||
{
|
||||
my_error(ER_OUTOFMEMORY, MYF(0), sizeof(longlong));
|
||||
YYABORT;
|
||||
}
|
||||
*value_ptr= $1;
|
||||
Lex->part_info->curr_part_elem->list_val_list.push_back(value_ptr);
|
||||
};
|
||||
|
||||
part_bit_expr:
|
||||
|
@ -2892,6 +2904,7 @@ part_bit_expr:
|
|||
Item *part_expr= $1;
|
||||
bool not_corr_func;
|
||||
LEX *lex= Lex;
|
||||
longlong item_value;
|
||||
Name_resolution_context *context= &lex->current_select->context;
|
||||
TABLE_LIST *save_list= context->table_list;
|
||||
|
||||
|
@ -2900,13 +2913,18 @@ part_bit_expr:
|
|||
context->table_list= save_list;
|
||||
not_corr_func= !part_expr->const_item() ||
|
||||
!lex->safe_to_cache_query;
|
||||
lex->safe_to_cache_query= 1;
|
||||
if (not_corr_func)
|
||||
{
|
||||
yyerror(ER(ER_NO_CONST_EXPR_IN_RANGE_OR_LIST_ERROR));
|
||||
YYABORT;
|
||||
}
|
||||
$$= part_expr;
|
||||
if (part_expr->result_type() != INT_RESULT)
|
||||
{
|
||||
yyerror(ER(ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR));
|
||||
YYABORT;
|
||||
}
|
||||
item_value= part_expr->val_int();
|
||||
$$= item_value;
|
||||
}
|
||||
|
||||
opt_sub_partition:
|
||||
|
|
Loading…
Reference in a new issue