diff options
author | Galina Shalygina <galina.shalygina@mariadb.com> | 2019-04-06 00:04:52 +0300 |
---|---|---|
committer | Galina Shalygina <galina.shalygina@mariadb.com> | 2019-04-06 00:04:52 +0300 |
commit | a2e477ffd0414248d1d3af2eeafe1e3cffddebc6 (patch) | |
tree | 24ecc1c126f72aa5bbcb3e5d226669d8e93b2ddf | |
parent | 694d1a50bd7754c5357dde184f87d63b7032ee5e (diff) | |
download | mariadb-git-a2e477ffd0414248d1d3af2eeafe1e3cffddebc6.tar.gz |
MDEV-19186: Assertion `field->table == table' failed in create_tmp_table
Temporary table is defined with the view field in HAVING.
Item_direct_view_ref for this field is dropped and that causes error.
To fix it Item_direct_view_ref::remove_item_direct_ref() is added.
-rw-r--r-- | mysql-test/main/having_cond_pushdown.result | 16 | ||||
-rw-r--r-- | mysql-test/main/having_cond_pushdown.test | 22 | ||||
-rw-r--r-- | sql/item.h | 1 |
3 files changed, 39 insertions, 0 deletions
diff --git a/mysql-test/main/having_cond_pushdown.result b/mysql-test/main/having_cond_pushdown.result index e9fcd633895..85ca0342dee 100644 --- a/mysql-test/main/having_cond_pushdown.result +++ b/mysql-test/main/having_cond_pushdown.result @@ -4641,3 +4641,19 @@ pk 3 DROP TABLE t1; DROP VIEW v1; +# +# MDEV-19186: temporary table defined with view field in HAVING +# +CREATE TABLE t1 (pk INT, x VARCHAR(10)); +INSERT INTO t1 VALUES (1,'y'),(2,'s'),(3,'aaa'); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 (pk INT, x VARCHAR(10)); +INSERT INTO t2 VALUES (1,'aa'),(2,'t'),(3,'bb'); +CREATE TABLE tmp1 +SELECT v1.pk +FROM t2,v1 +WHERE v1.x = t2.x +GROUP BY v1.pk +HAVING (v1.pk = 1); +DROP TABLE t1,t2,tmp1; +DROP VIEW v1; diff --git a/mysql-test/main/having_cond_pushdown.test b/mysql-test/main/having_cond_pushdown.test index a50fa11484d..257e5cb4875 100644 --- a/mysql-test/main/having_cond_pushdown.test +++ b/mysql-test/main/having_cond_pushdown.test @@ -1318,3 +1318,25 @@ HAVING (1 NOT IN (SELECT COUNT(t1.c1) FROM (v1, t1))); DROP TABLE t1; DROP VIEW v1; + + +--echo # +--echo # MDEV-19186: temporary table defined with view field in HAVING +--echo # + +CREATE TABLE t1 (pk INT, x VARCHAR(10)); +INSERT INTO t1 VALUES (1,'y'),(2,'s'),(3,'aaa'); +CREATE VIEW v1 AS SELECT * FROM t1; + +CREATE TABLE t2 (pk INT, x VARCHAR(10)); +INSERT INTO t2 VALUES (1,'aa'),(2,'t'),(3,'bb'); + +CREATE TABLE tmp1 +SELECT v1.pk +FROM t2,v1 +WHERE v1.x = t2.x +GROUP BY v1.pk +HAVING (v1.pk = 1); + +DROP TABLE t1,t2,tmp1; +DROP VIEW v1; diff --git a/sql/item.h b/sql/item.h index 716b411082f..97d31e6ba34 100644 --- a/sql/item.h +++ b/sql/item.h @@ -5733,6 +5733,7 @@ public: { return get_item_copy<Item_direct_view_ref>(thd, this); } Item *field_transformer_for_having_pushdown(THD *thd, uchar *arg) { return this; } + Item *remove_item_direct_ref() { return this; } }; |