diff options
author | Varun Gupta <varun.gupta@mariadb.com> | 2021-02-15 16:30:55 +0530 |
---|---|---|
committer | Varun Gupta <varun.gupta@mariadb.com> | 2021-02-16 11:53:13 +0530 |
commit | 3544643f0999081dcea022b67ecf7758c37b3ce9 (patch) | |
tree | b5200007e66e82616e03a771ce223b098a49daf7 /mysql-test | |
parent | 7e9a6b7f09bfb00e781d8ca63dfe7701900c368b (diff) | |
download | mariadb-git-3544643f0999081dcea022b67ecf7758c37b3ce9.tar.gz |
MDEV-23291: SUM column from a derived table returns invalid values
The issue here was the read_set bitmap was not set for a field which
was used as a reference in an inner select.
We need to make sure that if we are in an inner select and we have
references from outer select then we update the table bitmaps for
such references.
Introduced a function in the class Item_subselect that would
update bitmaps of table for the references within a
subquery that are defined in outer selects.
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/view.result | 15 | ||||
-rw-r--r-- | mysql-test/t/view.test | 16 |
2 files changed, 31 insertions, 0 deletions
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index e48a99f6aff..ef4f0a48534 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -6818,5 +6818,20 @@ DROP PROCEDURE sp1; DROP VIEW v1; DROP TABLE t1, t2; # +# MDEV-23291: SUM column from a derived table returns invalid values +# +CREATE TABLE t1(a INT, b INT); +INSERT INTO t1 VALUES (1,1), (2,2); +CREATE view v1 AS +SELECT a as x, (select x) as y, (select y) as z FROM t1; +SELECT sum(z) FROM (SELECT a as x, (select x) as y, (select y) as z FROM t1) q; +sum(z) +3 +SELECT sum(z) FROM v1; +sum(z) +3 +DROP TABLE t1; +DROP VIEW v1; +# # End of 10.2 tests # diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index b5ce6a1cabf..8cb00f7a6f4 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -6544,5 +6544,21 @@ DROP VIEW v1; DROP TABLE t1, t2; --echo # +--echo # MDEV-23291: SUM column from a derived table returns invalid values +--echo # + +CREATE TABLE t1(a INT, b INT); +INSERT INTO t1 VALUES (1,1), (2,2); + +CREATE view v1 AS +SELECT a as x, (select x) as y, (select y) as z FROM t1; + +SELECT sum(z) FROM (SELECT a as x, (select x) as y, (select y) as z FROM t1) q; +SELECT sum(z) FROM v1; + +DROP TABLE t1; +DROP VIEW v1; + +--echo # --echo # End of 10.2 tests --echo # |