summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <igor@rurik.mysql.com>2006-03-27 20:16:52 -0800
committerunknown <igor@rurik.mysql.com>2006-03-27 20:16:52 -0800
commit2568c2cfed7fc94ce63e7f7be87d48d7181fe182 (patch)
tree40970466770f1c8a1a14515ed728ad73b60d4213
parent4faee6658a19db81e756a57b6d45f48610074f0a (diff)
parentb0654461dfbde40f8419b0af1f3be17217638bd2 (diff)
downloadmariadb-git-2568c2cfed7fc94ce63e7f7be87d48d7181fe182.tar.gz
Merge ibabaev@bk-internal.mysql.com:/home/bk/mysql-5.0
into rurik.mysql.com:/home/igor/mysql-5.0
-rw-r--r--mysql-test/r/view.result9
-rw-r--r--mysql-test/t/view.test14
-rw-r--r--sql/item.cc11
3 files changed, 27 insertions, 7 deletions
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 7678c70bda2..5a5f60e9409 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -2553,3 +2553,12 @@ a b
3 3
drop view v2, v1;
drop table t1;
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (1), (2);
+CREATE VIEW v1 AS SELECT SQRT(a) my_sqrt FROM t1;
+SELECT my_sqrt FROM v1 ORDER BY my_sqrt;
+my_sqrt
+1
+1.4142135623731
+DROP VIEW v1;
+DROP TABLE t1;
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index e17e2b98527..e53988ad3d9 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -2399,3 +2399,17 @@ update v2 set b=3 where a=2;
select * from v2;
drop view v2, v1;
drop table t1;
+
+#
+# Bug #18386: select from view over a table with ORDER BY view_col clause
+# given view_col is not an image of any column from the base table
+
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (1), (2);
+
+CREATE VIEW v1 AS SELECT SQRT(a) my_sqrt FROM t1;
+
+SELECT my_sqrt FROM v1 ORDER BY my_sqrt;
+
+DROP VIEW v1;
+DROP TABLE t1;
diff --git a/sql/item.cc b/sql/item.cc
index c48bf19a88b..8ffe7a6b2fd 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -5076,11 +5076,8 @@ bool Item_direct_view_ref::fix_fields(THD *thd, Item **reference)
DESCRIPTION
A view column reference is considered equal to another column
reference if the second one is a view column and if both column
- references point to the same field. For views 'same field' means
- the same Item_field object in the view translation table, where
- the view translation table contains all result columns of the
- view. This definition ensures that view columns are resolved
- in the same manner as table columns.
+ references resolve to the same item. It is assumed that both
+ items are of the same type.
RETURN
TRUE Referenced item is equal to given item
@@ -5096,8 +5093,8 @@ bool Item_direct_view_ref::eq(const Item *item, bool binary_cmp) const
if (item_ref->ref_type() == VIEW_REF)
{
Item *item_ref_ref= *(item_ref->ref);
- DBUG_ASSERT((*ref)->real_item()->type() == FIELD_ITEM &&
- (item_ref_ref->real_item()->type() == FIELD_ITEM));
+ DBUG_ASSERT((*ref)->real_item()->type() ==
+ item_ref_ref->real_item()->type());
return ((*ref)->real_item() == item_ref_ref->real_item());
}
}