Commit 7412a020 authored by unknown's avatar unknown

Merge abotchkov@bk-internal.mysql.com:/home/bk/mysql-4.1

into deer.(none):/home/hf/work/mysql-4.1.2way

parents 7248ab7b 0f792995
...@@ -177,3 +177,12 @@ ERROR HY000: Invalid use of group function ...@@ -177,3 +177,12 @@ ERROR HY000: Invalid use of group function
select grp,group_concat(c order by 2) from t1 group by grp; select grp,group_concat(c order by 2) from t1 group by grp;
ERROR 42S22: Unknown column '2' in 'group statement' ERROR 42S22: Unknown column '2' in 'group statement'
drop table t1; drop table t1;
create table t1 (id int, name varchar(16));
insert into t1 values (1,'longername'),(1,'evenlongername');
select ifnull(group_concat(concat(t1.id, ':', t1.name)), 'shortname') as 'without distinct: how it should be' from t1;
without distinct: how it should be
1:longername,1:evenlongername
select distinct ifnull(group_concat(concat(t1.id, ':', t1.name)), 'shortname') as 'with distinct: cutoff at length of shortname' from t1;
with distinct: cutoff at length of shortname
1:longername,1:evenlongername
drop table t1;
...@@ -278,6 +278,12 @@ row('A','b','c') = row('a' COLLATE latin1_bin,'b','c') ...@@ -278,6 +278,12 @@ row('A','b','c') = row('a' COLLATE latin1_bin,'b','c')
0 0
select row('A' COLLATE latin1_general_ci,'b','c') = row('a' COLLATE latin1_bin,'b','c'); select row('A' COLLATE latin1_general_ci,'b','c') = row('a' COLLATE latin1_bin,'b','c');
ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation '=' ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation '='
select concat(_latin1'a',_latin2'a');
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'concat'
select concat(_latin1'a',_latin2'a',_latin5'a');
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin5_turkish_ci,COERCIBLE) for operation 'concat'
select concat(_latin1'a',_latin2'a',_latin5'a',_latin7'a');
ERROR HY000: Illegal mix of collations for operation 'concat'
select FIELD('b','A','B'); select FIELD('b','A','B');
FIELD('b','A','B') FIELD('b','A','B')
2 2
......
...@@ -148,3 +148,22 @@ alter table t1 type=MyISAM; ...@@ -148,3 +148,22 @@ alter table t1 type=MyISAM;
handler t2 read first; handler t2 read first;
ERROR 42S02: Unknown table 't2' in HANDLER ERROR 42S02: Unknown table 't2' in HANDLER
drop table t1; drop table t1;
create table t1 (a int);
insert into t1 values (1),(2),(3),(4),(5),(6);
delete from t1 limit 2;
handler t1 open;
handler t1 read first;
a
3
handler t1 read first limit 1,1;
a
4
handler t1 read first limit 2,2;
a
5
6
delete from t1 limit 3;
handler t1 read first;
a
6
drop table t1;
...@@ -93,3 +93,9 @@ select group_concat(sum(a)) from t1 group by grp; ...@@ -93,3 +93,9 @@ select group_concat(sum(a)) from t1 group by grp;
select grp,group_concat(c order by 2) from t1 group by grp; select grp,group_concat(c order by 2) from t1 group by grp;
drop table t1; drop table t1;
create table t1 (id int, name varchar(16));
insert into t1 values (1,'longername'),(1,'evenlongername');
select ifnull(group_concat(concat(t1.id, ':', t1.name)), 'shortname') as 'without distinct: how it should be' from t1;
select distinct ifnull(group_concat(concat(t1.id, ':', t1.name)), 'shortname') as 'with distinct: cutoff at length of shortname' from t1;
drop table t1;
...@@ -152,6 +152,14 @@ select row('A','b','c') = row('a' COLLATE latin1_bin,'b','c'); ...@@ -152,6 +152,14 @@ select row('A','b','c') = row('a' COLLATE latin1_bin,'b','c');
--error 1265 --error 1265
select row('A' COLLATE latin1_general_ci,'b','c') = row('a' COLLATE latin1_bin,'b','c'); select row('A' COLLATE latin1_general_ci,'b','c') = row('a' COLLATE latin1_bin,'b','c');
--error 1265
select concat(_latin1'a',_latin2'a');
--error 1268
select concat(_latin1'a',_latin2'a',_latin5'a');
--error 1269
select concat(_latin1'a',_latin2'a',_latin5'a',_latin7'a');
# #
# Test FIELD() and collations # Test FIELD() and collations
# #
......
...@@ -85,3 +85,17 @@ alter table t1 type=MyISAM; ...@@ -85,3 +85,17 @@ alter table t1 type=MyISAM;
handler t2 read first; handler t2 read first;
drop table t1; drop table t1;
#
# test case for the bug #787
#
create table t1 (a int);
insert into t1 values (1),(2),(3),(4),(5),(6);
delete from t1 limit 2;
handler t1 open;
handler t1 read first;
handler t1 read first limit 1,1;
handler t1 read first limit 2,2;
delete from t1 limit 3;
handler t1 read first;
drop table t1;
...@@ -781,6 +781,7 @@ drop table if exists t1; ...@@ -781,6 +781,7 @@ drop table if exists t1;
# #
# key field overflow test # key field overflow test
# #
--disable_warnings
CREATE TABLE t1 CREATE TABLE t1
( (
FOLDERID VARCHAR(32)BINARY NOT NULL FOLDERID VARCHAR(32)BINARY NOT NULL
...@@ -798,6 +799,7 @@ FOLDERID VARCHAR(32)BINARY NOT NULL ...@@ -798,6 +799,7 @@ FOLDERID VARCHAR(32)BINARY NOT NULL
, PRIMARY KEY ( FOLDERID ) , PRIMARY KEY ( FOLDERID )
) TYPE=InnoDB; ) TYPE=InnoDB;
--enable_warnings
CREATE INDEX FFOLDERID_IDX ON t1 (FOLDERID); CREATE INDEX FFOLDERID_IDX ON t1 (FOLDERID);
CREATE INDEX CMFLDRPARNT_IDX ON t1 (PARENTID); CREATE INDEX CMFLDRPARNT_IDX ON t1 (PARENTID);
INSERT INTO t1 VALUES("0c9aab05b15048c59bc35c8461507deb", "System", "System", "2003-06-05 16:30:00", "The system content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "9c9aab05b15048c59bc35c8461507deb", "1"); INSERT INTO t1 VALUES("0c9aab05b15048c59bc35c8461507deb", "System", "System", "2003-06-05 16:30:00", "The system content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "9c9aab05b15048c59bc35c8461507deb", "1");
......
...@@ -32,18 +32,6 @@ static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, const char *fnam ...@@ -32,18 +32,6 @@ static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, const char *fnam
fname); fname);
} }
static void my_coll_agg3_error(DTCollation &c1,
DTCollation &c2,
DTCollation &c3,
const char *fname)
{
my_error(ER_CANT_AGGREGATE_3COLLATIONS,MYF(0),
c1.collation->name,c1.derivation_name(),
c2.collation->name,c2.derivation_name(),
c3.collation->name,c3.derivation_name(),
fname);
}
Item_bool_func2* Item_bool_func2::eq_creator(Item *a, Item *b) Item_bool_func2* Item_bool_func2::eq_creator(Item *a, Item *b)
{ {
return new Item_func_eq(a, b); return new Item_func_eq(a, b);
...@@ -572,18 +560,9 @@ void Item_func_between::fix_length_and_dec() ...@@ -572,18 +560,9 @@ void Item_func_between::fix_length_and_dec()
item_cmp_type(args[1]->result_type(), item_cmp_type(args[1]->result_type(),
args[2]->result_type())); args[2]->result_type()));
if (cmp_type == STRING_RESULT) if (cmp_type == STRING_RESULT &&
{ agg_arg_collations_for_comparison(cmp_collation, args, 3))
cmp_collation.set(args[0]->collation);
if (!cmp_collation.aggregate(args[1]->collation))
cmp_collation.aggregate(args[2]->collation);
if (cmp_collation.derivation == DERIVATION_NONE)
{
my_coll_agg3_error(args[0]->collation, args[1]->collation,
args[2]->collation, func_name());
return; return;
}
}
/* /*
Make a special case of compare with date/time and longlong fields. Make a special case of compare with date/time and longlong fields.
...@@ -691,8 +670,8 @@ Item_func_ifnull::fix_length_and_dec() ...@@ -691,8 +670,8 @@ Item_func_ifnull::fix_length_and_dec()
args[1]->result_type())) != args[1]->result_type())) !=
REAL_RESULT) REAL_RESULT)
decimals= 0; decimals= 0;
if (collation.set(args[0]->collation,args[1]->collation)) if (cached_result_type == STRING_RESULT)
my_coll_agg_error(args[0]->collation, args[1]->collation, func_name()); agg_arg_collations(collation, args, arg_count);
} }
...@@ -768,12 +747,9 @@ Item_func_if::fix_length_and_dec() ...@@ -768,12 +747,9 @@ Item_func_if::fix_length_and_dec()
else if (arg1_type == STRING_RESULT || arg2_type == STRING_RESULT) else if (arg1_type == STRING_RESULT || arg2_type == STRING_RESULT)
{ {
cached_result_type = STRING_RESULT; cached_result_type = STRING_RESULT;
if (collation.set(args[1]->collation, args[2]->collation)) if (agg_arg_collations(collation, args+1, 2))
{
my_coll_agg_error(args[0]->collation, args[1]->collation, func_name());
return; return;
} }
}
else else
{ {
set_charset(&my_charset_bin); // Number set_charset(&my_charset_bin); // Number
...@@ -1972,11 +1948,8 @@ Item_func_regex::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -1972,11 +1948,8 @@ Item_func_regex::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
max_length= 1; max_length= 1;
decimals= 0; decimals= 0;
if (cmp_collation.set(args[0]->collation, args[1]->collation)) if (agg_arg_collations(cmp_collation, args, 2))
{
my_coll_agg_error(args[0]->collation, args[1]->collation, func_name());
return 1; return 1;
}
used_tables_cache=args[0]->used_tables() | args[1]->used_tables(); used_tables_cache=args[0]->used_tables() | args[1]->used_tables();
const_item_cache=args[0]->const_item() && args[1]->const_item(); const_item_cache=args[0]->const_item() && args[1]->const_item();
......
...@@ -39,6 +39,61 @@ static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, const char *fnam ...@@ -39,6 +39,61 @@ static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, const char *fnam
fname); fname);
} }
static void my_coll_agg_error(DTCollation &c1,
DTCollation &c2,
DTCollation &c3,
const char *fname)
{
my_error(ER_CANT_AGGREGATE_3COLLATIONS,MYF(0),
c1.collation->name,c1.derivation_name(),
c2.collation->name,c2.derivation_name(),
c3.collation->name,c3.derivation_name(),
fname);
}
static void my_coll_agg_error(Item** args, uint ac, const char *fname)
{
if (2 == ac)
my_coll_agg_error(args[0]->collation, args[1]->collation, fname);
else if (3 == ac)
my_coll_agg_error(args[0]->collation,
args[1]->collation,
args[2]->collation,
fname);
else
my_error(ER_CANT_AGGREGATE_NCOLLATIONS,MYF(0),fname);
}
bool Item_func::agg_arg_collations(DTCollation &c, Item **av, uint ac)
{
uint i;
c.set(av[0]->collation);
for (i= 1; i < ac; i++)
{
if (c.aggregate(av[i]->collation))
{
my_coll_agg_error(av, ac, func_name());
return TRUE;
}
}
return FALSE;
}
bool Item_func::agg_arg_collations_for_comparison(DTCollation &c,
Item **av, uint ac)
{
if (agg_arg_collations(c, av, ac))
return TRUE;
if (c.derivation == DERIVATION_NONE)
{
my_coll_agg_error(av, ac, func_name());
return TRUE;
}
return FALSE;
}
/* return TRUE if item is a constant */ /* return TRUE if item is a constant */
bool bool
...@@ -866,14 +921,9 @@ void Item_func_min_max::fix_length_and_dec() ...@@ -866,14 +921,9 @@ void Item_func_min_max::fix_length_and_dec()
if (!args[i]->maybe_null) if (!args[i]->maybe_null)
maybe_null=0; maybe_null=0;
cmp_type=item_cmp_type(cmp_type,args[i]->result_type()); cmp_type=item_cmp_type(cmp_type,args[i]->result_type());
if (i==0)
collation.set(args[0]->collation);
if (collation.aggregate(args[i]->collation))
{
my_coll_agg_error(collation, args[i]->collation, func_name());
break;
}
} }
if (cmp_type == STRING_RESULT)
agg_arg_collations_for_comparison(collation, args, arg_count);
} }
...@@ -1048,8 +1098,7 @@ longlong Item_func_coercibility::val_int() ...@@ -1048,8 +1098,7 @@ longlong Item_func_coercibility::val_int()
void Item_func_locate::fix_length_and_dec() void Item_func_locate::fix_length_and_dec()
{ {
maybe_null=0; max_length=11; maybe_null=0; max_length=11;
if (cmp_collation.set(args[0]->collation, args[1]->collation)) agg_arg_collations_for_comparison(cmp_collation, args, 2);
my_coll_agg_error(args[0]->collation, args[1]->collation, func_name());
} }
longlong Item_func_locate::val_int() longlong Item_func_locate::val_int()
...@@ -1255,8 +1304,7 @@ void Item_func_find_in_set::fix_length_and_dec() ...@@ -1255,8 +1304,7 @@ void Item_func_find_in_set::fix_length_and_dec()
} }
} }
} }
if (cmp_collation.set(args[0]->collation, args[1]->collation)) agg_arg_collations_for_comparison(cmp_collation, args, 2);
my_coll_agg_error(args[0]->collation, args[1]->collation, func_name());
} }
static const char separator=','; static const char separator=',';
......
...@@ -135,6 +135,9 @@ public: ...@@ -135,6 +135,9 @@ public:
Field *tmp_table_field(TABLE *t_arg); Field *tmp_table_field(TABLE *t_arg);
void set_outer_resolving(); void set_outer_resolving();
Item *get_tmp_table_item(THD *thd); Item *get_tmp_table_item(THD *thd);
bool agg_arg_collations(DTCollation &c, Item **items, uint nitems);
bool agg_arg_collations_for_comparison(DTCollation &c, Item **items, uint nitems);
}; };
......
...@@ -44,18 +44,6 @@ static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, const char *fnam ...@@ -44,18 +44,6 @@ static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, const char *fnam
fname); fname);
} }
static void my_coll_agg3_error(DTCollation &c1,
DTCollation &c2,
DTCollation &c3,
const char *fname)
{
my_error(ER_CANT_AGGREGATE_3COLLATIONS,MYF(0),
c1.collation->name,c1.derivation_name(),
c2.collation->name,c2.derivation_name(),
c3.collation->name,c3.derivation_name(),
fname);
}
uint nr_of_decimals(const char *str) uint nr_of_decimals(const char *str)
{ {
if ((str=strchr(str,'.'))) if ((str=strchr(str,'.')))
...@@ -336,16 +324,11 @@ void Item_func_concat::fix_length_and_dec() ...@@ -336,16 +324,11 @@ void Item_func_concat::fix_length_and_dec()
bool first_coll= 1; bool first_coll= 1;
max_length=0; max_length=0;
collation.set(args[0]->collation); if (agg_arg_collations(collation, args, arg_count))
return;
for (uint i=0 ; i < arg_count ; i++) for (uint i=0 ; i < arg_count ; i++)
{
max_length+=args[i]->max_length; max_length+=args[i]->max_length;
if (collation.aggregate(args[i]->collation))
{
my_coll_agg_error(collation, args[i]->collation, func_name());
break;
}
}
if (max_length > MAX_BLOB_WIDTH) if (max_length > MAX_BLOB_WIDTH)
{ {
...@@ -840,13 +823,8 @@ void Item_func_replace::fix_length_and_dec() ...@@ -840,13 +823,8 @@ void Item_func_replace::fix_length_and_dec()
maybe_null=1; maybe_null=1;
} }
collation.set(args[0]->collation); if (agg_arg_collations_for_comparison(collation, args, 3))
if (!collation.aggregate(args[1]->collation)) return;
collation.aggregate(args[2]->collation);
if (collation.derivation == DERIVATION_NONE)
my_coll_agg3_error(args[0]->collation, args[1]->collation,
args[2]->collation, func_name());
} }
...@@ -1050,9 +1028,9 @@ void Item_func_substr::fix_length_and_dec() ...@@ -1050,9 +1028,9 @@ void Item_func_substr::fix_length_and_dec()
void Item_func_substr_index::fix_length_and_dec() void Item_func_substr_index::fix_length_and_dec()
{ {
max_length= args[0]->max_length; max_length= args[0]->max_length;
if (collation.set(args[0]->collation, args[1]->collation) ||
(collation.derivation == DERIVATION_NONE)) if (agg_arg_collations_for_comparison(collation, args, 2))
my_coll_agg_error(args[0]->collation, args[1]->collation, func_name()); return;
} }
...@@ -1339,7 +1317,8 @@ void Item_func_trim::fix_length_and_dec() ...@@ -1339,7 +1317,8 @@ void Item_func_trim::fix_length_and_dec()
remove.set_ascii(" ",1); remove.set_ascii(" ",1);
} }
else else
if (collation.set(args[1]->collation, args[0]->collation)) if (collation.set(args[1]->collation, args[0]->collation) ||
collation.derivation == DERIVATION_NONE)
{ {
my_coll_agg_error(args[1]->collation, args[0]->collation, func_name()); my_coll_agg_error(args[1]->collation, args[0]->collation, func_name());
} }
...@@ -1680,20 +1659,13 @@ void Item_func_elt::fix_length_and_dec() ...@@ -1680,20 +1659,13 @@ void Item_func_elt::fix_length_and_dec()
max_length=0; max_length=0;
decimals=0; decimals=0;
if (agg_arg_collations(collation, args, arg_count))
return;
for (uint i=0 ; i < arg_count ; i++) for (uint i=0 ; i < arg_count ; i++)
{ {
set_if_bigger(max_length,args[i]->max_length); set_if_bigger(max_length,args[i]->max_length);
set_if_bigger(decimals,args[i]->decimals); set_if_bigger(decimals,args[i]->decimals);
if (i == 0)
collation.set(args[0]->collation);
else
{
if (collation.aggregate(args[i]->collation))
{
my_coll_agg_error(collation, args[i]->collation, func_name());
break;
}
}
} }
maybe_null=1; // NULL if wrong first arg maybe_null=1; // NULL if wrong first arg
with_sum_func= with_sum_func || item->with_sum_func; with_sum_func= with_sum_func || item->with_sum_func;
...@@ -1786,16 +1758,13 @@ void Item_func_make_set::split_sum_func(Item **ref_pointer_array, ...@@ -1786,16 +1758,13 @@ void Item_func_make_set::split_sum_func(Item **ref_pointer_array,
void Item_func_make_set::fix_length_and_dec() void Item_func_make_set::fix_length_and_dec()
{ {
max_length=arg_count-1; max_length=arg_count-1;
collation.set(args[0]->collation);
if (agg_arg_collations(collation, args, arg_count))
return;
for (uint i=0 ; i < arg_count ; i++) for (uint i=0 ; i < arg_count ; i++)
{
max_length+=args[i]->max_length; max_length+=args[i]->max_length;
if (collation.aggregate(args[i]->collation))
{
my_coll_agg_error(collation, args[i]->collation, func_name());
break;
}
}
used_tables_cache|=item->used_tables(); used_tables_cache|=item->used_tables();
const_item_cache&=item->const_item(); const_item_cache&=item->const_item();
with_sum_func= with_sum_func || item->with_sum_func; with_sum_func= with_sum_func || item->with_sum_func;
...@@ -2463,15 +2432,8 @@ void Item_func_export_set::fix_length_and_dec() ...@@ -2463,15 +2432,8 @@ void Item_func_export_set::fix_length_and_dec()
uint sep_length=(arg_count > 3 ? args[3]->max_length : 1); uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
max_length=length*64+sep_length*63; max_length=length*64+sep_length*63;
collation.set(args[1]->collation); if (agg_arg_collations(collation, args+1, min(4,arg_count)-1))
for (i=2 ; i < 4 && i < arg_count ; i++) return;
{
if (collation.aggregate(args[i]->collation))
{
my_coll_agg_error(collation, args[i]->collation, func_name());
break;
}
}
} }
String* Item_func_inet_ntoa::val_str(String* str) String* Item_func_inet_ntoa::val_str(String* str)
......
...@@ -1114,7 +1114,7 @@ void Item_sum_count_distinct::make_unique() ...@@ -1114,7 +1114,7 @@ void Item_sum_count_distinct::make_unique()
bool Item_sum_count_distinct::setup(THD *thd) bool Item_sum_count_distinct::setup(THD *thd)
{ {
List<Item> list; List<Item> list;
SELECT_LEX *select_lex= current_lex->current_select->select_lex(); SELECT_LEX *select_lex= thd->lex.current_select->select_lex();
if (select_lex->linkage == GLOBAL_OPTIONS_TYPE) if (select_lex->linkage == GLOBAL_OPTIONS_TYPE)
return 1; return 1;
...@@ -1599,7 +1599,7 @@ Item_func_group_concat::Item_func_group_concat(bool is_distinct, ...@@ -1599,7 +1599,7 @@ Item_func_group_concat::Item_func_group_concat(bool is_distinct,
warning_available(0), key_length(0), rec_offset(0), warning_available(0), key_length(0), rec_offset(0),
tree_mode(0), distinct(is_distinct), warning_for_row(0), tree_mode(0), distinct(is_distinct), warning_for_row(0),
separator(is_separator), tree(&tree_base), table(0), separator(is_separator), tree(&tree_base), table(0),
order(0), tables_list(0), group_concat_max_len(0), order(0), tables_list(0),
show_elements(0), arg_count_order(0), arg_count_field(0), show_elements(0), arg_count_order(0), arg_count_field(0),
arg_show_fields(0), count_cut_values(0) arg_show_fields(0), count_cut_values(0)
...@@ -1607,8 +1607,11 @@ Item_func_group_concat::Item_func_group_concat(bool is_distinct, ...@@ -1607,8 +1607,11 @@ Item_func_group_concat::Item_func_group_concat(bool is_distinct,
original= 0; original= 0;
quick_group= 0; quick_group= 0;
mark_as_sum_func(); mark_as_sum_func();
SELECT_LEX *select_lex= current_lex->current_select->select_lex(); item_thd= current_thd;
SELECT_LEX *select_lex= item_thd->lex.current_select->select_lex();
order= 0; order= 0;
group_concat_max_len= item_thd->variables.group_concat_max_len;
arg_show_fields= arg_count_field= is_select->elements; arg_show_fields= arg_count_field= is_select->elements;
arg_count_order= is_order ? is_order->elements : 0; arg_count_order= is_order ? is_order->elements : 0;
...@@ -1773,7 +1776,7 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -1773,7 +1776,7 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
} }
result_field= 0; result_field= 0;
null_value= 1; null_value= 1;
fix_length_and_dec(); max_length= group_concat_max_len;
thd->allow_sum_func= 1; thd->allow_sum_func= 1;
if (!(tmp_table_param= new TMP_TABLE_PARAM)) if (!(tmp_table_param= new TMP_TABLE_PARAM))
return 1; return 1;
...@@ -1786,7 +1789,7 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -1786,7 +1789,7 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
bool Item_func_group_concat::setup(THD *thd) bool Item_func_group_concat::setup(THD *thd)
{ {
List<Item> list; List<Item> list;
SELECT_LEX *select_lex= current_lex->current_select->select_lex(); SELECT_LEX *select_lex= thd->lex.current_select->select_lex();
if (select_lex->linkage == GLOBAL_OPTIONS_TYPE) if (select_lex->linkage == GLOBAL_OPTIONS_TYPE)
return 1; return 1;
...@@ -1873,9 +1876,6 @@ bool Item_func_group_concat::setup(THD *thd) ...@@ -1873,9 +1876,6 @@ bool Item_func_group_concat::setup(THD *thd)
max_elements_in_tree= ((key_length) ? max_elements_in_tree= ((key_length) ?
thd->variables.max_heap_table_size/key_length : 1); thd->variables.max_heap_table_size/key_length : 1);
}; };
item_thd= thd;
group_concat_max_len= thd->variables.group_concat_max_len;
/* /*
Copy table and tree_mode if they belong to this item (if item have not Copy table and tree_mode if they belong to this item (if item have not
......
...@@ -713,7 +713,6 @@ class Item_func_group_concat : public Item_sum ...@@ -713,7 +713,6 @@ class Item_func_group_concat : public Item_sum
enum Sumfunctype sum_func () const {return GROUP_CONCAT_FUNC;} enum Sumfunctype sum_func () const {return GROUP_CONCAT_FUNC;}
const char *func_name() const { return "group_concat"; } const char *func_name() const { return "group_concat"; }
enum Type type() const { return SUM_FUNC_ITEM; } enum Type type() const { return SUM_FUNC_ITEM; }
void fix_length_and_dec() { max_length=group_concat_max_len; }
virtual Item_result result_type () const { return STRING_RESULT; } virtual Item_result result_type () const { return STRING_RESULT; }
bool reset(); bool reset();
bool add(); bool add();
......
...@@ -2637,7 +2637,7 @@ int QUICK_SELECT_DESC::get_next() ...@@ -2637,7 +2637,7 @@ int QUICK_SELECT_DESC::get_next()
else else
{ {
DBUG_ASSERT(range->flag & NEAR_MAX || range_reads_after_key(range)); DBUG_ASSERT(range->flag & NEAR_MAX || range_reads_after_key(range));
#ifdef NOT_IMPLEMENTED_YET #ifndef NOT_IMPLEMENTED_YET
result=file->index_read(record, (byte*) range->max_key, result=file->index_read(record, (byte*) range->max_key,
range->max_length, range->max_length,
((range->flag & NEAR_MAX) ? ((range->flag & NEAR_MAX) ?
......
...@@ -222,6 +222,8 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, ...@@ -222,6 +222,8 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
goto err; goto err;
} }
if (err == HA_ERR_RECORD_DELETED)
continue;
if (err) if (err)
{ {
if (err != HA_ERR_KEY_NOT_FOUND && err != HA_ERR_END_OF_FILE) if (err != HA_ERR_KEY_NOT_FOUND && err != HA_ERR_END_OF_FILE)
...@@ -233,15 +235,9 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, ...@@ -233,15 +235,9 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
} }
goto ok; goto ok;
} }
if (cond) if (cond && !cond->val_int())
{
err=err;
if (!cond->val_int())
continue; continue;
} if (!err && num_rows >= offset_limit)
if (num_rows >= offset_limit)
{
if (!err)
{ {
String *packet = &thd->packet; String *packet = &thd->packet;
Item *item; Item *item;
...@@ -258,7 +254,6 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, ...@@ -258,7 +254,6 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
} }
protocol->write(); protocol->write();
} }
}
num_rows++; num_rows++;
} }
ok: ok:
......
...@@ -659,10 +659,13 @@ static bool mysql_test_select_fields(PREP_STMT *stmt, TABLE_LIST *tables, ...@@ -659,10 +659,13 @@ static bool mysql_test_select_fields(PREP_STMT *stmt, TABLE_LIST *tables,
wild_num, conds, og_num, order, group, having, proc, wild_num, conds, og_num, order, group, having, proc,
select_lex, unit, 0)) select_lex, unit, 0))
DBUG_RETURN(1); DBUG_RETURN(1);
#ifndef EMBEDDED_LIBRARY
if (send_prep_stmt(stmt, fields.elements) || if (send_prep_stmt(stmt, fields.elements) ||
thd->protocol_simple.send_fields(&fields, 0) || thd->protocol_simple.send_fields(&fields, 0) ||
net_flush(&thd->net) ||
send_item_params(stmt)) send_item_params(stmt))
DBUG_RETURN(1); DBUG_RETURN(1);
#endif
join->cleanup(); join->cleanup();
} }
DBUG_RETURN(0); DBUG_RETURN(0);
......
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