From: Date: March 28 2006 4:29am Subject: bk commit into 5.0 tree (igor:1.2098) BUG#18386 List-Archive: http://lists.mysql.com/commits/4219 X-Bug: 18386 Message-Id: <20060328022905.7BC9124B903@rurik.mysql.com> Below is the list of changes that have just been committed into a local 5.0 repository of igor. When igor does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.2098 06/03/27 18:28:55 igor@stripped +3 -0 Fixed bug #18386. An invalid assertion in Item_direct_view_ref::eq caused an assertion abort in the debug version. sql/item.cc 1.210 06/03/27 18:28:49 igor@stripped +4 -7 Fixed bug #18386. An invalid assertion in Item_direct_view_ref::eq caused an assertion abort in the debug version. Changed the assertion. mysql-test/t/view.test 1.138 06/03/27 18:28:49 igor@stripped +14 -0 Added a test case for bug #18386. mysql-test/r/view.result 1.149 06/03/27 18:28:49 igor@stripped +9 -0 Added a test case for bug #18386. # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: igor # Host: rurik.mysql.com # Root: /home/igor/dev/mysql-5.0-0 --- 1.209/sql/item.cc 2006-03-21 05:35:44 -08:00 +++ 1.210/sql/item.cc 2006-03-27 18:28:49 -08:00 @@ -5076,11 +5076,8 @@ 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 @@ 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()); } } --- 1.148/mysql-test/r/view.result 2006-03-03 05:09:06 -08:00 +++ 1.149/mysql-test/r/view.result 2006-03-27 18:28:49 -08:00 @@ -2553,3 +2553,12 @@ 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; --- 1.137/mysql-test/t/view.test 2006-03-03 05:08:43 -08:00 +++ 1.138/mysql-test/t/view.test 2006-03-27 18:28:49 -08:00 @@ -2399,3 +2399,17 @@ 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;