[Commits] 409cc5bda27: MDEV-20922: Adding an order by changes the query results
revision-id: 409cc5bda27a518c244e82e9e24c61fee9f1f8a3 (mariadb-10.1.41-106-g409cc5bda27) parent(s): d930422e9e84aa1bc265963225dd29295203e9d3 author: Varun Gupta committer: Varun Gupta timestamp: 2019-12-18 23:41:32 +0530 message: MDEV-20922: Adding an order by changes the query results For Item_direct_ref and its subclasses, get value from val_* methods instead of result* family The val_* methods gets value of item on which it is referred. --- mysql-test/r/group_by.result | 16 ++++++++++++++++ mysql-test/t/group_by.test | 14 ++++++++++++++ sql/item.h | 6 ++++++ 3 files changed, 36 insertions(+) diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index eb730a8c954..bde24afa6e3 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -2792,3 +2792,19 @@ SELECT 1 IN ( SELECT COUNT( DISTINCT f2 ) FROM t1 WHERE f1 <= 4 ); 1 IN ( SELECT COUNT( DISTINCT f2 ) FROM t1 WHERE f1 <= 4 ) 0 drop table t1; +# +# MDEV-20922: Adding an order by changes the query results +# +CREATE TABLE t1(a int, b int); +INSERT INTO t1 values (1, 100), (2, 200), (3, 100), (4, 200); +create view v1 as select a, b+1 as x from t1; +select x, count(distinct a) as y from v1 group by x order by y; +x y +101 2 +201 2 +select b+1 as x, count(distinct a) as y from t1 group by x order by y; +x y +101 2 +201 2 +drop view v1; +drop table t1; diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index 0401ad9780c..b3e12a93147 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -1915,3 +1915,17 @@ INSERT INTO t1 VALUES (0,'foo'),(1,'bar'); SELECT 1 IN ( SELECT COUNT( DISTINCT f2 ) FROM t1 WHERE f1 <= 4 ); drop table t1; +--echo # +--echo # MDEV-20922: Adding an order by changes the query results +--echo # + +CREATE TABLE t1(a int, b int); +INSERT INTO t1 values (1, 100), (2, 200), (3, 100), (4, 200); + +create view v1 as select a, b+1 as x from t1; + +select x, count(distinct a) as y from v1 group by x order by y; +select b+1 as x, count(distinct a) as y from t1 group by x order by y; + +drop view v1; +drop table t1; diff --git a/sql/item.h b/sql/item.h index fb11064f122..bb8dc788f81 100644 --- a/sql/item.h +++ b/sql/item.h @@ -4146,6 +4146,12 @@ class Item_direct_ref :public Item_ref bool val_bool(); bool is_null(); bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate); + double val_result() { return val_real(); } + longlong val_int_result() { return val_int(); } + String *str_result(String* tmp) { return val_str(tmp); } + my_decimal *val_decimal_result(my_decimal *val) + { return val_decimal(val); } + bool val_bool_result() { return val_bool(); } virtual Ref_Type ref_type() { return DIRECT_REF; } };
participants (1)
-
Varun