fixed DISTINCT in subselect bug
small Item_ref fix
This commit is contained in:
parent
cd032e0418
commit
c2da10ae18
@ -198,4 +198,10 @@ EXPLAIN SELECT (SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002
|
|||||||
id select_type table type possible_keys key key_len ref rows Extra
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
1 PRIMARY No tables used
|
1 PRIMARY No tables used
|
||||||
2 SUBSELECT searchconthardwarefr3 index NULL PRIMARY 41 NULL 2 where used; Using index
|
2 SUBSELECT searchconthardwarefr3 index NULL PRIMARY 41 NULL 2 where used; Using index
|
||||||
|
SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002-08-03';
|
||||||
|
date
|
||||||
|
2002-08-03
|
||||||
|
SELECT (SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002-08-03');
|
||||||
|
(SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002-08-03')
|
||||||
|
2002-08-03
|
||||||
drop table searchconthardwarefr3;
|
drop table searchconthardwarefr3;
|
||||||
|
@ -108,4 +108,6 @@ INSERT INTO searchconthardwarefr3 (topic,date,pseudo) VALUES
|
|||||||
('43506','2002-10-02','joce'),('40143','2002-08-03','joce');
|
('43506','2002-10-02','joce'),('40143','2002-08-03','joce');
|
||||||
EXPLAIN SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002-08-03';
|
EXPLAIN SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002-08-03';
|
||||||
EXPLAIN SELECT (SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002-08-03');
|
EXPLAIN SELECT (SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002-08-03');
|
||||||
|
SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002-08-03';
|
||||||
|
SELECT (SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002-08-03');
|
||||||
drop table searchconthardwarefr3;
|
drop table searchconthardwarefr3;
|
10
sql/item.h
10
sql/item.h
@ -71,6 +71,7 @@ public:
|
|||||||
virtual double val_result() { return val(); }
|
virtual double val_result() { return val(); }
|
||||||
virtual longlong val_int_result() { return val_int(); }
|
virtual longlong val_int_result() { return val_int(); }
|
||||||
virtual String *str_result(String* tmp) { return val_str(tmp); }
|
virtual String *str_result(String* tmp) { return val_str(tmp); }
|
||||||
|
virtual bool is_null_result() { return is_null(); }
|
||||||
virtual table_map used_tables() const { return (table_map) 0L; }
|
virtual table_map used_tables() const { return (table_map) 0L; }
|
||||||
virtual bool basic_const_item() const { return 0; }
|
virtual bool basic_const_item() const { return 0; }
|
||||||
virtual Item *new_item() { return 0; } /* Only for const items */
|
virtual Item *new_item() { return 0; } /* Only for const items */
|
||||||
@ -124,6 +125,7 @@ public:
|
|||||||
double val_result();
|
double val_result();
|
||||||
longlong val_int_result();
|
longlong val_int_result();
|
||||||
String *str_result(String* tmp);
|
String *str_result(String* tmp);
|
||||||
|
bool is_null_result() { return result_field->is_null(); }
|
||||||
bool send(THD *thd, String *str_arg)
|
bool send(THD *thd, String *str_arg)
|
||||||
{
|
{
|
||||||
return result_field->send(thd,str_arg);
|
return result_field->send(thd,str_arg);
|
||||||
@ -398,25 +400,25 @@ public:
|
|||||||
double val()
|
double val()
|
||||||
{
|
{
|
||||||
double tmp=(*ref)->val_result();
|
double tmp=(*ref)->val_result();
|
||||||
null_value=(*ref)->null_value;
|
null_value=(*ref)->is_null_result();
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
longlong val_int()
|
longlong val_int()
|
||||||
{
|
{
|
||||||
longlong tmp=(*ref)->val_int_result();
|
longlong tmp=(*ref)->val_int_result();
|
||||||
null_value=(*ref)->null_value;
|
null_value=(*ref)->is_null_result();
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
String *val_str(String* tmp)
|
String *val_str(String* tmp)
|
||||||
{
|
{
|
||||||
tmp=(*ref)->str_result(tmp);
|
tmp=(*ref)->str_result(tmp);
|
||||||
null_value=(*ref)->null_value;
|
null_value=(*ref)->is_null_result();
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
bool is_null()
|
bool is_null()
|
||||||
{
|
{
|
||||||
(void) (*ref)->val_int_result();
|
(void) (*ref)->val_int_result();
|
||||||
return (*ref)->null_value;
|
return (*ref)->is_null_result();
|
||||||
}
|
}
|
||||||
bool get_date(TIME *ltime,bool fuzzydate)
|
bool get_date(TIME *ltime,bool fuzzydate)
|
||||||
{
|
{
|
||||||
|
@ -873,8 +873,8 @@ bool select_singleval_subselect::send_data(List<Item> &items)
|
|||||||
Following val() call have to be first, because function AVG() & STD()
|
Following val() call have to be first, because function AVG() & STD()
|
||||||
calculate value on it & determinate "is it NULL?".
|
calculate value on it & determinate "is it NULL?".
|
||||||
*/
|
*/
|
||||||
it->real_value= val_item->val();
|
it->real_value= val_item->val_result();
|
||||||
if ((it->null_value= val_item->is_null()))
|
if ((it->null_value= val_item->is_null_result()))
|
||||||
{
|
{
|
||||||
it->assign_null();
|
it->assign_null();
|
||||||
}
|
}
|
||||||
@ -883,8 +883,8 @@ bool select_singleval_subselect::send_data(List<Item> &items)
|
|||||||
it->max_length= val_item->max_length;
|
it->max_length= val_item->max_length;
|
||||||
it->decimals= val_item->decimals;
|
it->decimals= val_item->decimals;
|
||||||
it->binary= val_item->binary;
|
it->binary= val_item->binary;
|
||||||
it->int_value= val_item->val_int();
|
it->int_value= val_item->val_int_result();
|
||||||
String *s= val_item->val_str(&it->string_value);
|
String *s= val_item->str_result(&it->string_value);
|
||||||
if (s != &it->string_value)
|
if (s != &it->string_value)
|
||||||
{
|
{
|
||||||
it->string_value.set(*s, 0, s->length());
|
it->string_value.set(*s, 0, s->length());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user