Commit 96629f2c authored by gkodinov/kgeorge@magare.gmz's avatar gkodinov/kgeorge@magare.gmz

Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt

into  magare.gmz:/home/kgeorge/mysql/autopush/B26672-5.0-opt
parents d0a62312 d2c977a9
......@@ -958,3 +958,25 @@ a ratio
19 1.3333
9 2.6667
drop table t1;
CREATE TABLE t1 (a INT UNSIGNED NOT NULL, b TIME);
INSERT INTO t1 (a) VALUES (100000), (0), (100), (1000000),(10000), (1000), (10);
UPDATE t1 SET b = SEC_TO_TIME(a);
SELECT a, b FROM t1 ORDER BY b DESC;
a b
1000000 277:46:40
100000 27:46:40
10000 02:46:40
1000 00:16:40
100 00:01:40
10 00:00:10
0 00:00:00
SELECT a, b FROM t1 ORDER BY SEC_TO_TIME(a) DESC;
a b
1000000 277:46:40
100000 27:46:40
10000 02:46:40
1000 00:16:40
100 00:01:40
10 00:00:10
0 00:00:00
DROP TABLE t1;
......@@ -677,3 +677,18 @@ create table t1 (a int, b int, c int);
insert into t1 values (1,2,3), (9,8,3), (19,4,3), (1,4,9);
select a,(sum(b)/sum(c)) as ratio from t1 group by a order by sum(b)/sum(c) asc;
drop table t1;
#
# Bug#26672: Incorrect SEC_TO_TIME() casting in ORDER BY
#
CREATE TABLE t1 (a INT UNSIGNED NOT NULL, b TIME);
INSERT INTO t1 (a) VALUES (100000), (0), (100), (1000000),(10000), (1000), (10);
UPDATE t1 SET b = SEC_TO_TIME(a);
-- Correct ORDER
SELECT a, b FROM t1 ORDER BY b DESC;
-- must be ordered as the above
SELECT a, b FROM t1 ORDER BY SEC_TO_TIME(a) DESC;
DROP TABLE t1;
......@@ -1298,7 +1298,10 @@ sortlength(THD *thd, SORT_FIELD *sortorder, uint s_length,
}
else
{
switch ((sortorder->result_type=sortorder->item->result_type())) {
sortorder->result_type= sortorder->item->result_type();
if (sortorder->item->result_as_longlong())
sortorder->result_type= INT_RESULT;
switch (sortorder->result_type) {
case STRING_RESULT:
sortorder->length=sortorder->item->max_length;
set_if_smaller(sortorder->length, thd->variables.max_sort_length);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment