Commit eb075f22 authored by evgen@sunlight.local's avatar evgen@sunlight.local

Manual merge

parents 2618be80 47f9b465
......@@ -1471,7 +1471,7 @@ _mi_calc_var_pack_key_length(MI_KEYDEF *keyinfo,uint nod_flag,uchar *next_key,
if (!*key++)
{
s_temp->key=key;
s_temp->ref_length=s_temp->key_length=0;
s_temp->key_length= 0;
s_temp->totlength=key_length-1+diff_flag;
s_temp->next_key_pos=0; /* No next key */
return (s_temp->totlength);
......@@ -1626,12 +1626,12 @@ _mi_calc_var_pack_key_length(MI_KEYDEF *keyinfo,uint nod_flag,uchar *next_key,
s_temp->prev_length= org_key_length;
s_temp->n_ref_length=s_temp->n_length= org_key_length;
length+= org_key_length;
/* +get_pack_length(org_key_length); */
}
return (int) length;
}
ref_length=n_length;
/* Get information about not packed key suffix */
get_key_pack_length(n_length,next_length_pack,next_key);
/* Test if new keys has fewer characters that match the previous key */
......@@ -1640,7 +1640,6 @@ _mi_calc_var_pack_key_length(MI_KEYDEF *keyinfo,uint nod_flag,uchar *next_key,
s_temp->part_of_prev_key= 0;
s_temp->prev_length= ref_length;
s_temp->n_ref_length= s_temp->n_length= n_length+ref_length;
/* s_temp->prev_key+= get_pack_length(org_key_length); */
return (int) length+ref_length-next_length_pack;
}
if (ref_length+pack_marker > new_ref_length)
......@@ -1651,9 +1650,7 @@ _mi_calc_var_pack_key_length(MI_KEYDEF *keyinfo,uint nod_flag,uchar *next_key,
s_temp->prev_length= ref_length - new_pack_length;
s_temp->n_ref_length=s_temp->n_length=n_length + s_temp->prev_length;
s_temp->prev_key+= new_pack_length;
/* +get_pack_length(org_key_length); */
length= length-get_pack_length(ref_length)+
get_pack_length(new_pack_length);
length-= (next_length_pack - get_pack_length(s_temp->n_length));
return (int) length + s_temp->prev_length;
}
}
......
......@@ -1066,6 +1066,52 @@ LENGTH(bug)
100
DROP TABLE t2;
DROP TABLE t1;
SET NAMES utf8;
DROP TABLE IF EXISTS t1;
Warnings:
Note 1051 Unknown table 't1'
CREATE TABLE t1(a VARCHAR(255), KEY(a)) ENGINE=MyISAM DEFAULT CHARSET=utf8;
INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
INSERT INTO t1 VALUES('uu');
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
INSERT INTO t1 VALUES('uU');
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
INSERT INTO t1 VALUES('uu');
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
INSERT INTO t1 VALUES('uuABC');
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
INSERT INTO t1 VALUES('UuABC');
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
INSERT INTO t1 VALUES('uuABC');
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
alter table t1 add b int;
INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1);
INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb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bb',4);
delete from t1 where b=3;
INSERT INTO t1 VALUES('uUABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3);
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
CREATE TABLE t1(id varchar(20) NOT NULL) DEFAULT CHARSET=utf8;
INSERT INTO t1 VALUES ('xxx'), ('aa'), ('yyy'), ('aa');
SELECT id FROM t1;
......
......@@ -596,6 +596,21 @@ GROUP_CONCAT(a ORDER BY a)
,x
,z
DROP TABLE t1;
create table t1(f1 int);
insert into t1 values(1),(2),(3);
select f1, group_concat(f1+1) from t1 group by f1 with rollup;
f1 group_concat(f1+1)
1 2
2 3
3 4
NULL 2,3,4
select count(distinct (f1+1)) from t1 group by f1 with rollup;
count(distinct (f1+1))
1
1
1
3
drop table t1;
set names latin1;
create table t1 (a char, b char);
insert into t1 values ('a', 'a'), ('a', 'b'), ('b', 'a'), ('b', 'b');
......
......@@ -878,6 +878,40 @@ SELECT LENGTH(bug) FROM t2;
DROP TABLE t2;
DROP TABLE t1;
#
# Bug#17705: Corruption of compressed index when index length changes between
# 254 and 256
#
SET NAMES utf8;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(a VARCHAR(255), KEY(a)) ENGINE=MyISAM DEFAULT CHARSET=utf8;
INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
INSERT INTO t1 VALUES('uu');
check table t1;
INSERT INTO t1 VALUES('uU');
check table t1;
INSERT INTO t1 VALUES('uu');
check table t1;
INSERT INTO t1 VALUES('uuABC');
check table t1;
INSERT INTO t1 VALUES('UuABC');
check table t1;
INSERT INTO t1 VALUES('uuABC');
check table t1;
alter table t1 add b int;
INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1);
INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',2);
delete from t1 where b=1;
INSERT INTO t1 VALUES('UUABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1);
check table t1;
INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3);
INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',4);
delete from t1 where b=3;
INSERT INTO t1 VALUES('uUABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3);
check table t1;
drop table t1;
# End of 4.1 tests
#
......
......@@ -389,6 +389,14 @@ SELECT GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY id;
DROP TABLE t1;
#
# Bug #15560: GROUP_CONCAT wasn't ready for WITH ROLLUP queries
#
create table t1(f1 int);
insert into t1 values(1),(2),(3);
select f1, group_concat(f1+1) from t1 group by f1 with rollup;
select count(distinct (f1+1)) from t1 group by f1 with rollup;
drop table t1;
# End of 4.1 tests
#
......
......@@ -532,7 +532,7 @@ ha_rows ha_heap::records_in_range(uint inx, key_range *min_key,
return records;
/* Assert that info() did run. We need current statistics here. */
DBUG_ASSERT(key_stat_version);
DBUG_ASSERT(key_stat_version == file->s->key_stat_version);
return key->rec_per_key[key->key_parts-1];
}
......
......@@ -2472,6 +2472,7 @@ void Item_sum_count_distinct::make_unique()
{
table=0;
original= 0;
force_copy_fields= 1;
tree= 0;
tmp_table_param= 0;
always_null= FALSE;
......@@ -2515,6 +2516,7 @@ bool Item_sum_count_distinct::setup(THD *thd)
if (always_null)
return FALSE;
count_field_types(tmp_table_param,list,0);
tmp_table_param->force_copy_fields= force_copy_fields;
DBUG_ASSERT(table == 0);
if (!(table= create_tmp_table(thd, tmp_table_param, list, (ORDER*) 0, 1,
0,
......@@ -3022,7 +3024,7 @@ Item_func_group_concat(Name_resolution_context *context_arg,
bool distinct_arg, List<Item> *select_list,
SQL_LIST *order_list, String *separator_arg)
:tmp_table_param(0), warning(0),
separator(separator_arg), tree(0), table(0),
force_copy_fields(0), separator(separator_arg), tree(0), table(0),
order(0), context(context_arg),
arg_count_order(order_list ? order_list->elements : 0),
arg_count_field(select_list->elements),
......@@ -3075,6 +3077,7 @@ Item_func_group_concat::Item_func_group_concat(THD *thd,
:Item_sum(thd, item),
tmp_table_param(item->tmp_table_param),
warning(item->warning),
force_copy_fields(item->force_copy_fields),
separator(item->separator),
tree(item->tree),
table(item->table),
......@@ -3287,6 +3290,7 @@ bool Item_func_group_concat::setup(THD *thd)
DBUG_RETURN(TRUE);
count_field_types(tmp_table_param,all_fields,0);
tmp_table_param->force_copy_fields= force_copy_fields;
DBUG_ASSERT(table == 0);
/*
We have to create a temporary table to get descriptions of fields
......@@ -3349,6 +3353,7 @@ void Item_func_group_concat::make_unique()
tmp_table_param= 0;
table=0;
original= 0;
force_copy_fields= 1;
tree= 0;
}
......
......@@ -501,6 +501,7 @@ class Item_sum_count_distinct :public Item_sum_int
TABLE *table;
uint32 *field_lengths;
TMP_TABLE_PARAM *tmp_table_param;
bool force_copy_fields;
/*
If there are no blobs, we can use a tree, which
is faster than heap table. In that case, we still use the table
......@@ -524,13 +525,14 @@ class Item_sum_count_distinct :public Item_sum_int
public:
Item_sum_count_distinct(List<Item> &list)
:Item_sum_int(list), table(0), field_lengths(0), tmp_table_param(0),
tree(0), original(0), always_null(FALSE)
tree(0), force_copy_fields(0), original(0), always_null(FALSE)
{ quick_group= 0; }
Item_sum_count_distinct(THD *thd, Item_sum_count_distinct *item)
:Item_sum_int(thd, item), table(item->table),
field_lengths(item->field_lengths),
tmp_table_param(item->tmp_table_param),
tree(item->tree), original(item), tree_key_length(item->tree_key_length),
tree(item->tree), force_copy_fields(0), original(item),
tree_key_length(item->tree_key_length),
always_null(item->always_null)
{}
~Item_sum_count_distinct();
......@@ -1086,6 +1088,7 @@ class Item_func_group_concat : public Item_sum
bool distinct;
bool warning_for_row;
bool always_null;
bool force_copy_fields;
bool no_appended;
/*
Following is 0 normal object and pointer to original one for copy
......
......@@ -706,6 +706,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
Item ***copy_func, Field **from_field,
bool group, bool modify_item,
bool table_cant_handle_bit_fields,
bool make_copy_field,
uint convert_blob_length);
void sp_prepare_create_field(THD *thd, create_field *sql_field);
int prepare_create_field(create_field *sql_field,
......
......@@ -1829,11 +1829,12 @@ public:
aggregate functions as normal functions.
*/
bool precomputed_group_by;
bool force_copy_fields;
TMP_TABLE_PARAM()
:copy_field(0), group_parts(0),
group_length(0), group_null_parts(0), convert_blob_length(0),
schema_table(0), precomputed_group_by(0)
schema_table(0), precomputed_group_by(0), force_copy_fields(0)
{}
~TMP_TABLE_PARAM()
{
......
......@@ -8294,6 +8294,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
Item ***copy_func, Field **from_field,
bool group, bool modify_item,
bool table_cant_handle_bit_fields,
bool make_copy_field,
uint convert_blob_length)
{
Item::Type orig_type= type;
......@@ -8373,7 +8374,13 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
case Item::REF_ITEM:
case Item::NULL_ITEM:
case Item::VARBIN_ITEM:
return create_tmp_field_from_item(thd, item, table, copy_func, modify_item,
if (make_copy_field)
{
DBUG_ASSERT(((Item_result_field*)item)->result_field);
*from_field= ((Item_result_field*)item)->result_field;
}
return create_tmp_field_from_item(thd, item, table, (make_copy_field ? 0 :
copy_func), modify_item,
convert_blob_length);
case Item::TYPE_HOLDER:
return ((Item_type_holder *)item)->make_field_by_type(table);
......@@ -8445,6 +8452,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
Item **copy_func;
MI_COLUMNDEF *recinfo;
uint total_uneven_bit_length= 0;
bool force_copy_fields= param->force_copy_fields;
DBUG_ENTER("create_tmp_table");
DBUG_PRINT("enter",("distinct: %d save_sum_fields: %d rows_limit: %lu group: %d",
(int) distinct, (int) save_sum_fields,
......@@ -8605,7 +8613,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
Field *new_field=
create_tmp_field(thd, table, arg, arg->type(), &copy_func,
tmp_from_field, group != 0,not_all_columns,
distinct,
distinct, 0,
param->convert_blob_length);
if (!new_field)
goto err; // Should be OOM
......@@ -8662,7 +8670,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
create_tmp_field(thd, table, item, type, &copy_func,
tmp_from_field, group != 0,
not_all_columns || group != 0,
item->marker == 4,
item->marker == 4, 0,
param->convert_blob_length);
if (!new_field)
......
......@@ -1798,7 +1798,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
field=item->tmp_table_field(&tmp_table);
else
field=create_tmp_field(thd, &tmp_table, item, item->type(),
(Item ***) 0, &tmp_field, 0, 0, 0, 0);
(Item ***) 0, &tmp_field, 0, 0, 0, 0, 0);
if (!field ||
!(cr_field=new create_field(field,(item->type() == Item::FIELD_ITEM ?
((Item_field *)item)->field :
......
......@@ -12992,7 +12992,6 @@ static void test_bug9520()
}
/*
We can't have more than one cursor open for a prepared statement.
Test re-executions of a PS with cursor; mysql_stmt_reset must close
the cursor attached to the statement, if there is one.
......
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