From: Date: June 17 2005 6:30pm Subject: bk commit into 5.0 tree (evgen:1.1943) BUG#7422 List-Archive: http://lists.mysql.com/internals/26109 X-Bug: 7422 Message-Id: <20050617163005.A46B213EB48@localhost.moonbone.local> Below is the list of changes that have just been committed into a local 5.0 repository of evgen. When evgen 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.1943 05/06/17 20:30:00 evgen@stripped +3 -0 Fix bug #7422 "order by" doesn't work Field with wrong buffer was used to make sort key, which results in producing same sort key for all records. mysql-test/r/view.result 1.82 05/06/17 20:19:14 evgen@stripped +19 -0 Test case for bug#7422 "order by" doesn't work mysql-test/t/view.test 1.71 05/06/17 20:18:19 evgen@stripped +13 -0 Test case for bug#7422 "order by" doesn't work sql/filesort.cc 1.103 05/06/17 19:59:55 evgen@stripped +22 -4 Fix bug#7422 "order by" doesn't work # 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: evgen # Host: moonbone.local # Root: /work/mysql-5.0-bug-7422 --- 1.102/sql/filesort.cc 2005-04-07 20:24:08 +04:00 +++ 1.103/sql/filesort.cc 2005-06-17 19:59:55 +04:00 @@ -631,7 +631,12 @@ *to++=1; /* All item->str() to use some extra byte for end null.. */ String tmp((char*) to,sort_field->length+4,cs); - String *res=item->val_str(&tmp); + String *res; + if (item->type() == Item::REF_ITEM && ((Item_ref*)item)->result_field) + res= ((Item_ref*)item)->result_field->val_str(&tmp); + else + res= item->val_str(&tmp); + if (!res) { if (maybe_null) @@ -673,7 +678,12 @@ } case INT_RESULT: { - longlong value=item->val_int(); + longlong value; + if (item->type() == Item::REF_ITEM && ((Item_ref*)item)->result_field) + value= ((Item_ref*)item)->result_field->val_int(); + else + value= item->val_int(); + if (maybe_null) { *to++=1; /* purecov: inspected */ @@ -715,7 +725,11 @@ } case DECIMAL_RESULT: { - my_decimal dec_buf, *dec_val= item->val_decimal(&dec_buf); + my_decimal dec_buf, *dec_val; + if (item->type() == Item::REF_ITEM && ((Item_ref*)item)->result_field) + dec_val= ((Item_ref *)item)->result_field->val_decimal(&dec_buf); + else + dec_val= item->val_decimal(&dec_buf); if (maybe_null) { if (item->null_value) @@ -733,7 +747,11 @@ } case REAL_RESULT: { - double value= item->val_real(); + double value; + if (item->type() == Item::REF_ITEM && ((Item_ref*)item)->result_field) + value= ((Item_ref*)item)->result_field->val_real(); + else + value= item->val_real(); if (maybe_null) { if (item->null_value) --- 1.81/mysql-test/r/view.result 2005-05-17 19:05:06 +04:00 +++ 1.82/mysql-test/r/view.result 2005-06-17 20:19:14 +04:00 @@ -1726,3 +1726,22 @@ drop procedure p1; drop view v1; drop table t1; +DROP TABLE IF EXISTS t1, t2, v; +Warnings: +Note 1051 Unknown table 't1' +Note 1051 Unknown table 't2' +Note 1051 Unknown table 'v' +CREATE TABLE t1(a char(2) primary key, b char(2)); +CREATE TABLE t2(a char(2), b char(2), index i(a)); +INSERT INTO t1 VALUES ('a','1'), ('b','2'); +INSERT INTO t2 VALUES ('a','5'), ('a','6'), ('b','5'), ('b','6'); +CREATE VIEW v AS +SELECT t1.b as c, t2.b as d FROM t1,t2 WHERE t1.a=t2.a; +SELECT d, c FROM v ORDER BY d; +d c +5 1 +5 2 +6 1 +6 2 +DROP VIEW v; +DROP TABLE t1, t2; --- 1.70/mysql-test/t/view.test 2005-05-17 19:05:06 +04:00 +++ 1.71/mysql-test/t/view.test 2005-06-17 20:18:19 +04:00 @@ -1569,3 +1569,16 @@ drop view v1; drop table t1; +# +# Bug#7422 "order by" doesn't work +# +DROP TABLE IF EXISTS t1, t2, v; +CREATE TABLE t1(a char(2) primary key, b char(2)); +CREATE TABLE t2(a char(2), b char(2), index i(a)); +INSERT INTO t1 VALUES ('a','1'), ('b','2'); +INSERT INTO t2 VALUES ('a','5'), ('a','6'), ('b','5'), ('b','6'); +CREATE VIEW v AS + SELECT t1.b as c, t2.b as d FROM t1,t2 WHERE t1.a=t2.a; +SELECT d, c FROM v ORDER BY d; +DROP VIEW v; +DROP TABLE t1, t2;