diff options
author | unknown <bell@sanja.is.com.ua> | 2002-10-23 23:36:11 +0300 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2002-10-23 23:36:11 +0300 |
commit | 4aef2862965978b6bc4168c349757aa5fd23bc48 (patch) | |
tree | 49ea1e25de8e73e07e157831b2800cdf36c73e8d | |
parent | efe61a86bf5039cd5b07b838680fdfbb17c8c42a (diff) | |
download | mariadb-git-4aef2862965978b6bc4168c349757aa5fd23bc48.tar.gz |
fixed DISTINCT in subselect bug
small Item_ref fix
mysql-test/r/subselect.result:
DISTINCT in subselect test
mysql-test/t/subselect.test:
DISTINCT in subselect test
sql/sql_class.cc:
fixed DISTINCT in subselect bug
-rw-r--r-- | mysql-test/r/subselect.result | 6 | ||||
-rw-r--r-- | mysql-test/t/subselect.test | 2 | ||||
-rw-r--r-- | sql/item.h | 10 | ||||
-rw-r--r-- | sql/sql_class.cc | 8 |
4 files changed, 18 insertions, 8 deletions
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 2dcafe2c9cb..3f89f546ca3 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -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 1 PRIMARY No tables used 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; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 518ade7fcf7..6e585883f1c 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -108,4 +108,6 @@ INSERT INTO searchconthardwarefr3 (topic,date,pseudo) VALUES ('43506','2002-10-02','joce'),('40143','2002-08-03','joce'); EXPLAIN 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;
\ No newline at end of file diff --git a/sql/item.h b/sql/item.h index 115e9426691..497a43c2214 100644 --- a/sql/item.h +++ b/sql/item.h @@ -71,6 +71,7 @@ public: virtual double val_result() { return val(); } virtual longlong val_int_result() { return val_int(); } 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 bool basic_const_item() const { return 0; } virtual Item *new_item() { return 0; } /* Only for const items */ @@ -124,6 +125,7 @@ public: double val_result(); longlong val_int_result(); String *str_result(String* tmp); + bool is_null_result() { return result_field->is_null(); } bool send(THD *thd, String *str_arg) { return result_field->send(thd,str_arg); @@ -398,25 +400,25 @@ public: double val() { double tmp=(*ref)->val_result(); - null_value=(*ref)->null_value; + null_value=(*ref)->is_null_result(); return tmp; } longlong val_int() { longlong tmp=(*ref)->val_int_result(); - null_value=(*ref)->null_value; + null_value=(*ref)->is_null_result(); return tmp; } String *val_str(String* tmp) { tmp=(*ref)->str_result(tmp); - null_value=(*ref)->null_value; + null_value=(*ref)->is_null_result(); return tmp; } bool is_null() { (void) (*ref)->val_int_result(); - return (*ref)->null_value; + return (*ref)->is_null_result(); } bool get_date(TIME *ltime,bool fuzzydate) { diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 083b0ed2543..59c28797a43 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -873,8 +873,8 @@ bool select_singleval_subselect::send_data(List<Item> &items) Following val() call have to be first, because function AVG() & STD() calculate value on it & determinate "is it NULL?". */ - it->real_value= val_item->val(); - if ((it->null_value= val_item->is_null())) + it->real_value= val_item->val_result(); + if ((it->null_value= val_item->is_null_result())) { it->assign_null(); } @@ -883,8 +883,8 @@ bool select_singleval_subselect::send_data(List<Item> &items) it->max_length= val_item->max_length; it->decimals= val_item->decimals; it->binary= val_item->binary; - it->int_value= val_item->val_int(); - String *s= val_item->val_str(&it->string_value); + it->int_value= val_item->val_int_result(); + String *s= val_item->str_result(&it->string_value); if (s != &it->string_value) { it->string_value.set(*s, 0, s->length()); |