diff options
author | unknown <kaa@kaamos.(none)> | 2008-02-22 11:34:18 +0300 |
---|---|---|
committer | unknown <kaa@kaamos.(none)> | 2008-02-22 11:34:18 +0300 |
commit | 012aab7d8bf7ae9c30751a6d5f666c7731ecfdf3 (patch) | |
tree | 083d0b2d329bd84d153bfe6bc799c20d2251015f | |
parent | c4fc5b096e582f23bac8bc14cb93f6ade63f476f (diff) | |
download | mariadb-git-012aab7d8bf7ae9c30751a6d5f666c7731ecfdf3.tar.gz |
Fix for bug #33049: Assert while running test-as3ap test(mysql-bench
suite)
Under some circumstances a combination of aggregate functions and
GROUP BY in a SELECT query over a VIEW could lead to incorrect
calculation of the result type of the aggregate function. This in
turn could result in incorrect results, or assertion failures on debug
builds.
Fixed by changing the logic in Item_sum_hybrid::fix_fields() so that
the argument's item is dereferenced before calling its type() method.
mysql-test/r/view.result:
Added a test case for bug #33049.
mysql-test/t/view.test:
Added a test case for bug #33049.
sql/item_sum.cc:
When calculating the result type of an aggregate function, dereference
the argument's item before calling its type() method.
-rw-r--r-- | mysql-test/r/view.result | 8 | ||||
-rw-r--r-- | mysql-test/t/view.test | 13 | ||||
-rw-r--r-- | sql/item_sum.cc | 1 |
3 files changed, 22 insertions, 0 deletions
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index f7f6debee6e..4ba46079b27 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -3634,4 +3634,12 @@ a 1 drop view v1, v2; drop table t1, t2; +CREATE TABLE t1 (a INT); +CREATE VIEW v1 AS SELECT p.a AS a FROM t1 p, t1 q; +INSERT INTO t1 VALUES (1), (1); +SELECT MAX(a), COUNT(DISTINCT a) FROM v1 GROUP BY a; +MAX(a) COUNT(DISTINCT a) +1 1 +DROP VIEW v1; +DROP TABLE t1; End of 5.0 tests. diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index b321f8604f7..d7461504b20 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -3492,5 +3492,18 @@ execute stmt; drop view v1, v2; drop table t1, t2; +# +# Bug #33049: Assert while running test-as3ap test(mysql-bench suite) +# + +CREATE TABLE t1 (a INT); +CREATE VIEW v1 AS SELECT p.a AS a FROM t1 p, t1 q; + +INSERT INTO t1 VALUES (1), (1); +SELECT MAX(a), COUNT(DISTINCT a) FROM v1 GROUP BY a; + +DROP VIEW v1; +DROP TABLE t1; + --echo End of 5.0 tests. diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 3d261dc2c36..47a7073c2e7 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -597,6 +597,7 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref) result_field=0; null_value=1; fix_length_and_dec(); + item= item->real_item(); if (item->type() == Item::FIELD_ITEM) hybrid_field_type= ((Item_field*) item)->field->type(); else |